Collisions with ODE

I think you are looking to implement what is called a “trigger” in coppertop’s ODE Middleware.

This middleware, which I highly recommend, does not use the autocollide feature; it uses OdeUtil.collide() and then manually iterates through the collisions and creates contact joints (for non-triggers) and issues callback functions for the others. It’s well documented, so you can look through it for instruction. (It’s the only complete Panda/ODE example I could find online)

Alternatively, you could use Panda’s collision detection in addition to ODE for just detecting and initiating the callbacks. Suppose you want some objects to be containers, so you can remember when something goes inside of them. You could initialize a CollisionHandlerEvent as:

        # Initialize the handler.
        base.cEvent = CollisionHandlerEvent()
        base.cEvent.addInPattern("%fn-into-%(container)it")
        base.cEvent.addOutPattern("%fn-outof-%(container)it")
        # initialize listeners
        base.accept('object-into-acontainer', self._enterContainer)
        base.accept('object-outof-acontainer', self._exitContainer)

Then, for each such container, define a collision box and tag it as a container.

        lcorner, ucorner =self.model.getTightBounds()
        self.fullBoxCN = CollisionNode('object')
        cGeom = CollisionBox(lcorner, ucorner)
        cGeom.setTangible(1)
        self.fullBoxNP = self.attachNewNode(self.fullBoxCN)
        self.fullBoxCN.addSolid(cGeom)
        self.fullBoxNP.setTag('container','acontainer')
        base.cTrav.addCollider(self.fullBoxNP, base.cEvent)

Hope this helps!

Dustin