Motor flash physics development update

What I have done the last days:

– contact point calculations
– two collision response models (simple & fast + physical accurate)
– different integrators (Euler, Verlet, Mid-Point, RK4)
– basic forces (gravity, spring, attractor, repulsor..)
– dynamic and static friction

So basically the engine is working now. There are some small bugs when handling multiple simultaneous contacts which I’ll solve later. Now it’s time to build a framework, optimize and clean-up the code and convert it to AS3.

I’ll post some new demos the next day, but here is a small preview: Scene A, Scene B

11 thoughts on “Motor flash physics development update”

  1. Great work. any chance you can release code so some of us less physics savvy people can follow along?

  2. Since I put a lot of work into my engine I will not publish the source code but I will perhaps release the API so anybode can use it by including a compiled swf.

  3. wow, that’s impressive. could you breifly explain the difference between the collision response models? ..i’m guessing this is all impulse-based, and i only know of one way to handle normal and tangent/friction impulses.

  4. also, AFAIK your method for finding the moment of inertia for convex polygons works with concave polygons too: triangles with negative signed areas have their moments “subtracted” from the total.

    of course, the hard part is triangulating ;)

  5. you are right, it should work with convex polygons, too. I didn’t realized it, because my engine only supports convex polygons anyway.

    the cheap collision model does only a simple vector reflection about the normal of collision, so the new reflected velocity is v – (2 * (v.n)) * n. It computes the linear momemtum p of the center of mass only (p = mass times velocity). The linear momentums derivative is force: F = dp/dt = d(m*v)/dt = ma.

    the advanced method supplies angular effects by taking into account where the object was hit and computes the angular momentum, too. The derivative of angular momentum is torque.

    Adding force and torque together and integrating over time finally gives velocity and position.

  6. actually both, because you can’t really seperate impulses and forces.
    I am calculating impulses from forces, after all forces acting on the body have been summed up. (forces are integrated to get impulses). when a collision occurs, an impulse is applied directly to the body to change their velocities instantly.

  7. do you mean the standard “integrate the bodies forward in time (which does involve summing and integrating forces), then resolve collisions using impulses”? or is there something special going on with how you treat the forces?

    i guess i meant penalty-methods or impulses.. i’m asking because things seem very stable/un-jittery for an impulse-based simulator, but very solid for penalty-methods.

  8. ah now I know what you mean. I use standard impulses as you said first. However they are averaged and applied until the bodies become stable. Its hard to explain right know because I am experimenting with a mix of different approaches and still have to figure out the best way. e.g. if I increase the timestep or/and use objects with large variations in masses the jittering becomes more apparent.

  9. cool — i was wondering about how you were using impulses, because i haven’t gotten them to behave as nicely as in your demos. but i’ll wait till it’s done “cooking” to find out ;)

Comments are closed.