[Opal-commits] opal/src Defines.h,1.73,1.74 Matrix44r.h,1.30,1.31 OpalMath.h,1.9,1.10 Point3r.h,1.11
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-04-12 06:46:54
|
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4177/src Modified Files: Defines.h Matrix44r.h OpalMath.h Point3r.h Quaternion.h Rayr.h Simulator.cpp Simulator.h Solid.h SpringMotor.cpp Vec3r.h Log Message: added a rotational stability fix for ODESolids Index: Vec3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Vec3r.h 30 Mar 2005 23:26:23 -0000 1.14 --- Vec3r.h 12 Apr 2005 06:46:44 -0000 1.15 *************** *** 62,65 **** --- 62,68 ---- inline bool areCollinear(const Vec3r& u, const Vec3r& v); + /// Basic printing helper function. + inline std::ostream& operator<<(std::ostream& o, const Vec3r& v); + class Vec3r { *************** *** 122,125 **** --- 125,129 ---- inline real & operator[](unsigned int i) { + assert(i < 3); return mData[i]; } *************** *** 127,130 **** --- 131,135 ---- inline const real & operator[](unsigned int i)const { + assert(i < 3); return mData[i]; } *************** *** 296,300 **** { real value = 1 - dot(u, v); ! if (fabs(value) < globals::OPAL_EPSILON) { return true; --- 301,305 ---- { real value = 1 - dot(u, v); ! if (opal::abs(value) < globals::OPAL_EPSILON) { return true; *************** *** 305,308 **** --- 310,318 ---- } } + + inline std::ostream& operator<<(std::ostream& o, const Vec3r& v) + { + return o << "[" << v[0] << " " << v[1] << " " << v[2] << "]"; + } } Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** Simulator.cpp 9 Apr 2005 06:23:58 -0000 1.58 --- Simulator.cpp 12 Apr 2005 06:46:43 -0000 1.59 *************** *** 49,54 **** mTimeBuffer = 0; setStepSize(defaults::stepSize); ! setMaxLinearVel(defaults::maxLinearVel); ! setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); setPostStepEventHandler(NULL); --- 49,54 ---- mTimeBuffer = 0; setStepSize(defaults::stepSize); ! //setMaxLinearVel(defaults::maxLinearVel); ! //setMaxAngularVel(defaults::maxAngularVel); setUserData(NULL); setPostStepEventHandler(NULL); *************** *** 121,179 **** 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(); ! } ! } } --- 121,125 ---- solidIter != mSolidList.end(); ++solidIter) { ! (*solidIter)->internal_applyForces(mStepSize); } *************** *** 193,197 **** // Now do physics engine-specific stuff; collision events will // be sent from here. ! internal_stepPhysics(); // Loop over Solids again to handle a few more things... --- 139,143 ---- // Now do physics engine-specific stuff; collision events will // be sent from here. ! stepPhysics(); // Loop over Solids again to handle a few more things... *************** *** 278,286 **** bool useScale = false; ! Matrix44r scaleMat; if (1 != scale) { useScale = true; ! scaleMat.makeScale(scale); } --- 224,232 ---- bool useScale = false; ! //Matrix44r scaleMat; if (1 != scale) { useScale = true; ! //scaleMat.makeScale(scale); } *************** *** 596,620 **** } ! void Simulator::setMaxLinearVel(real max) ! { ! assert(max >= 0.0); ! mMaxLinearVel = max; ! } ! real Simulator::getMaxLinearVel()const ! { ! return mMaxLinearVel; ! } ! void Simulator::setMaxAngularVel(real max) ! { ! assert(max >= 0.0); ! mMaxAngularVel = max; ! } ! real Simulator::getMaxAngularVel()const ! { ! return mMaxAngularVel; ! } //void Simulator::setDefaultLinearDamping(real ld) --- 542,566 ---- } ! //void Simulator::setMaxLinearVel(real max) ! //{ ! // assert(max >= 0.0); ! // mMaxLinearVel = max; ! //} ! //real Simulator::getMaxLinearVel()const ! //{ ! // return mMaxLinearVel; ! //} ! //void Simulator::setMaxAngularVel(real max) ! //{ ! // assert(max >= 0.0); ! // mMaxAngularVel = max; ! //} ! //real Simulator::getMaxAngularVel()const ! //{ ! // return mMaxAngularVel; ! //} //void Simulator::setDefaultLinearDamping(real ld) Index: Simulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.h,v retrieving revision 1.96 retrieving revision 1.97 diff -C2 -d -r1.96 -r1.97 *** Simulator.h 9 Apr 2005 06:23:58 -0000 1.96 --- Simulator.h 12 Apr 2005 06:46:43 -0000 1.97 *************** *** 133,149 **** /// Sets the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual void OPAL_CALL setMaxLinearVel(real max); /// Returns the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual real OPAL_CALL getMaxLinearVel()const; /// Sets the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual void OPAL_CALL setMaxAngularVel(real max); /// Returns the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! virtual real OPAL_CALL getMaxAngularVel()const; /// Set the user data pointer to some external data. The user data --- 133,149 ---- /// Sets the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual void OPAL_CALL setMaxLinearVel(real max); /// Returns the maximum linear velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual real OPAL_CALL getMaxLinearVel()const; /// Sets the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual void OPAL_CALL setMaxAngularVel(real max); /// Returns the maximum angular velocity for any Solid. This limits /// Solid motion to prevent explosions from numerical innacuracy. ! //virtual real OPAL_CALL getMaxAngularVel()const; /// Set the user data pointer to some external data. The user data *************** *** 278,286 **** virtual Space* OPAL_CALL createSpace() = 0; - /// This function is physics engine-specific. It handles collision - /// detection and steps the simulation ahead by a constant step - /// size. - virtual void OPAL_CALL internal_stepPhysics() = 0; - /// Helper function used for ray casting. Immediately fires a ray /// into the scene and returns intersections results. Uses the --- 278,281 ---- *************** *** 300,303 **** --- 295,303 ---- virtual ~Simulator(); + /// This function is physics engine-specific. It handles collision + /// detection and steps the simulation ahead by a constant step + /// size. + virtual void stepPhysics() = 0; + /// Adds a Solid to the internal list of Solids. void addSolid(Solid* s); *************** *** 350,358 **** /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! real mMaxLinearVel; /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! real mMaxAngularVel; /// An internal list of all Solids. --- 350,358 ---- /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! //real mMaxLinearVel; /// A limit on Solid motion to protect against simulation explosions /// due to numerical inaccuracy. ! //real mMaxAngularVel; /// An internal list of all Solids. Index: OpalMath.h =================================================================== RCS file: /cvsroot/opal/opal/src/OpalMath.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** OpalMath.h 29 Mar 2005 03:05:46 -0000 1.9 --- OpalMath.h 12 Apr 2005 06:46:43 -0000 1.10 *************** *** 54,57 **** --- 54,62 ---- return (r2d * rad); } + + inline real abs(real value) + { + return fabs(value); + } } Index: Defines.h =================================================================== RCS file: /cvsroot/opal/opal/src/Defines.h,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** Defines.h 9 Apr 2005 06:23:58 -0000 1.73 --- Defines.h 12 Apr 2005 06:46:43 -0000 1.74 *************** *** 281,286 **** //const bool allowPartialFrames=true; //const int maxStepsPerFrame=10; ! const real maxLinearVel = (real)10000.0; ! const real maxAngularVel = (real)1000.0; const bool staticSleepingContactsEnabled = false; --- 281,286 ---- //const bool allowPartialFrames=true; //const int maxStepsPerFrame=10; ! //const real maxLinearVel = (real)10000.0; ! //const real maxAngularVel = (real)1000.0; const bool staticSleepingContactsEnabled = false; *************** *** 308,313 **** const real capsuleLength = 1; const real planeABCD[4] = {0, 1, 0, 0}; - //const Point3r rayOrigin = Point3r(0, 0, 0); - //const Vec3r rayDir = Vec3r(0, 0, -1); } --- 308,311 ---- Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** Solid.h 6 Apr 2005 04:48:44 -0000 1.87 --- Solid.h 12 Apr 2005 06:46:44 -0000 1.88 *************** *** 247,250 **** --- 247,251 ---- void* mUserData; + /// Data used for private: }; Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Quaternion.h 7 Feb 2005 02:08:22 -0000 1.7 --- Quaternion.h 12 Apr 2005 06:46:43 -0000 1.8 *************** *** 38,41 **** --- 38,42 ---- inline Quaternion operator*(const Quaternion& q, real scalar); inline Quaternion operator*(real scalar, const Quaternion& q); + inline std::ostream& operator<<(std::ostream& o, const Point3r& p); class Quaternion *************** *** 139,142 **** --- 140,144 ---- inline real & operator[](unsigned int i) { + assert(i < 4); return mData[i]; } *************** *** 144,147 **** --- 146,150 ---- inline const real & operator[](unsigned int i)const { + assert(i < 4); return mData[i]; } *************** *** 171,174 **** --- 174,183 ---- scalar * q[3]); } + + inline std::ostream& operator<<(std::ostream& o, const Quaternion& q) + { + return o << "[" << q[0] << " " << q[1] << " " << q[2] << " " + << q[3] << "]"; + } } Index: SpringMotor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/SpringMotor.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** SpringMotor.cpp 4 Apr 2005 13:09:12 -0000 1.13 --- SpringMotor.cpp 12 Apr 2005 06:46:44 -0000 1.14 *************** *** 197,202 **** // Convert the global point to a local point offset from the Solid's // transform. ! Matrix44r inv; ! fastInverse(inv, mData.solid->getTransform()); mData.attachOffset = inv * p; } --- 197,202 ---- // Convert the global point to a local point offset from the Solid's // transform. ! Matrix44r inv = mData.solid->getTransform(); ! inv.fastInvert(); mData.attachOffset = inv * p; } Index: Point3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Point3r.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Point3r.h 7 Feb 2005 02:08:22 -0000 1.11 --- Point3r.h 12 Apr 2005 06:46:43 -0000 1.12 *************** *** 94,97 **** --- 94,98 ---- inline real & operator[](unsigned int i) { + assert(i < 3); return mData[i]; } *************** *** 99,102 **** --- 100,104 ---- inline const real & operator[](unsigned int i)const { + assert(i < 3); return mData[i]; } *************** *** 183,186 **** --- 185,193 ---- return p * -1; } + + inline std::ostream& operator<<(std::ostream& o, const Point3r& p) + { + return o << "[" << p[0] << " " << p[1] << " " << p[2] << "]"; + } } Index: Rayr.h =================================================================== RCS file: /cvsroot/opal/opal/src/Rayr.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Rayr.h 22 Feb 2005 04:28:11 -0000 1.6 --- Rayr.h 12 Apr 2005 06:46:43 -0000 1.7 *************** *** 33,36 **** --- 33,39 ---- namespace opal { + class Rayr; + inline std::ostream& operator<<(std::ostream& o, const Rayr& r); + class Rayr { *************** *** 101,104 **** --- 104,116 ---- } }; + + inline std::ostream& operator<<(std::ostream& o, const Rayr& r) + { + Point3r origin = r.getOrigin(); + Vec3r dir = r.getDir(); + return o << "Origin: [" << origin[0] << " " << origin[1] << " " + << origin[2] << "] Direction: [" << dir[0] << " " << dir[1] + << " " << dir[2] << "]"; + } } Index: Matrix44r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Matrix44r.h,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Matrix44r.h 29 Mar 2005 03:05:46 -0000 1.30 --- Matrix44r.h 12 Apr 2005 06:46:43 -0000 1.31 *************** *** 48,51 **** --- 48,52 ---- inline bool inverse(Matrix44r & dest, const Matrix44r & src); inline void fastInverse(Matrix44r & dest, const Matrix44r & src); + inline std::ostream& operator<<(std::ostream& o, const Matrix44r& m); class Matrix44r *************** *** 514,518 **** fastInverse for affine transforms" << std::endl; real det = src.determinant(); ! if(abs(det < globals::OPAL_EPSILON)) return false; dest = ((real)1.0 / det) * src; return true; --- 515,519 ---- fastInverse for affine transforms" << std::endl; real det = src.determinant(); ! if(opal::abs(det < globals::OPAL_EPSILON)) return false; dest = ((real)1.0 / det) * src; return true; *************** *** 542,549 **** result(2, 2)).lengthSquared(); ! // TODO: write opal::abs. ! if(fabs(l0) > globals::OPAL_EPSILON) l0 = 1.0f / l0; ! if(fabs(l1) > globals::OPAL_EPSILON) l1 = 1.0f / l1; ! if(fabs(l2) > globals::OPAL_EPSILON) l2 = 1.0f / l2; // apply the inverse scale to the 3x3 --- 543,549 ---- result(2, 2)).lengthSquared(); ! if(opal::abs(l0) > globals::OPAL_EPSILON) l0 = 1.0f / l0; ! if(opal::abs(l1) > globals::OPAL_EPSILON) l1 = 1.0f / l1; ! if(opal::abs(l2) > globals::OPAL_EPSILON) l2 = 1.0f / l2; // apply the inverse scale to the 3x3 *************** *** 570,574 **** // invert scale. ! const real tw = (fabs(src(3, 3)) > globals::OPAL_EPSILON) ? 1.0f / src(3, 3) : 0.0f; --- 570,574 ---- // invert scale. ! const real tw = (opal::abs(src(3, 3)) > globals::OPAL_EPSILON) ? 1.0f / src(3, 3) : 0.0f; *************** *** 653,656 **** --- 653,669 ---- return ray; } + + inline std::ostream& operator<<(std::ostream& o, const Matrix44r& m) + { + return o + << "[" << m[0] << " " << m[1] << " " << m[2] << " " << m[3] + << "]" << std::endl + << "[" << m[4] << " " << m[5] << " " << m[6] << " " << m[7] + << "]" << std::endl + << "[" << m[8] << " " << m[9] << " " << m[10] << " " << m[11] + << "]" << std::endl + << "[" << m[12] << " " << m[13] << " " << m[14] << " " << m[15] + << "]"; + } } |