No contact information returned

My contacts seem to have stoped working :frowning:
Here is my code if anyone spots I have missed something stupid.
The contacts that come always have id’s of 0. Body id’s or geom id’s. The collisions work fine though in the actual simulator.
I am using the new BulkContact but it still does not work with the old one


package odeAbstraction;

import org.odejava.Space;
import org.odejava.Geom;
import org.odejava.ode.Ode;
import org.odejava.collision.BulkContact;
import org.odejava.collision.JavaCollision;
import org.odejava.collision.Contact;

import java.util.Observable;

import odeAbstraction.events.ObjectManagerEvents.SimObjectEventListener;
import odeAbstraction.events.ObjectManagerEvents.DynamicObjectEvent;
import odeAbstraction.events.ObjectManagerEvents.StaticObjectEvent;
import odeAbstraction.collision.CollisionRuleManager;
import model.geometry.RelativePrimative;

/**
 * User: ttl0
 * Date: 02-Aug-2004
 * Time: 15:37:07
 */
public class CollisionManager implements SimObjectEventListener {
    private final SimWorld world;
    private CollisionRuleManager ruleManager = new CollisionRuleManager();

    Space space = new Space();
    JavaCollision collision = new JavaCollision();
    BulkContact contact = new BulkContact(collision.getContactIntBuffer(),
            collision.getContactFloatBuffer());

    public CollisionManager(SimWorld world) {
        setupDefaultCollision();

        this.world = world;
    }

    private void setupDefaultCollision() {
        // Setup some surface parameters
        collision.setSurfaceMu(1000f);
        collision.setSurfaceBounce(0.14f);
        collision.setSurfaceBounceVel(0.1f);
        collision.setSurfaceMode(Ode.dContactBounce | Ode.dContactApprox1);
    }

    public void handleCollisions() {
        //collision.emptyContactGroup();    allready done in collide
        // Collide objects in given space
        collision.collide(space);
        // Read & modify contact information
        iterateContacts();

        //update all the contact buffers in one call
        contact.commit();
        // Add all contacts to contact jointGroup
        collision.applyContacts();
    }

    private void iterateContacts() {
        for (Object o : space.getGeoms()) {
            Geom geom = (Geom) o;
            System.out.println("geom.getNativeAddr() = " + geom.getNativeAddr());
        }
        for (int i = 0; i < collision.getContactCount(); i++) {
            contact.setIndex(i);
            System.out.println("contact.getGeomID1() = " + contact.getGeomID1());
            System.out.println("contact.getGeomID2() = " + contact.getGeomID2());
            System.out.println("contact.getBodyID1() = " + contact.getBodyID1());
            System.out.println("contact.getBodyID2() = " + contact.getBodyID2());

            ruleManager.process(contact, world);
        }
    }


    public void dynamicObjectListChange(DynamicObjectEvent evt) {
        for (RelativePrimative primative : evt.getSimObject().getInfo().getPrimatives()) {
            if (evt.getType() == (DynamicObjectEvent.ADDED)) {
                space.add(primative.getGeom());
            } else if (evt.getType() == (DynamicObjectEvent.REMOVED)) {
                space.remove(primative.getGeom());
            }
        }
    }

    public void staticObjectListChange(StaticObjectEvent evt) {
        //System.out.println("static added to collision");
        if (evt.getType() == (StaticObjectEvent.ADDED)){
            space.add(evt.getSimObject().getPrimative().getGeom());
        }
        else if (evt.getType() == (StaticObjectEvent.REMOVED)) {
            space.remove(evt.getSimObject().getPrimative().getGeom());
        }
    }

    public CollisionRuleManager getRuleManager() {
        return ruleManager;
    }
}

what happened when they stopped working? did you upgrade the version of Odejava (more notably the native library version)?

Are you using version control software on your own code - can you recover the last good version?

I find using some sort of versioning system even on personal projects is pretty much essential, especially when you are using API’s prone to nasty silent bugs (like Odejava…).

Are using the debug version of the native library? If not, can you give that a try?

Will.

Wise words, and yes indeed I have version control. Unfortunately last Friday my 2 hard drives blew up so I have lost all data I ever owned. Including all my work on ode (which by the way is for a masters thesis) So no rollbacks.
So yeah previously contacts were working fine and now they have dissapeared since getting the latest package of odejava. I shall try putting debug mode on ode, all my non-deterministic crashes have dissapeared though since restarting (and I havn’t reimplemented the thread safty thing yet)

ouch! you lost two hard drives?

I definitally recommend debug mode - it warns you about stuff you may not think is important but can cause unexplained to happen things down the track.

Will.