Creating Stable And Accurate Physics With Newton

Sage
Posts: 1,066
Joined: 2004.07
Post: #1
I'm trying to use the Newton physics library to create a 2D game, but things don't seem to be working right. In my demo, some boxes are stopping oddly on inclines that they are sliding down. All the boxes that I drop also stop spinning in the air after a certain amount of time, even though I'm not using any technique of air resistance. Also, I'm not sure if I'm updating Newton correctly or not. Here's the code for my update function:

Code:
#define TARGET_PHYSICS_RATE    1.0f / 120.0f
void update( SimApp *app ) {
    if( app->getFrameInterval() <= TARGET_PHYSICS_RATE ) {
        NewtonUpdate( world, TARGET_PHYSICS_RATE );
    }
    else {
        for( float t = 0.0f; t < app->getFrameInterval(); t += TARGET_PHYSICS_RATE )
            NewtonUpdate( world, TARGET_PHYSICS_RATE );
    }
}

Where app->getFrameInterval() is the time elapsed since the last frame.

If anyone is interested in looking at the project either to help themselves or myself, the Xcode 2 project (as is right now) can be downloaded here (1.6mb).
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Bullet Physics Library / COLLADA physics viewer erwincoumans 14 12,377 Aug 12, 2006 12:59 AM
Last Post: Fenris
  Accurate FPS Phate 3 3,208 Mar 23, 2003 04:05 AM
Last Post: DoG