I have 2 objects, a sphere and a box that, when one collides with the other, will do some action (i.e. destroy the box).
I have tried several ways:
- checkCollideWith always returns true;
- contactPairTest - this I do not understand how to use. It takes 3 arguments, the 2 objects and a callback. I thought that the callback can be any function in my code, but it doesn't work like that.
Could someone please give an example of how to call a method, for example CollissionResult(), when 2 btRigidBodies collide (i.e. bodyA and bodyB)?
Maybe this example will help explain the concept. You have to define a new class, derived from an existing abstract class. You override one of the abstract classes methods with your callback code. You then create an object of the derived class and pass that to the function you want to call the callback. It's a common enough C++ technique.
I should add that I nothing whatsoever about this library. I've just read the docs.
EDIT
Showing how to add a context member to
MyContactResultCallback
.ptr_to_some_object
is the pointer to the object with thecurrentPoints
that you want to increment. I don't know what type of object that is, so I've just saidsome_type
, you can replace that with whatever the real type is.This is the point of using an object as a callback instead of a function. If the callback is an object you can add data members to it for whatever purpose you want, you cannot do that to a function.