Git Product home page Git Product logo

liquidfun's Introduction

LiquidFun logo

LiquidFun Version 1.1.0

Welcome to LiquidFun!

LiquidFun is a 2D physics engine for games. Go to our landing page to browse our documentation and see some examples.

LiquidFun is an extension of Box2D. It adds a particle based fluid and soft body simulation to the rigid body functionality of Box2D. LiquidFun can be built for many different systems, including Android, iOS, Windows, OS X, Linux, and JavaScript. Please see Box2D/Documentation/Building/ for details.

Discuss LiquidFun with other developers and users on the LiquidFun Google Group. File issues on the LiquidFun Issues Tracker or post your questions to stackoverflow.com with a mention of liquidfun.

Please see Box2D/Documentation/Building/ to learn how to build LiquidFun and run the testbed.

LiquidFun has a logo that you can use, in your splash screens or documentation, for example. Please see the Programmer's Guide for the graphics and further details.

For applications on Google Play that integrate this tool, usage is tracked. This tracking is done automatically using the embedded version string (b2_liquidFunVersionString), and helps us continue to optimize it. Aside from consuming a few extra bytes in your application binary, it shouldn't affect your application at all. We use this information to let us know if LiquidFun is useful and if we should continue to invest in it. Since this is open source, you are free to remove the version string but we would appreciate if you would leave it in.

liquidfun's People

Contributors

atahiri80 avatar auselen avatar camerondm9 avatar cco3 avatar chadj-at-google avatar doebi avatar enh-google avatar eugenis avatar haskasu avatar iainmerrick avatar imerr avatar joshualitt avatar jsanmiya avatar kant avatar mortonfox avatar neszt avatar onoratoj avatar qknight avatar shantzis1962 avatar stephenhines avatar stewartmiles avatar thedmail avatar tmotee avatar tomnielsen avatar ukirazci avatar vharrong avatar wolffg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liquidfun's Issues

Fix -Wshift-negative-value error

Running run_tests.sh yielded

/Users/henry/liquidfun/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp:55:57: error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
                                                    (-1 << xShift));
                                                     ~~ ^

This can be fixed with

diff --git a/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp b/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
index ce1c01e..dbc02c4 100644
--- a/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
+++ b/liquidfun/Box2D/Box2D/Particle/b2ParticleSystem.cpp
@@ -52,7 +52,7 @@ static const uint32 yMask = ((1u << yTruncBits) - 1u) << yShift;
 static const uint32 xMask = ~yMask;
 static const uint32 relativeTagRight = 1u << xShift;
 static const uint32 relativeTagBottomLeft = (uint32)((1 << yShift) +
-                                                    (-1 << xShift));
+                                                    -(1L << xShift));

 static const uint32 relativeTagBottomRight = (1u << yShift) + (1u << xShift);

And then the unit tests complete without problem (yes the + - is unnecessary, but I thought it read the cleanest).

Particle orientation

From the Programmer's Guide, in regards to rigid particle groups:

"For example, firing a bullet that leaves a hole in a box-shaped group of particles."

This snippet gave me hope that I could create a destructible rigid body. Sadly, I can't because I can't get the orientation of particles, necessary for rendering.

Imagine removing, from a box-shaped group of particles, half its particles, diagonally. The remaining particles would rotate and fall over. If each particles represent a portion of a larger texture (like a crate), then it's impossible to render properly without the orientation of each particle.

I would really like this to be addressed in the future. I understand this would be more computationally expensive, so I suggest adding an option to enable this feature selectively.

b2Fixture::Synchronize() crashes sometimes under Android

Hello,
I'm writing a game based on Liquidfun (thanks for releasing the lib as open source!! :)
The Android version started to crash randomly when a particle system collided with other bodies.
In the stack you can see that it happens in b2Fixture::Synchronize()
Either the m_shape or the proxy pointer happens to be NULL sometimes. I haven't examined so far which one. The Windows version never crashes.

