From: <he...@us...> - 2009-07-30 17:25:57
|
Revision: 80 http://simspark.svn.sourceforge.net/simspark/?rev=80&view=rev Author: hedayat Date: 2009-07-30 17:25:42 +0000 (Thu, 30 Jul 2009) Log Message: ----------- performance improvement: do not call dSpaceCollide() for spaces with disabled internal collision. do not output too small skipped times move PrePhysicsUpdate() call just before PhysicsUpdate() call in RunMultiThreaded() function => 1 less wait() call with no speed loss. Modified Paths: -------------- trunk/spark/ChangeLog trunk/spark/lib/oxygen/physicsserver/space.cpp trunk/spark/lib/oxygen/physicsserver/space.h trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp Modified: trunk/spark/ChangeLog =================================================================== --- trunk/spark/ChangeLog 2009-07-30 17:21:13 UTC (rev 79) +++ trunk/spark/ChangeLog 2009-07-30 17:25:42 UTC (rev 80) @@ -1,3 +1,15 @@ +2009-07-30 Hedayat Vatankhah <he...@gr...> + + * lib/oxygen/physicsserver/space.h (Space): + * lib/oxygen/physicsserver/space.cpp (Space::Collide): + - performance improvement: do not call dSpaceCollide() for spaces with + disabled internal collision. + + * lib/oxygen/simulationserver/simulationserver.cpp: + - do not output too small skipped times + - move PrePhysicsUpdate() call just before PhysicsUpdate() call in + RunMultiThreaded() function => 1 less wait() call with no speed loss. + 2009-07-29 Hedayat Vatankhah <he...@gr...> * lib/oxygen/simulationserver/simulationserver.h: Modified: trunk/spark/lib/oxygen/physicsserver/space.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/space.cpp 2009-07-30 17:21:13 UTC (rev 79) +++ trunk/spark/lib/oxygen/physicsserver/space.cpp 2009-07-30 17:25:42 UTC (rev 80) @@ -58,9 +58,17 @@ void Space::Collide() { // bind collision callback function to this object - dSpaceCollide(mODESpace, this, collisionNearCallback); + Collide(mODESpace); } +void Space::Collide(dSpaceID space) +{ + if (gDisabledInnerCollisionSet.find(space) == gDisabledInnerCollisionSet.end()) + { + dSpaceCollide(space, this, collisionNearCallback); + } +} + void Space::HandleSpaceCollide(dGeomID obj1, dGeomID obj2) { // collide all geoms internal to the space(s) @@ -68,12 +76,12 @@ if (dGeomIsSpace (obj1)) { - dSpaceCollide ((dSpaceID)(obj1),this,&collisionNearCallback); + Collide((dSpaceID)obj1); } if (dGeomIsSpace (obj2)) { - dSpaceCollide ((dSpaceID)(obj2),this,&collisionNearCallback); + Collide((dSpaceID)obj2); } } @@ -107,16 +115,17 @@ const dSpaceID s1 = dGeomGetSpace(obj1); const dSpaceID s2 = dGeomGetSpace(obj2); - if ( - (s1 == s2) && - (gDisabledInnerCollisionSet.find(s1) != gDisabledInnerCollisionSet.end()) - ) - { - return; - } + // NOTICE: this should not happen since it is checked in Collide(dSpaceID) +// if ( +// (s1 == s2) && +// (gDisabledInnerCollisionSet.find(s1) != gDisabledInnerCollisionSet.end()) +// ) +// { +// return; +// } - - // if obj1 and obj2 are in the same space, and + + // if obj1 and obj2 are in the same space, and // obj1 is in obj2's "mNotCollideWithSet" or ojb2 is in obj1's // reject the collision Modified: trunk/spark/lib/oxygen/physicsserver/space.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/space.h 2009-07-30 17:21:13 UTC (rev 79) +++ trunk/spark/lib/oxygen/physicsserver/space.h 2009-07-30 17:25:42 UTC (rev 80) @@ -84,6 +84,11 @@ /** registers the managed space to the containing parent space */ virtual void OnLink(); + /** calls ODE's collision detection for this space if internal collision + * detection is enabled for this space. + */ + void Collide(dSpaceID space); + /** callback to handle a potential collision between two contained geoms. It will look up and notify the corresponding colliders for a potential collision. Modified: trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp =================================================================== --- trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp 2009-07-30 17:21:13 UTC (rev 79) +++ trunk/spark/lib/oxygen/simulationserver/simulationserver.cpp 2009-07-30 17:25:42 UTC (rev 80) @@ -426,14 +426,13 @@ { ++mCycle; mThreadBarrier->wait(); - mSceneServer->PrePhysicsUpdate(mSimStep); mThreadBarrier->wait(); - mThreadBarrier->wait(); if (mExit) // this check should be here so that all threads will quit break; finalDelta = initDelta = mSumDeltaTime; + mSceneServer->PrePhysicsUpdate(mSimStep); mSceneServer->PhysicsUpdate(mSimStep); if (mAutoTime) AdvanceTime(mSimStep); @@ -477,8 +476,6 @@ while ( true ) { mThreadBarrier->wait(); - // wait for PrePhysicsUpdate() - mThreadBarrier->wait(); newCycle = false; if ( controlNode->GetTime() - mSimTime <= 0.005f ) { @@ -524,12 +521,16 @@ { if (mAdjustSpeed && deltaTime > mMaxStepsPerCycle * mSimStep) + { + float diff = deltaTime - mSimStep; + if (diff > 0.0001) { GetLog()->Debug() << "(SimulationServer) Warning: Skipping remaining time: " - << deltaTime - mSimStep << '\n'; - deltaTime = 0; + << diff << '\n'; } + deltaTime = 0; + } else deltaTime -= mSimStep; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |