newton physics time
BlitzMax Forums/MiniB3D Module/newton physics time
| ||
It is my (possibly mis)understanding that the line 382 ( Physic.Update(TGLobal.GetDelta()) ) in the Physic.bmx sample included with minib3dext is supposed to control physics simulation speed? In my observation, it doesn't. Regardless of its use The simulation speed is tied to the loop update speed. I have tried using delta time, or just other random variables. it doesn't seem to have an effect. Is this not working, or am I doing something wrong? (as usual) |
| ||
it is a bit buggy try this instead: Field accumulator:Float Field lastupdate:Int = MilliSecs() Field updates:Int Method Update(UpTime:Float = - 1.0) Local Time:Int = MilliSecs() If Uptime < 0 Then NewtonUpdate(World , GetDelta() ) Else NewtonUpdate(World , Uptime ) EndIf End Method Method AccuUpdate() GCSuspend() accumulator:+ Min(MilliSecs() - lastupdate,60)/1000.0 lastupdate = MilliSecs() updates:Int = 0 While accumulator >= dt Update(dt) accumulator:- dt updates:+1 Wend GCResume() End Method |
| ||
Thanks for the prompt response. I tried your code, and there was no difference. As the frame rate drops, so does the physics speed. Am I supposed to call AccuUpdate() somewhere? This is what the modified TPhysik.bmx looks like (I had to change one or two things in your code above) I am using the sample physic.bmx to see the results. Any other help would be greatly appreciated! |
| ||
sry, I had forgotten to mention that in the new Version you don't have to manage the update ad it is managed in UpdateWorld. So with your version you have to replace the PhysicWorld.Update() in the sample with PhysicWorld.AccuUpdate() Then it should work much better. |