I added three checks for the pointers (broadPhase - which is probably always valid -, m_shape, and proxy) to Synchronize() which fixed this issue:

void b2Fixture::Synchronize(b2BroadPhase* broadPhase, const b2Transform& transform1, const      b2Transform& transform2)
{
if (m_proxyCount == 0)
    return;

if (!broadPhase)
    return;

if (!m_shape)
    return;

for (int32 i = 0; i < m_proxyCount; ++i)
{
    b2FixtureProxy* proxy = m_proxies + i;

    if (!proxy)
        continue;

    // Compute an AABB that covers the swept shape (may miss some rotation effect).
    b2AABB aabb1, aabb2;
    m_shape->ComputeAABB(&aabb1, transform1, proxy->childIndex);
    m_shape->ComputeAABB(&aabb2, transform2, proxy->childIndex);

    proxy->aabb.Combine(aabb1, aabb2);

    b2Vec2 displacement = transform2.p - transform1.p;

    broadPhase->MoveProxy(proxy->proxyId, proxy->aabb, displacement);
}
}

best regards
n-o-d

--- from LogCat ----

03-02 22:50:58.761: I/DEBUG(8794): pid: 8680, tid: 8694, name: Thread-396 >>> de.nikodeon.GameName <<<
03-02 22:50:58.761: I/DEBUG(8794): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000

03-02 22:50:58.886: I/DEBUG(8794): r0 00000000 r1 638871e8 r2 0000001c r3 00000000
03-02 22:50:58.886: I/DEBUG(8794): r4 61fbebd4 r5 639b5008 r6 00000066 r7 00000000
03-02 22:50:58.886: I/DEBUG(8794): r8 60277b00 r9 60179f28 sl 6013f290 fp 60277b14
03-02 22:50:58.886: I/DEBUG(8794): ip cdf7ee36 sp 602776a0 lr 5ff3b9cb pc 5ff3c764 cpsr 400e0030
03-02 22:50:58.887: I/DEBUG(8794): backtrace:
03-02 22:50:58.888: I/DEBUG(8794): #00 pc 003a8764 /data/app-lib/de.nikodeon.GameName-1/libgame.so (b2Fixture::Synchronize(b2BroadPhase_, b2Transform const&, b2Transform const&)+31)
03-02 22:50:58.888: I/DEBUG(8794): #1 pc 003a79c7 /data/app-lib/de.nikodeon.GameName-1/libgame.so (b2Body::SynchronizeFixtures()+134)
03-02 22:50:58.888: I/DEBUG(8794): #2 pc 003a9d0d /data/app-lib/de.nikodeon.GameName-1/libgame.so (b2World::Solve(b2TimeStep const&)+556)
03-02 22:50:58.888: I/DEBUG(8794): #3 pc 003aa371 /data/app-lib/de.nikodeon.GameName-1/libgame.so (b2World::Step(float, int, int, int)+196)
03-02 22:50:58.888: I/DEBUG(8794): #4 pc 001c7b63 /data/app-lib/de.nikodeon.GameName-1/libgame.so (LiquidFunController::execute1Frame_noParam()+1594)
03-02 22:50:58.888: I/DEBUG(8794): stack:
03-02 22:50:58.888: I/DEBUG(8794): 60277660 c3cdcfcb
03-02 22:50:58.888: I/DEBUG(8794): 60277664 c26cc12d
03-02 22:50:58.888: I/DEBUG(8794): 60277668 c3cdcff6
03-02 22:50:58.888: I/DEBUG(8794): 6027766c c38033a6
03-02 22:50:58.888: I/DEBUG(8794): 60277670 c26cc12d
03-02 22:50:58.888: I/DEBUG(8794): 60277674 42cc0fa6 /dev/ashmem/dalvik-heap (deleted)
03-02 22:50:58.888: I/DEBUG(8794): 60277678 42cbdc73 /dev/ashmem/dalvik-heap (deleted)
03-02 22:50:58.888: I/DEBUG(8794): 6027767c 638871e8
03-02 22:50:58.888: I/DEBUG(8794): 60277680 638871e8
03-02 22:50:58.888: I/DEBUG(8794): 60277684 00000049
03-02 22:50:58.888: I/DEBUG(8794): 60277688 61fac648
03-02 22:50:58.888: I/DEBUG(8794): 6027768c 5ff297f3 /data/app-lib/de.nikodeon.GameName-1/libgame.so (b2BroadPhase::MoveProxy(int, b2AABB const&, b2Vec2 const&)+22)
03-02 22:50:58.888: I/DEBUG(8794): 60277690 602776b0 [stack:8694]
03-02 22:50:58.888: I/DEBUG(8794): 60277694 c0000000
03-02 22:50:58.888: I/DEBUG(8794): 60277698 61fc1950
03-02 22:50:58.888: I/DEBUG(8794): 6027769c 5ff3c7b7 /data/app-lib/de.nikodeon.GameName-1/libgame.so (b2Fixture::Synchronize(b2BroadPhase_, b2Transform const&, b2Transform const&)+114)
03-02 22:50:58.888: I/DEBUG(8794): #00 602776a0 6386e384
03-02 22:50:58.888: I/DEBUG(8794): 602776a4 60277700 [stack:8694]

