Initial Angular Velocity

Makail
Posts: 3
Joined: Sun Oct 02, 2011 8:32 pm

Initial Angular Velocity

Post by Makail »

I'm having a problem where if I specify maxSubSteps > 1 in the physics step any object in the scene that I have initially rotating will spin at a ridiculous speed.

Any idea why this could be?
Last edited by Makail on Sun Oct 02, 2011 8:46 pm, edited 1 time in total.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Initial Angular Velocity

Post by Dr.Shepherd »

What's your parameters for timeStep, maxSubSteps and fixedTimeStep?

Code: Select all

btDynamicsWorld::stepSimulation(
   btScalar timeStep,
   int maxSubSteps=1,
   btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
Makail
Posts: 3
Joined: Sun Oct 02, 2011 8:32 pm

Re: Initial Angular Velocity

Post by Makail »

Elapsed time between frames (in seconds), 4 sub steps, and 1/30.0f.

Edit: First post should have maxSubSteps > 1. Not 0.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Initial Angular Velocity

Post by Dr.Shepherd »

You can just print "Elapsed time between frames (in seconds)" out, and see how big it is approximately.

The substep time size is 1/30, your max substep is 4, so it can go as far as 4*1/30=0.133333 (s)

Oh jesus, this should be ok. Are you sure that the problem is this MaxSubStep variable ?
Makail
Posts: 3
Joined: Sun Oct 02, 2011 8:32 pm

Re: Initial Angular Velocity

Post by Makail »

My elapsed time checks out, it comes in at ~0.033sec. Reducing the number of steps to 1 causes the object to rotate with the correct velocity. It might also be worth noting that if I pass in exactly 1/30.0 as the elapsed time the initial velocity is correct as well.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Initial Angular Velocity

Post by Dr.Shepherd »

I don't clearly understand the mechanism, your values satisfy the condition that:
timestep < maxSubStep * fixedTimeStep

But I did try some experiments on my BasicDemo, and it works in a strange way, definitely there is something wrong or special points we don't notice.