Disappearing object with 2D joint

abecam

02-07-2006 00:14:22

Hi everyone...
Almost all work in my project, expected OpenAL (3rd solution I try, 3rd time I have an issue :) ), and a nasty calculation problem. It's not the OpenAL forum, so let's go to the second one:

I have an object constrained by a 2D-joint, and sometime it just disappears. I know (thanks to the forum and with some logging), that the position goes crazy and so it isn't in the scene anymore (but does not crash, thanks Ogre). The "funny" thing is that it appears first (so everything is fine) and disappears then... It's not always possible to see it, but the force&torque callback sees it well:


00:34:46: Me before callback info: Orientation 0.707107 0 0 0 Scale 0.5 1 0.5 Position 0 42.5 0
00:34:46: Me-body before callback info: Orientation 1 0 0 0 Position 0 42.5 0
00:34:46: Me after callback info: Orientation 0.707107 0 0 0 Scale 0.5 1 0.5 Position 0 42.5 0
00:34:46: Me-body after callback info: Orientation 1 0 0 0 Position 0 42.5 0
00:34:46: Me before callback info: Orientation 1 0 0 0 Scale 0.5 1 0.5 Position -1.#IND -1.#IND -1.#IND
00:34:46: Me-body before callback info: Orientation 1 0 0 0 Position -1.#IND -1.#IND -1.#IND
00:34:46: Me after callback info: Orientation 1 0 0 0 Scale 0.5 1 0.5 Position -1.#IND -1.#IND -1.#IND
00:34:46: Me-body after callback info: Orientation 1 0 0 0 Position -1.#IND -1.#IND -1.#IND
00:34:46: Me before callback info: Orientation 1 0 0 0 Scale 0.5 1 0.5 Position 1.#QNAN 1.#QNAN 1.#QNAN
00:34:46: Me-body before callback info: Orientation 1 0 0 0 Position 1.#QNAN 1.#QNAN 1.#QNAN


or


23:38:31: Me before callback info: Orientation 0.707107 0 0 0 Scale 0.5 1 0.5 Position 0 42.5 0
23:38:31: Me-body before callback info: Orientation 1 0 0 0 Position 0 42.5 0
23:38:31: Me after callback info: Orientation 0.707107 0 0 0 Scale 0.5 1 0.5 Position 0 42.5 0
23:38:31: Me-body after callback info: Orientation 1 0 0 0 Position 0 42.5 0
23:38:31: Me before callback info: Orientation 1 0 0 0 Scale 0.5 1 0.5 Position -1.#IND -1.#IND -1.#IND
23:38:31: Me-body before callback info: Orientation 1 0 0 0 Position -1.#IND -1.#IND -1.#IND
23:38:31: Me after callback info: Orientation 1 0 0 0 Scale 0.5 1 0.5 Position -1.#IND -1.#IND -1.#IND
23:38:31: Me-body after callback info: Orientation 1 0 0 0 Position -1.#IND -1.#IND -1.#IND


So it doesn't appear in the callback too. And the next time I set up a scene, everything is generally ok (it's totaly random... ).
I was thinking it's a problem with the world being simulated while I set up the scene (create the objects, create the joints, ...), so I eliminated BasicFrameListener and push the "update code" in the OgreFrameListener, and added a pause function, which push a stop to the update:


if (!inPause)
{
if ((m_elapsed > m_update) && (m_elapsed < (1.0f)) )
{
while (m_elapsed > m_update)
{
m_World->update( m_update );
m_elapsed -= m_update;
countUpdt++;
}
}
else
{
if (m_elapsed < (m_update))
{
// not enough time has passed this loop, so ignore for now.
}
else
{
m_World->update( m_elapsed );
countUpdt++;
m_elapsed = 0.0f; // reset the elapsed time so we don't become "eternally behind".
}
}
}
else
{
m_elapsed = 0.0f;
}


And the creation code is below:

((OgreNewtonFrameListener *)mFrameListener)->pause();
Ogre::Quaternion orientHandle ( Ogre::Vector3(0,0,0),Ogre::Vector3(0,1,0),Ogre::Vector3(0,0,0) );

handleBox = makeSimpleEll(Ogre::Vector3(0.5,1,0.5), Ogre::Vector3(0,42.5,0),orientHandle,rigiBodyNod);
handleBox->setVelocity(Ogre::Vector3(0,0,0));
handleBox->setOmega(Ogre::Vector3::ZERO);

joint2= new OgreNewt::PrebuiltCustomJoints::Custom2DJoint(handleBox,Ogre::Vector3(0,1,0));

joint2->setLimits(Ogre::Degree(10),Ogre::Degree(300));

((OgreNewtonFrameListener *)mFrameListener)->unPause();


(hope it's not too crappy, I am an old C-dog, always struggling with C++, I like OO in Java :wink: )

I have tried with/without my own force&torque callback, it doesn't change anything. Something is wrong in rotating/moving/... my object, but what??? :(

Any idea someone?

walaber

02-07-2006 06:48:46

how old is your copy of OgreNewt?

abecam

02-07-2006 11:46:02

I have the version 0.08, end of may (just before the new TreeCollisionSceneParser(), because I have my own).
Also, a small update, I have forced the pause to be on until I press a key, and the object disappears only when the simulation starts.