Bullet position update?

mp3butcher
Posts: 13
Joined: Wed Jun 06, 2007 8:05 am

Bullet position update?

Post by mp3butcher »

Hello I'm a newbie with physics engine . I'm using Bullet cause i don't know how to integrate movement of a N spherical bodies in contact problem accuratly and i would like to take into account physical collision in my simulation.
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
If anybody could help I would be glad...
mp3butcher
Posts: 13
Joined: Wed Jun 06, 2007 8:05 am

Re: Bullet position update?

Post by mp3butcher »

oki i have understand alone this is that damned default parameters of stepSimulation(elapsedT,int substep=1,float fixedframerate=1/60);
when i wrote
stepSimulation(elapsedT);
it consider that where are in a fixed timestep integration then elapsed is completly discarded...

then I wrote

stepSimulation(elapsedT,0) in order not to use internal timestep

But i always have a problem when collision occurs: mybtdynamicobject->getCenterofMass() return a NAN NAN NAN vector

Is there anyone that can help me with this problem?