A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Auradrummer » Thu Oct 01, 2009 11:17 am
Hello guys!
I'm really lost.
I made a rayCast, and I liked it. The reactions are responding my commands as I wish. The only problem I'm facing is the slow gravity.
Searching around, I discovered that is a FPS problem.
Now my 'drama' begins:
My car runs nicely when I deactivate the Irrlicht Vsync and set NewtonUpdateWorld(nWorld,0.0001).
But, I'm sure that when I carry on the graphics a bit more, that Frame Rate will drop and the car "flickering" and another misbehaviours will happen.
Someone have any idea?
PS.:
I promiss that when I found a solution I'll write a tutorial about it!

Developing a racing game.
-
Auradrummer
-
- Posts: 132
- Joined: Sat May 17, 2008 9:17 am
by JernejL » Thu Oct 01, 2009 2:30 pm
you can time-slice the simulation - run several newtonupdates during one frame, or increase gravity force.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by kallaspriit » Fri Oct 02, 2009 3:35 am
Update step of 0,0001 seems way too small, this is as if running physics at over 600FPS, 60FPS is 0,016. At 600FPS, you would have to decrease your damping or control it yourself or it will make everything move in slow motion.
-
kallaspriit
-
- Posts: 216
- Joined: Sun Aug 14, 2005 6:31 pm
by Auradrummer » Fri Oct 02, 2009 9:13 am
Humm .... that looks promising. I made six physics turns at on frame, and the things seems to get better ... let see.
Developing a racing game.
-
Auradrummer
-
- Posts: 132
- Joined: Sat May 17, 2008 9:17 am
by JernejL » Fri Oct 02, 2009 11:15 am
Auradrummer wrote:Humm .... that looks promising. I made six physics turns at on frame, and the things seems to get better ... let see.
That's a wasteful approac, try increasing update delta time.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by kallaspriit » Fri Oct 02, 2009 3:09 pm
This is what I am using in my app with OgreNewt:
- Code: Select all
bool GameManager::updatePhysics()
{
//physicsUpdateStep = 1.0f / physicsTargetFramerate; //< somewhere in setup, use target framerate 60..120, depends what accuracy you need
unsigned int maxUpdates = 5;
unsigned long currentTime = root->getTimer()->getMilliseconds();
if(lastPhysicsUpdateTime > 0)
{
lastPhysicsFrameDuration = currentTime - lastPhysicsUpdateTime;
physicsElapsedTime += lastPhysicsFrameDuration / 1000.0f;
}
else
{
physicsElapsedTime = physicsUpdateStep;
}
if((physicsElapsedTime >= physicsUpdateStep) && (physicsElapsedTime <= (physicsUpdateStep * maxUpdates)))
{
while(physicsElapsedTime >= physicsUpdateStep)
{
physicsWorld->update(physicsUpdateStep);
physicsElapsedTime -= physicsUpdateStep;
lastPhysicsUpdateTime = currentTime;
}
return true;
}
else if(physicsElapsedTime >= physicsUpdateStep)
{
physicsWorld->update(physicsUpdateStep);
physicsElapsedTime = 0.0f;
lastPhysicsUpdateTime = currentTime;
return true;
}
return false;
}
-
kallaspriit
-
- Posts: 216
- Joined: Sun Aug 14, 2005 6:31 pm
by Stucuk » Fri Oct 02, 2009 7:29 pm
Are you using realistic units of measurement? If you are using a scale where the units are like 50 per meter, then you need to scale the physics world down or everything will seem slower at falling, etc. Most FPS map editors like Valves Hammer use incorrect unit measurements where about 40 units = 1 meter. Your physics should be scaled down so that 1 unit in the physics world = 1 meter.
-

Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by Auradrummer » Wed Oct 07, 2009 2:54 pm
Hi Kallaspriit:
I'll check your code, seems good. I'll study it to discover how it works exactly and implement it in my game too.
Stucuk:
Man, I could never think about it, but seems to be true ... I read somewhere that Irrlicht have different scale than Newton. I made some tests, printed some values, and my game looks that everything have to be greater than should... My car is reacting like a cruiser, really.
I'll check, but I think you hit the target!
Developing a racing game.
-
Auradrummer
-
- Posts: 132
- Joined: Sat May 17, 2008 9:17 am
by Auradrummer » Wed Oct 07, 2009 3:31 pm
I think I was making too physics calculations
I was making Newton Update this way:
NewtonUpdate(nWorld,1/(FPS*8))
So, graphics updates every 1/60: 0.016 secs
and physics updates every 1/480 : 0.002 secs
Now, I did
NewtonUpdate(nWorld, 1/(FPS*1.5))
The car is with a small flickering (I guess is some suspension set). But seems that I found the path... keep observing
Developing a racing game.
-
Auradrummer
-
- Posts: 132
- Joined: Sat May 17, 2008 9:17 am
by Stucuk » Wed Oct 07, 2009 3:39 pm
You should always use the same value in the NewtonUpdate. So always doing NewtonUpdate(World,1/60) for example. The only thing that should be FPS dependant is the amount of times your calling NewtonUpdate.
Note: FTimeSlice is set to 1/60 in the example below.
- Code: Select all
procedure TNewtonWorld.Update(FrameTime : Float);
begin
if not FEnabled then Exit;
FLastFrameTime := FLastFrameTime + FrameTime;
If FLastFrameTime > 1 then
FLastFrameTime := 1;
If FLastFrameTime >= FTimeSlice then
Repeat
NewtonUpdate(FWorld, FTimeSlice);
FLastFrameTime := FLastFrameTime - FTimeSlice;
Until (FLastFrameTime < FTimeSlice);
end;
-

Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests