Thread: [Opal-commits] opal/src CollisionEventHandler.cpp,NONE,1.1 CollisionEventHandler.h,NONE,1.1 JointBre
Status: Inactive
Brought to you by:
tylerstreeter
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11795/src Modified Files: AttractorMotor.h BoxShapeData.h CapsuleShapeData.h Defines.h EventHandler.h Joint.cpp Joint.h JointData.h Logger.cpp Logger.h MeshShapeData.h PlaneShapeData.h SConscript ShapeData.h Simulator.cpp Simulator.h Singleton.h Solid.cpp Solid.h SphereShapeData.h SpringMotor.h ThrusterMotor.h opal.h Added Files: CollisionEventHandler.cpp CollisionEventHandler.h JointBreakEventHandler.h Log Message: added contact groups; added separate event handlers for collisions and joint break events; commented out mass ratio stuff Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** opal.h 5 Mar 2005 21:26:24 -0000 1.19 --- opal.h 8 Mar 2005 16:10:23 -0000 1.20 *************** *** 55,58 **** --- 55,60 ---- #include "SensorData.h" #include "EventHandler.h" + #include "JointBreakEventHandler.h" + #include "CollisionEventHandler.h" #include "Blueprint.h" #include "BlueprintInstance.h" Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SConscript 26 Feb 2005 10:22:23 -0000 1.11 --- SConscript 8 Mar 2005 16:10:23 -0000 1.12 *************** *** 11,14 **** --- 11,15 ---- BoxShapeData.h CapsuleShapeData.h + CollisionEventHandler.h Defines.h EventHandler.h *************** *** 16,19 **** --- 17,21 ---- GearedMotorData.h Joint.h + JointBreakEventHandler.h JointData.h Logger.h *************** *** 54,57 **** --- 56,60 ---- BlueprintInstance.cpp BlueprintManager.cpp + CollisionEventHandler.cpp GearedMotor.cpp Joint.cpp Index: ShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/ShapeData.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ShapeData.h 5 Mar 2005 21:26:24 -0000 1.5 --- ShapeData.h 8 Mar 2005 16:10:23 -0000 1.6 *************** *** 56,59 **** --- 56,60 ---- // Leave the offset as an identity matrix. material = defaults::shape::material; + contactGroup = defaults::shape::contactGroup; } *************** *** 74,77 **** --- 75,82 ---- Material material; + /// The Shape's contact group. If this exceeds 31, bad things + /// might happen since there are only 32 groups. + unsigned long int contactGroup; + protected: /// The Shape type. Index: Logger.h =================================================================== RCS file: /cvsroot/opal/opal/src/Logger.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Logger.h 28 Feb 2005 03:27:56 -0000 1.3 --- Logger.h 8 Mar 2005 16:10:23 -0000 1.4 *************** *** 74,77 **** --- 74,78 ---- //static void unsilenceStream(const std::string& name); + /// Returns the named stream. std::ostream& OPAL_CALL stream(const std::string& name); Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** Simulator.h 5 Mar 2005 21:26:24 -0000 1.79 --- Simulator.h 8 Mar 2005 16:10:23 -0000 1.80 *************** *** 50,53 **** --- 50,61 ---- struct RaycastResult { + RaycastResult() + { + solid = NULL; + // "intersection" is initialized in its own constructor. + // "normal" is initialized in its own constructor. + distance = 0; + } + /// The first Solid hit by the ray. Solid* solid; *************** *** 150,156 **** /// last argument is true, the two groups will generate physical /// points when they collide. Otherwise, they will pass through ! /// each other. This does not affect collision events; two ! /// colliding objects might not generate contacts but still ! /// generate collision events. virtual void OPAL_CALL setupContactGroups(unsigned int group0, unsigned int group1, bool makeContacts); --- 158,169 ---- /// 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 ! /// generate collision events sent to their CollisionEventHandlers. virtual void OPAL_CALL setupContactGroups(unsigned int group0, unsigned int group1, bool makeContacts); *************** *** 161,168 **** virtual Solid* OPAL_CALL createSolid() = 0; ! /// Marks the given Solid as garbage. virtual void OPAL_CALL destroySolid(Solid* s); ! /// Marks all Solids in the Simulator as garbage. virtual void OPAL_CALL destroyAllSolids(); --- 174,183 ---- virtual Solid* OPAL_CALL createSolid() = 0; ! /// Immediately destroys the given Solid. All Joints, Motors, and ! /// Sensors that depend on this Solid will be automatically ! /// disabled. virtual void OPAL_CALL destroySolid(Solid* s); ! /// Immediately destroys all Solids in the Simulator. virtual void OPAL_CALL destroyAllSolids(); *************** *** 175,182 **** virtual Joint* OPAL_CALL createJoint() = 0; ! /// Marks the given Joint as garbage. virtual void OPAL_CALL destroyJoint(Joint* j); ! /// Marks all Joints in the Simulator as garbage. virtual void OPAL_CALL destroyAllJoints(); --- 190,198 ---- virtual Joint* OPAL_CALL createJoint() = 0; ! /// Immediately destroys the given Joint. All Motors that depend ! /// on this Solid will be automatically disabled. virtual void OPAL_CALL destroyJoint(Joint* j); ! /// Immediately destroys all Joints in the Simulator. virtual void OPAL_CALL destroyAllJoints(); *************** *** 202,209 **** //virtual void OPAL_CALL registerCustomMotor(Motor* m); ! /// Marks the given Motor as garbage. virtual void OPAL_CALL destroyMotor(Motor* m); ! /// Marks all Motors in the Simulator as garbage. virtual void OPAL_CALL destroyAllMotors(); --- 218,225 ---- //virtual void OPAL_CALL registerCustomMotor(Motor* m); ! /// Immediately destroys the given Motor. virtual void OPAL_CALL destroyMotor(Motor* m); ! /// Immediately destroys all Motors in the Simulator. virtual void OPAL_CALL destroyAllMotors(); *************** *** 213,220 **** virtual Solid* OPAL_CALL createSensor(); ! /// Marks the given Sensor as garbage. virtual void OPAL_CALL destroySensor(Sensor* s); ! /// Marks all Sensors in the Simulator as garbage. virtual void OPAL_CALL destroyAllSensors(); --- 229,236 ---- virtual Solid* OPAL_CALL createSensor(); ! /// Immediately destroys the given Sensor. virtual void OPAL_CALL destroySensor(Sensor* s); ! /// Immediately destroys all Sensors in the Simulator. virtual void OPAL_CALL destroyAllSensors(); *************** *** 230,238 **** virtual void OPAL_CALL internal_stepPhysics() = 0; protected: virtual ~Simulator(); ! /// Destroys all objects in the Simulator marked as garbage. ! void collectGarbage(); /// Adds a Solid to the internal list of Solids. --- 246,257 ---- virtual void OPAL_CALL internal_stepPhysics() = 0; + /// Returns the Simulator's contact group flags. + virtual unsigned long int OPAL_CALL + internal_getContactGroupFlags(unsigned int groupNum)const; protected: virtual ~Simulator(); ! ///// Destroys all objects in the Simulator marked as garbage. ! //void collectGarbage(); /// Adds a Solid to the internal list of Solids. *************** *** 300,314 **** std::vector<Sensor*> mSensorList; ! /// An internal list of all Solids marked as garbage. ! std::vector<Solid*> mSolidGarbageList; ! /// An internal list of all Joints. ! std::vector<Joint*> mJointGarbageList; ! /// An internal list of all Motors marked as garbage. ! std::vector<Motor*> mMotorGarbageList; ! /// An internal list of all Sensors marked as garbage. ! std::vector<Sensor*> mSensorGarbageList; /// Spaces are stored here so the user doesn't have to destroy them; --- 319,333 ---- std::vector<Sensor*> mSensorList; ! ///// An internal list of all Solids marked as garbage. ! //std::vector<Solid*> mSolidGarbageList; ! ///// An internal list of all Joints. ! //std::vector<Joint*> mJointGarbageList; ! ///// An internal list of all Motors marked as garbage. ! //std::vector<Motor*> mMotorGarbageList; ! ///// An internal list of all Sensors marked as garbage. ! //std::vector<Sensor*> mSensorGarbageList; /// Spaces are stored here so the user doesn't have to destroy them; Index: PlaneShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/PlaneShapeData.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PlaneShapeData.h 3 Mar 2005 02:32:28 -0000 1.3 --- PlaneShapeData.h 8 Mar 2005 16:10:23 -0000 1.4 *************** *** 65,68 **** --- 65,69 ---- offset = data.offset; material = data.material; + contactGroup = data.contactGroup; for (int i=0; i<4; ++i) --- NEW FILE: CollisionEventHandler.h --- /************************************************************************* * * * Open Physics Abstraction Layer * * Copyright (C) 2004-2005 * * Alan Fischer ala...@gm... * * Andres Reinot an...@re... * * Tyler Streeter tyl...@gm... * * All rights reserved. * * Web: opal.sourceforge.net * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of EITHER: * * (1) The GNU Lesser General Public License as published by the Free * * Software Foundation; either version 2.1 of the License, or (at * * your option) any later version. The text of the GNU Lesser * * General Public License is included with this library in the * * file license-LGPL.txt. * * (2) The BSD-style license that is included with this library in * * the file license-BSD.txt. * * * * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files * * license-LGPL.txt and license-BSD.txt for more details. * * * *************************************************************************/ #ifndef OPAL_COLLISION_EVENT_HANDLER_H #define OPAL_COLLISION_EVENT_HANDLER_H #include "Defines.h" #include "EventHandler.h" namespace opal { class Solid; /// A data structure containing info about a specific collision event /// involving two Solids. struct CollisionEvent { CollisionEvent() { thisSolid = NULL; otherSolid = NULL; // "pos" is initialized in its own constructor. // "normal" is initialized in its own constructor. depth = 0; } /// The colliding Solid whose CollisionEventHandler gets called. Solid* thisSolid; /// The Solid that collided with the one owning the /// CollisionEventHandler. Solid* otherSolid; /// The point of collision. Point3r pos; /// The normal vector at the point of collision. Vec3r normal; /// The depth of interpenetration. This may not be very helpful /// if the two Solids are allowed to pass through each other (i.e. /// their contact groups do not generate contacts). real depth; }; /// A listener that gets notified when two Solids touch. class CollisionEventHandler : public EventHandler { public: CollisionEventHandler(); virtual ~CollisionEventHandler(); /// Called once for each pending CollisionEvent. This is always /// called at the end of a time step, so CollisionEvents always /// get handled right away. virtual void OPAL_CALL handleCollisionEvent( const CollisionEvent& e) = 0; /// Adds a CollisionEvent to this handler's internal list. These /// will get handled at the end of the current time step. virtual void OPAL_CALL internal_pushCollisionEvent( const CollisionEvent& e); /// Loops through the pending CollisionEvents, calling the event /// handling function (which is always user-defined) for each. virtual void OPAL_CALL internal_handlePendingCollisionEvents(); protected: /// This list holds pending CollisionEvents. It allows events to /// be queued during collision detection and handled at a safe time. std::vector<CollisionEvent> mPendingCollisionEvents; private: }; } #endif Index: SpringMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SpringMotor.h 1 Mar 2005 05:04:22 -0000 1.9 --- SpringMotor.h 8 Mar 2005 16:10:23 -0000 1.10 *************** *** 109,146 **** SpringMotorData mData; - ///// Pointer to the Solid affected by this Motor. - //Solid* mSolid; - - ///// The Motor's mode of operation. - //Mode mMode; - - ///// The Motor's desired position. This is only used if the - ///// appropriate mode is set. - //Point3r mDesiredPos; - - ///// The Motor's desired forward direction, part of the desired - ///// orientation. This is only used if the appropriate mode is set. - //Vec3r mDesiredForward; - - ///// The Motor's desired up direction, part of the desired - ///// orientation. This is only used if the appropriate mode is set. - //Vec3r mDesiredUp; - - ///// The Motor's desired right direction, part of the desired - ///// orientation. This is only used if the appropriate mode is set. - //Vec3r mDesiredRight; - - ///// The damping constant for linear mode. - //real mLinearKd; - - ///// The spring constant for linear mode. - //real mLinearKs; - - ///// The damping constant for angular mode. - //real mAngularKd; - - ///// The spring constant for angular mode. - //real mAngularKs; - private: }; --- 109,112 ---- Index: ThrusterMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/ThrusterMotor.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ThrusterMotor.h 4 Mar 2005 05:09:24 -0000 1.10 --- ThrusterMotor.h 8 Mar 2005 16:10:23 -0000 1.11 *************** *** 83,92 **** ThrusterMotorData mData; - /// Pointer to the Solid affected by this Motor. - //Solid* mSolid; - - /// The Force that gets applied to the Solid every time step. - //Force mForce; - private: }; --- 83,86 ---- Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** Solid.h 4 Mar 2005 23:26:54 -0000 1.80 --- Solid.h 8 Mar 2005 16:10:23 -0000 1.81 *************** *** 30,34 **** #include "Defines.h" ! #include "EventHandler.h" #include "SolidData.h" --- 30,34 ---- #include "Defines.h" ! #include "CollisionEventHandler.h" #include "SolidData.h" *************** *** 177,184 **** /// Sets the Solid's event handler. ! virtual void OPAL_CALL setEventHandler(EventHandler* eventHandler); /// Returns the Solid's event handler. ! virtual EventHandler* OPAL_CALL getEventHandler()const; //// Quickly spinning solids should be set as fast rotating solids to --- 177,185 ---- /// Sets the Solid's event handler. ! virtual void OPAL_CALL setEventHandler( ! CollisionEventHandler* eventHandler); /// Returns the Solid's event handler. ! virtual CollisionEventHandler* OPAL_CALL getEventHandler()const; //// Quickly spinning solids should be set as fast rotating solids to *************** *** 220,224 **** /// Pointer to this Solid's event handler. ! EventHandler* mEventHandler; /// Pointer to user data. This is totally user-managed (i.e. OPAL --- 221,225 ---- /// Pointer to this Solid's event handler. ! CollisionEventHandler* mCollisionEventHandler; /// Pointer to user data. This is totally user-managed (i.e. OPAL Index: CapsuleShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/CapsuleShapeData.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CapsuleShapeData.h 3 Mar 2005 02:32:28 -0000 1.3 --- CapsuleShapeData.h 8 Mar 2005 16:10:23 -0000 1.4 *************** *** 62,65 **** --- 62,66 ---- offset = data.offset; material = data.material; + contactGroup = data.contactGroup; radius = data.radius; length = data.length; Index: SphereShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/SphereShapeData.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SphereShapeData.h 3 Mar 2005 02:32:28 -0000 1.3 --- SphereShapeData.h 8 Mar 2005 16:10:23 -0000 1.4 *************** *** 61,64 **** --- 61,65 ---- offset = data.offset; material = data.material; + contactGroup = data.contactGroup; radius = data.radius; } Index: AttractorMotor.h =================================================================== RCS file: /cvsroot/opal/opal/src/AttractorMotor.h,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** AttractorMotor.h 1 Mar 2005 05:04:22 -0000 1.25 --- AttractorMotor.h 8 Mar 2005 16:10:23 -0000 1.26 *************** *** 88,97 **** AttractorMotorData mData; - /// Pointer to Solid 0. - //Solid* mSolid0; - - /// Pointer to Solid 1. - //Solid* mSolid1; - /// Cached copy of Solid 0's mass. real mSolid0Mass; --- 88,91 ---- *************** *** 100,112 **** real mSolid1Mass; - /// Constant used to scale attraction (repulsion if strength < 0). - //real mStrength; - /// Cached copy of strength * m0 * m1. real mMassConstant; - /// Determines exponential relationship of attraction/repulsion. - //real mExponent; - private: --- 94,100 ---- Index: BoxShapeData.h =================================================================== RCS file: /cvsroot/opal/opal/src/BoxShapeData.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BoxShapeData.h 3 Mar 2005 02:32:28 -0000 1.3 --- BoxShapeData.h 8 Mar 2005 16:10:23 -0000 1.4 *************** *** 61,64 **** --- 61,65 ---- offset = data.offset; material = data.material; + contactGroup = data.contactGroup; dimensions = data.dimensions; } Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.66 retrieving revision 1.67 diff -C2 -d -r1.66 -r1.67 *** Defines.h 5 Mar 2005 21:26:24 -0000 1.66 --- Defines.h 8 Mar 2005 16:10:23 -0000 1.67 *************** *** 283,286 **** --- 283,289 ---- const real maxAngularVel = (real)1000.0; + /// All groups make contacts with all other groups by default. + const unsigned long int contactGroupFlags = 0xFFFFFFFF; + /// Default parameters used in Solid creation. namespace solid *************** *** 325,328 **** --- 328,332 ---- const real breakThresh = (real)100.0; const real accumThresh = (real)1000.0; + const bool enableContacts = false; } Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Simulator.cpp 5 Mar 2005 21:26:24 -0000 1.42 --- Simulator.cpp 8 Mar 2005 16:10:23 -0000 1.43 *************** *** 39,76 **** mTimeBuffer = 0; setStepSize(defaults::stepSize); - //setDefaultLinearDamping(defaults::linearDamping); - //setDefaultAngularDamping(defaults::angularDamping); - //mAllowPartialFrames = defaults::allowPartialFrames; setMaxLinearVel(defaults::maxLinearVel); setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); } Simulator::~Simulator() { ! // Mark everything as garbage, then collect the garbage. ! size_t i; ! for (i=0; i<mSolidList.size(); ++i) ! { ! mSolidGarbageList.push_back(mSolidList[i]); ! } ! for (i=0; i<mJointList.size(); ++i) ! { ! mJointGarbageList.push_back(mJointList[i]); ! } ! for (i=0; i<mMotorList.size(); ++i) ! { ! mMotorGarbageList.push_back(mMotorList[i]); ! } ! for (i=0; i<mSensorList.size(); ++i) ! { ! mSensorGarbageList.push_back(mSensorList[i]); ! } ! collectGarbage(); while (!mSpaceList.empty()) --- 39,84 ---- mTimeBuffer = 0; setStepSize(defaults::stepSize); setMaxLinearVel(defaults::maxLinearVel); setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); + + int i=0; + for (i=0; i<32; ++i) + { + mContactGroupFlags[i] = defaults::contactGroupFlags; + } } Simulator::~Simulator() { ! //// Mark everything as garbage, then collect the garbage. ! //size_t i; ! //for (i=0; i<mSolidList.size(); ++i) ! //{ ! // mSolidGarbageList.push_back(mSolidList[i]); ! //} ! //for (i=0; i<mJointList.size(); ++i) ! //{ ! // mJointGarbageList.push_back(mJointList[i]); ! //} ! //for (i=0; i<mMotorList.size(); ++i) ! //{ ! // mMotorGarbageList.push_back(mMotorList[i]); ! //} ! //for (i=0; i<mSensorList.size(); ++i) ! //{ ! // mSensorGarbageList.push_back(mSensorList[i]); ! //} ! //collectGarbage(); ! ! destroyAllSolids(); ! destroyAllJoints(); ! destroyAllMotors(); ! destroyAllSensors(); while (!mSpaceList.empty()) *************** *** 130,135 **** jointIter != mJointList.end(); ++jointIter) { ! // If the Joint gets broken here, it will automatically ! // send a Joint break event. (*jointIter)->internal_update(); } --- 138,144 ---- jointIter != mJointList.end(); ++jointIter) { ! // If a Joint gets broken here, it will automatically ! // send a Joint break event to the Joint's ! // JointBreakEventHandler (assuming one exists). (*jointIter)->internal_update(); } *************** *** 139,143 **** internal_stepPhysics(); ! // Loop over Solids again. for (solidIter = mSolidList.begin(); solidIter != mSolidList.end(); ++solidIter) --- 148,152 ---- internal_stepPhysics(); ! // Loop over Solids again to handle a few more things... for (solidIter = mSolidList.begin(); solidIter != mSolidList.end(); ++solidIter) *************** *** 194,202 **** // Update the sleeping value from the physics engine. This ! // needs to be updated to keep the Solid's SolidDate valid. solid->internal_updateSleeping(); ! //// Update accelerations ! //solid->internal_updateAcceleration(dt); } --- 203,215 ---- // Update the sleeping value from the physics engine. This ! // needs to be updated to keep the Solid's SolidData valid. solid->internal_updateSleeping(); ! // Update the Solid's CollisionEventHandler if applicable. ! if (solid->getEventHandler()) ! { ! solid->getEventHandler()-> ! internal_handlePendingCollisionEvents(); ! } } *************** *** 205,210 **** } ! // Deallocate memory here now that it's safe. ! collectGarbage(); return stepOccurred; --- 218,223 ---- } ! //// Deallocate memory here now that it's safe. ! //collectGarbage(); return stepOccurred; *************** *** 549,554 **** --- 562,584 ---- unsigned int group1, bool makeContacts) { + if (group0 > 31) + { + OPAL_LOGGER("warning") << "opal::Simulator::setupContactGroups: " + << "Invalid contact group " << group0 + << ". Request will be ignored." << std::endl; + return; + } + + if (group1 > 31) + { + OPAL_LOGGER("warning") << "opal::Simulator::setupContactGroups: " + << "Invalid contact group " << group1 + << ". Request will be ignored." << std::endl; + return; + } + // The interaction always goes both ways, so we need to set the bit // flags both ways. + unsigned long int group0Bit = 1 << group0; unsigned long int group1Bit = 1 << group1; *************** *** 556,580 **** if (makeContacts) { ! //m } else { } } void Simulator::destroySolid(Solid* s) { ! mSolidGarbageList.push_back(s); } void Simulator::destroyAllSolids() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mSolidList.size(); ++i) { ! mSolidGarbageList.push_back(mSolidList[i]); } } --- 586,627 ---- if (makeContacts) { ! // Raise the group1 bit in group0's array. ! mContactGroupFlags[group0] |= group1Bit; ! ! // Raise the group0 bit in group1's array. ! mContactGroupFlags[group1] |= group0Bit; } else { + unsigned long int tempMask = 0xFFFFFFFF; + unsigned long int notGroup0Bit = group0 ^ tempMask; + unsigned long int notGroup1Bit = group1 ^ tempMask; + + // Lower the group1 bit in group0's array. + mContactGroupFlags[group0] &= notGroup1Bit; + // Lower the group0 bit in group1's array. + mContactGroupFlags[group1] &= notGroup0Bit; } } + unsigned long int Simulator::internal_getContactGroupFlags( + unsigned int groupNum)const + { + return mContactGroupFlags[groupNum]; + } + void Simulator::destroySolid(Solid* s) { ! //mSolidGarbageList.push_back(s); ! removeSolid(s); } void Simulator::destroyAllSolids() { for (size_t i=0; i<mSolidList.size(); ++i) { ! //mSolidGarbageList.push_back(mSolidList[i]); ! removeSolid(mSolidList[i]); } } *************** *** 587,591 **** void Simulator::destroyJoint(Joint* j) { ! mJointGarbageList.push_back(j); } --- 634,639 ---- void Simulator::destroyJoint(Joint* j) { ! //mJointGarbageList.push_back(j); ! removeJoint(j); } *************** *** 597,601 **** for (size_t i=0; i<mJointList.size(); ++i) { ! mJointGarbageList.push_back(mJointList[i]); } } --- 645,650 ---- for (size_t i=0; i<mJointList.size(); ++i) { ! //mJointGarbageList.push_back(mJointList[i]); ! removeJoint(mJointList[i]); } } *************** *** 644,648 **** void Simulator::destroyMotor(Motor* m) { ! mMotorGarbageList.push_back(m); } --- 693,698 ---- void Simulator::destroyMotor(Motor* m) { ! //mMotorGarbageList.push_back(m); ! removeMotor(m); } *************** *** 654,658 **** for (size_t i=0; i<mMotorList.size(); ++i) { ! mMotorGarbageList.push_back(mMotorList[i]); } } --- 704,709 ---- for (size_t i=0; i<mMotorList.size(); ++i) { ! //mMotorGarbageList.push_back(mMotorList[i]); ! removeMotor(mMotorList[i]); } } *************** *** 670,674 **** void Simulator::destroySensor(Sensor* s) { ! mSensorGarbageList.push_back(s); } --- 721,726 ---- void Simulator::destroySensor(Sensor* s) { ! //mSensorGarbageList.push_back(s); ! removeSensor(s); } *************** *** 680,684 **** for (size_t i=0; i<mSensorList.size(); ++i) { ! mSensorGarbageList.push_back(mSensorList[i]); } } --- 732,737 ---- for (size_t i=0; i<mSensorList.size(); ++i) { ! //mSensorGarbageList.push_back(mSensorList[i]); ! removeSensor(mSensorList[i]); } } *************** *** 712,718 **** void Simulator::removeSolid(Solid* s) { ! // TODO: make this more efficient by not iterating through all Motors ! // and Joints; maybe have the Solid maintain pointers to things that ! // depend on it. // Disable Motors that depend on the given Solid. --- 765,771 ---- void Simulator::removeSolid(Solid* s) { ! // TODO: make this more efficient by not iterating through all Motors, ! // Sensors, and Joints; maybe have the Solid maintain pointers to ! // things that depend on it. // Disable Motors that depend on the given Solid. *************** *** 767,772 **** void Simulator::removeJoint(Joint* j) { ! // TODO: make this more efficient by not iterating through all Motors ! // and Joints; maybe have the Solid maintain pointers to things that // depend on it. --- 820,825 ---- void Simulator::removeJoint(Joint* j) { ! // TODO: make this more efficient by not iterating through all Motors; ! // maybe have the Solid maintain pointers to things that // depend on it. *************** *** 844,871 **** } ! void Simulator::collectGarbage() ! { ! size_t i; ! for (i=0; i<mSolidGarbageList.size(); ++i) ! { ! removeSolid(mSolidGarbageList[i]); ! } ! mSolidGarbageList.clear(); ! for (i=0; i<mJointGarb... [truncated message content] |