Bug with Fraps

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Bug with Fraps

Postby Witek900 » Wed Dec 09, 2009 12:11 pm

I have strange problem. When i record my game with fraps Newton 2.10 behaves like this:
http://www.youtube.com/watch?v=RyUUo5CKyY8

When i turn off fraps recording everything works OK. Any ideas?
Last edited by Witek900 on Wed Dec 09, 2009 12:34 pm, edited 1 time in total.
Witek900
 
Posts: 38
Joined: Mon Jan 26, 2009 1:29 pm
Location: Warsaw

Re: Bug with Fraps

Postby JernejL » Wed Dec 09, 2009 12:33 pm

is fraps limiting your fps or changing anything weird in fpu control words?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Bug with Fraps

Postby Witek900 » Wed Dec 09, 2009 12:37 pm

Yes, normally i have 80 - 200 FPS, and when I start recording by fraps it limits to 60FPS. But when i slow down engine to 30fps in natural way (by adding lots of lights, bodies) it behaves also normally. I'll downlad Newton 2.12 and I'll see if it help
Witek900
 
Posts: 38
Joined: Mon Jan 26, 2009 1:29 pm
Location: Warsaw

Re: Bug with Fraps

Postby Witek900 » Wed Dec 09, 2009 6:04 pm

I have still this bug even on Newton 2.12. I noticed that boxes jump when FPS is lower than 60 then i do more than one NewtonUpdate call per frame, bacause NewtonUpdate accepts delta time > 60FPS. BUG APPEAR EVEN WHEN I TURN OFF FRAPS!!!

SolverModel / FrictionModel doesn't matter.
I don't use materials.
Masses and inertias are OK.


My PhysicsUpdate function:
Code: Select all
//NewtonUpdate acceptable values
#define UPDATE_MAX_THRESHOLD  1.0f/60.0f
#define UPDATE_MIN_THRESHOLD  1.0f/500.0f

void PhysicsUpdate()
{
   //accumulator
   Physics_DT += DeltaTime;

   if (Physics_DT < UPDATE_MIN_THRESHOLD)
      return;

   if (Physics_DT <= UPDATE_MAX_THRESHOLD)
   {
      Engine_GetObjectsPositions();
      Engine_SetObjectsForces();
      NewtonUpdate(NW, Physics_DT);
      Physics_DT = 0.0f;
      return;
   }

   if (Physics_DT>UPDATE_MAX_THRESHOLD)
   {
      for (int i = 0; i < 10; i++)
      {
         Engine_GetObjectsPositions();  //get objects' matrices, velocities etc.
         Engine_SetObjectsForces();   //set objects' forces

         if (Physics_DT > UPDATE_MAX_THRESHOLD)
         {
            NewtonUpdate(NW, UPDATE_MAX_THRESHOLD);
            Physics_DT -= UPDATE_MAX_THRESHOLD;
         }
         else
         {
            NewtonUpdate(NW, Physics_DT);
            break;
         }   
      }

      Physics_DT = 0.0f;
   }
}
Witek900
 
Posts: 38
Joined: Mon Jan 26, 2009 1:29 pm
Location: Warsaw

Re: Bug with Fraps

Postby Julio Jerez » Wed Dec 09, 2009 6:10 pm

you should call newton update with a fixed timestep. But even of it was not fixed that doe not seems right.

if you want to see and implemntation of using a fix step and visual interpotation you can check the wiki tutorials, this do it that way.
http://newtondynamics.com/wiki/index.php5?title=Tutorial_101:_-_Getting_Started

bu fis jsut tru callunt newtopUpdate (1.0/60.0)
to see if they behaviour is smooth. like this
Code: Select all
void PhysicsUpdate()
{
      NewtonUpdate(1.0/60.0f);
}

then if that fixed it, juts get emulate the implementation from the tutorial.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bug with Fraps

Postby JernejL » Wed Dec 09, 2009 6:55 pm

what's the scale of those boxes? in units.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Bug with Fraps

Postby Witek900 » Thu Dec 10, 2009 2:52 pm

Thanks Julio. With fixed time step it works OK. :) But why not-fixed time step cause this bug? The second paramener in NewtonUpdate should be created to pass various valuse, i think :?:
Witek900
 
Posts: 38
Joined: Mon Jan 26, 2009 1:29 pm
Location: Warsaw

Re: Bug with Fraps

Postby Julio Jerez » Thu Dec 10, 2009 3:22 pm

The reason is that constrating dynamcis generates very high non linear reaction forces.
The contact forces are basicaly spike tha rise form zero to doem valeu in one time step.

These impulse are converted to forces so that the solver can deal with impule and force simutaneuly,
The proccess of conveting impusle to force is by dividing by the time step.
when the time step in itself is a function of time, then the contact forces became even mouh more non linear.

All those non linrearities should cancell each other and the net force ssoudl be the same, but when the force are high or small an exact constraint solver is needed.
Netwon 2.0 uses and Iterative solver, whech means the forces are calculate based of previeus calculated values, but if the previus values were calculted with an diffenete time step.
then the new values may not be correct since the solver do not try to calculate teh exact solution.
This is why there is a tutorial, whic show how to run teh phhsics at a fix step, and interpolate the transformation matrix
Take a look it is not too dificult to do.


Also the exact solve will do a much better job when usin varivle tiem step, but that solver is much slower.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Bug with Fraps

Postby Witek900 » Thu Dec 10, 2009 5:46 pm

I understand. So maby this change would be better

Code: Select all
NewtonWorldSetFixedTimeStep(NW, 1.0f/60.f); //on the beginning

//and in main loop:
PhysicsAccumulator += GameDeltaTime;

int loops = 0;
while ((loops < 10) && (PhysicsAccumulator >= 1.0f/60.f))
{
   loops++;
   NewtonUpdate(NW); // with fixed time step set by NewtonWorldSetTimeStep
   PhysicsAccumulator -= 1.0f/60.f;
}

:D
Witek900
 
Posts: 38
Joined: Mon Jan 26, 2009 1:29 pm
Location: Warsaw

Re: Bug with Fraps

Postby Julio Jerez » Thu Dec 10, 2009 6:44 pm

yes that cal Netwon upddate with a fix step, but you also must implement the part the does the Frame interpolation so that you have smooth visuals.

say for exampel teh visual spf is 80 fps and the physics is 60,
you display will look shopy because evnery few frame ther will be on physics advace whiel in othere teh will be two.
the interplation makes sure the display is the correct fraction of time between the last tow physics updates.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 3 guests

cron