Problem with setCustomForceAndTorqueCallback [SOLVED]

durmieu

25-09-2007 00:28:44

I've starting a game with ogrenewt and I'm having some trouble with setCustomForceAndTorqueCallback. When I run the app I get a "Fallo de segmentación (core dumped)".

The callback function is as follows:

void TestState::forceCallback(OgreNewt::Body* me){

me->addLocalForce(Vector3(0,-10,0),Vector3::ZERO);
}


and y call it this way (form inside TestState)

bod->setCustomForceAndTorqueCallback<TestState>(&TestState::forceCallback,this);

Compiles fine, but then Boooom! Here is the stacktrace from gdb:

(gdb) bt
#0 0x08140015 in ?? ()
#1 0xb7f62131 in boost::function1<void, OgreNewt::Body*, std::allocator<void> >::assign_to_own () from /usr/lib/libOgreNewt.so
#2 0xb7f6217b in boost::function1<void, OgreNewt::Body*, std::allocator<void> >::function1 () from /usr/lib/libOgreNewt.so
#3 0xb7f621a6 in boost::function<void ()(OgreNewt::Body*), std::allocator<void> >::function () from /usr/lib/libOgreNewt.so
#4 0xb7f62a36 in boost::function<void ()(OgreNewt::Body*), std::allocator<void> >::operator= () from /usr/lib/libOgreNewt.so
#5 0xb7f60eaf in OgreNewt::Body::setCustomForceAndTorqueCallback ()
from /usr/lib/libOgreNewt.so
#6 0x0810ee07 in TestState::enter (this=0x813fe40)
at /usr/include/OgreNewt/OgreNewt_Body.h:162
#7 0x08107cf6 in GameManager::changeState (this=0x81450d0, state=0x813fe40)
at GameManager.cpp:55
#8 0x08108d5b in GameManager::start (this=0x81450d0, state=0x813fe40)
at GameManager.cpp:40
#9 0x0810793f in main () at Main.cpp:21


I tried with bod->setCustomForceAndTorqueCallback(forceCallback); and the function outside the class and got the same result. Did I make any mistake or is it a OgreNewt bug? Is there any workaround? Another way to apply forces?

Thank you,

durmieu

26-09-2007 18:06:09

Here is how I solved this, to whom it may interest:


$ cd ogrenewt/OgreNewt_Main/inc/
$ mv boost boost.evil
$ sudo apt-get install libboost-dev
$ ln -s /usr/include/boost/ boost

recompile and reinstall

Game_Ender

26-09-2007 22:16:19

Are you using the Scons based build system? It allows you to pick a different boost directory.

durmieu

27-09-2007 00:09:56

Have no experience with scons, but after having a closer look at the scripts... interesting. But still don't understand why the boost included with ogrenewt crashes in my computer, because no one has report such a problem, right? Well, anyway, the important thing is that now it works. :mrgreen:

Game_Ender

27-09-2007 06:25:17

I had the exact same problem. The boost directory needs to be moved out of the default search path, then the build system can let you pick whether you want to use the included boost files, or you local ones.

I have gotten the same crashes, its because the version of boost you have installed your machine is different then the one in OgreNewt.