Getting Bodies to pass through one another?

Hi,

I just asked this question to the ODE mailing list and got the response below. I am not quite sure how to implement the suggestion with OdeJava. Are there any examples using nearCallBack methods for collisions? Any other suggestions on how to implement this would be greatly appreciated.

Thanks,
James

MY QUESTION:

Hi,

I’m hoping this is an easy one.

I have two bodies and I want them to be able to occupy the same position in the world without ode trying to shake them apart. Basically - like ghosts.

The thing is, I need regular physics to apply when they interact with other particular bodies (I have the body IDs in a list). Imagine something like, ghosts can pass through each other, but can’t go through walls.

I have tried to play with the ERP and CFM values for the contact I get back from their collision, but it doesn’t help. I can’t change the world values for these params, beause then everything becomes a ghost. How do I do this?

Your help is greatly appreciated - thanks in advance!
James

THE RESPONSE:

RE: Getting Bodies to pass through one another?

Ok, so you have your nearCallback function that has the two Geoms.

You can get the bodies for these Geom by dBodyID body = dGeomGetBody(geom);

Ok, so now you have the bodies.

If both of these bodies are the ones you don’t wont to collide, then return.

Return BEFORE dJointCreateContact is called.

Hope that helps.

when iterating through the contacts generated. Do this:


for (int i = 0; i < collision.getContactCount(); i++) {
  contact.setIndex(i);
  Geom geo1 = contact.getGeom1();
  Geom geo2 = contact.getGeom2();
  if (geo1.getName().equals("IGNORE") || (geo2.getName().equals("IGNORE")) {
    contact.ignoreContact();
  }
}

I use this alot for particle physics. You dont want two particles from the same particle system colliding. so when they do, just ignore it.

DP
}

darkprophet :

Spot on man. That worked!

A follow up question though - but it isn’t urgent.

If I add multiple geoms to a Body with a GeomTransform, in my collision code, do I need to check each for these geoms against:

contact.getGeomID1() and contact.getGeomID2()

Or can I simply do check using the Body’s ID (body.getNativeAddress()) against:

contact.getBodyID1() and contact.getBodyID1()

So far, just checking BodyID seems to work - but I don’t want to miss anything.

Thanks again!
James

GeomTransforms are Geoms themselves, dont worry about them. There are no special cases you need to consider.

DP

this works, yes…but aren’t CategoryBits and CollideBits meant to speed these things up considerably as some kind of an early fail mechanism in case of complex geometry collisions (trimeshes)? I can’t figure out how to use them to my advantage though.

I have a problem similar to that described by James. Just an example: Let’s have a car chassis (body1) with wheels (body2 … 5) and we want the contact between the wheels and the chassis to be ignored, but when there are 2 cars in the scene, we want the wheels of car1 to collide with the chassis of car2 should it come to it.

Now the Bits thing is rather confusing for me. As I understand it, you set:

geom1.setCategoryBits( cat1 );
geom1.setCollisionBits( coll1 );
geom2.setCategoryBits( cat2 );
geom2.setCollisionBits( coll2 );

…then, before each [geom1 <-> geom2] collision testing:

if(cat1 == coll2 OR cat2 == coll1) create contacts;
else ignore;

This might be helpful if you want to define concrete collision cases, but what if I need to REJECT certain cases. How did the authors of Ode intend this functionality to be taken advantage of?

Setting the collision catagories takes effect without you having to do anything. So you set the catagory bits to define what catagories a geom belongs to, and then you set the collision bits to define what catagories the geom will collide with. You have 32 bits to play with. This situation you are describing can’t be solved using bit catagories if the number of cars is not a fixed small number, becuase each cars geoms need their own identifying catagories.
The authors of ODE designed the system for global definitions of collision cases. So for things like projectiles never collide with each other, only the player collides with powerups etc.