Horde3D
http://horde3d.org/forums/

GameEngine: Fixed-Timestep GameLoop
http://horde3d.org/forums/viewtopic.php?f=1&t=1716
Page 1 of 1

Author:  Roland [ 18.09.2012, 11:23 ]
Post subject:  GameEngine: Fixed-Timestep GameLoop

Since there sadly is no GameEngine specific subforum I'll post this topic here in the "General Discussion" forum:

Over the last couple of weeks implementing new components I started to realize I really should separate my render() and my GameUpdate().

The current GameEngine::Update() works like this (please correct me if I'm wrong!):

Update the GameEngine timer:

Update the component managers, which triggers
  1. the render() function in the scenegraph manager, which calls the h3drender using the active camera, and "Reset OpenGL camera so other components can render their content too"
  2. Then the run() methods of all components get called (using OpenMp)
  3. Then the update() gets called on every manager (using the order specified in the plugin.cfg)
  4. and at last we call render() on all components, excluding the scengraphcomponents.


The complete game loop in the demo apps is:

Every frame:
  • KeyStateHandler(); // handle keyboard input;
  • Update the GameEngine() // render + gameloop, as described above
  • glfwSwapBuffers(); // triggers glfwPollEvents -> getting keyboard/mouse/etc input

Now the way I see it, with the current way the GameEngine works, it is rather difficult to separate my GameLoop (handling user input, updating the game state, handling AI, playing sounds, etc) from my render loop.

What I want is a fixed time step implementation, updating my game about 30 times per second, and render it as often is I can (and in the process, remove unnecessary timers, since at the moment we have the Horde3D timer, the GameEngine timer, the GLFW timer, and the bullet physics timer being used).

Basically this: http://lspiroengine.com/?p=378

More detailed information is linked to in the post:

http://gafferongames.com/game-physics/f ... -timestep/
http://www.koonsolo.com/news/dewitters-gameloop/

To realize this, seperating the public GameEngine::Update() into
GameEngine::Update() //calling run() and update()
GameEngine::Render()
should work.

But now we have the problem of not having any interpolation regarding animation/transformation of entities.
Meaning if I update my game loop 30 times per second, and render at 120fps, particles, which get rendered by Horde3D, get updated every frame, but everything else would have the same position for 4 frames.

Hence I'd have to rewrite the scenegraph and animation component to support interpolation, and update those two components every frame as well, complicating the GameEngine::Update() function with "special cases".

So what I'm looking for from you guys is some input on whether my thought process is correct, what I missed, and ways to realize this.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/