Thread: [Opal-commits] opal/src CollisionEventHandler.cpp,1.1,1.2 CollisionEventHandler.h,1.3,1.4 Defines.h,
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-09 06:24:08
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31248/src Modified Files: CollisionEventHandler.cpp CollisionEventHandler.h Defines.h EventHandler.h Simulator.cpp Simulator.h Log Message: made changes to collision detection "early out" cases to make things faster Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** Defines.h 6 Apr 2005 04:48:44 -0000 1.72 --- Defines.h 9 Apr 2005 06:23:58 -0000 1.73 *************** *** 283,286 **** --- 283,287 ---- const real maxLinearVel = (real)10000.0; const real maxAngularVel = (real)1000.0; + const bool staticSleepingContactsEnabled = false; /// All groups make contacts with all other groups by default. Index: CollisionEventHandler.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/CollisionEventHandler.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CollisionEventHandler.cpp 8 Mar 2005 16:10:23 -0000 1.1 --- CollisionEventHandler.cpp 9 Apr 2005 06:23:58 -0000 1.2 *************** *** 47,55 **** void CollisionEventHandler::internal_handlePendingCollisionEvents() { ! std::vector<CollisionEvent>::iterator iter; ! for (iter = mPendingCollisionEvents.begin(); ! iter != mPendingCollisionEvents.end(); ++iter) { ! handleCollisionEvent(*iter); } } --- 47,54 ---- void CollisionEventHandler::internal_handlePendingCollisionEvents() { ! while (!mPendingCollisionEvents.empty()) { ! handleCollisionEvent(mPendingCollisionEvents.back()); ! mPendingCollisionEvents.pop_back(); } } Index: EventHandler.h =================================================================== RCS file: /cvsroot/opal/opal/src/EventHandler.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** EventHandler.h 8 Mar 2005 16:10:23 -0000 1.21 --- EventHandler.h 9 Apr 2005 06:23:58 -0000 1.22 *************** *** 34,38 **** { /// Base class for various other event handling classes. EventHandlers ! /// are listeners that respond to particular events. class EventHandler { --- 34,39 ---- { /// Base class for various other event handling classes. EventHandlers ! /// are listeners that respond to particular events. It is perfectly ! /// safe to destroy objects when events are handled. class EventHandler { Index: CollisionEventHandler.h =================================================================== RCS file: /cvsroot/opal/opal/src/CollisionEventHandler.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CollisionEventHandler.h 8 Apr 2005 20:46:00 -0000 1.3 --- CollisionEventHandler.h 9 Apr 2005 06:23:58 -0000 1.4 *************** *** 80,84 **** /// Called once for each pending CollisionEvent. This is always ! /// called at the end of a time step, so CollisionEvents always /// get handled right away. OPAL_DECL virtual void OPAL_CALL handleCollisionEvent( --- 80,84 ---- /// Called once for each pending CollisionEvent. This is always ! /// called at the end of every time step so CollisionEvents /// get handled right away. OPAL_DECL virtual void OPAL_CALL handleCollisionEvent( Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** Simulator.cpp 8 Apr 2005 20:46:00 -0000 1.57 --- Simulator.cpp 9 Apr 2005 06:23:58 -0000 1.58 *************** *** 55,58 **** --- 55,60 ---- mIsSolidDestructionSafe = true; mIsJointDestructionSafe = true; + mStaticSleepingContactsEnabled = + defaults::staticSleepingContactsEnabled; int i=0; *************** *** 724,727 **** --- 726,739 ---- } + void Simulator::setStaticSleepingContactsEnabled(bool enable) + { + mStaticSleepingContactsEnabled = enable; + } + + bool Simulator::areStaticSleepingContactsEnabled() + { + return mStaticSleepingContactsEnabled; + } + unsigned long int Simulator::internal_getContactGroupFlags( unsigned int groupNum)const Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** Simulator.h 8 Apr 2005 20:46:00 -0000 1.95 --- Simulator.h 9 Apr 2005 06:23:58 -0000 1.96 *************** *** 67,75 **** virtual void OPAL_CALL destroy() = 0; ! /// This function takes the amount of time to simulate and advances ! /// the simulation ahead by that much. Internally, it steps through /// the simulation iteratively using a fixed step size. "Leftover" /// time will be saved until the next time this is called. The ! /// function returns true if at least one time step has been taken. virtual bool OPAL_CALL simulate(real dt); --- 67,94 ---- virtual void OPAL_CALL destroy() = 0; ! /// This function performs collision detection and simulates ! /// everything ahead by the given dt. Internally, it steps through /// the simulation iteratively using a fixed step size. "Leftover" /// time will be saved until the next time this is called. The ! /// function returns true if at least one time step has been taken. ! /// During collision detection, the following cases are ignored ! /// when deciding whether to collide two Solids (both for physical ! /// contact generation and collision event handling): ! /// 1. Two static Solids, each without a CollisionEventHandler. ! /// 2. Two Shapes that are part of the same Solid. ! /// 3. Two sleeping Solids. ! /// 4. Two Solids connected by a fixed Joint. ! /// 5. Two Solids connected by a Joint with contacts disabled. ! /// 6. Solid0 is static, Solid1 is sleeping, ! /// static-to-sleeping contacts are ignored by the ! /// Simulator, and neither Solid has a ! /// CollisionEventHandler. ! /// 7. Solid1 is static, Solid0 is sleeping, ! /// static-to-sleeping contacts are ignored by the ! /// Simulator, and neither Solid has a ! /// CollisionEventHandler. ! /// 8. The two Solids' contact groups do not generate ! /// contacts when they collide, and neither Solid has a ! /// CollisionEventHandler. virtual bool OPAL_CALL simulate(real dt); *************** *** 139,147 **** /// last argument is true, the two groups will generate physical /// points when they collide. Otherwise, they will pass through ! /// each other. Keep in mind that the following cases are already ! /// ignored when performing collision detection: two sleeping ! /// Solids don't collide; two Solids connected by a fixed Joint ! /// don't collide; two Solids connected by a Joint with its ! /// contacts enabled property set to false don't collide. /// Note that contact groups do not affect collision events; two /// colliding objects might not generate contacts and still --- 158,164 ---- /// last argument is true, the two groups will generate physical /// points when they collide. Otherwise, they will pass through ! /// each other. Keep in mind that certain cases are already ! /// ignored when performing collision detection; see comments ! /// on Simulator::simulate for more details. /// Note that contact groups do not affect collision events; two /// colliding objects might not generate contacts and still *************** *** 163,166 **** --- 180,193 ---- unsigned int group1); + /// Sets whether contacts should be generated between static Solids + /// and sleeping Solids. Usually this isn't necessary, but + /// sometimes you might want a static Solid to wake up a sleeping + /// dynamic Solid by touching it. + virtual void OPAL_CALL setStaticSleepingContactsEnabled(bool enable); + + /// Returns true if contacts are generated between static Solids + /// and sleeping Solids. + virtual bool OPAL_CALL areStaticSleepingContactsEnabled(); + // SOLIDS *************** *** 363,366 **** --- 390,397 ---- unsigned long int mContactGroupFlags[32]; + /// True if contacts are generated between static Solids and + /// sleeping Solids. + bool mStaticSleepingContactsEnabled; + /// Pointer to the Simulator's post-step event handler. PostStepEventHandler* mPostStepEventHandler; |