Julio Jerez wrote:you mean this
is that is what you are doing, ther mous be something else wrong.
is you make a debug build and step over the function, you will see that from begin to end is no more than a few dozen lines of code, including every thing, certainly less than 100.
Yes, that, and also this (how I create the body and set up mass and inertia):
- 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
// grab the inertia which will be later used to set decreasing mass to the body
dFloat dummyMass;
dVector dvInertia;
NewtonBodyGetMass(newEntity->nBody, &dummyMass, &dvInertia.m_x, &dvInertia.m_y, &dvInertia.m_z);
newEntity->SetInertia(dvInertia);
It is important to remember that, when I change mass at visual update level (~60 FPS) everything is fine. But when I use the same call on a physics update level (perhaps ~500 fps?) I get a crash.
So, I don't think there is anything wrong with how I set up my scene (body built with compound collision) and the method I am using to decrease the mass. However, it seems as if I am using NewtonBodySetMassMatrix the way it wasn't intended (perhaps too often?).
Also, zak, I am using synchronous version of NewtonUpdate:
- Code: Select all
NewtonUpdate(g_world, timestepInSecunds);
I'm not proficient enough in multithreaded coding - I am simply calling NewtonUpdate the way it was set up in sandbox examples. My app is a DLL with an event loop.
Event loop is calling synchronous version of NewtonUpdate on every iteration (not sure how fast this is iterating, but let's say 500 fps). One of the events is a frame update notification (which happens at ~60fps), where I grab all of the object's positions and rotations, and pass it on to a simulator client for visual display - that is all.