Getting Linker errors in Xcode project.

When I try to compile the Xcode project I get three linker errors:

clang: error: no such file or directory: '/opt/local/lib/libX11.dylib'
clang: error: no such file or directory: '/opt/local/lib/libXext.dylib'
clang: error: no such file or directory: '/opt/local/lib/libXrandr.dylib'

I couldn't find any documentation indicating any additional installs required to run the project.

I'm trying to compile the included Xcode project under the 1.0.0 release over here: https://github.com/google/liquidfun/releases

I'm running Mac OS X Version 10.9.2, Xcode Version 5.0.2. Additionally, I do have the latest XQuartz (X11) installed.

As a note, running the Xcode generated through Cmake does work.

Generate C# wrappers with SWIG

Liquidfun uses SWIG to create Java JNI wrappers.

It would be nice that liquidfun has support for C# binding generations using SWIG too.

Basic question: How to run an example code without testbed?

I want to run an example code and only see debugging outputs, that is without running testbed or test framework. Just one example once and see logs.

I'm new to c/c++ and I'm not familiar with build process in this project. Can you please tell me how should I do that.

I have manually ported box2d to JS, but there are some issues in my code. I'm trying fix them by comparing debugging logs.

deserializing/networking - request to add velocityData* to group-definition

b2ParticleGroupDef has a
const b2Vec2 * positionData
which allows to sync a group of particles over network by recreating a group using received positionData.
it would be great if this worked for the velocities too, to reduce initial differences between the local and remote particles.
once local and remote particles are set up, and as long as the amount of particles did not change, one may just write updated positions/velocities directly into the b2ParticleSystem's buffers. but in case amount of particles has changed or remote needs to create a copy of a "live" b2ParticleGroup (particles already have moved and aren't at their shape-defined position anymore) this would be very useful.

b2ParticleSystemDef

You may want to consider bringing the values gravityScale and density into b2ParticleSystemDef...

Final project based on liquidfun

My team likes to parallelize liquidfun for our final project in Parallel Computer Architecture and Programming course (15-418) in Carnegie Mellon University. I would appreciate any input or suggestions or insights regarding algorithm in the starter code that can be parallelized.

Multiple world instances in javascript

I don't know wether this is a bug or a feature, but I cannot seem to make anything work unless I have my b2World in a global variable named 'world' when using the javascript compiled version of liquidfun.

AutoBuild/build.sh fails on OSX due to unused-const-variable

b2ParticleSystem.cpp:39:21: 
error: unused variable 'xMask' [-Werror,-Wunused-const-variable]
static const uint32 xMask = (1 << xTruncBits) - 1;

