wrong velocity value with variable timestep??

mohamed
Posts: 15
Joined: Sun Jun 23, 2013 3:41 am

wrong velocity value with variable timestep??

Post by mohamed »

I got a kinematic object "from gimpact test demo" which is animated by a value of 0.1 in x direction each timestep

I printed out velocity "for timestep 1/60" and it prints 6 (which is ok)
now I did some modification to time step so it varies from 1/60 to 1/30 (like 1/60 then 1/30 then 1/60 then 1/30 and so on)
the velocity stays the same value!! so may someone help me understand what is wrong here?
mohamed
Posts: 15
Joined: Sun Jun 23, 2013 3:41 am

Re: wrong velocity value with variable timestep??

Post by mohamed »

well I have solved it (after making max steps to 0 so that I force use my timestep even if it is larger than fixed time step)
STTrife
Posts: 109
Joined: Tue May 01, 2012 10:42 am

Re: wrong velocity value with variable timestep??

Post by STTrife »

Another way is to use the internal tick callback, and update the position in there. That way bullet can still do variable timesteps, but the update for your object is still called exactly each 1/60 timestep or whatever your internal timestep is set to.
mohamed
Posts: 15
Joined: Sun Jun 23, 2013 3:41 am

Re: wrong velocity value with variable timestep??

Post by mohamed »

explain more about this please :)

to be clear about what I want to do:
I'm making a fluid and rigid coupling (fluid code is mine,rigid coding with bullet)
so the fluid may have adaptive time step (variable)
what I want to do is give that time step to bullet,and at the same time do more sub steps if required for more accurate calculation
STTrife
Posts: 109
Joined: Tue May 01, 2012 10:42 am

Re: wrong velocity value with variable timestep??

Post by STTrife »

I'm not sure I fully understand your problem, but this page explains about the internal tick callbacks:

http://bulletphysics.org/mediawiki-1.5. ... _Callbacks

Any custom updating should be done in a tick callback, which is called for every internal tick. so if you give a timestep of 1/30 it will normally do 2 timesteps of 1/60, but it will call the update code twice.

But as I said now I read your questions more carefully and I'm not sure I understand exactly what your problem is. If this doesn't help then you should try to explain more about your problem.
mohamed
Posts: 15
Joined: Sun Jun 23, 2013 3:41 am

Re: wrong velocity value with variable timestep??

Post by mohamed »

well

here is the full picture of what I want to do:
I got a fluid simulation with time step 0.01 sec (it may do substeps at non equal intervals like 5% 55% 100% "depends on the calculations" )

assuming there is no substeps (so the step is constant at 0.01 sec)
I can pass that step directly,get the velocity,angular velocity,transform matrix and solve the whole thing :)

here is the worst case,at a substep of 55% (of 0.01sec) for example , I want to pass the interpolation of velocity,interpolation of angular velocity,interpolation of transform matrix,but don't know how ...

what you said about interpolation I understand,but don't know how to step the world of 0.04 for example , here is what you said
"if you use the normal 1/60 internal time step and you step the world with for example 0.04 seconds it will do 2 full internal timesteps and interpolate the remaining time"

hope you can explain with a sample code please if possible :)

thanks in advance