I manually set rotations of a part, to mimic an angular velocity.
For each frame:
Code: Select all
m_bodies[0]->activate();
btVector3 angularVelocityLocalCoord(0.,0.,1.5);
// Convert to world coordinates
btVector3 angVWorld = m_bodies[0]->getWorldTransform().getBasis() * (angularVelocityLocalCoord);
btMatrix3x3 w_cross = btMatrix3x3( 0., -angVWorld.z(), angVWorld.y()
, angVWorld.z(), 0., -angVWorld.x()
, -angVWorld.y(), angVWorld.x(), 0.);
// Step the rotation
// This line works fine
//btMatrix3x3 newRot = m_bodies[0]->getWorldTransform().getBasis() + (w_cross * m_bodies[0]->getWorldTransform().getBasis()) * timestep;
// This line causes twitchy rotation
btMatrix3x3 newRot = partRotation + (w_cross * partRotation) * timestep;
m_bodies[0]->getWorldTransform().setBasis(newRot);
partRotation = newRot;
...
m_dynamicsWorld->stepSimulation(timestep)
Would someone explain what the difference is between the two rotations please? I've attached a modified demo that demonstrates the problem. The lines in question are in RagDoll::Rotate()
Thanks,
Tom