Bullet update loop.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Bullet update loop.

Post by 3DModelerMan »

Hey, I decided not to use Havok, and to use Bullet instead. But I have a question.

Code: Select all

driver->beginScene(true, true, SColor(255,100,101,140));
 
 smgr->drawAll();
 guienv->drawAll();
 
 driver->endScene();  
  
 //Update physics.                
 m_DynamicsWorld->stepSimulation(1/60.f,10);
Should I update the physics before, after, or in between the beginScene() and endScene() calls? And if it should be in between, then should it be before or after the drawAll() call?
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
randomMesh
Posts: 1186
Joined: Fri Dec 29, 2006 12:04 am

Re: Bullet update loop.

Post by randomMesh »

The main loop of my application looks like this:

Code: Select all

	irr::IrrlichtDevice* const device = game.getDevice();
	btDiscreteDynamicsWorld* const dynamicsWorld = game.getPhysics()->getWorld();

	while (device->run())
	{
		if (device->isWindowActive())
		{
			//update game timer
			game.tick();

			//update the state machine (aka rendering and event receiving)
			game.onUpdate();

			//update physics
			dynamicsWorld->stepSimulation(game.getElapsed(), 10);
		}
		else
			device->yield();
	}
Last edited by randomMesh on Fri Nov 06, 2009 11:10 pm, edited 2 times in total.
"Whoops..."
squisher
Competition winner
Posts: 91
Joined: Sat May 17, 2008 2:23 am
Contact:

Post by squisher »

There's no reason for it to be in between.
The beginScene and endScene methods are only necessary to house the rendering code. (all the draw* methods)

Doesn't matter whether you put the stepSimulation before after the begin-end block.
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

Post by Jookia »

You generally should draw stuff AFTER you update the position.
3DModelerMan
Posts: 1691
Joined: Sun May 18, 2008 9:42 pm

Post by 3DModelerMan »

Yeah, good point. You could probably get hacked in motion blur if you updated after though. :lol:
That would be illogical captain...

My first full game:
http://www.kongregate.com/games/3DModel ... tor#tipjar
Jookia
Posts: 170
Joined: Wed Nov 19, 2008 1:11 am

Post by Jookia »

Or if you stored the current position of crap before you update physics and then use that infro to draw the blur.
Post Reply