Subclassing BasicRayCast

Night Elf

23-01-2007 14:18:32

I've subclassed BasicRayCast like this:

class BodyTypeFilteredRayCast : public OgreNewt::BasicRaycast
{
private:

int _bodyType;

public:

BodyTypeFilteredRayCast(int bodyType, const OgreNewt::World* world, const Ogre::Vector3& startpt, const Ogre::Vector3& endpt)
: BasicRaycast(world, startpt, endpt), _bodyType(bodyType) { }
bool userPreFilterCallback(OgreNewt::Body* body);
};



bool BodyTypeFilteredRayCast::userPreFilterCallback(OgreNewt::Body* body)
{
int bodyType = body->getType();
return bodyType == _bodyType;
}


This class filters bodies based on their body type. The problem is that BodyTypeFilteredRayCast::userPreFilterCallback never gets called, Raycast::userPreFilterCallback is called instead... Am I doing something wrong?

OvermindDL1

24-01-2007 16:45:56

I would guess that Walaber forgot to either make it virtual, or he is trying to call it from the constructor. :P

durmieu

21-12-2007 20:40:21

Same problem here. My code is quite similar to the above, and userPreFilterCallback doesn't get called neither. While debbuging, I put a breakpoint in the function but the program never reaches it.

Night Elf: Did you ever solve the problem?

Edit: inheritance problems. That was it. Solved inheriting directly from Raycast & copping some functions from BasicRaycast to my new raycasting class.

walaber

22-12-2007 05:45:02

sorry it is not more clear... you are intended to inherit from Raycast directly with any custom implementation... BasicRayCast is just there to get people up and running quickly...

durmieu

22-12-2007 15:07:49

I see... I don't have much experience with OOP. But looking at it now I understand...
Very clear and useful, like the rest of your code. Cheers :wink: