# Physics engine order

This topic is 4448 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, this week I'm going to try my hand at my first physics engine! First of all can any of you give me advice or important points? and my main question, in my engine I'll have 5 main parts: force calculation, collision detection, collision response, integration, rendering. Is that the correct order? If not what order should I do them in? Thanks.

##### Share on other sites
A physics engine should not do rendering. Leave that to the rendering engine.

##### Share on other sites
I suggest you do some reading/research before even thinking about writing code. For example, Chris Hecker's pages, David Baraff's notes, this paper, etc etc.

##### Share on other sites
I looked at "this paper" and it was very interesting. I liked how it handeled collision detection. But there was something I didn't understand they say:
Quote:
 Instead, our algorithm uses a novel fixed-time integration scheme, where we allow for penetration between bodies inside a simulation step. A simple Euler integration scheme with time step 0.01s has shown to be sufficiently robust for all our tests. Our algorithm splits the collision and resting contact phases, where only the velocities are updated between both: Algorithm 1: Fixed-time integration scheme Collision detection and resolution. Update velocities. Resting contact resolution. Update positions. Update time. Basically, both stages 1 and 3 perform a collision resolution step, but the only difference between both is the coefficient of restitution used in the impulse computation. In the contact resolution phase, we model the collision as completely plastic (ε = 0).

what is the difference between Collision detection and resolution and Resting Contact resolution. Do I define some velocity threashhold that if the Colliding bodys are moving slower than it they are in "resting contact"? Or do I also have to define a minimum collision the below it turns into contact? And when do I do Contact detection - in the third step or in the first?
Thanks!

##### Share on other sites
At the risk of seeming not very helpful - it's all explained quite well in the paper...

However - bear in mind their implementation seems designed for non-real-time animation, and they seem to do multiple collision detections per time-step. For real-time simulation you can get away with just one (seems to work just as well anyway).

There's also some "notes" I made a while back here, though they may not be completely up to date with my implementation.

##### Share on other sites
MrRowl -- just checked out your demo. pretty awesome stuff.

##### Share on other sites
MrRowl, you're demo's and movies are incredible!!
Quote:
 The basic order of integration is this: -Get all forces acting on the bodies. -Integrate velocity using the forces. Use the new velocities integrate positions. Detect collisions (ideally a swept test from old positions to new ones... but I currently just do an overlap test with the new positions). -Restore positions and velocity to their original values. -Process (see below) all collisions and constraints using impulses, iterating a few times over the list. These impulses update the velocities, but not the positions, of course. -Integrate the velocities (again) using the forces. -Process all collisions and constraints using impulses again, except now treat all collisions as inelastic, iterating a few times over the list. -Do a "shock" step - see below. This allows objects to stack up even when the number of iterations in the previous steps is small. -Integrate the positions using the new velocities.

I can see how you'd do that with Euler integration but how do you implement that with RK4? how do you first do the velocity and then the postion?
Thanks.

##### Share on other sites
Quote:
 Original post by daniel_i_lI can see how you'd do that with Euler integration but how do you implement that with RK4?

Unfortunately, I don't have an answer to that. Wish I did...

##### Share on other sites
Is you're demo with Euler then? Maybe I should just do Euler and forget RK4?
Thanks.

##### Share on other sites
RK4 is good for springs.
I recommend velocity verlet.

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632998
• Total Posts
3009808
• ### Who's Online (See full list)

There are no registered users currently online

×