[WIP] Fluid for Box2D

Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

[WIP] Fluid for Box2D

Postby kenneth_g » Sun Feb 24, 2013 10:17 am

Hello all!

As mentioned in my previous post, I have been working on getting fluids to work with Box2D, and have finally made enough progress to show you guys a working example!

I have attached a testbed with two preliminary tests: a standard dam break, and a buoyancy test that I have been experimenting with.

Some controls:
    You can click a particle to show some debug info.
    Check the 'AABBs' checkbox to see the fluids contact groups.
    Check the 'Contact Points' to render all the edges connecting the particles. You don't have zoom out very far, before it looks solid :)

The fluid in its current state is stable-ish. There are situations were the fact that it is 'only' running at 60hz is apparent, like during high-pressure situations. The lack of simulation precision causes it to temporary become unstable, but never so much that it explodes. I will look into this issue in the future, maybe using some kind of adaptive time-stepping.

- Kenneth G.
Attachments
Testbed.zip
(158.31 KiB) Downloaded 306 times

irresistible force
Posts: 1988
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: [WIP] Fluid for Box2D

Postby irresistible force » Sun Feb 24, 2013 4:39 pm

Unlike your earlier upload, this one is saying I need MSVCP110.dll and MSVCR110.dll. I found these on the net pretty quickly but there seems to be some incompatibility, at least with wine on linux :)
I wonder if you could build it in the same way as before - looking forward to trying it out!

kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

Re: [WIP] Fluid for Box2D

Postby kenneth_g » Mon Feb 25, 2013 12:16 am

I recently upgraded to Visual Studio 2012, which is causing these issues for you. I re-downloaded and installed 2010, and here is a recompiled version.

Btw, I noticed that the 2010 version is several milliseconds slower than the 2012 version. Guess Microsoft put some more aggressive optimizations in the latest VS :)

irresistible force
Posts: 1988
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: [WIP] Fluid for Box2D

Postby irresistible force » Mon Feb 25, 2013 4:45 am

Outstanding. Looks like your particles system was a good solid foundation to build this on :)

genbox
Posts: 69
Joined: Mon Jun 15, 2009 4:34 pm

Re: [WIP] Fluid for Box2D

Postby genbox » Mon Feb 25, 2013 5:49 pm

I'm wondering if you are able to simulate a larger number of particles, and what kind of method are you using for collisions on particles vs. rigid bodies?

kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

Re: [WIP] Fluid for Box2D

Postby kenneth_g » Tue Feb 26, 2013 10:25 am

genbox wrote:I'm wondering if you are able to simulate a larger number of particles

I actually recently had a realization regarding my data-structures and how I was organising things, that I could change some things around, and speed it up considerably. I have attached the newest version of the testbed, with 4 different versions for the dambreak test (2K, 4K, 8K and 16K versions) that you can try out. I also managed to vastly stabilize the pressure calculations, so there is no more of the near-explosion fluctuations in high pressure areas, that I saw in earlier versions.

genbox wrote:...what kind of method are you using for collisions on particles vs. rigid bodies?

It's almost the same code as the particle system, except I am testing against circles, and not particles.
The collision response is a slightly modified (optimized for particles) version of the collision response found in Box2Ds b2ContactSolver.cpp
Attachments
Testbed_vs2012.zip
(157.14 KiB) Downloaded 222 times
Testbed_vs2010.zip
(161.38 KiB) Downloaded 193 times

kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

Re: [WIP] Fluid for Box2D

Postby kenneth_g » Tue Feb 26, 2013 12:53 pm

irresistible force wrote:Outstanding. Looks like your particles system was a good solid foundation to build this on :)

Thanks :)

Yeah, having the particle system done and ready to build on, makes it easier to stay focused on the fluid code, and getting that working and running fast.

bitshit
Posts: 14
Joined: Thu Aug 13, 2009 8:28 am

Re: [WIP] Fluid for Box2D

Postby bitshit » Mon Mar 04, 2013 2:47 pm

Awesome!
This should pave the way for more interesting and dynamic physics!

I did notice the simulation gets unstable when I set the update step to 30Hz, has this to do with the fluid simulation itself?

kenneth_g
Posts: 16
Joined: Sun Mar 28, 2010 11:58 am

Re: [WIP] Fluid for Box2D

Postby kenneth_g » Wed Mar 13, 2013 7:44 am

bitshit wrote:I did notice the simulation gets unstable when I set the update step to 30Hz, has this to do with the fluid simulation itself?


Yes it does. All SPH fluid simulations are sensitive to the step size, and ideally it should run at a higher rate, but for now, 60hz seems to be adequate.

genkigama
Posts: 2
Joined: Tue Sep 24, 2013 8:18 pm

Re: [WIP] Fluid for Box2D

Postby genkigama » Tue Sep 24, 2013 8:21 pm

Hi Kenneth,

Do you have any plan to release your code?


Return to “General Discussion”



Who is online

Users browsing this forum: Exabot [Bot] and 1 guest