Update of /cvsroot/simspark/simspark/spark/oxygen/physicsserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv7790/spark/oxygen/physicsserver Modified Files: angularmotor_c.cpp body.cpp body.h bodycontroller.cpp bodycontroller.h collider.cpp collider.h collisionhandler.cpp collisionhandler.h contactjointhandler_c.cpp fixedjoint.cpp fixedjoint.h fixedjoint_c.cpp joint.cpp joint.h odeobject.cpp odeobject.h physicsserver.cpp physicsserver.h space.cpp space.h world.cpp world.h world_c.cpp Added Files: odewrapper.h transformcollider_c.cpp Log Message: Merged WIN32 branch back to main trunk (access previous version with tag pre_merge_WIN32) Index: physicsserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/physicsserver.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** physicsserver.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- physicsserver.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 21,25 **** #include "physicsserver.h" - #include <ode/ode.h> using namespace oxygen; --- 21,24 ---- Index: collider.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/collider.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** collider.cpp 14 Apr 2006 16:27:27 -0000 1.2 --- collider.cpp 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 38,46 **** Collider::~Collider() { - if (mODEGeom) - { - dGeomDestroy(mODEGeom); - mODEGeom = 0; - } } --- 38,41 ---- *************** *** 252,253 **** --- 247,258 ---- } + void Collider::DestroyODEObject() + { + if (! mODEGeom) + { + return; + } + + dGeomDestroy(mODEGeom); + mODEGeom = 0; + } Index: joint.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/joint.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** joint.cpp 12 Feb 2006 11:36:52 -0000 1.4 --- joint.cpp 15 Mar 2007 07:26:27 -0000 1.5 *************** *** 33,42 **** Joint::~Joint() { - EnableFeedback(false); - if (mODEJoint) - { - dJointDestroy(mODEJoint); - mODEJoint = 0; - } } --- 33,36 ---- *************** *** 182,186 **** } ! return dAreConnected(body1->GetODEBody(),body2->GetODEBody()); } --- 176,184 ---- } ! const bool connected = ! (dAreConnected(body1->GetODEBody(),body2->GetODEBody()) ! == 1); ! ! return connected; } *************** *** 197,202 **** } ! return dAreConnectedExcluding(body1->GetODEBody(),body2->GetODEBody(), ! joint_type); } --- 195,206 ---- } ! const bool connected = ! (dAreConnectedExcluding(body1->GetODEBody(), ! body2->GetODEBody(), ! joint_type ! ) ! == 1); ! ! return connected; } *************** *** 414,419 **** } ! ! ! --- 418,430 ---- } + void Joint::DestroyODEObject() + { + if (! mODEJoint) + { + return; + } ! EnableFeedback(false); ! dJointDestroy(mODEJoint); ! mODEJoint = 0; ! } Index: bodycontroller.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/bodycontroller.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bodycontroller.h 5 Dec 2005 21:16:49 -0000 1.1 --- bodycontroller.h 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 38,41 **** --- 38,44 ---- virtual ~BodyController() {} + /** update variables from a script */ + virtual void UpdateCached(); + protected: /** sets up the reference to the controlled body */ --- NEW FILE: transformcollider_c.cpp --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2003 Koblenz University $Id: transformcollider_c.cpp,v 1.2 2007/03/15 07:26:27 fruit Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program 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 GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "transformcollider.h" using namespace oxygen; using namespace boost; using namespace salt; void CLASS(TransformCollider)::DefineClass() { DEFINE_BASECLASS(oxygen/Collider); } Index: joint.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/joint.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** joint.h 12 Feb 2006 11:36:52 -0000 1.2 --- joint.h 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 66,69 **** --- 66,72 ---- virtual ~Joint(); + /** destroy the managed ODE object */ + virtual void DestroyODEObject(); + /** attaches the joint to some new bodies. If the joint is already attached, it will be detached from the old bodies first. To Index: collider.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/collider.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** collider.h 14 Apr 2006 16:27:27 -0000 1.2 --- collider.h 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 128,131 **** --- 128,134 ---- virtual void PrePhysicsUpdateInternal(float deltaTime); + /** destroy the managed ODE object */ + virtual void DestroyODEObject(); + // // Members --- NEW FILE: odewrapper.h --- /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- this file is part of rcssserver3D Fri May 9 2003 Copyright (C) 2002,2003 Koblenz University Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group $Id: odewrapper.h,v 1.2 2007/03/15 07:26:27 fruit Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. This program 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 GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef OXYGEN_ODEWRAPPER_H #define OXYGEN_ODEWRAPPER_H #undef PACKAGE #undef PACKAGE_VERSION #undef VERSION #undef PACKAGE_TARNAME #undef PACKAGE_STRING #undef PACKAGE_NAME #undef PACKAGE_BUGREPORT #ifdef WIN32 #ifdef copysignf #undef copysignf #endif #ifdef copysign #undef copysign #endif #endif // WIN32 #include <ode/ode.h> #undef PACKAGE #undef PACKAGE_VERSION #undef VERSION #undef PACKAGE_TARNAME #undef PACKAGE_STRING #undef PACKAGE_NAME #undef PACKAGE_BUGREPORT #ifdef HAVE_CONFIG_H #include <config.h> #endif #endif // OXYGEN_ODEWRAPPER Index: physicsserver.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/physicsserver.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** physicsserver.h 5 Dec 2005 21:16:49 -0000 1.1 --- physicsserver.h 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 25,29 **** #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> ! #include <ode/ode.h> namespace oxygen --- 25,29 ---- #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> ! #include "odewrapper.h" namespace oxygen Index: collisionhandler.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/collisionhandler.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** collisionhandler.h 5 Dec 2005 21:16:49 -0000 1.1 --- collisionhandler.h 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 24,28 **** #include <oxygen/sceneserver/basenode.h> ! #include <ode/ode.h> namespace oxygen --- 24,28 ---- #include <oxygen/sceneserver/basenode.h> ! #include "odewrapper.h" namespace oxygen *************** *** 50,53 **** --- 50,56 ---- virtual ~CollisionHandler() {}; + /** update variables from a script */ + virtual void UpdateCached(); + /** HandleCollision is called from the Collider to which this CollisionHandler is registered to. Derived classes implement *************** *** 100,103 **** --- 103,108 ---- virtual void OnUnlink(); + void ResetCache(); + // // Members Index: collisionhandler.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/collisionhandler.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** collisionhandler.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- collisionhandler.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 33,39 **** --- 33,59 ---- CollisionHandler::OnLink() { + UpdateCached(); + } + + void + CollisionHandler::ResetCache() + { + mCollider.reset(); + mWorld.reset(); + mSpace.reset(); + } + + void + CollisionHandler::UpdateCached() + { // setup the scene, world, space and collider references shared_ptr<Scene> scene = GetScene(); + ResetCache(); + if (scene.get() == 0) + { + return; + } + mWorld = shared_static_cast<World>(scene->GetChildOfClass("World")); if (mWorld.get() == 0) *************** *** 61,67 **** CollisionHandler::OnUnlink() { ! mCollider.reset(); ! mWorld.reset(); ! mSpace.reset(); } --- 81,86 ---- CollisionHandler::OnUnlink() { ! BaseNode::OnUnlink(); ! ResetCache(); } Index: space.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/space.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** space.h 5 Dec 2005 21:16:49 -0000 1.1 --- space.h 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 65,68 **** --- 65,71 ---- virtual void HandleCollide(dGeomID obj1, dGeomID obj2); + /** destroy the managed ODE object */ + virtual void DestroyODEObject(); + protected: /** creates them managed ODE space and a contact joint group */ *************** *** 72,75 **** --- 75,83 ---- virtual void PostPhysicsUpdateInternal(); + /** destroys the ODE bodies managed by all Body objects that are + registered to this Space + */ + void DestroySpaceObjects(); + // // Members Index: space.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/space.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** space.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- space.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 35,39 **** } ! Space::Space() : mODESpace(0), mODEContactGroup(0) { } --- 35,39 ---- } ! Space::Space() : ODEObject(), mODESpace(0), mODEContactGroup(0) { } *************** *** 46,56 **** mODEContactGroup = 0; } - - // release the ODE space - if (mODESpace) - { - dSpaceDestroy(mODESpace); - mODESpace = 0; - } } --- 46,49 ---- *************** *** 77,81 **** const dBodyID b2 = dGeomGetBody(obj2); ! if ((b1) && (b2) && (dAreConnected(b1,b2))) { return; --- 70,74 ---- const dBodyID b2 = dGeomGetBody(obj2); ! if ((b1) && (b2) && (dAreConnectedExcluding(b1,b2,dJointTypeContact))) { return; *************** *** 88,92 **** // expect that dCollide() will return contacts for every pair // passed to the callback. ! static const int nContacts = 6; static dContact contacts[nContacts]; --- 81,85 ---- // expect that dCollide() will return contacts for every pair // passed to the callback. ! static const int nContacts = 4; static dContact contacts[nContacts]; *************** *** 141,142 **** --- 134,188 ---- } + void Space::DestroySpaceObjects() + { + shared_ptr<Scene> scene = GetScene(); + if (scene.get() == 0) + { + return; + } + + TLeafList objects; + + const bool recursive = true; + scene->ListChildrenSupportingClass<ODEObject>(objects, recursive); + + for ( + TLeafList::iterator iter = objects.begin(); + iter != objects.end(); + ++iter + ) + { + shared_ptr<ODEObject> object = shared_static_cast<ODEObject>(*iter); + if (object->GetSpaceID() != mODESpace) + { + continue; + } + + object->DestroyODEObject(); + } + } + + void Space::DestroyODEObject() + { + static bool recurseLock = false; + + if ( + (recurseLock) || + (! mODESpace) + ) + { + return; + } + + recurseLock = true; + + // make sure that all objects registered to this space are destroyed + // before this space. Any other order provokes a segfault in ODE. + DestroySpaceObjects(); + + // release the ODE space + dSpaceDestroy(mODESpace); + mODESpace = 0; + + recurseLock = false; + } Index: fixedjoint.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/fixedjoint.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fixedjoint.h 12 Feb 2006 11:36:52 -0000 1.2 --- fixedjoint.h 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 35,38 **** --- 35,43 ---- virtual ~FixedJoint(); + /** Call this on the fixed joint after it has been attached to remember + the current desired relative offset and desired relative rotation + between the bodies. */ + void SetFixed(); + protected: /** creates a new fixed joint */ Index: fixedjoint.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/fixedjoint.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fixedjoint.cpp 12 Feb 2006 11:36:52 -0000 1.2 --- fixedjoint.cpp 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 55,56 **** --- 55,61 ---- } + void FixedJoint::SetFixed() + { + dJointSetFixed(mODEJoint); + } + Index: world.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/world.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** world.h 22 Jan 2006 18:57:15 -0000 1.2 --- world.h 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 89,92 **** --- 89,108 ---- void Step(float deltaTime); + bool GetAutoDisableFlag() const; + void SetAutoDisableFlag(bool flag); + + /** Set and get the depth of the surface layer around all geometry + objects. Contacts are allowed to sink into the surface layer up to + the given depth before coming to rest. The default value is + zero. Increasing this to some small value (e.g. 0.001) can help + prevent jittering problems due to contacts being repeatedly made + and broken. + */ + void SetContactSurfaceLayer(float depth); + float GetContactSurfaceLayer() const; + + /** destroy the managed ODE object */ + virtual void DestroyODEObject(); + protected: /** creates them managed ODE world */ Index: angularmotor_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/angularmotor_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** angularmotor_c.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- angularmotor_c.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 116,120 **** } ! obj->SetAxisAngle(static_cast<Joint::EAxisIndex>(inAxisIdx),inDegAngle); return true; } --- 116,120 ---- } ! obj->SetAxisAngle(static_cast<Joint::EAxisIndex>(inAxisIdx),static_cast<float>(inDegAngle)); return true; } Index: body.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/body.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** body.cpp 14 Apr 2006 16:27:27 -0000 1.2 --- body.cpp 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 35,43 **** Body::~Body() { - if (mODEBody) - { - dBodyDestroy(mODEBody); - mODEBody = 0; - } } --- 35,38 ---- *************** *** 106,109 **** --- 101,115 ---- } + void Body::DestroyODEObject() + { + if (mODEBody == 0) + { + return; + } + + dBodyDestroy(mODEBody); + mODEBody = 0; + } + void Body::OnLink() { Index: body.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/body.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** body.h 14 Apr 2006 16:27:26 -0000 1.2 --- body.h 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 176,179 **** --- 176,182 ---- salt::Vector3f GetPosition() const; + /** destroy the managed ODE object */ + virtual void DestroyODEObject(); + protected: /** creates the managed ODE body and moves it to the position of Index: odeobject.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/odeobject.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** odeobject.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- odeobject.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 29,33 **** using namespace boost; ! /** returns the world node */ shared_ptr<World> ODEObject::GetWorld() { --- 29,45 ---- using namespace boost; ! ODEObject::ODEObject() : BaseNode() ! { ! } ! ! ODEObject::~ODEObject() ! { ! } ! ! void ODEObject::OnUnlink() ! { ! DestroyODEObject(); ! } ! shared_ptr<World> ODEObject::GetWorld() { *************** *** 120,123 **** matrix[11] = 0; } - - --- 132,133 ---- Index: world_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/world_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** world_c.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- world_c.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 84,87 **** --- 84,129 ---- } + FUNCTION(World,setAutoDisableFlag) + { + bool inFlag; + + if ( + (in.GetSize() != 1) || + (! in.GetValue(in.begin(),inFlag)) + ) + { + return false; + } + + obj->SetAutoDisableFlag(inFlag); + return true; + } + + FUNCTION(World,getAutoDisableFlag) + { + return obj->GetAutoDisableFlag(); + } + + FUNCTION(World,setContactSurfaceLayer) + { + float inDepth; + + if ( + (in.GetSize() != 1) || + (! in.GetValue(in.begin(),inDepth)) + ) + { + return false; + } + + obj->SetContactSurfaceLayer(inDepth); + return true; + } + + FUNCTION(World,getContactSurfaceLayer) + { + return obj->GetContactSurfaceLayer(); + } + void CLASS(World)::DefineClass() { *************** *** 92,94 **** --- 134,140 ---- DEFINE_FUNCTION(setCFM); DEFINE_FUNCTION(getCFM); + DEFINE_FUNCTION(setAutoDisableFlag); + DEFINE_FUNCTION(getAutoDisableFlag); + DEFINE_FUNCTION(setContactSurfaceLayer); + DEFINE_FUNCTION(getContactSurfaceLayer); } Index: contactjointhandler_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/contactjointhandler_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** contactjointhandler_c.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- contactjointhandler_c.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 50,54 **** } ! obj->SetMinBounceVel(inVel); return true; } --- 50,54 ---- } ! obj->SetMinBounceVel(static_cast<float>(inVel)); return true; } *************** *** 65,69 **** } ! obj->SetBounceValue(inValue); return true; } --- 65,69 ---- } ! obj->SetBounceValue(static_cast<float>(inValue)); return true; } *************** *** 95,99 **** } ! obj->SetContactSoftERP(inERP); return true; } --- 95,99 ---- } ! obj->SetContactSoftERP(static_cast<float>(inERP)); return true; } *************** *** 125,129 **** } ! obj->SetContactSoftCFM(inCFM); return true; } --- 125,129 ---- } ! obj->SetContactSoftCFM(static_cast<float>(inCFM)); return true; } *************** *** 155,159 **** } ! obj->SetContactSlip(inSlip); return true; } --- 155,159 ---- } ! obj->SetContactSlip(static_cast<float>(inSlip)); return true; } *************** *** 170,174 **** } ! obj->SetContactMu(inMu); return true; --- 170,174 ---- } ! obj->SetContactMu(static_cast<float>(inMu)); return true; Index: world.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/world.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** world.cpp 22 Jan 2006 18:57:14 -0000 1.2 --- world.cpp 15 Mar 2007 07:26:27 -0000 1.3 *************** *** 21,29 **** #include "world.h" using namespace oxygen; using namespace salt; ! World::World() : mODEWorld(0) { } --- 21,32 ---- #include "world.h" + #include "space.h" + #include <oxygen/sceneserver/scene.h> + using namespace boost; using namespace oxygen; using namespace salt; ! World::World() : ODEObject(), mODEWorld(0) { } *************** *** 31,40 **** World::~World() { - // release the ODE world - if (mODEWorld) - { - dWorldDestroy(mODEWorld); - mODEWorld = 0; - } } --- 34,37 ---- *************** *** 85,88 **** --- 82,105 ---- } + bool World::GetAutoDisableFlag() const + { + return (dWorldGetAutoDisableFlag(mODEWorld) == 1); + } + + void World::SetAutoDisableFlag(bool flag) + { + dWorldSetAutoDisableFlag(mODEWorld, static_cast<int>(flag)); + } + + void World::SetContactSurfaceLayer(float depth) + { + dWorldSetContactSurfaceLayer(mODEWorld, depth); + } + + float World::GetContactSurfaceLayer() const + { + return dWorldGetContactSurfaceLayer(mODEWorld); + } + bool World::ConstructInternal() { *************** *** 92,93 **** --- 109,138 ---- return (mODEWorld != 0); } + + void World::DestroyODEObject() + { + static bool recurseLock = false; + if (recurseLock) + { + return; + } + + recurseLock = true; + + shared_ptr<Space> space = GetSpace(); + if (space.get() != 0) + { + space->DestroyODEObject(); + } + + if (mODEWorld == 0) + { + return; + } + + // release the ODE world + dWorldDestroy(mODEWorld); + mODEWorld = 0; + + recurseLock = false; + } Index: odeobject.h =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/odeobject.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** odeobject.h 5 Dec 2005 21:16:49 -0000 1.1 --- odeobject.h 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 24,28 **** #include <oxygen/sceneserver/basenode.h> ! #include <ode/ode.h> namespace oxygen --- 24,28 ---- #include <oxygen/sceneserver/basenode.h> ! #include "odewrapper.h" namespace oxygen *************** *** 39,51 **** // Functions // ! ODEObject() : BaseNode() {}; ! virtual ~ODEObject() {}; ! ! protected: ! /** returns the world node */ ! boost::shared_ptr<World> GetWorld(); ! /** returns the space node */ ! boost::shared_ptr<Space> GetSpace(); /** returns the ODE world handle */ --- 39,50 ---- // Functions // ! ODEObject(); ! virtual ~ODEObject(); ! /** This rountine is called, before the hierarchy object is ! removed from the parent. It can be overridden to support ! custom 'unlink' behavior. ! */ ! virtual void OnUnlink(); /** returns the ODE world handle */ *************** *** 55,58 **** --- 54,67 ---- dSpaceID GetSpaceID(); + /** destroy the managed ODE object */ + virtual void DestroyODEObject() = 0; + + protected: + /** returns the world node */ + boost::shared_ptr<World> GetWorld(); + + /** returns the space node */ + boost::shared_ptr<Space> GetSpace(); + /** converts the rotation part of a salt::Matrix to an ODE dMatrix3 */ Index: bodycontroller.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/bodycontroller.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** bodycontroller.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- bodycontroller.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 30,33 **** --- 30,46 ---- void BodyController::OnLink() { + UpdateCached(); + } + + void BodyController::OnUnlink() + { + BaseNode::OnUnlink(); + mBody.reset(); + } + + void BodyController::UpdateCached() + { + mBody.reset(); + mBody = shared_dynamic_cast<Body> (make_shared(GetParentSupportingClass("Body"))); *************** *** 39,45 **** } } - - void BodyController::OnUnlink() - { - mBody.reset(); - } --- 52,53 ---- Index: fixedjoint_c.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/oxygen/physicsserver/fixedjoint_c.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fixedjoint_c.cpp 5 Dec 2005 21:16:49 -0000 1.1 --- fixedjoint_c.cpp 15 Mar 2007 07:26:27 -0000 1.2 *************** *** 26,31 **** --- 26,38 ---- using namespace salt; + FUNCTION(FixedJoint, setFixed) + { + obj->SetFixed(); + return true; + } + void CLASS(FixedJoint)::DefineClass() { DEFINE_BASECLASS(oxygen/Joint); + DEFINE_FUNCTION(setFixed); } |