Julio Jerez wrote:Michio how are you calculation the inertia? I remember we talk about this in the pass.
are you using a compound are a helper to calculate the inertia distribution?
if this is the case and you compound is made of dense convex shapes them the slow down in on function of some equivalent. NewtonConvexCollisionCalculateInertialMatrix
the reason is the convex for a convex polygonal shape the only way I know to calculable the inertia is by using the divergence and the green theorem. and that iterates over the entire polygonal mesh of the collision shape so it can by quiet expensive for a dense shape.
Is that what you are doing?
tell me how are calculating the inertia after you change the mass?
Morning (?) guys!
To calculate inertia, I first load up the compound collisions (cylinders, cones, etc) and create a body using the compound collision and STARTING mass. For the main orange rocket body, for example, I have 9 cylinder compound collision... is that what you consider dense?
- Code: Select all
// create a body with given compound collision and mass
newEntity->nBody = CreateRigidBody (world, newEntity, objectCollision, newEntity->GetGrossMass()); // <- mass parameter. read this from the object data
When that's done, I get inertia vector using:
- Code: Select all
NewtonBodyGetMass(newEntity->nBody, &dummyMass, &dvInertia.m_x, &dvInertia.m_y, &dvInertia.m_z);
I save dvInertia vector and I NEVER re-calculate it again (because I assume symmetry, what JoeJ mentioned). I re-apply new mass in a visual frame loop, with the NewtonBodySetMassMatrix method, new mass, and this saved inertia... Yes we talked about this before and this is how I understood this needs to be done. Is that correct?
I should mention that while investigating this, I shifted some code around and now I'm getting crashes instead of performance degradation. They are definitely because of NewtonBodySetMassMatrix (when I comment it out, everything works, except of course the mass isn't changing). So:
with NewtonBodySetMassMatrix in visual loop, all is ok
with NewtonBodySetMassMatrix in physics loop, crash
with NewtonBodySetMassMatrix in physics loop commented out, fine.
Crashes are always at the same point of execution, but not in the NewtonBodySetMassMatrix but a few lines before or after... I checked all the NewtonBodySetMassMatrix parameters and everything I pass in is valid...
the only reason I can think of is that, when in physics loop, NewtonBodySetMassMatrix is called earlier than when in visual frame loop. Perhaps some objects and links aren't created yet, and that presents a problem?