[Opal-commits] opal/src/ODE ODESolid.cpp,1.68,1.69 ODESolid.h,1.61,1.62
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-02-23 04:56:58
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27467/src/ODE Modified Files: ODESolid.cpp ODESolid.h Log Message: added Solid init function; fixed sample apps Index: ODESolid.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.h,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** ODESolid.h 23 Feb 2005 03:58:23 -0000 1.61 --- ODESolid.h 23 Feb 2005 04:56:49 -0000 1.62 *************** *** 67,70 **** --- 67,72 ---- virtual ~ODESolid(); + virtual void OPAL_CALL init(const SolidData& data); + virtual void OPAL_CALL setEnabled(bool e); *************** *** 159,162 **** --- 161,167 ---- void setupNewGeom(GeomData* newGeom); + /// Destroys all of this Solid's ODE geoms. + void destroyGeoms(); + virtual void applyForce(const Force& f); Index: ODESolid.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** ODESolid.cpp 23 Feb 2005 03:58:23 -0000 1.68 --- ODESolid.cpp 23 Feb 2005 04:56:49 -0000 1.69 *************** *** 59,62 **** --- 59,74 ---- ODESolid::~ODESolid() { + destroyGeoms(); + + if (!mData.isStatic) + { + // This is a dynamic solid, so it has an ODE body that needs + // to be destroyed. + dBodyDestroy(mBodyID); + } + } + + void ODESolid::destroyGeoms() + { while (!mGeomDataList.empty()) { *************** *** 72,80 **** if (0 != mGeomDataList.back()->trimeshDataID) { ! // This geom uses a trimesh. Destroy it. dGeomTriMeshDataDestroy(mGeomDataList.back()->trimeshDataID); } ! // Destroy the actual geom. dGeomDestroy(mGeomDataList.back()->geomID); --- 84,94 ---- if (0 != mGeomDataList.back()->trimeshDataID) { ! // This geom uses a trimesh. Destroy it. (This does NOT ! // touch the user's mesh data, just internal ODE trimesh ! // data.) dGeomTriMeshDataDestroy(mGeomDataList.back()->trimeshDataID); } ! // Destroy the ODE geom. dGeomDestroy(mGeomDataList.back()->geomID); *************** *** 84,94 **** mGeomDataList.pop_back(); } ! if (!mData.isStatic) { ! // this is a dynamic solid, so it has an ODE body that needs to be ! // destroyed ! dBodyDestroy(mBodyID); } } --- 98,140 ---- mGeomDataList.pop_back(); } + } ! void ODESolid::init(const SolidData& data) ! { ! // Destroy the old Shapes. ! while (!mData.shapes.empty()) { ! delete mData.shapes.back(); ! mData.shapes.pop_back(); } + + // Destroy the old ODE geoms. + destroyGeoms(); + + // Set whether the Solid is static. + setStatic(data.isStatic); + + // Set the new transform. + setTransform(data.transform); + + // Add the new Shapes. + for (unsigned int i=0; i<data.shapes.size(); ++i) + { + addShape(*(data.shapes[i])); + } + + // Set whether the Solid is sleeping. + setSleeping(data.sleeping); + + // Set whether the Solid is enabled. + setEnabled(data.enabled); + + // Set damping levels. + setLinearDamping(data.linearDamping); + setAngularDamping(data.angularDamping); + + // Set velocities. + setGlobalLinearVel(data.globalLinearVel); + setGlobalAngularVel(data.globalAngularVel); } |