[ODE] What NearCallback must be like? I cannot place it inside a class!

michael kapelko kornerr at gmail.com
Wed Jul 26 22:50:27 MST 2006


I created a basic physics class to incapsulate world creation, callback 
func, etc.
But when I try to compile main.cpp where I use it, I get:
main.cpp: In function `void Simulate(bool)':
main.cpp:251: error: ISO C++ forbids taking the address of a bound member
    function to form a pointer to member function.  Say `&PhysicsBasic::
    NearCallback'
main.cpp:251: error: cannot convert `void (PhysicsBasic::*)(void*, dxGeom*,
    dxGeom*)' to `void (*)(void*, dxGeom*, dxGeom*)' for argument `3' to 
`void
    dSpaceCollide(dxSpace*, void*, void (*)(void*, dxGeom*, dxGeom*))'
make: *** [.obj/main.o] Error 1

I tried both PhysicsBasic phys and PhysicsBasic *phys, but none works.
Does this function must be outside any class? But how to encapsulate it 
then?
Thanks.


/// Basic physics implementation

#ifndef PHYSICS_BASIC_H
#define PHYSICS_BASIC_H

#include "../globals.h"

class PhysicsBasic {
         public:
                 /// Constructor
                 PhysicsBasic ();
                 /// Destructor
                 ~PhysicsBasic ();
                 /// Gets called when two objects are close enough

                 /// ODE calls this function whenever it thinks two 
objects are close enough                /// to check for collision
                 /// \param data can't remember...
                 /// \param o1 the first geom of two which should be 
checked for collision
                 /// \param o2 the second geom of two which should be 
checked for collision
                 void NearCallback (void *data, dGeomID o1, dGeomID o2);
                 /// Create main world
                 void CreateWorld ();
                 /// Destory main world
                 void DestroyWorld ();

                 /// Main world
                 dWorldID world;
                 /// Main space (used by collision detection)
                 dSpaceID space;
                 /// Contact joints group (used by collision detection)
                 dJointGroupID contact_group;
                 /// Level geometry representation

                 /// We define our level as geom only, because we don't 
want it to be affected by
                 /// gravity. When we want an object to be affected by 
gravity, we define
                 /// it as geom AND body.
                 /// \n\n TODO: but how then it's known that this should 
be collidable?
                 /// NearCallback (...) retrieves body info for 
collision detection...
                 dGeomID level;
};

#endif // PHYSICS_BASIC_H


More information about the ODE mailing list