TomUK
25-03-2008 11:14:39
Hi,
I'm writing a game which I have got to compile and run under windows and was trying to run it on linux as well. I've successfully compiled and linked it on linux but when I run it it crashes in the setCustomForceAndTorqueCallback function (it didn't do this on Windows).
I've got the latest version of OgreNewt from the CVS repository, Newton v1.53, Ogre v1.4.6. I compiled the OgreNewt code with a few printfs in OgreNewt::Body::setCustomForceAndTorqueCallback and it appears to crash in the if block when setting assigning callback to m_forceCallback. I'm fairly new to c++ so I could be doing something wrong but I've tried a few different ways:
1) body->setCustomForceAndTorqueCallback<MyClass>(&MyClass::forceCallback, this) from within the constuctor
2) body->setCustomForceAndTorqueCallback(boost::bind(&MyClass::forceCallback, this, _1)) in the constructor
3) the above but after the object has been constructed.
All three compile and then crash in the same place
I reconstructed it with the following code:
The output is:
Gets here
Segmentation fault (core dumped)
Am I doing something wrong? Is there any fix or way round it?
Thanks in advance
I'm writing a game which I have got to compile and run under windows and was trying to run it on linux as well. I've successfully compiled and linked it on linux but when I run it it crashes in the setCustomForceAndTorqueCallback function (it didn't do this on Windows).
I've got the latest version of OgreNewt from the CVS repository, Newton v1.53, Ogre v1.4.6. I compiled the OgreNewt code with a few printfs in OgreNewt::Body::setCustomForceAndTorqueCallback and it appears to crash in the if block when setting assigning callback to m_forceCallback. I'm fairly new to c++ so I could be doing something wrong but I've tried a few different ways:
1) body->setCustomForceAndTorqueCallback<MyClass>(&MyClass::forceCallback, this) from within the constuctor
2) body->setCustomForceAndTorqueCallback(boost::bind(&MyClass::forceCallback, this, _1)) in the constructor
3) the above but after the object has been constructed.
All three compile and then crash in the same place
I reconstructed it with the following code:
#include <OgreNewt_Body.h>
#include <OgreNewt_Collision.h>
#include <OgreNewt_CollisionPrimitives.h>
#include <OgreNewt_World.h>
#include <OgreVector3.h>
class Test
{
public:
OgreNewt::Body *b;
Test();
void callback(OgreNewt::Body *me);
} ;
Test::Test()
{
OgreNewt::World *world = new OgreNewt::World();
OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Ellipsoid(world, Ogre::Vector3(1, 1, 1));
b = new OgreNewt::Body(world, col);
printf("Gets here\n");
b->setCustomForceAndTorqueCallback<Test>(&Test::callback, this);
printf("but not to here\n");
}
void Test::callback(OgreNewt::Body *me)
{
// do something interesting
}
int main(int argc, char **argv)
{
Test *t = new Test();
}
The output is:
Gets here
Segmentation fault (core dumped)
Am I doing something wrong? Is there any fix or way round it?
Thanks in advance