[SOLVED]custom callback problems

neomxl

17-02-2008 16:37:23

Hey all!

I am really struggling with this error, I am trying to setup a custom torque and force feedback but it crashes when I run it. It crashes with a standard "Instruction at xxx referenced memory at yyy. The Memory could not be read"

On debugging I find it crashes in this function:


void setCustomForceAndTorqueCallback( ForceCallback callback );
template<class c> void setCustomForceAndTorqueCallback( boost::function<void(c*, Body*)> callback, c *instancedClassPointer )
{
setCustomForceAndTorqueCallback( boost::bind(callback, instancedClassPointer, _1) );
}


This comes from my Character Initialisation function:

OgreNewt::Body* Character::init(OgreNewt::World *mWorld,OgreNewt::Collision *col){
thisBody = new OgreNewt::Body(mWorld,col,0);
thisBody->setCustomForceAndTorqueCallback<Character>(&Character::CharacterForceAndTorque, this);
return thisBody;
}


I have a well defined world that I have been using, I create the col just before I create a character:

col = new OgreNewt::CollisionPrimitives::Ellipsoid(W,Vector3(10,30,5),Quaternion(1,0,0,0),Vector3(100,0,100));

At the moment, as you can probably tell, I don't fully understand alot of things, so alot of things are being hacked together just to see it working and then I was goign to refine things as I go along, at the moment I have no idea why this isn't working.

One thing I did notice when debugging though, compared to my friends who works fine, is that if I step into my newtonWorld variable, and then into m_leavefeedback, down past the two boost functions I come to a 'vtable' variable: "Error expression could not be evaluated". I don't know if this has any effect on what I am trying to do, but it is the only difference between mine and my friends whose works.

I have searched the forums and such already, so any ideas at all will be muchly appreciated, because I am completely stumped :P!

walaber

18-02-2008 06:55:26

can you show the declaration for the callback please?

neomxl

18-02-2008 23:18:05

I have since solved this problem.

I was having some .cfg file conflicts, and then I did some stupid things with an OgreNewt::Body and didn't initialise it correctly.

Sorry for posting!

Just incase someone has similar troubles, check your plugins.cfg file and your body initialisations!

Thankyou for your reply anyway, appreciated.