My main problem is that I already use the simpliest integration method that is euler'one to compute steering force
F=mA , v=Adt and newpos= pos+ v dt
...Then it's easy to clamp my force in order not to exceed an arbitrary maxspeed .
When i push my clamped force in bullet my maxspeed is atteigned in bullet model...:It drive me to the conclusion that bullet integration model is really a simple euler one as i expected...
But the problem is that when I print (newpos-oldpos).length()/elapsedT the speed is completely different, I dont understand.
Code: Select all
btPoint3 oldpos=BulletBody->getCenterOfMassPosition ( )
float maxSpeed =5;
Vec3 newAcceleration = (SteeringForce / mass());
Vec3 newVelocity = velocity()+newAcceleration* elapsedTime;
// enforce speed limit
newVelocity = newVelocity.truncateLength (maxSpeed );
btVector3 vel(newVelocity.x,newVelocity.z,0);
BulletBody->setLinearVelocity(vel );
bulletWorld->stepSimulation(elapsedTime);
btPoint3 newpos=BulletBody->getCenterOfMassPosition ( )
cout<<(newpos-oldpos).length()/elapsedTime<<endl; //2.6
cout<<BulletBody->getLinearVelocity()<<endl; //5