but the Bullet's function getOrigin seem to lag (delay) by one timestep.
Here are pseudo code :-
At every time step (just before "stepSimulation") , I called this
Code: Select all
old = getPositon(rigidBody); //print to "old"
targetPositionWish = Vec3(0,20,0); //print to "wish"
velocityShould = targetPositionWish - old ; //print to "vel"
rigidBody->setLinearVelocity(velocityShould / timeInSecondPerTimeStep );
Code: Select all
btTransform kk;
motion->getWorldTransform(kk); <---- this motion is the same pointer as when create RigidBody
return kk.getOrigin();
Code: Select all
0 old=(0,0,0)
0 wish=(0,20,0)
0 vel=(0,1200,0)
1 old=(0,0,0) //<----- should be (0,20,0) now
1 wish=(0,20,0)
1 vel=(0,1200,0)
2 old=(0,20,0) //<----- it happen at this line instead, too lag
2 wish=(0,20,0)
2 vel=(0,0.0001144409107,0)
If it is designed to be laggy (delay), how to set position via linear velocity?
Any a wild guess can help, thank!
Edit1: I misunderstood that linearVelocity is laggy, but actually getOrigin() is laggy.
Edit2: Using rigidBody->getCenterOfMassPosition() instead of getOrigin() is the solution for this problem.
But ... why getOrigin()!=getCenterOfMassPosition()?