From: <a-...@us...> - 2009-11-18 07:42:32
|
Revision: 103 http://simspark.svn.sourceforge.net/simspark/?rev=103&view=rev Author: a-held Date: 2009-11-18 07:42:23 +0000 (Wed, 18 Nov 2009) Log Message: ----------- undid changes to trunk that were accidentally commited yesterday Modified Paths: -------------- trunk/spark/lib/oxygen/CMakeLists.txt trunk/spark/lib/oxygen/oxygen.cpp trunk/spark/lib/oxygen/oxygen.h trunk/spark/lib/oxygen/physicsserver/body.cpp trunk/spark/lib/oxygen/physicsserver/body.h trunk/spark/lib/oxygen/physicsserver/boxcollider.h trunk/spark/lib/oxygen/physicsserver/collider.h trunk/spark/lib/oxygen/physicsserver/collisionhandler.h trunk/spark/lib/oxygen/physicsserver/joint.h trunk/spark/lib/oxygen/physicsserver/physicsserver.h trunk/spark/lib/oxygen/physicsserver/space.h trunk/spark/lib/oxygen/physicsserver/world.cpp trunk/spark/lib/oxygen/physicsserver/world.h trunk/spark/lib/oxygen/physicsserver/world_c.cpp trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.h Added Paths: ----------- trunk/spark/lib/oxygen/physicsserver/odeobject.cpp trunk/spark/lib/oxygen/physicsserver/odeobject.h trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp trunk/spark/lib/oxygen/physicsserver/odewrapper.h Removed Paths: ------------- trunk/spark/lib/oxygen/physicsserver/imp/ trunk/spark/lib/oxygen/physicsserver/ode/ Modified: trunk/spark/lib/oxygen/CMakeLists.txt =================================================================== --- trunk/spark/lib/oxygen/CMakeLists.txt 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/CMakeLists.txt 2009-11-18 07:42:23 UTC (rev 103) @@ -21,6 +21,8 @@ physicsserver/collider.h physicsserver/collisionhandler.h physicsserver/contactjointhandler.h + physicsserver/odeobject.h + physicsserver/odewrapper.h physicsserver/physicsserver.h physicsserver/planecollider.h physicsserver/raycollider.h @@ -39,15 +41,6 @@ physicsserver/universaljoint.h physicsserver/hinge2joint.h physicsserver/angularmotor.h - - #interfaces - physicsserver/imp/worldimp.h - - #ode-specific files - physicsserver/ode/odeobject.h - physicsserver/ode/odeworld.h - physicsserver/ode/odewrapper.h - sceneserver/sceneimporter.h sceneserver/basenode.h sceneserver/fpscontroller.h @@ -123,6 +116,8 @@ physicsserver/collisionhandler_c.cpp physicsserver/contactjointhandler.cpp physicsserver/contactjointhandler_c.cpp + physicsserver/odeobject.cpp + physicsserver/odeobject_c.cpp physicsserver/physicsserver.cpp physicsserver/physicsserver_c.cpp physicsserver/planecollider.cpp @@ -157,16 +152,6 @@ physicsserver/hinge2joint_c.cpp physicsserver/angularmotor.cpp physicsserver/angularmotor_c.cpp - - #interfaces - physicsserver/imp/worldimp_c.cpp - - #ODE-specific files - physicsserver/ode/odeworld.cpp - physicsserver/ode/odeworld_c.cpp - physicsserver/ode/odeobject.cpp - physicsserver/ode/odeobject_c.cpp - sceneserver/basenode.cpp sceneserver/basenode_c.cpp sceneserver/fpscontroller.cpp Modified: trunk/spark/lib/oxygen/oxygen.cpp =================================================================== --- trunk/spark/lib/oxygen/oxygen.cpp 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/oxygen.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -57,9 +57,9 @@ zg.GetCore()->RegisterClassObject(new CLASS(BodyController), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(DragController), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(VelocityController), "oxygen/"); + zg.GetCore()->RegisterClassObject(new CLASS(ODEObject), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(Space), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(World), "oxygen/"); - zg.GetCore()->RegisterClassObject(new CLASS(WorldImp), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(Joint), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(BallJoint), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(HingeJoint), "oxygen/"); @@ -86,11 +86,6 @@ zg.GetCore()->RegisterClassObject(new CLASS(AgentAspect), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(Effector), "oxygen/"); zg.GetCore()->RegisterClassObject(new CLASS(Perceptor), "oxygen/"); - - //ODE-specific classes - zg.GetCore()->RegisterClassObject(new CLASS(ODEObject), "oxygen/"); - zg.GetCore()->RegisterClassObject(new CLASS(ODEWorld), "oxygen/"); - #ifdef HAVE_SPADES_HEADERS // spades Modified: trunk/spark/lib/oxygen/oxygen.h =================================================================== --- trunk/spark/lib/oxygen/oxygen.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/oxygen.h 2009-11-18 07:42:23 UTC (rev 103) @@ -34,7 +34,6 @@ #include "gamecontrolserver/actionobject.h" #include "gamecontrolserver/behavior.h" -//abstract physics classes #include "physicsserver/body.h" #include "physicsserver/bodycontroller.h" #include "physicsserver/dragcontroller.h" @@ -43,6 +42,7 @@ #include "physicsserver/boxcollider.h" #include "physicsserver/ccylindercollider.h" #include "physicsserver/collider.h" +#include "physicsserver/odeobject.h" #include "physicsserver/physicsserver.h" #include "physicsserver/planecollider.h" #include "physicsserver/raycollider.h" @@ -60,13 +60,6 @@ #include "physicsserver/universaljoint.h" #include "physicsserver/hinge2joint.h" -//physics interfaces -#include "physicsserver/imp/worldimp.h" - -//ode-specific includes -#include <oxygen/physicsserver/ode/odeobject.h> -#include <oxygen/physicsserver/ode/odeworld.h> - #include "sceneserver/basenode.h" #include "sceneserver/camera.h" #include "sceneserver/fpscontroller.h" Modified: trunk/spark/lib/oxygen/physicsserver/body.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/body.cpp 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/body.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -339,7 +339,7 @@ // direction: (1=x, 2=y, 3=z) int direction = 3; - dMassSetCapsule (&mass, density, direction, radius, length); + dMassSetCappedCylinder (&mass, density, direction, radius, length); } void Body::SetCappedCylinder (float density, float radius, float length) @@ -361,7 +361,7 @@ // direction: (1=x, 2=y, 3=z) int direction = 3; - dMassSetCapsuleTotal(&mass, total_mass, direction, radius, length); + dMassSetCappedCylinderTotal(&mass, total_mass, direction, radius, length); } void Body::SetCappedCylinderTotal(float total_mass, float radius, float length) Modified: trunk/spark/lib/oxygen/physicsserver/body.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/body.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/body.h 2009-11-18 07:42:23 UTC (rev 103) @@ -23,7 +23,7 @@ #define OXYGEN_BODY_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odeobject.h> +#include "odeobject.h" namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/boxcollider.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/boxcollider.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/boxcollider.h 2009-11-18 07:42:23 UTC (rev 103) @@ -23,7 +23,7 @@ #define OXYGEN_BOXCOLLIDER_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/collider.h> +#include "collider.h" namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/collider.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/collider.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/collider.h 2009-11-18 07:42:23 UTC (rev 103) @@ -22,7 +22,7 @@ #ifndef OXYGEN_COLLIDER_H #define OXYGEN_COLLIDER_H -#include <oxygen/physicsserver/ode/odeobject.h> +#include "odeobject.h" #include <string> #include <set> #include <oxygen/oxygen_defines.h> Modified: trunk/spark/lib/oxygen/physicsserver/collisionhandler.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/collisionhandler.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/collisionhandler.h 2009-11-18 07:42:23 UTC (rev 103) @@ -24,7 +24,7 @@ #include <oxygen/sceneserver/basenode.h> #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odewrapper.h> +#include "odewrapper.h" namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/joint.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/joint.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/joint.h 2009-11-18 07:42:23 UTC (rev 103) @@ -23,7 +23,7 @@ #define OXYGEN_JOINT_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odeobject.h> +#include "odeobject.h" namespace oxygen { Copied: trunk/spark/lib/oxygen/physicsserver/odeobject.cpp (from rev 97, trunk/spark/lib/oxygen/physicsserver/odeobject.cpp) =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odeobject.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/odeobject.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -0,0 +1,167 @@ +/* -*- 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$ + + 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 "odeobject.h" +#include "space.h" +#include "world.h" +#include <oxygen/sceneserver/scene.h> +#include <zeitgeist/logserver/logserver.h> + +using namespace oxygen; +using namespace boost; + +ODEObject::ODEObject() : BaseNode() +{ +} + +ODEObject::~ODEObject() +{ +} + +void ODEObject::OnUnlink() +{ + DestroyODEObject(); +} + +/** returns the world node */ +shared_ptr<World> ODEObject::GetWorld() +{ + shared_ptr<Scene> scene = GetScene(); + if (scene.get() == 0) + { + GetLog()->Error() << "(ODEObject) ERROR: found no Scene node\n"; + return shared_ptr<World>(); + } + + shared_ptr<World> worldNode = shared_dynamic_cast<World> + (scene->GetChildOfClass("World")); + if (worldNode.get() == 0) + { + GetLog()->Error() << "(ODEObject) ERROR: found no World node\n"; + } + + return worldNode; +} + +shared_ptr<Space> ODEObject::GetSpace() +{ + // try to find the nearest parent space object + weak_ptr<Space> parentSpace = FindParentSupportingClass<Space>(); + if (! parentSpace.expired()) + { + return parentSpace.lock(); + } + + // return the global space instance + shared_ptr<Scene> scene = GetScene(); + if (scene.get() == 0) + { + GetLog()->Error() << "(ODEObject) ERROR: found no Scene node\n"; + return shared_ptr<Space>(); + } + + shared_ptr<Space> spaceNode = shared_dynamic_cast<Space> + (scene->GetChildOfClass("Space")); + if (spaceNode.get() == 0) + { + GetLog()->Error() << "(ODEObject) ERROR: found no Space node\n"; + } + + return spaceNode; +} + +dWorldID ODEObject::GetWorldID() +{ + shared_ptr<World> world = GetWorld(); + if (world.get() == 0) + { + return 0; + } + + dWorldID worldId = world->GetODEWorld(); + if (worldId == 0) + { + GetLog()->Error() + << "(ODEObject) ERROR: World returned empty ODE handle\n"; + } + + return worldId; +} + +dSpaceID ODEObject::FindSpaceID() +{ + shared_ptr<Space> space = GetSpace(); + if (space.get() == 0) + { + return 0; + } + + dSpaceID spaceId = space->GetODESpace(); + + if (spaceId == 0) + { + GetLog()->Error() + << "(ODEObject) ERROR: Space returned empty ODE handle\n"; + } + + return spaceId; +} + +dSpaceID ODEObject::GetParentSpaceID() +{ + return 0; +} + +void ODEObject::ConvertRotationMatrix(const salt::Matrix& rot, dMatrix3& matrix) +{ + matrix[0] = rot.m[0]; + matrix[1] = rot.m[4]; + matrix[2] = rot.m[8]; + matrix[3] = 0; + matrix[4] = rot.m[1]; + matrix[5] = rot.m[5]; + matrix[6] = rot.m[9]; + matrix[7] = 0; + matrix[8] = rot.m[2]; + matrix[9] = rot.m[6]; + matrix[10] = rot.m[10]; + matrix[11] = 0; +} + +void ODEObject::ConvertRotationMatrix(const dReal* matrix, salt::Matrix& rot) const +{ + rot.m[0] = matrix[0] ; + rot.m[4] = matrix[1] ; + rot.m[8] = matrix[2]; + rot.m[12] = matrix[3]; + rot.m[1] = matrix[4]; + rot.m[5] = matrix[5]; + rot.m[9] = matrix[6]; + rot.m[13] = matrix[7]; + rot.m[2] = matrix[8]; + rot.m[6] = matrix[9]; + rot.m[10] = matrix[10] ; + rot.m[14] = matrix[11]; + rot.m[3] = 0.0; + rot.m[7] = 0.0; + rot.m[11] = 0.0; + rot.m[15] = 1.0; +} Copied: trunk/spark/lib/oxygen/physicsserver/odeobject.h (from rev 97, trunk/spark/lib/oxygen/physicsserver/odeobject.h) =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odeobject.h (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/odeobject.h 2009-11-18 07:42:23 UTC (rev 103) @@ -0,0 +1,83 @@ +/* -*- 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$ + $Id$ + + 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_ODEOBJECT_H +#define OXYGEN_ODEOBJECT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/sceneserver/basenode.h> +#include "odewrapper.h" + +namespace oxygen +{ +class Space; +class World; + +/** ODEObject is the base of all classes encapsulating ODE concepts + */ +class OXYGEN_API ODEObject : public BaseNode +{ +public: + // + // 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 */ + dWorldID GetWorldID(); + + /** returns the nearest parent space ODE handle */ + dSpaceID FindSpaceID(); + + /** returns the ODE handle ID of the containing parent space */ + virtual dSpaceID GetParentSpaceID(); + + /** destroy the managed ODE object */ + virtual void DestroyODEObject() = 0; + +protected: + /** returns the world node */ + boost::shared_ptr<World> GetWorld(); + + /** finds the nearest parent space node */ + boost::shared_ptr<Space> GetSpace(); + + /** converts the rotation part of a salt::Matrix to an ODE + dMatrix3 */ + void ConvertRotationMatrix(const salt::Matrix& rot, dMatrix3& matrix); + + /** coverts the ODE dMatrix3 to the rotation part of a salt::Matrix */ + void ConvertRotationMatrix(const dReal* matrix, salt::Matrix& rot) const; +}; + +DECLARE_ABSTRACTCLASS(ODEObject); + +} //namespace oxygen + +#endif //OXYGEN_ODEOBJECT_H Copied: trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp (from rev 97, trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp) =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -0,0 +1,29 @@ +/* -*- mode: c++ -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2003 Koblenz University + $Id$ + + 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 "odeobject.h" + +using namespace oxygen; + +void CLASS(ODEObject)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/BaseNode); +} Copied: trunk/spark/lib/oxygen/physicsserver/odewrapper.h (from rev 97, trunk/spark/lib/oxygen/physicsserver/odewrapper.h) =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odewrapper.h (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/odewrapper.h 2009-11-18 07:42:23 UTC (rev 103) @@ -0,0 +1,80 @@ +/* -*- 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$ + + 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 EXTERN +#undef HAVE_VPRINTF +#undef PACKAGE +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PREFIX +#undef VERSION + +#ifdef WIN32 + +#ifdef copysignf +#undef copysignf +#endif + +#ifdef copysign +#undef copysign +#endif + +#endif // WIN32 + +#ifdef __APPLE__ + +// there is a conflicting type in a system header (Leopard) +// so we define a dummy here +#define uint32 dummy + +#endif + +#include <ode/ode.h> + +#ifdef __APPLE__ + +// undefine the dummy +#undef uint32 + +#endif + +#undef EXTERN +#undef HAVE_VPRINTF +#undef PACKAGE +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION +#undef PREFIX +#undef VERSION + +#ifdef HAVE_CONFIG_H +#include <sparkconfig.h> +#endif + +#endif // OXYGEN_ODEWRAPPER Modified: trunk/spark/lib/oxygen/physicsserver/physicsserver.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/physicsserver.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/physicsserver.h 2009-11-18 07:42:23 UTC (rev 103) @@ -25,7 +25,7 @@ #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odewrapper.h> +#include "odewrapper.h" namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/space.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/space.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/space.h 2009-11-18 07:42:23 UTC (rev 103) @@ -22,7 +22,7 @@ #ifndef OXYGEN_SPACE_H #define OXYGEN_SPACE_H -#include <oxygen/physicsserver/ode/odeobject.h> +#include "odeobject.h" #include <set> #include <oxygen/oxygen_defines.h> Modified: trunk/spark/lib/oxygen/physicsserver/world.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/world.cpp 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/world.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -19,19 +19,16 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <oxygen/physicsserver/ode/odeworld.h> -#include <oxygen/physicsserver/world.h> -#include <oxygen/physicsserver/space.h> +#include "world.h" +#include "space.h" #include <oxygen/sceneserver/scene.h> using namespace boost; using namespace oxygen; using namespace salt; -World::World() : ODEObject() +World::World() : ODEObject(), mODEWorld(0) { - shared_ptr<ODEWorld> odeworld(new ODEWorld()); - mWorldImp = (shared_dynamic_cast<WorldImp>(odeworld)); } World::~World() @@ -40,70 +37,102 @@ dWorldID World::GetODEWorld() const { - return mWorldImp->GetODEWorldImp(); + return mODEWorld; } void World::SetGravity(const Vector3f& gravity) { - mWorldImp->SetGravityImp(gravity); + dWorldSetGravity(mODEWorld, + gravity.x(), + gravity.y(), + gravity.z() + ); } salt::Vector3f World::GetGravity() const { - return mWorldImp->GetGravityImp(); + dVector3 dGravity; + dWorldGetGravity(mODEWorld,dGravity); + return Vector3f(dGravity[0],dGravity[1],dGravity[2]); } void World::SetERP(float erp) { - mWorldImp->SetERPImp(erp); + dWorldSetERP(mODEWorld, erp); } float World::GetERP() const { - return mWorldImp->GetERPImp(); + return dWorldGetERP(mODEWorld); } void World::SetCFM(float cfm) { - mWorldImp->SetCFMImp(cfm); + dWorldSetCFM(mODEWorld, cfm); } float World::GetCFM() const { - return mWorldImp->GetCFMImp(); + return dWorldGetCFM(mODEWorld); } void World::Step(float deltaTime) { - mWorldImp->StepImp(deltaTime); + dWorldStep(mODEWorld, deltaTime); } bool World::GetAutoDisableFlag() const { - return mWorldImp->GetAutoDisableFlagImp(); + return (dWorldGetAutoDisableFlag(mODEWorld) == 1); } void World::SetAutoDisableFlag(bool flag) { - mWorldImp->SetAutoDisableFlagImp(flag); + dWorldSetAutoDisableFlag(mODEWorld, static_cast<int>(flag)); } void World::SetContactSurfaceLayer(float depth) { - mWorldImp->SetContactSurfaceLayerImp(depth); + dWorldSetContactSurfaceLayer(mODEWorld, depth); } float World::GetContactSurfaceLayer() const { - return mWorldImp->GetContactSurfaceLayerImp(); + return dWorldGetContactSurfaceLayer(mODEWorld); } bool World::ConstructInternal() { - return mWorldImp->ConstructInternalImp(); + // create an ode world + mODEWorld = dWorldCreate(); + + return (mODEWorld != 0); } void World::DestroyODEObject() { - mWorldImp->DestroyODEObjectImp(); + 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; } Modified: trunk/spark/lib/oxygen/physicsserver/world.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/world.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/world.h 2009-11-18 07:42:23 UTC (rev 103) @@ -23,14 +23,11 @@ #define OXYGEN_WORLD_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/ode/odeobject.h> +#include "odeobject.h" namespace oxygen { -class WorldImp; -class ODEWorld; - /** World encapsulates an ODE world object. It is a container for rigid bodies and joints. Objects in different worlds can not interact, for example rigid bodies from two different worlds can @@ -116,11 +113,12 @@ // Members // private: - boost::shared_ptr<WorldImp> mWorldImp; + /** the dynamics world represented by this object */ + dWorldID mODEWorld; }; DECLARE_CLASS(World); -} +}; #endif //OXYGEN_WORLD_H Modified: trunk/spark/lib/oxygen/physicsserver/world_c.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/world_c.cpp 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/lib/oxygen/physicsserver/world_c.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -19,7 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <oxygen/physicsserver/world.h> +#include "world.h" using namespace boost; using namespace oxygen; Modified: trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp =================================================================== --- trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp 2009-11-18 07:42:23 UTC (rev 103) @@ -21,7 +21,7 @@ */ #include "forceresistanceperceptor.h" -#include <oxygen/physicsserver/ode/odewrapper.h> +#include <oxygen/physicsserver/odewrapper.h> #include <oxygen/sceneserver/transform.h> using namespace std; Modified: trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.h =================================================================== --- trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.h 2009-11-18 07:24:29 UTC (rev 102) +++ trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.h 2009-11-18 07:42:23 UTC (rev 103) @@ -24,7 +24,7 @@ #define FORCERESISTANCEPERCEPTOR_H_ #include <oxygen/agentaspect/perceptor.h> -#include <oxygen/physicsserver/ode/odewrapper.h> +#include <oxygen/physicsserver/odewrapper.h> #include <oxygen/sceneserver/transform.h> #include <salt/vector.h> #include <list> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |