[odejava] collision problems

I’m having a strange problem:

I have a Body that has an attached GeomSphere. Prior to executing the following code, it can collide with any object without issues. After executing the following, which is supposed to swap out the GeomSphere with one of a different size, it can only collide with other Bodies. It can’t, for example, collide with bodyless GeomBoxes.

I’ve verified that the collisions are detected when I loop over the contact object. The problem is that no matter what flags I set on contact, there is no visible effect on the spheres.

The sphere objects do start to rotate by some very tiny amount after the “collision,” though. Also, I’m using the current cvs version of odejava.


    // Remove old geom objects
    PlaceableGeom geo = (PlaceableGeom)this.sim_body.getGeom();
    this.sim_body.removeGeom(geo);
    space.remove(geo);
    geo.delete();
    geo=null;

    // Add new geom objects
    geo = new GeomSphere((float)(this.bounds.getWidth()
                         + Marble.border_width
                         + Marble.stroke_width)/2);

    this.sim_body.addGeom(geo);
    this.sim_geomIDs.add(geo.getNativeAddr());
    space.addGeom(geo);

As a workaround, you could use Ode.dGeomSphereSetRadius(SWIGTYPE_p_dGeomID sphere, float radius) to change the radius of the sphere.

Thanks! That worked well, although I’m still curious why the original code was broken.

Adding a new Geom to a Body changes the mass and inertia parameters (to defaults for the specified Geom) of the Body. Maybe that was the problem? These things can be difficult to track down :slight_smile: