[Yake-svn] SF.net SVN: yake: [1696] trunk/yake
Status: Beta
Brought to you by:
psyclonist
From: <psy...@us...> - 2007-03-28 15:27:09
|
Revision: 1696 http://svn.sourceforge.net/yake/?rev=1696&view=rev Author: psyclonist Date: 2007-03-28 08:27:09 -0700 (Wed, 28 Mar 2007) Log Message: ----------- fixed static-vs-static actor bug (patch), improved exception safety, new parameters for OdeWorld: num_iterations, ERP, CFM (patch) Modified Paths: -------------- trunk/yake/src/plugins/physicsODE/OdeWorld.cpp trunk/yake/yake/plugins/physicsODE/OdeWorld.h Modified: trunk/yake/src/plugins/physicsODE/OdeWorld.cpp =================================================================== --- trunk/yake/src/plugins/physicsODE/OdeWorld.cpp 2007-03-28 15:24:23 UTC (rev 1695) +++ trunk/yake/src/plugins/physicsODE/OdeWorld.cpp 2007-03-28 15:27:09 UTC (rev 1696) @@ -43,30 +43,29 @@ //----------------------------------------------------- OdeWorld::OdeWorld() : mNextMeshId( 0 ), mTimeOverflow(0.) { - //TODO make these settings configurable for user //simulation mStepSize = real( 1./50. ); - mOdeWorld = new dWorld(); - YAKE_ASSERT( mOdeWorld ); + mOdeWorld.reset( new dWorld() ); - mOdeSpace = new dSimpleSpace( 0 ); - YAKE_ASSERT( mOdeSpace ); + //mOdeSpace.reset( new dSimpleSpace( 0 ) ); + mOdeSpace.reset( new dHashSpace( 0 ) ); + //dHashSpaceSetLevels (mOdeSpace->id(),10, 20); - mOdeContactGroup = new dJointGroup( 0 ); + mOdeContactGroup.reset( new dJointGroup( 0 ) ); mOdeWorld->setAutoDisableFlag( 1 ); mOdeWorld->setAutoDisableAngularThreshold( dReal(0.01) ); // ODE default: 0.01 mOdeWorld->setAutoDisableLinearThreshold( dReal(0.01) ); // ODE default: 0.01 mOdeWorld->setAutoDisableSteps( 10 ); // ODE default: 10 - mOdeWorld->setAutoDisableTime( 0 ); // ODE default: 0. (= ignore time) + mOdeWorld->setAutoDisableTime( 0 ); // ODE default: 0. (= ignore time)*/ // We do not set any default gravity setting // as we don't want to enforce a specific coordinate system. // mOdeWorld->setGravity( 0., -9.81, 0. ); - // Global ERP and CFM values should be configurable via some (properties?) interface + // Global ERP and CFM values are configurable via the properties interface // Individual values ( for joints and such ) should also be accessable // perhaps via direct_ode access. mOdeWorld->setCFM( dReal(0.001) ); @@ -77,7 +76,6 @@ dWorldSetContactMaxCorrectingVel( mOdeWorld->id(), dReal(2.) ); dWorldSetContactSurfaceLayer( mOdeWorld->id(), dReal(0.01) ); - mTime = real(0.); mMaterials["default"] = SharedPtr<OdeMaterial>(new OdeMaterial("default")); @@ -103,9 +101,9 @@ YAKE_SAFE_DELETE_ARRAY( mesh_data.normals ); } - YAKE_SAFE_DELETE( mOdeContactGroup ); - YAKE_SAFE_DELETE( mOdeSpace ); - YAKE_SAFE_DELETE( mOdeWorld ); + mOdeContactGroup.reset(); + mOdeSpace.reset(); + mOdeWorld.reset(); } //----------------------------------------------------- @@ -210,6 +208,18 @@ { mStepSize = boost::any_cast<real>(rValue); } + else if (rName == "num_iterations") + { + dWorldSetQuickStepNumIterations( mOdeWorld->id(), boost::any_cast<int>(rValue)); + } + else if (rName == "ERP") + { + mOdeWorld->setERP(boost::any_cast<real>(rValue)); + } + else if (rName == "CFM") + { + mOdeWorld->setCFM(boost::any_cast<real>(rValue)); + } } catch (boost::bad_any_cast& e) { YAKE_EXCEPT(String("Failed to set solver parameter! (") + e.what() + ")"); @@ -516,6 +526,8 @@ if ( b1 && b2 && dAreConnected( b1, b2 ) ) return; + + void* data1 = dGeomGetData( o1 ); void* data2 = dGeomGetData( o2 ); @@ -533,12 +545,12 @@ { OdeActor* pA = static_cast<OdeGeom*>( data1 )->getOwner(); OdeActor* pB = static_cast<OdeGeom*>( data2 )->getOwner(); - + if (!pA || !pB) return; // collision between two static objects: do nothing - if ((pA->getType() == ACTOR_STATIC) && (pA->getType() == ACTOR_STATIC)) + if ((pA->getType() == ACTOR_STATIC) && (pB->getType() == ACTOR_STATIC)) { return; } Modified: trunk/yake/yake/plugins/physicsODE/OdeWorld.h =================================================================== --- trunk/yake/yake/plugins/physicsODE/OdeWorld.h 2007-03-28 15:24:23 UTC (rev 1695) +++ trunk/yake/yake/plugins/physicsODE/OdeWorld.h 2007-03-28 15:27:09 UTC (rev 1696) @@ -88,10 +88,10 @@ // helpers dWorldID _getOdeID() const; dJointGroup* _getOdeContactJointGroup() const - { return mOdeContactGroup; } + { return mOdeContactGroup.get(); } dSpace* _getOdeSpace() const - { return mOdeSpace; } + { return mOdeSpace.get(); } dSpaceID _getOdeSpaceID() const { return mOdeSpace->id(); } @@ -110,9 +110,9 @@ real mTimeOverflow; real mTime; real mStepSize; - dWorld* mOdeWorld; - dJointGroup* mOdeContactGroup; - dSpace* mOdeSpace; + SharedPtr<dWorld> mOdeWorld; + SharedPtr<dJointGroup> mOdeContactGroup; + SharedPtr<dSpace> mOdeSpace; typedef std::vector< OdeBody* > BodyList; BodyList mBodies; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |