Settings for (very) simple physics ?

ceacy

20-05-2007 11:43:10

Hi,
I'm currently trying to set up physics, with OgreODE, in a RPG project. Physics do not have to be accuracy, or realistic : the main purpose is
- to prevent things from entering in each others
- to simulate gravity
- not to make moves seeming weird

For the characters, i use the "wiki way" : a capsule and a sphere.



This is the code used to make moves/etc :
http://ceacy.free.fr/tmp/physics.htm

This is the OgreODE initialization code :
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_NotAutomatic, mRoot );
// mStepper->setStepListener( this );
mWorld->setCollisionListener( this );

(i disabled the collision listener automatic stuff, because it seems to cause stack corruption under windows ; i manually call preStep() every TIME_STEP, even it is is much less accurate).
bool PlayState::collision( OgreOde::Contact* contact )
{
// Check for collisions between things that are connected and ignore them
OgreOde::Geometry * const g1 = contact->getFirstGeometry();
OgreOde::Geometry * const g2 = contact->getSecondGeometry();

if (g1 && g2)
{
const OgreOde::Body * const b1 = g1->getBody();
const OgreOde::Body * const b2 = g2->getBody();
if (b1 && b2 && OgreOde::Joint::areConnected(b1, b2))
return false;
}

// Set the friction at the contact
contact->setCoulombFriction( OgreOde::Utility::Infinity );
contact->setBouncyness( 0.01 );
contact->setSoftness( 0.8, 10e-5 ); // http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=3578
contact->setFrictionMode( OgreOde::Contact::Flag_FrictionPyramid );

// Yes, this collision is valid
return true;
}


What i would like to know is : are these settings all right ? I mean, i don't know how to tune these values (cfm, erp, bouncyness, sofness, ...), i don't even know if the way i did this is right. What settings should i use to have collisions "normal" (objects not bouncing and not merging, just stopping) ?

Thank you,
Ceacy.

Tabarn@kdeca.lis

29-05-2007 17:44:07

I'm actually looking forward to know which settings is best for a character to glide around, without floor falling through and without bouncing as in a pinball game. Here are the best settings I've found yet, but there are too much bouncyness... I have made a simple debug code to tweak parameter in real time, so I might come up with better settings soon. Well I'm hoping so cause I must!

CFM = 100e-5;
ERP = 0.8f;
ContactCorrectionVelocity = 0.2f;
ContactSurfaceLayer = -0.05f;
setAutoSleepAngularThreshold(OgreOde::Utility::Infinity);
setAutoSleep(false);


contact->setBouncyness(0.0f);
contact->setCoulombFriction(5.0f);


Please post your settings that work best!

Thanks