Newton problem when reloading level

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
goutbouyo
Posts: 47
Joined: Thu Mar 24, 2005 6:55 pm

Newton problem when reloading level

Post by goutbouyo »

Hi,
I have a big problem with Newton ...

When I start my game, my object falls on the floor directly.
But when I stop my game(in order to restart the level) my object doesn't fall directly on the floor.
With 1 restart, I must shoot on it 1 second and he falls.
With 2 restart 2 secconds, with 3 restarts 4 seconds ...

I use this functions to release Newton:

NewtonDestroyAllBodies(nWorld);

// release the collision tree
NewtonReleaseCollision(nWorld, g_newtonmap);

for (int i=0; i<numNewtonObject; i++)
NewtonReleaseCollision(nWorld, newtonObject->collision);

// destory the newton world object
NewtonDestroy(nWorld);


Can you help me please ???
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Maybe a Newton forum can help you !?!?!
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
goutbouyo
Posts: 47
Joined: Thu Mar 24, 2005 6:55 pm

Post by goutbouyo »

I found the problem :

Code: Select all

//NEWTON		
// Update newton 100 times / second
if (device->getTimer()->getTime() > lasttick + 10)
{	
	lasttick = device->getTimer()->getTime();
	NewtonUpdate(nWorld, 0.01f);
}
lasttick was not reinitialized at the restart, so the newton world was not updated directly.

I add that at the restart :
lasttick=0;

And now it's working !!!
Post Reply