[ODE] ODE physics part in a game engine

Jon Watte (ODE) hplus-ode at mindcontrol.org
Fri Jan 26 11:49:21 MST 2007


You have the double-dispatch problem. First, you need to use the user 
data of the bodies to get to data that's specific for each body. Then 
you need to figure out what it means to "correctly" collide the two 
bodies in question, which is where double dispatch comes in. You can, 
for example, create a 2D array, or hash table, of material/material 
interaction constants to use for the contact joint.

I believe what I did in RayCar is create the joint using default 
parameters, then call a virtual function on objects attached to each of 
B1 and B2 that passed in the other object as an argument, and let them 
adjust the contact joint parameters before the joint is created. Worked 
allright, although you still have the "is it glass against wood, or wood 
against glass" problem.

Cheers,

          / h+


michael kapelko wrote:
> 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.
> _______________________________________________
> ODE mailing list
> ODE at ode.org
> http://mooshika.org/mailman/listinfo/ode
>
>
>   


More information about the ODE mailing list