[ODE] ODE physics part in a game engine

michael kapelko kornerr at gmail.com
Fri Jan 26 07:03:42 MST 2007


I'm thinking of embedding physics *correctly* into a game engine. Let's 
start...
Collision handling occurs in my game this way:

void MapScene::NearCallback (dGeomID o1, dGeomID o2) {
        dBodyID b1 = dGeomGetBody (o1);
        dBodyID b2 = dGeomGetBody (o2);
        - - - -
        // Do not check joined bodies
        if (b1 && b2 && dAreConnected (b1, b2))
                return;
        const int N = 4;
        dContact contact[N];
        int n = dCollide (o1, o2, N, &contact[0].geom, sizeof (dContact));
        if (n > 0)
                for (unsigned short i = 0; i < n; i++) {
                        contact[i].surface.mode = dContactSlip1 | 
dContactSlip2 |
                                dContactSoftERP | dContactSoftCFM | 
dContactApprox1;
                        contact[i].surface.mu = dInfinity;
                        contact[i].surface.slip1 = 0.0;
                        contact[i].surface.slip2 = 0.0;
                        contact[i].surface.soft_erp = 0.0001;
                        contact[i].surface.soft_cfm = 0.001;
                        dJointID c = dJointCreateContact (reg->world, 
reg->jg, &contact[i]);
                        dJointAttach (c, b1, b2);
                }
}

All bodies are collided the same boring unnatural way. Making each body 
hold its collision parameters (properties) is obviously the way to go. 
But this is the problem. Collision is dependent on collision points, not 
on bodies' properties. So I wonder how to combine two bodies' collision 
parameters and perform *correct* collision.
Any advice?
Thanks.


More information about the ODE mailing list