Where to implement hydrodynamics

Post Reply
kris928
Posts: 9
Joined: Wed Mar 05, 2014 7:22 pm

Where to implement hydrodynamics

Post by kris928 »

Hi,

I've successfully implemented a basic buoyancy / hydrodynamics prototype with bullet within the btActionInterface. However, I've noticed it experiences stability issues and also behaves in crazy ways when my objects are not heavy enough.

I'm aware of at least a few issues with this approach, and I was wondering if I am using bullet correctly. Here's what I'm doing inside of the btActionInterface I wrote:

1. Computing the drag / lift forces for each face and applying them in sequence as impulses.
2. Then, computing the buoyancy force as a function of the submerged volume and applying it as an impulse with applyImpulse at the center of the submerged mass.

I believe this is creating the following issues:

1. I'm applying impulses which are effecting the velocity of the body immediately. As a result, when I calculate the next point velocity for the next face it has already accounted for the impulses from the previous face which I don't want. Do I have to accumulate these myself before applying them or is there a way to use forces inside of btActionInterface instead of impulses so the velocity is not immediately effected?

2. For low mass objects with relatively high surface area, the impulses are much too high when I drop the objects from the air and they first touch the water. Presumably this is because they penetrate the water more than they should, and possibly also because I'm not capping the drag/lift appropriately?

I feel like I can keep working through these issues, but I feel like I'm working around bullet more than I should be. Is there a better way to model this in bullet than what i am doing?

Thanks,
Kris
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Where to implement hydrodynamics

Post by Basroil »

Try running the simulation with smaller steps (1/500, 1/1000) and see if the light weight objects work better. If so, then your issue is entirely within penetration, and better time-steps or collision methods would help.

And since you're calculating the per-face forces already, why not just add pressure? Buoyancy isn't a real force, it's just the result of unbalanced forces. You might as well just add local pressure when you do lift, since that too is just pressure differences.
kris928
Posts: 9
Joined: Wed Mar 05, 2014 7:22 pm

Re: Where to implement hydrodynamics

Post by kris928 »

Thanks for the quick reply. Running the simulation with smaller steps fixed the issue. If I didn't have the horsepower to run the simulation at smaller steps then presumably there is some other way I could improve stability?

You mentioned collision detection. I haven't thought much about collision detection because I'm not really doing it in this game other than the fluid interactions. Intuitively, I can see how you would want to approximate the time two objects first intersected so that you could "rewind" their position and apply the appropriate impulse. I'm not entirely sure how to think of interaction between a rigid body and two fluids (water and air) as collision detection. Is there a better solution than trying to just "tick" the water action interface more frequently than the rest of the simulation?

With respect to using pressure instead of modeling pressure as buoyancy, I don't actually know enough about pressure to do that. I would assume you are suggesting that I approximate the integral of the pressure on a per face basis but I'm not really sure how I would go about doing that, and don't know if it will actually be any more accurate. I did a quick search for information but came up short. Perhaps you know of something online I can read to learn more?

Thanks so much.

Kris
kris928
Posts: 9
Joined: Wed Mar 05, 2014 7:22 pm

Re: Where to implement hydrodynamics

Post by kris928 »

With regard to pressure, I want to clarify that I'm looking for information that relates pressure to buoyancy, not how to code it ;). I just don't know enough about pressure forces to see how I would accomplish buoyancy in code with it.
zbuffer
Posts: 8
Joined: Sat Jan 05, 2013 11:13 am

Re: Where to implement hydrodynamics

Post by zbuffer »

That is simple. The buoyancy is caused by a difference in hydrostatic pressure. The bottom polygons of a submerged mesh will be under a higher pressure than the top ones so the mesh will be pushed up.
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Where to implement hydrodynamics

Post by Basroil »

zbuffer wrote:That is simple. The buoyancy is caused by a difference in hydrostatic pressure. The bottom polygons of a submerged mesh will be under a higher pressure than the top ones so the mesh will be pushed up.
Exactly. The best part is that you don't need to calculate the bouyancy at all, just apply a force along the face normal at the center of the face relative to the local pressure at the point.

Interestingly enough, it doesn't matter how "deep" in a medium your object is if you use a linear pressure curve, so if you want to you can just calculate the resultant force in different mediums ahead of time if it's a sphere (or close enough that shape doesn't matter) and just test for the amount of the object in each medium.
User avatar
L83
Posts: 2
Joined: Tue Jul 29, 2014 1:56 pm
Location: France

Re: Where to implement hydrodynamics

Post by L83 »

nikkimerrill wrote:Neither open source, nor PHP,
What the frig are you speaking about ?

Nyeh, kris, if you want a better stability of your Object, you can subdivide that into differents parts (4 are necessary) and apply the forces, drag and lift (divide by the number of parts) on each of them.

I'm working on a similar project, so I can tell how difficult it is ! :p
Post Reply