saladin
03-12-2007 12:24:09
Hi,
I found this piece of code in the OgreNewt demo's BasicFrameListen class.
The main purpose of the code is to advance the physics system in a frame independent manner. However since the physics world cannot update by bigger step than 0.016666 i.e. 1/60, the line "self.World.update( self.elapsed )" doesn't work for the given condition: self.elapsed > 1.0. Maybe we can do:
Hope someone can tell me the reason. If this were a mistake maybe it should get fixed in the coming demo.
I found this piece of code in the OgreNewt demo's BasicFrameListen class.
def frameStarted(self, evt):
Ogre.FrameListener.frameStarted(self, evt)
self.elapsed += evt.timeSinceLastFrame
if self.debugflag == True:
pass
##OgreNewt.Debugger.getSingleton().showLines(self.World)
if ((self.elapsed > self.update) and (self.elapsed < (1.0)) ):
while (self.elapsed > self.update):
self.World.update( self.update )
self.elapsed -= self.update
else:
if (self.elapsed < self.update):
## not enough time has passed this loop, so ignore for now.
pass
else:
self.World.update( self.elapsed )
self.elapsed = 0.0 ## reset the elapsed time so we don't become "eternally behind"
return True
The main purpose of the code is to advance the physics system in a frame independent manner. However since the physics world cannot update by bigger step than 0.016666 i.e. 1/60, the line "self.World.update( self.elapsed )" doesn't work for the given condition: self.elapsed > 1.0. Maybe we can do:
def frameStarted(self, evt):
Ogre.FrameListener.frameStarted(self, evt)
self.elapsed += evt.timeSinceLastFrame
if self.debugflag == True:
pass
while (self.elapsed > self.update):
self.World.update( self.update )
self.elapsed -= self.update
if self.elapsed < self.udpate:
self.World.update(self.elapsed)
self.elapsed = 0
return True
Hope someone can tell me the reason. If this were a mistake maybe it should get fixed in the coming demo.