[Opal-commits] opal/src Defines.h,1.71,1.72 JointData.h,1.7,1.8 Simulator.cpp,1.55,1.56 Simulator.h,
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-06 04:48:53
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1764/src Modified Files: Defines.h JointData.h Simulator.cpp Simulator.h Solid.h Log Message: minor changes; added stuff to sample app Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** Simulator.cpp 31 Mar 2005 08:47:02 -0000 1.55 --- Simulator.cpp 6 Apr 2005 04:48:44 -0000 1.56 *************** *** 63,91 **** 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(); --- 63,66 ---- *************** *** 139,143 **** solidIter != mSolidList.end(); ++solidIter) { ! (*solidIter)->internal_applyForces(mStepSize); } --- 114,172 ---- solidIter != mSolidList.end(); ++solidIter) { ! Solid* solid = *solidIter; ! ! solid->internal_applyForces(mStepSize); ! ! // Limit velocities and forces of moving Solids to ! // limit numerical inaccuracy from explicit integration ! // (mostly from quickly-spinning long, thin objects). ! if (!solid->isSleeping() && !solid->isStatic()) ! { ! bool velChanged = false; ! Vec3r linearVel = solid->getGlobalLinearVel(); ! if (linearVel[0] > mMaxLinearVel) ! { ! linearVel[0] = mMaxLinearVel; ! velChanged = true; ! } ! if (linearVel[1] > mMaxLinearVel) ! { ! linearVel[1] = mMaxLinearVel; ! velChanged = true; ! } ! if (linearVel[2] > mMaxLinearVel) ! { ! linearVel[2] = mMaxLinearVel; ! velChanged = true; ! } ! if (velChanged) ! { ! solid->setGlobalLinearVel(linearVel); ! solid->zeroForces(); ! } ! ! velChanged = false; ! Vec3r angularVel = solid->getGlobalAngularVel(); ! if (angularVel[0] > mMaxAngularVel) ! { ! angularVel[0] = mMaxAngularVel; ! velChanged = true; ! } ! if (angularVel[1] > mMaxAngularVel) ! { ! angularVel[1] = mMaxAngularVel; ! velChanged = true; ! } ! if (angularVel[2] > mMaxAngularVel) ! { ! angularVel[2] = mMaxAngularVel; ! velChanged = true; ! } ! if (velChanged) ! { ! solid->setGlobalAngularVel(angularVel); ! solid->zeroForces(); ! } ! } } *************** *** 163,211 **** Solid* solid = *solidIter; - // Cap velocities. - bool velChanged = false; - Vec3r linearVel = solid->getGlobalLinearVel(); - if (linearVel[0] > mMaxLinearVel) - { - linearVel[0] = mMaxLinearVel; - velChanged = true; - } - if (linearVel[1] > mMaxLinearVel) - { - linearVel[1] = mMaxLinearVel; - velChanged = true; - } - if (linearVel[2] > mMaxLinearVel) - { - linearVel[2] = mMaxLinearVel; - velChanged = true; - } - if (velChanged) - { - solid->setGlobalLinearVel(linearVel); - } - - velChanged = false; - Vec3r angularVel = solid->getGlobalAngularVel(); - if (angularVel[0] > mMaxAngularVel) - { - angularVel[0] = mMaxAngularVel; - velChanged = true; - } - if (angularVel[1] > mMaxAngularVel) - { - angularVel[1] = mMaxAngularVel; - velChanged = true; - } - if (angularVel[2] > mMaxAngularVel) - { - angularVel[2] = mMaxAngularVel; - velChanged = true; - } - if (velChanged) - { - solid->setGlobalAngularVel(angularVel); - } - // Get each Solid's new transform from the physics engine. solid->internal_updateOPALTransform(); --- 192,195 ---- *************** *** 233,239 **** } - //// Deallocate memory here now that it's safe. - //collectGarbage(); - return stepOccurred; } --- 217,220 ---- *************** *** 770,774 **** void Simulator::destroySolid(Solid* s) { - //mSolidGarbageList.push_back(s); removeSolid(s); } --- 751,754 ---- *************** *** 778,782 **** for (size_t i=0; i<mSolidList.size(); ++i) { - //mSolidGarbageList.push_back(mSolidList[i]); removeSolid(mSolidList[i]); } --- 758,761 ---- *************** *** 785,789 **** void Simulator::destroyJoint(Joint* j) { - //mJointGarbageList.push_back(j); removeJoint(j); } --- 764,767 ---- *************** *** 791,800 **** void Simulator::destroyAllJoints() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mJointList.size(); ++i) { - //mJointGarbageList.push_back(mJointList[i]); removeJoint(mJointList[i]); } --- 769,774 ---- *************** *** 844,848 **** void Simulator::destroyMotor(Motor* m) { - //mMotorGarbageList.push_back(m); removeMotor(m); } --- 818,821 ---- *************** *** 850,859 **** void Simulator::destroyAllMotors() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mMotorList.size(); ++i) { - //mMotorGarbageList.push_back(mMotorList[i]); removeMotor(mMotorList[i]); } --- 823,828 ---- *************** *** 890,894 **** void Simulator::destroySensor(Sensor* s) { - //mSensorGarbageList.push_back(s); removeSensor(s); } --- 859,862 ---- *************** *** 896,920 **** void Simulator::destroyAllSensors() { - // Just mark everything as garbage; it'll get destroyed at the end of - // the current step. - for (size_t i=0; i<mSensorList.size(); ++i) { - //mSensorGarbageList.push_back(mSensorList[i]); removeSensor(mSensorList[i]); } } - //void Simulator::setDefaultSleepiness(real value) - //{ - // assert(value >= 0.0 && value <= 1.0); - // mDefaultSleepiness = value; - //} - - //real Simulator::getDefaultSleepiness()const - //{ - // return mDefaultSleepiness; - //} - void Simulator::setSolverAccuracy(SolverAccuracyLevel level) { --- 864,873 ---- *************** *** 1065,1100 **** mSpaceList.push_back(s); } - - //void Simulator::collectGarbage() - //{ - // size_t i; - - // for (i=0; i<mSolidGarbageList.size(); ++i) - // { - // removeSolid(mSolidGarbageList[i]); - // } - - // mSolidGarbageList.clear(); - - // for (i=0; i<mJointGarbageList.size(); ++i) - // { - // removeJoint(mJointGarbageList[i]); - // } - - // mJointGarbageList.clear(); - - // for (i=0; i<mMotorGarbageList.size(); ++i) - // { - // removeMotor(mMotorGarbageList[i]); - // } - - // mMotorGarbageList.clear(); - - // for (i=0; i<mSensorGarbageList.size(); ++i) - // { - // removeSensor(mSensorGarbageList[i]); - // } - - // mSensorGarbageList.clear(); - //} } --- 1018,1020 ---- Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** Defines.h 31 Mar 2005 08:47:02 -0000 1.71 --- Defines.h 6 Apr 2005 04:48:44 -0000 1.72 *************** *** 132,139 **** Material(real h, real f, real b, real d) { ! assert(h >= 0.0 && h <= 1.0); ! assert(f >= 0.0 && f <= 1.0); ! assert(b >= 0.0 && b <= 1.0); ! assert(d >= 0.0); hardness = h; --- 132,139 ---- Material(real h, real f, real b, real d) { ! //assert(h >= 0.0 && h <= 1.0); ! //assert(f >= 0.0 && f <= 1.0); ! //assert(b >= 0.0 && b <= 1.0); ! //assert(d >= 0.0); hardness = h; *************** *** 151,158 **** } ! /// Determines how far Solids can interpenetrate. real hardness; ! /// Simple friction constant. real friction; --- 151,159 ---- } ! /// Determines how far Solids can interpenetrate. This must ! /// be between 0 and 1. real hardness; ! /// Simple friction constant. This must be between 0 and 1. real friction; *************** *** 161,169 **** /// words, the more bounciness, the farther the Solids will bounce /// when they collide (and, in real life, the less energy is lost ! /// due to heat and sound). real bounciness; /// Density combined with the volume of a Solid's shapes determine ! /// the Solid's mass. real density; }; --- 162,170 ---- /// words, the more bounciness, the farther the Solids will bounce /// when they collide (and, in real life, the less energy is lost ! /// due to heat and sound). This must be between 0 and 1. real bounciness; /// Density combined with the volume of a Solid's shapes determine ! /// the Solid's mass. This must be >= 0. real density; }; Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.86 retrieving revision 1.87 diff -C2 -d -r1.86 -r1.87 *** Solid.h 4 Apr 2005 13:09:11 -0000 1.86 --- Solid.h 6 Apr 2005 04:48:44 -0000 1.87 *************** *** 151,154 **** --- 151,157 ---- virtual void OPAL_CALL addForce(const Force& f); + /// Removes all forces and torques currently affecting this Solid. + virtual void OPAL_CALL zeroForces() = 0; + /// Sets the Solid's linear velocity in local coordinates. virtual void OPAL_CALL setLocalLinearVel(const Vec3r& vel) = 0; Index: JointData.h =================================================================== RCS file: /cvsroot/opal/opal/src/JointData.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JointData.h 28 Mar 2005 22:33:07 -0000 1.7 --- JointData.h 6 Apr 2005 04:48:44 -0000 1.8 *************** *** 50,54 **** real high; ! /// Determines how far a Joint can exceed its limits. real hardness; --- 50,55 ---- real high; ! /// Determines how far a Joint can exceed its limits. This must ! /// be between 0 and 1. real hardness; Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** Simulator.h 31 Mar 2005 08:47:02 -0000 1.93 --- Simulator.h 6 Apr 2005 04:48:44 -0000 1.94 *************** *** 273,279 **** virtual ~Simulator(); - ///// Destroys all objects in the Simulator marked as garbage. - //void collectGarbage(); - /// Adds a Solid to the internal list of Solids. void addSolid(Solid* s); --- 273,276 ---- *************** *** 340,355 **** 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; /// they get destroyed when the Simulator is destroyed. --- 337,340 ---- |