Weird error with StepListener

ceacy

13-04-2007 16:55:20

Hi,
I almost went crazy with an error i couldn't understand using Ogreode (i finally changed my code, since i didn't know how to solve the problem). Someone told me it could be a case of stack corruption, but i don't know why ... the code is working under Linux, but causes a runtime error on Windows (compiling with VS2003 or VC++2005 Express).

class PlayState : public GameState,
public OgreOde::StepListener,
public OgreOde::CollisionListener,
public Singleton<PlayState>
{
//...
virtual bool collision( OgreOde::Contact* contact );
virtual bool preStep( Ogre::Real time );


void PlayState::enter()
{
//...
mWorld = new OgreOde::World( mSceneMgr );
mWorld->setGravity( Ogre::Vector3( 0, World::Physics::GRAVITY, 0 ) );
mWorld->setCFM( 100e-5 ); // http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=3578
mWorld->setERP( 0.8 );
mWorld->setAutoSleep( true );
mWorld->setContactCorrectionVelocity( 1.0 );
mStepper = new OgreOde::ForwardFixedInterpolatedStepHandler( mWorld, OgreOde::StepHandler::QuickStep, World::Physics::TIME_STEP );
mStepper->setAutomatic( OgreOde::StepHandler::AutoMode_PreFrame, mRoot );

// Physics listener
mStepper->setStepListener( this );
mWorld->setCollisionListener( this );


During the execution, i get an error because PlayState::enter() (which must be called only once) is called a second time ; and it's called from somewhere in the code there is no mention of it (in the OgreOde code !) :

bool StepHandler::basicStep(const Ogre::Real time)
{
if (_listener && !_listener->preStep(time))
return false;

_world->getDefaultSpace()->collide();

if (_listener && !_listener->middleStep(time)) // It is called here (according to the breakpoints i set)
return false;

_current_stepper->step(time);


This does look like stack corruption, but i don't know what could cause it ... has anyone already experienced that ?