-Wno-unused-const-variable helps.
I'm not sure if this proper solution and where to put it exactly.

Liquid fun memory leak

Hi
I just put the following lines in main() in Testbed for memory leak check:

if defined(_WIN32)

// Enable memory-leak reports
_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG));

endif

the result shows large memory leak.

Allow particles to pass through non-sensor fixtures via filtering

When you use the b2ContactFilter, you can prevent fixtures from applying a reactive force to particles, but the particles are still stopped by the fixture. There should be an option that lets particles pass through non-sensor fixtures via flags, similar to the collision masking between two fixtures.

C-Compiler reports Errors

I am trying to implement LiquidFun into my Android project but the compiler fails and points out different #includes which he can't find.

Example
screenshot
This is a SWIG generated file but also #includes in the already existing files in the downloadable LiquidFun directory get marked and it stops compiling

"C:\\AndroidSDK\\android-sdk-windows\\AndroidNDK\\ndk-build.cmd" all 
[armeabi] Compile++ arm  : liquidfun_jni <= liquidfun_wrap.cpp
In file included from ../../../../../Libraries/LiquidFun/liquidfun/Box2D/swig/jni/../../Box2D/Box2D.h:40:0,
                 from ../../../../../Libraries/LiquidFun/liquidfun/Box2D/swig/jni/../gen/cpp/armeabi/liquidfun_wrap.cpp:619:
../../../../../Libraries/LiquidFun/liquidfun/Box2D/swig/jni/../../Box2D/Collision/b2BroadPhase.h:25:21: fatal error: algorithm: No such file or directory
 #include <algorithm>
                     ^
compilation terminated.
make.exe: *** [obj/local/armeabi/objs/liquidfun_jni/gen/cpp/armeabi/liquidfun_wrap.o] Error 1

SWIG works fine, AndroidNDK works fine and both are updated to absolute latest version.
As well is Java, Eclipse, AndroidSDK and all of its additional libraries and (maybe it makes a difference) VisualStudio.

I don't know if the errors are caused by the different tools, by myself or by the available liquidfun libraries but since everything worked (most of the time) trustworthy and this is a LiquidFun-only-problem so far I am asking/reporting here.

With Best Regards

Project based on LiquidFun

Hello all,

Similarly to Jim Hye (who posted an issue about a year and a half ago), my team and I found LiquidFun very intriguing and have selected it as the subject of our final project. Rather than parallelizing the code however, we are looking for ways to make LiquidFun run faster or more efficiently relating to data stuctures. Basically we are looking for anywhere in the program that might slow up a little bit - where we might be able to implement an alternative, more efficient sorting algorithm, searching algorithm, or data structure to store things.

We would appreciate any advice as to where in the program these optimizations might be most useful!

Thanks,
Patrick Drumm

How to Manipulate Density/Force on a Body dynamically using LiquidFun.js

Hi, I am trying to use the JavaScript version of LiquidFun to achieve a density based interactive simulation, where I change the density of a ball dynamically so that it floats or sinks or partially float. I took the TestSoup.js example code as my base code. I tried assigning density values to the ball and the liquid molecules, in the hope that the physics would play out itself and the ball would do the expected accordingly. However, it didnt make any difference and the ball some or the otherway always goes to a floating position.(just like in the TestSoup example, unless you use the mouse to force and place it at the bottom) Shouldn't the density property alone do the needful for my case? Or if it doesn't, is there a way to apply a continual force(just on the ball), so that it will stay sinked or float or partially float , depending on the values I specify.
selection_036

Issues in Programmer's Guide

Typo in
Joints -> Joint Definition
Third sentence states "One body may static."

Formatting problem in
Joints -> Using Joints -> Revolute Joint
13th paragraph is a code fragment that is not formatted correctly (not in code format and contains no line breaks)

Swig b2PolygonShape missing functionality (patch enclosed)

