Creating Stable And Accurate Physics With Newton
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:
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).
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).
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Bullet Physics Library / COLLADA physics viewer | erwincoumans | 14 | 11,251 |
Aug 12, 2006 12:59 AM Last Post: Fenris |
|
| Accurate FPS | Phate | 3 | 3,049 |
Mar 23, 2003 04:05 AM Last Post: DoG |
|

