Update of /cvsroot/opal/opal/src/ODE
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31248/src/ODE
Modified Files:
ODESimulator.cpp
Log Message:
made changes to collision detection "early out" cases to make things faster
Index: ODESimulator.cpp
===================================================================
RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v
retrieving revision 1.96
retrieving revision 1.97
diff -C2 -d -r1.96 -r1.97
*** ODESimulator.cpp 6 Apr 2005 04:48:44 -0000 1.96
--- ODESimulator.cpp 9 Apr 2005 06:23:58 -0000 1.97
***************
*** 299,325 ****
// The following is a set of special cases where we might
! // not want to do collision detection (but not all are
// enforced here for various reasons):
! // 1. Two static Solids (neither geom has a body): this is
! // not enforced because sometimes you might want two
! // static Solids to generate collision events.
// 2. Two Shapes that are part of the same Solid (they
// share a body): this is not enforced because ODE
// already takes care of it.
// 3. Two sleeping Solids (note: both must have bodies to
! // check this): this is enforced. ODE should handle
! // this, but it doesn't.
// 4. Two Solids connected by a fixed Joint: this is
// enforced.
// 5. Two Solids connected by a Joint (besides ODE
! // contact joints, which never generate
! // contacts) with contacts disabled; (note: both must have
// bodies to check this): this is enforced.
! // 6. Solid0 is static and Solid1 is sleeping: not enforced
! // because sometimes you might want to wake up a sleeping
! // Solid with a static Solid.
! // 7. Solid1 is static and Solid0 is sleeping: not enforced
! // because sometimes you might want to wake up a sleeping
! // Solid with a static Solid.
// 8. The two Solids' contact groups do not generate
// contacts when they collide AND neither Solid has a
--- 299,327 ----
// The following is a set of special cases where we might
! // want to skip collision detection (but not all are
// enforced here for various reasons):
! // 1. Two static Solids (neither geom has a body) AND
! // neither Solid has a CollisionEventHandler: this is
! // enforced.
// 2. Two Shapes that are part of the same Solid (they
// share a body): this is not enforced because ODE
// already takes care of it.
// 3. Two sleeping Solids (note: both must have bodies to
! // check this): this is enforced. (ODE should handle
! // this, but it doesn't.)
// 4. Two Solids connected by a fixed Joint: this is
// enforced.
// 5. Two Solids connected by a Joint (besides ODE
! // contact joints, which should never generate more
! // contacts) with contacts disabled (note: both must have
// bodies to check this): this is enforced.
! // 6. Solid0 is static, Solid1 is sleeping,
! // static-to-sleeping contacts are ignored by the
! // Simulator, and neither Solid has a
! // CollisionEventHandler: this is enforced.
! // 7. Solid1 is static, Solid0 is sleeping,
! // static-to-sleeping contacts are ignored by the
! // Simulator, and neither Solid has a
! // CollisionEventHandler: this is enforced.
// 8. The two Solids' contact groups do not generate
// contacts when they collide AND neither Solid has a
***************
*** 329,332 ****
--- 331,336 ----
dBodyID o0BodyID = dGeomGetBody(o0);
dBodyID o1BodyID = dGeomGetBody(o1);
+ bool solid0Static = (0 == o0BodyID);
+ bool solid1Static = (0 == o1BodyID);
// Check if both Solids are dynamic (i.e. have ODE bodies).
***************
*** 364,367 ****
--- 368,376 ----
shape0->contactGroup, shape1->contactGroup);
+ // Find out whether the Simulator has static-to-sleeping
+ // contacts disabled.
+ bool ignoreStaticSleepingContacts =
+ !sim->areStaticSleepingContactsEnabled();
+
// Get pointers to the geoms' Solids.
Solid* solid0 = geomData0->solid;
***************
*** 376,390 ****
solid1->getCollisionEventHandler();
! if (//(0 == o0BodyID && 0 == o1BodyID) //case 1
//|| (o0BodyID == o1BodyID) //case 2
! (bothHaveBodies && !dBodyIsEnabled(o0BodyID) &&
! !dBodyIsEnabled(o1BodyID)) //case 3
|| (commonJoint &&
commonJoint->getType() == FIXED_JOINT) // case 4
! || (commonJoint &&
! !commonJoint->areContactsEnabled()) // case 5
! //|| (0 == o0BodyID && !dBodyIsEnabled(o1BodyID)) //case 6
! //|| (0 == o1BodyID && !dBodyIsEnabled(o0BodyID)) //case 7
! || (!makeContacts && !(handler0 || handler1))
)
{
--- 385,408 ----
solid1->getCollisionEventHandler();
! bool neitherHasEventHandler = !(handler0 || handler1);
!
! // It is important here that we don't check if a static body
! // is disabled (sleeping) because that crashes ODE.
! if ((neitherHasEventHandler
! && solid0Static && solid1Static) //case 1
//|| (o0BodyID == o1BodyID) //case 2
! || (bothHaveBodies && !dBodyIsEnabled(o0BodyID)
! && !dBodyIsEnabled(o1BodyID)) //case 3
|| (commonJoint &&
commonJoint->getType() == FIXED_JOINT) // case 4
! || (commonJoint
! && !commonJoint->areContactsEnabled()) // case 5
! || (solid0Static && !dBodyIsEnabled(o1BodyID)
! && ignoreStaticSleepingContacts
! && neitherHasEventHandler) //case 6
! || (solid1Static && !dBodyIsEnabled(o0BodyID)
! && ignoreStaticSleepingContacts
! && neitherHasEventHandler) //case 7
! || (!makeContacts && neitherHasEventHandler) // case 8
)
{
***************
*** 433,437 ****
if (handler0)
{
! handler0->handleCollisionEvent(e);
}
--- 451,455 ----
if (handler0)
{
! handler0->internal_pushCollisionEvent(e);
}
***************
*** 443,447 ****
e.thisSolid = solid1;
e.otherSolid = solid0;
! handler1->handleCollisionEvent(e);
}
}
--- 461,465 ----
e.thisSolid = solid1;
e.otherSolid = solid0;
! handler1->internal_pushCollisionEvent(e);
}
}
|