Patch for Box2D/swig/java/Collision/Shapes/b2PolygonShape.swig. It adds a binding for the Set(b2Vec2 *points, int32 count) function, allowing the creation of a polygon that's not rectangular. I'm a total noob with Swig - I just copied similar code from another file, and tweaked a few things - if there's a better way to do this, let me know.

25,44d24
< %typemap(jni) (b2Vec2 *points, int32 count) "jobject"
< %typemap(jtype) (b2Vec2 *points, int32 count) "java.nio.ByteBuffer"
< %typemap(jstype) (b2Vec2 *points, int32 count) "java.nio.ByteBuffer"
< %typemap(javain) (b2Vec2 *points, int32 count) "$javainput"
< %typemap(javaout) (b2Vec2 *points, int32 count) {
<     return $jnicall;
< }
< // This extracts the Java ByteBuffer address from C++
< %typemap(in) (b2Vec2 *points, int32 count) {
<     $1 = (b2Vec2*) jenv->GetDirectBufferAddress($input);
<     $2 = jenv->GetDirectBufferCapacity($input) / 8;
<     if (($1 == NULL) && ($2 != 0)) {
<         SWIG_JavaThrowException(
<                 jenv,
<                 SWIG_JavaRuntimeException,
<                 "Unable to get address of java.nio.ByteBuffer. "
<                 "Is the ByteBuffer initialized?");
<     }
< }
< 
56d35
<     void Set(b2Vec2 *points, int32 count);
58,60d36
< 
< /// Clear the typemaps
< %clear (void* outBuf, int size);

Serious Bug about particle collision

  1. Some times in special coordinate (example when x between 325.19 and 330.3309) , particle not collide with any fixtures;
  2. Please add origin shift to particle system.

The problem maybe in here :
b2FixtureParticleQueryCallback::ReportFixture

// Receive a fixture and call ReportFixtureAndParticle() for each particle
// inside aabb of the fixture.
bool ReportFixture(b2Fixture* fixture)
{
    if (fixture->IsSensor())
    {
        return true;
    }
    const b2Shape* shape = fixture->GetShape();
    int32 childCount = shape->GetChildCount();
    for (int32 childIndex = 0; childIndex < childCount; childIndex++)
    {
        b2AABB aabb = fixture->GetAABB(childIndex);
        b2ParticleSystem::InsideBoundsEnumerator enumerator =
                            m_system->GetInsideBoundsEnumerator(aabb);
        int32 index;
        //////////////////////////////////////////////////////////////////////////////////////////
        **// bus in here:  the enumerator always have zero item**
        while ((index = enumerator.GetNext()) >= 0)  
        {
            ReportFixtureAndParticle(fixture, childIndex, index);
        }
    }
    return true;
}

b2DebugDraw is undefined in Javascript version

This is a Great project! but I'm having trouble figuring out how to draw debug data onto the canvas using the included version of liquidfun.js which was updated a month ago.
In the online documentation it says "You can implement the b2DebugDraw "... does this mean it debug drawing hasn't been implemented in this version of liquidrfun?
I'm not savy enough to bend the testbed to my will for use as a debugdraw, and don't want to rewrite the logic to loop through the world and draw debug if something like this already exists, so any help will be much appreciated. :)

GCC also needs find_package(Threads)

The current CMakeLists.txt only call find_package(Threads) for clang, but I found gcc also needs it, tested in Ubuntu 15.10, with gcc version 5.2.1. I found this PR claims MSVC needs it but it was deleted later. And this PR claims WIN32 needs it but has not been merged. However, They also claim gcc do not need this call. So when should we use find_package(Threads) after all?

Cocoapod integration

It should make it easier if we can use Cocoapod to install the library, just like Box2D had done.

Instructions can be found here: http://guides.cocoapods.org/making/getting-setup-with-trunk.html

Here is a working Podspec I used in my private repository:

{
  "name": "liquidfun",
  "license": {
    "type": "zlib"
  },
  "version": "1.1.0",
  "summary": "LiquidFun is a 2D physics engine for games.",
  "description": "LiquidFun is an extension of Box2D. It adds a particle based fluid and soft body simulation to the rigid body functionality of Box2D.",
  "homepage": "http://google.github.io/liquidfun/",
  "authors": "Google",
  "source": {
    "git": "https://github.com/google/liquidfun.git",
    "tag": "v1.1.0"
  },
  "source_files": "liquidfun/Box2D/Box2D/**/*.{h,cpp}",
  "header_mappings_dir": "liquidfun/Box2D",
  "requires_arc": false
}

Segmentation fault when running Convex Hull

Hi,

I installed Liquid Fun v1.0 (stable) with DEBUG build type mentioned here. However, after executing the Testbed, the program throws segmentation fault whenever I select Convex Hull test from the menu.

How it can be used in Libgdx for Destop and Core projects

I imported the Testbed as a Android Application and it is running fine in Android, but i want to use it in libgdx core project so that I can use water in any place for Desktop and Android application.
I know it is using Native code, but i want to call this native code from core-project so that I can use this in Tiled+Libgdx game.
In my game I am using Libgdx + Tiled + Eclipse.
Please suggest.

OSX build results in blank white screen when running Testbed

So this is sort of a combo problem. First issue is that using

cmake -G Xcode

A proper Xcode project file does not build. There are a slew of errors. They range from TryCompile issues to get_filename_component called with incorrect number of arguments. If you try running cmake -G Xcode a few times, it eventually churns out an Xcode project file, which does build. However, when running 64-bit, it produces a white screen only. In 32-bit, you see the graphics, but the simulators do not run and it seems to have no keyboard input.

Alternatively, I tried to build it using build.sh. This worked. But the result was the same: Testbed ran with a pure white screen.

I'm running OSX 10.9.5. I installed XQuartz 2.7.7. My cmake version is 2.8.12.1. I am however, using Xcode 6.1. I should also note that the iOS version runs fine.

Unsatisfactory state

I recently in the study of SPH fluid simulation. Now encountered a very thorny problem. When the liquid depth is larger, the underlying state of particles is not stable, but violent vibration, end up some very not ideal state. I've tested the many programs, such as the OE - Cake, and LiquidFun,And many other implementations. All have the same problem. I want to know whether this is the flaw of SPH algorithm itself or the other?
oe-cake
liquidfun

Drawing Particles test, javascript version, keyboard shortcuts not working.

While running Drawing Particles test, javascript version, and pressing on of the available keyboard shortcuts (defined here) flags and groups should change instead particles start being generated on mouse move even if mousedown has not been triggered.
The solution found is to add toUpperCase() function to the key variable at line 84 in the testDrawingParticles file, or, changing al case statements within the switch conditional to lower cases letters.

A small question

Hi,cai i ask you a question?
I use liquidfun with my game project, ( i use the cocos2dx game engine)
and i add the soft-body(Elastic Paricles) to the game, and then bind it to the sprite.
the question is, the soft-body change it's shape anytime, but my sprite's picture is fixed species.
so, how can i make the sprite's picture same as the soft-body's shape?

someone adjust me to use openGL to change the picture's shape,
but i don't know how to do it.

thanks for all

Are there any example code for liquidfun?

Hi, I'm new to this, i think it is a good project,
but i found less example for it.
i don't know how to use it for my project
can you show me some example code for it?
thank you very much

EXC_BAD_ACCESS in testbed "Drawing Particles"

Start "Drawing Particles" example in the testbed, choose Elastic Particles and slowly draw a vertical line of particles like this:
screen shot 2014-03-10 at 10 49 55 am

Resulting EXC_BAD_ACCESS, see attached Xcode screenshot:
screen shot 2014-03-10 at 10 35 55 am

Particle-polygon collision callback

