Ok I found the Bug, you are setting the Inertia matrix of each body to zero.
That makes the body spins very unrealistically, because if a body with zero resistance to spin any amoundt of torque from teh solver traslate to a very high angular velocity.
I am surprised it did not just blew up right away, the solver is so good that it always calculated force that amount to zero torque when the body is on flat ground,
but when the contact normal are not parallel, then the net torque is not zero and that give the body a high velocity.
It did not blow up because the integrator in Newton does not allow bodies spin faster than one half of a turn in one frame.
I looked at your file NewtonPhysics.cpp and I found the place where you create the body.
I added this modification
- Code: Select all
// Julio made this modification to make sure body have correct inertia
if (N_Mass > 0.0f) {
NewtonCollision* shape = NewtonBodyGetCollision(pN_RigidBody);
D3DXVECTOR3 inertia;
D3DXVECTOR3 centerOfMass;
NewtonConvexCollisionCalculateInertialMatrix (shape, &inertia.x, ¢erOfMass.x);
//NewtonBodySetMassMatrix (pN_RigidBody, N_Mass, N_VectorMassOffset.x, N_VectorMassOffset.y, N_VectorMassOffset.z);
NewtonBodySetMassMatrix (pN_RigidBody, N_Mass, N_Mass * inertia.x, N_Mass * inertia.y, N_Mass * inertia.z);
NewtonBodySetCentreOfMass(pN_RigidBody, ¢erOfMass.x);
}
With that change it seems to work fine now.
I also saw the you gravity is really, really high, but I am guessing you are doing something different than Earth Gravity system.
Just for the record I thonk you are using a metric system, and if that is correct a gravity of 40, it amost twice as high as a Jupiter Gravity, that’s too extreme.