callback problem with convex[Solved]

Nox587

12-08-2007 02:25:20

I've created a body using the OgreNewt::CollisionPrimitives::ConvexHull collision (passing it a scene node). The collision is displayed properly (with debug lines) on my object, but I can not get a customForceAndTorqueCallback to work with the object.


//...

//Inertia
convex->calculateInertialMatrix(m_Inertia, m_Offset);

//Center of mass, mass matrix
m_Body->setCenterOfMass(Ogre::Vector3(m_Offset.x, m_Offset.y, m_Offset.z));
m_Body->setMassMatrix(m_Mass, m_Inertia);

//I set the callback like this -
m_Body->setCustomForceAndTorqueCallback(&CCmpProp::standardForceCallback);

//Even replacing the above with this won't work
//m_Body->setStandardForceCallback();

//...


The CCmpProp::standardForceCallback is a static member function:


class CCmpNode : public ICmpNode
{
public:
//...
static void standardForceCallback(OgreNewt::Body *me);
//...
};


Neither the custom callback I assign, or the standard callback are working for the object, and I can't seem to find what I'm doing wrong.




walaber

12-08-2007 02:46:57

what are you setting the mass to?

and are you remembering to call OgreNewt::World::update() ? sometimes it's the obvious things like that that you can miss :)

Nox587

12-08-2007 02:55:56

My mass is being set to 150, and I have a framelistener set up for physics, frame started method:


bool Physics::frameStarted(const Ogre::FrameEvent &evt)
{
m_Elapsed = evt.timeSinceLastFrame;

if(BaseGame::Get()->getInputManager()->getKeyboard()->isKeyDown(OIS::KC_F2))
{
OgreNewt::Debugger::getSingleton().showLines(m_World);
}
else
{
OgreNewt::Debugger::getSingleton().hideLines();
}

int count = 0;

if ((m_Elapsed > m_FrameRate) && (m_Elapsed < (m_FrameRate * 10)))
{
while(m_Elapsed > m_FrameRate)
{
m_World->update(m_FrameRate);
m_Elapsed -= m_FrameRate;
count++;
}
}
else
{
if(m_Elapsed < (m_FrameRate))
{
//ignore loop
}
else
{
m_World->update(m_FrameRate);
count++;
m_Elapsed = 0.0f;
}
}

return true;
}


This was all taken from the basic frame listener, I just removed some of the debug messaging.

Nox587

12-08-2007 05:55:10

After recompiling into release form, the convex moves with the OgreNewt standardForceCallback, but very very slowly. No matter what I set the mass to, the convex moves very slowly. It still colides with other objects in the scene, just very slowly.

My application is still running at about 70FPS, and any movement that uses translation instead of forces behaves normally. Any ideas on whats going on here?

Nox587

12-08-2007 06:06:08

Ok, problem was that my gravity amount in my custom callback was to small, well even the one in OgreNewt was to small for the size of the object I was using. After increasing the amount the objects are working correctly.