[Opal-commits] opal/src Space.cpp,NONE,1.1 Blueprint.cpp,1.22,1.23 BlueprintManager.cpp,1.39,1.40 Bl
Status: Inactive
Brought to you by:
tylerstreeter
Update of /cvsroot/opal/opal/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32731/src Modified Files: Blueprint.cpp BlueprintManager.cpp BlueprintManager.h Joint.cpp Joint.h Logger.cpp Matrix44r.h Motor.cpp Motor.h OpalMath.h Point3r.h Portability.h Quaternion.h Rayr.h SConscript Sensor.cpp Sensor.h Simulator.cpp Solid.cpp Solid.h Space.h Vec3r.h opal.h Added Files: Space.cpp Log Message: made destructor protected for objects instantiated by OPAL; cleaned up a lot of things to prepare for 0.3.0 release Index: BlueprintManager.h =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** BlueprintManager.h 23 Mar 2005 07:54:34 -0000 1.19 --- BlueprintManager.h 18 Apr 2005 22:21:03 -0000 1.20 *************** *** 43,46 **** --- 43,47 ---- class ThrusterMotorData; class AccelerationSensorData; + class InclineSensorData; class RaycastSensorData; class VolumeSensorData; *************** *** 140,143 **** --- 141,150 ---- const std::string& filename); + /// Helper function for parsing InclineSensor XML elements. + /// Allocates and returns a pointer to a new InclineSensorData + /// object. Returns NULL if the element could not be loaded. + InclineSensorData* loadInclineSensor(const TiXmlNode* nodePtr, + const Blueprint& bp, const std::string& filename); + /// Helper function for parsing RaycastSensor XML elements. /// Allocates and returns a pointer to a new RaycastSensorData Index: Motor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Motor.h,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Motor.h 30 Mar 2005 23:26:22 -0000 1.39 --- Motor.h 18 Apr 2005 22:21:03 -0000 1.40 *************** *** 50,55 **** Motor(); - virtual ~Motor(); - /// Sets whether the Motor has any effect. virtual void OPAL_CALL setEnabled(bool e) = 0; --- 50,53 ---- *************** *** 92,96 **** --- 90,99 ---- //virtual bool OPAL_CALL internal_isCustom(); + /// Internal function used to destroy this object. + virtual void OPAL_CALL internal_destroy(); + protected: + virtual ~Motor(); + /// Called by subclasses when they are initialized. void init(); Index: Blueprint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Blueprint.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** Blueprint.cpp 31 Mar 2005 08:47:02 -0000 1.22 --- Blueprint.cpp 18 Apr 2005 22:21:02 -0000 1.23 *************** *** 357,360 **** --- 357,366 ---- break; } + case INCLINE_SENSOR: + { + newData = + new InclineSensorData(*((InclineSensorData*)data)); + break; + } case RAYCAST_SENSOR: { Index: Space.h =================================================================== RCS file: /cvsroot/opal/opal/src/Space.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Space.h 18 Feb 2005 23:59:37 -0000 1.9 --- Space.h 18 Apr 2005 22:21:04 -0000 1.10 *************** *** 40,48 **** { public: ! Space() ! {} ! ! virtual ~Space() ! {} /// Removes the Space from its current parent Space and adds it to --- 40,44 ---- { public: ! Space(); /// Removes the Space from its current parent Space and adds it to *************** *** 50,54 **** --- 46,54 ---- virtual void OPAL_CALL setParentSpace(Space* parentSpace) = 0; + /// Internal function used to destroy this object. + virtual void OPAL_CALL internal_destroy(); + protected: + virtual ~Space(); private: Index: OpalMath.h =================================================================== RCS file: /cvsroot/opal/opal/src/OpalMath.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** OpalMath.h 12 Apr 2005 06:46:43 -0000 1.10 --- OpalMath.h 18 Apr 2005 22:21:03 -0000 1.11 *************** *** 43,46 **** --- 43,47 ---- } + /// Converts a value from degrees to radians. inline real degToRad(real deg) { *************** *** 49,52 **** --- 50,54 ---- } + /// Converts a value from radians to degrees. inline real radToDeg(real rad) { *************** *** 55,58 **** --- 57,61 ---- } + /// Returns the absolute value of a real number. inline real abs(real value) { --- NEW FILE: Space.cpp --- /************************************************************************* * * * 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. * * * *************************************************************************/ #include "Space.h" namespace opal { Space::Space() { } Space::~Space() { } void Space::internal_destroy() { delete this; } } Index: Simulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Simulator.cpp,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** Simulator.cpp 15 Apr 2005 08:50:42 -0000 1.62 --- Simulator.cpp 18 Apr 2005 22:21:03 -0000 1.63 *************** *** 76,80 **** while (!mSpaceList.empty()) { ! delete mSpaceList.back(); mSpaceList.pop_back(); } --- 76,80 ---- while (!mSpaceList.empty()) { ! mSpaceList.back()->internal_destroy(); mSpaceList.pop_back(); } *************** *** 510,513 **** --- 510,524 ---- break; } + case INCLINE_SENSOR: + { + // Make a local copy of the Sensor's data. + InclineSensorData data = *(InclineSensorData*)sensorData; + data.solid = solidPtr; + data.transform = transform; + + s = createInclineSensor(); + ((InclineSensor*)s)->init(data); + break; + } case RAYCAST_SENSOR: { *************** *** 934,938 **** if(mSolidList[i] == s) { ! delete s; mSolidList[i] = mSolidList.back(); mSolidList.pop_back(); --- 945,949 ---- if(mSolidList[i] == s) { ! s->internal_destroy(); mSolidList[i] = mSolidList.back(); mSolidList.pop_back(); *************** *** 969,973 **** if(mJointList[i] == j) { ! delete j; mJointList[i] = mJointList.back(); mJointList.pop_back(); --- 980,984 ---- if(mJointList[i] == j) { ! j->internal_destroy(); mJointList[i] = mJointList.back(); mJointList.pop_back(); *************** *** 993,997 **** // delete m; //} ! delete m; mMotorList[i] = mMotorList.back(); mMotorList.pop_back(); --- 1004,1008 ---- // delete m; //} ! m->internal_destroy(); mMotorList[i] = mMotorList.back(); mMotorList.pop_back(); *************** *** 1013,1017 **** if(mSensorList[i] == s) { ! delete s; mSensorList[i] = mSensorList.back(); mSensorList.pop_back(); --- 1024,1028 ---- if(mSensorList[i] == s) { ! s->internal_destroy(); mSensorList[i] = mSensorList.back(); mSensorList.pop_back(); Index: BlueprintManager.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/BlueprintManager.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** BlueprintManager.cpp 29 Mar 2005 03:05:46 -0000 1.39 --- BlueprintManager.cpp 18 Apr 2005 22:21:03 -0000 1.40 *************** *** 49,53 **** namespace opal { ! OPAL_EXPORT void OPAL_CALL loadFile(Blueprint& bp, const std::string& filename) { --- 49,53 ---- namespace opal { ! OPAL_EXPORT_FUNCTION(void) loadFile(Blueprint& bp, const std::string& filename) { *************** *** 1218,1221 **** --- 1218,1225 ---- data = loadAccelerationSensor(nodePtr, bp, filename); } + else if ("incline" == type) + { + data = loadInclineSensor(nodePtr, bp, filename); + } else if ("raycast" == type) { *************** *** 1306,1309 **** --- 1310,1341 ---- } + InclineSensorData* BlueprintManager::loadInclineSensor( + const TiXmlNode* nodePtr, const Blueprint& bp, + const std::string& filename) + { + // This data structure automatically gets initialized to + // default values in its constructor. + InclineSensorData* data = new InclineSensorData(); + + #ifdef OPAL_USE_XML + + TiXmlNode* paramNodePtr = NULL; + + // Load Ray element if it exists. + paramNodePtr = + const_cast<TiXmlNode*>(nodePtr)->FirstChild("Axis"); + if (NULL != paramNodePtr) + { + Vec3r axis; + axis[0] = getAttributeReal(paramNodePtr, "x"); + axis[1] = getAttributeReal(paramNodePtr, "y"); + axis[2] = getAttributeReal(paramNodePtr, "z"); + data->axis = axis; + } + + #endif + return data; + } + RaycastSensorData* BlueprintManager::loadRaycastSensor( const TiXmlNode* nodePtr, const Blueprint& bp, Index: Solid.h =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.h,v retrieving revision 1.88 retrieving revision 1.89 diff -C2 -d -r1.88 -r1.89 *** Solid.h 12 Apr 2005 06:46:44 -0000 1.88 --- Solid.h 18 Apr 2005 22:21:04 -0000 1.89 *************** *** 50,55 **** Solid(); - virtual ~Solid(); - /// Initializes the Solid with the given data structure. Calling /// this more than once will automatically destroy all the old --- 50,53 ---- *************** *** 229,233 **** --- 227,236 ---- void internal_updateSleeping(); + /// Internal function used to destroy this object. + virtual void OPAL_CALL internal_destroy(); + protected: + virtual ~Solid(); + /// Physics engine-specific function for applying Forces to /// Solids. Index: Matrix44r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Matrix44r.h,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** Matrix44r.h 15 Apr 2005 08:50:42 -0000 1.32 --- Matrix44r.h 18 Apr 2005 22:21:03 -0000 1.33 *************** *** 34,39 **** namespace opal { ! // internally the matrix is column major order (openGL) ! // the accessors are (row, col), but the set)16 x real) function // is column, row order because then it is easier to write // the 16 real out. --- 34,39 ---- namespace opal { ! // Internally the matrix is column major order (openGL) ! // the accessors are (row, col), but the set(16 x real) function // is column, row order because then it is easier to write // the 16 real out. *************** *** 46,51 **** --- 46,58 ---- inline Point3r operator*(const Matrix44r & m, const Point3r &p); inline Rayr operator*(const Matrix44r & m, const Rayr &r); + + /// Inverts src, and puts the result into dest, and returns true. + /// If no valid inverse is found, returns false and leaves dest unchanged. inline bool inverse(Matrix44r & dest, const Matrix44r & src); + + /// Fast invert function for affine transformations only. inline void fastInverse(Matrix44r & dest, const Matrix44r & src); + + /// Prints the Matrix44r to the given output stream. inline std::ostream& operator<<(std::ostream& o, const Matrix44r& m); *************** *** 507,513 **** } }; ! ! // inverts src and puts the result into dest if valid ! // if no valid inverse is found, returns false and leaves dest unchanged inline bool inverse(Matrix44r & dest, const Matrix44r & src) { --- 514,518 ---- } }; ! inline bool inverse(Matrix44r & dest, const Matrix44r & src) { *************** *** 519,525 **** return true; } ! ! // assumes a transform matrix with only rotation, scale, and translation ! // components inline void fastInverse(Matrix44r & result, const Matrix44r & source) { --- 524,528 ---- return true; } ! inline void fastInverse(Matrix44r & result, const Matrix44r & source) { Index: Sensor.h =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Sensor.h 30 Mar 2005 23:26:22 -0000 1.11 --- Sensor.h 18 Apr 2005 22:21:03 -0000 1.12 *************** *** 45,50 **** Sensor(); - virtual ~Sensor(); - /// Sets whether the Sensor can update its measurements. virtual void OPAL_CALL setEnabled(bool e) = 0; --- 45,48 ---- *************** *** 83,87 **** --- 81,90 ---- virtual bool OPAL_CALL internal_dependsOnSolid(Solid* s); + /// Internal function used to destroy this object. + virtual void OPAL_CALL internal_destroy(); + protected: + virtual ~Sensor(); + /// Called by subclasses when they are initialized. void init(); Index: opal.h =================================================================== RCS file: /cvsroot/opal/opal/src/opal.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** opal.h 29 Mar 2005 03:05:46 -0000 1.26 --- opal.h 18 Apr 2005 22:21:04 -0000 1.27 *************** *** 74,85 **** { /// Creates a Simulator. ! OPAL_EXPORT Simulator* OPAL_CALL createSimulator(); /// Loads a Blueprint from an OPAL XML file. ! OPAL_EXPORT void OPAL_CALL loadFile(Blueprint& bp, const std::string& filename); /// Saves a Blueprint in an OPAL XML file. ! //OPAL_EXPORT void OPAL_CALL saveFile(const Blueprint& bp, // const std::string& filename); } --- 74,85 ---- { /// Creates a Simulator. ! OPAL_EXPORT_FUNCTION(Simulator*) createSimulator(); /// Loads a Blueprint from an OPAL XML file. ! OPAL_EXPORT_FUNCTION(void) loadFile(Blueprint& bp, const std::string& filename); /// Saves a Blueprint in an OPAL XML file. ! //OPAL_EXPORT_FUNCTION(void) saveFile(const Blueprint& bp, // const std::string& filename); } Index: Quaternion.h =================================================================== RCS file: /cvsroot/opal/opal/src/Quaternion.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Quaternion.h 12 Apr 2005 06:46:43 -0000 1.8 --- Quaternion.h 18 Apr 2005 22:21:03 -0000 1.9 *************** *** 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 --- 38,44 ---- inline Quaternion operator*(const Quaternion& q, real scalar); inline Quaternion operator*(real scalar, const Quaternion& q); ! ! /// Prints the Quaternion to the given output stream. ! inline std::ostream& operator<<(std::ostream& o, const Quaternion& q); class Quaternion Index: Vec3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Vec3r.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Vec3r.h 12 Apr 2005 06:46:44 -0000 1.15 --- Vec3r.h 18 Apr 2005 22:21:04 -0000 1.16 *************** *** 62,66 **** inline bool areCollinear(const Vec3r& u, const Vec3r& v); ! /// Basic printing helper function. inline std::ostream& operator<<(std::ostream& o, const Vec3r& v); --- 62,66 ---- inline bool areCollinear(const Vec3r& u, const Vec3r& v); ! /// Prints the Vec3r to the given output stream. inline std::ostream& operator<<(std::ostream& o, const Vec3r& v); Index: SConscript =================================================================== RCS file: /cvsroot/opal/opal/src/SConscript,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** SConscript 29 Mar 2005 03:05:46 -0000 1.19 --- SConscript 18 Apr 2005 22:21:03 -0000 1.20 *************** *** 77,80 **** --- 77,81 ---- Solid.cpp SolidData.cpp + Space.cpp SpringMotor.cpp ThrusterMotor.cpp Index: Sensor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Sensor.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Sensor.cpp 23 Mar 2005 04:04:30 -0000 1.6 --- Sensor.cpp 18 Apr 2005 22:21:03 -0000 1.7 *************** *** 40,43 **** --- 40,48 ---- } + void Sensor::internal_destroy() + { + delete this; + } + void Sensor::init() { Index: Rayr.h =================================================================== RCS file: /cvsroot/opal/opal/src/Rayr.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Rayr.h 12 Apr 2005 06:46:43 -0000 1.7 --- Rayr.h 18 Apr 2005 22:21:03 -0000 1.8 *************** *** 34,37 **** --- 34,39 ---- { class Rayr; + + /// Prints the Rayr to the given output stream. inline std::ostream& operator<<(std::ostream& o, const Rayr& r); Index: Motor.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Motor.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Motor.cpp 23 Mar 2005 04:04:30 -0000 1.17 --- Motor.cpp 18 Apr 2005 22:21:03 -0000 1.18 *************** *** 41,44 **** --- 41,49 ---- } + void Motor::internal_destroy() + { + delete this; + } + void Motor::init() { Index: Solid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Solid.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** Solid.cpp 10 Apr 2005 23:09:21 -0000 1.33 --- Solid.cpp 18 Apr 2005 22:21:04 -0000 1.34 *************** *** 42,45 **** --- 42,50 ---- } + void Solid::internal_destroy() + { + delete this; + } + const SolidData& Solid::getData()const { Index: Joint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Joint.cpp 25 Mar 2005 04:18:59 -0000 1.29 --- Joint.cpp 18 Apr 2005 22:21:03 -0000 1.30 *************** *** 47,50 **** --- 47,55 ---- } + void Joint::internal_destroy() + { + delete this; + } + void Joint::init(const JointData& data) { Index: Portability.h =================================================================== RCS file: /cvsroot/opal/opal/src/Portability.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Portability.h 15 Apr 2005 08:50:42 -0000 1.6 --- Portability.h 18 Apr 2005 22:21:03 -0000 1.7 *************** *** 51,58 **** #endif ! // Macro for keeping function names from being mangled. ! // TODO: change all OPAL_DECL to use OPAL_EXPORT to prevent name mangling. ! //#define OPAL_EXPORT(rtype) extern "C" OPAL_DECL rtype OPAL_CALL ! #define OPAL_EXPORT extern "C" OPAL_DECL // In Visual Studio, this is the only way to conditionally link with --- 51,62 ---- #endif ! /// Macro for exporting functions that keeps function names from being ! /// mangled and uses the correct calling convention. Note: All class ! /// methods for classes instantiated by OPAL (through factory creation ! /// calls) simply need to be virtual. Classes instantiated by the user ! /// should simply OPAL_DECL to export their public symbols. This doesn't ! /// allow extern "C" to be used to avoid name mangling of those class ! /// methods, but that probably isn't even possible...) ! #define OPAL_EXPORT_FUNCTION(returnType) extern "C" OPAL_DECL returnType OPAL_CALL // In Visual Studio, this is the only way to conditionally link with Index: Joint.h =================================================================== RCS file: /cvsroot/opal/opal/src/Joint.h,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** Joint.h 30 Mar 2005 23:26:22 -0000 1.67 --- Joint.h 18 Apr 2005 22:21:03 -0000 1.68 *************** *** 57,62 **** Joint(); - virtual ~Joint(); - /// Initializes the Joint with the given data structure. Calling /// this more than once will automatically detach the Joint from --- 57,60 ---- *************** *** 224,228 **** --- 222,231 ---- virtual bool OPAL_CALL internal_dependsOnSolid(Solid* s); + /// Internal function used to destroy this object. + virtual void OPAL_CALL internal_destroy(); + protected: + virtual ~Joint(); + /// Sets the Solids constrained by this Joint. void setSolids(Solid* s0, Solid* s1); Index: Point3r.h =================================================================== RCS file: /cvsroot/opal/opal/src/Point3r.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Point3r.h 12 Apr 2005 06:46:43 -0000 1.12 --- Point3r.h 18 Apr 2005 22:21:03 -0000 1.13 *************** *** 34,37 **** --- 34,52 ---- namespace opal { + class Point3r; + inline Point3r operator+(const Point3r &u, const Vec3r &v); + inline Point3r operator-(const Point3r &u, const Vec3r &v); + inline Vec3r operator-(const Point3r &u, const Point3r &v); + inline Point3r operator*(const Point3r &v, real scalar); + inline Point3r operator*(real scalar, const Point3r &v); + inline Point3r operator/(const Point3r &v, real scalar); + inline Point3r operator-(const Point3r &p); + + /// Returns the Euclidean distance between two points. + inline real distance(const Point3r& p1, const Point3r& p2); + + /// Prints the Point3r to the given output stream. + inline std::ostream& operator<<(std::ostream& o, const Point3r& p); + class Point3r { Index: Logger.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/Logger.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Logger.cpp 8 Mar 2005 16:10:23 -0000 1.3 --- Logger.cpp 18 Apr 2005 22:21:03 -0000 1.4 *************** *** 65,69 **** if(s.mark != '\0') { ! std::cout<<s.mark; std::cout.flush(); } --- 65,69 ---- if(s.mark != '\0') { ! std::cout << s.mark; std::cout.flush(); } |