Is there any way to set up a callback for contact begin/end between particles and Box2D bodies?
I've searched the specification but found nothing โ€“ the listener is fired only on collisions between Box2D bodies. I'm using the JavaScript version.
Thanks a lot, what an amazing library!

liquidfun.js bugs

I found some problems with the existing bindings.

b2Body.CreateFixtureFrom(Def|Shape) accesses a global variable called world instead of the world the b2Body belongs to.

The methods GetParticleCount/GetPositionBuffer don't work quite right. Sometimes GetParticleCount is off by one, which might be because of the int/double casting.
The position buffer is too small. It has the same size as the numberGetParticleCount() returns, but should be twice as large. The current bindings code seems to allocate the buffers correctly, but still results in this problem while running the code. Unfortunately, I'm not so acquainted with Emscripten so I can't figure out where the problem lies.

ParticleCollission and other missing functionality in Javascript Port

I have been experimenting with Liquidfun in Javascript for a while and already added some missing bindings. But to add some more complex logic to games i would need much more functions exposed.

It is quite frustrating to read about all those cool features in the API Doc, but not being able to use them. In the Source files are a lot of TODOs aiming to fix that, but are the original devs still trying to finish that any time soon?

What i did so far was adding simple functions with void or non-complex return values. But to get any further i would need b2ParticleSystem.GetBodyContacts() which returns an Array of b2ParticleBodyContact. Emscripten returns the Pointer to that Object, which is pretty useless in JavaScript.

I looked up the other JS code and learned from the example of b2World.CreateBody() that the created objects get saved in a dictionary with the pointer as key.

var body = new b2Body(..);
this.bodiesLookup[body.ptr] = body;
return body;

So far so good, i added code to keep a reference to every single Particle i create. But since the method i want to port returns an object i never created, i don't have a reference to it.

Additionally i wanted to ask what the particle flags b2_fixtureContactListenerParticle, etc are about?
I created a listener in JavaScript, but only seem to get Contacts between Dynamic Bodies. even when i flag my particles with those ContactListener flags. - Does this call the other overloaded callback BeginContact (b2ParticleSystem *particleSystem, b2ParticleBodyContact *particleBodyContact) ?

If yes, this would make 2 methods for getting contact information of particles?
What is the difference and which is to prefer and why?

I would like to get this going and add more functionality, but i would need some guidance and hints in doing so. Really looking forward to hearing from the devs or anyone else providing some knowledge to this.

liquidfun.js: ParticleCount and length of PositionBuffer don't match

When you create particles in the JavaScript version, the ParticleCount and PositionBuffer.length don't match the expected result.

Expected result:

ParticleCount: Number of particles in the system
PositionBuffer.length: 2*ParticleCount

Actual result:

ParticleCount: 2 * Number of particles in the system
PositionBuffer.length: ParticleCount

You can check the bug with this testbed implementation: https://gist.github.com/zilluss/219a4c32feb59c3a0222

b2GrowableBuffer.h missing from CMakeLists.txt

liquidfun/Box2D/Box2D/CMakeLists.txt needs to have Common/b2GrowableBuffer.h in BOX2D_Common_HDRS. Without this, the header will not be installed on the system, resulting in failing builds when including Box2D.

This affects v.1.1.0.

Pull request #21 fixes this.

b2ContactFilter with particles and fixtures doesn't work.

Using a b2ContactFilter (SetContactFilter & b2_fixtureContactFilterParticle) to allow particles to pass through fixtures results in the particles getting stuck to the edge of the fixture.

I tracked down the issue to the SolveCollisionCallback class not correctly calling ShouldCollide() when it would adjust particle to avoid them passing through fixture boundaries in a single step.

Testbed Javascript: Air in water and not changing

I don't know if this really is a bug, but I was just playing (spawning particles on the side to speed them up) with the Testbed and then suddenly this happened: (this really is air, because after changing something thereafter it collapsed)

Testbed Javascript problem

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.