Advertisement
Guest User

Untitled

a guest
Nov 24th, 2010
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. // was:
  2.  
  3.     if (this->simulator != 0) {
  4.         int deltaTime = min(max(glutGet(GLUT_ELAPSED_TIME) - this->previousTicks, 0), 1000);
  5.         this->accumulator += deltaTime / 1000.0f;
  6.         float timeStep = 1.0f / 62.5f;
  7.         while (this->accumulator > timeStep) {
  8.             this->simulator->step(timeStep);
  9.             this->accumulator -= timeStep;
  10.         }
  11.         Drawer::getInstance()->drawSimulation();
  12.  
  13.         this->previousTicks = glutGet(GLUT_ELAPSED_TIME);
  14.     }
  15.  
  16. // should be:
  17.  
  18.     if (this->simulator != 0) {
  19.         int currentTicks = glutGet(GLUT_ELAPSED_TIME);
  20.         int deltaTime = min(max(currentTicks - this->previousTicks, 0), 1000);
  21.  
  22.         this->accumulator += deltaTime / 1000.0f;
  23.         float timeStep = 1.0f / 62.5f;
  24.         while (this->accumulator > timeStep) {
  25.             this->simulator->step(timeStep);
  26.             this->accumulator -= timeStep;
  27.         }
  28.         Drawer::getInstance()->drawSimulation();
  29.  
  30.         this->previousTicks = currentTicks;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement