i'm adding a buoyancy momentum to all my entities in their update method this way:
Code: Select all
// add buoyancy momentum
if (buoyancy == true) // apply buoyancy force only to objects which are already moving to allow the entities to fall to sleep mode if they got to a rest
if ((convexHull.AngularVelocity.LengthSquared() > 0.01f) || (convexHull.LinearVelocity.LengthSquared() > 0.01f))
convexHull.LinearMomentum += buoyancyMomentumVector;
my approach works well together with the global gravity. i use the if statement to make sure, that the entities can fall to inactive mode to save (lots) of cpu time if they don't move anyway. if i would just add the buoyancy momentum every frame they would never get inactive and waste cpu cycles.
well, that's some kind of solution, but i'm not really happy with it. it would mean, that if an object gets stuck beneath another object due to buoyancy and the top object suddenly disappears, the object beneath would not feel a buoyancy force until it gets some momentum from somewhere else.
what would be great would be some kind of entity based gravity (so i could add together gravity and buoyancy force, which would also save cpu cycles since both work in the same dimension, just in opposite directions).
i use the framework for only two days now (and its great by the way), so i don't have that much experience with it yet.
how could i improve my approach?
thx
trick