From: <a-...@us...> - 2009-11-17 11:29:38
|
Revision: 99 http://simspark.svn.sourceforge.net/simspark/?rev=99&view=rev Author: a-held Date: 2009-11-17 11:29:29 +0000 (Tue, 17 Nov 2009) Log Message: ----------- Reverted changes in last revision added abstract layer on World via bridge pattern refactored CappedCylinder to Capsule moved ODE-specific classes to a new ODE folder moved implementation classes to a new imp folder 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/imp/ trunk/spark/lib/oxygen/physicsserver/imp/worldimp.h trunk/spark/lib/oxygen/physicsserver/imp/worldimp_c.cpp trunk/spark/lib/oxygen/physicsserver/ode/ trunk/spark/lib/oxygen/physicsserver/ode/odeobject.cpp trunk/spark/lib/oxygen/physicsserver/ode/odeobject.h trunk/spark/lib/oxygen/physicsserver/ode/odeobject_c.cpp trunk/spark/lib/oxygen/physicsserver/ode/odeworld.cpp trunk/spark/lib/oxygen/physicsserver/ode/odeworld.h trunk/spark/lib/oxygen/physicsserver/ode/odeworld_c.cpp trunk/spark/lib/oxygen/physicsserver/ode/odewrapper.h Removed 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 Modified: trunk/spark/lib/oxygen/CMakeLists.txt =================================================================== --- trunk/spark/lib/oxygen/CMakeLists.txt 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/CMakeLists.txt 2009-11-17 11:29:29 UTC (rev 99) @@ -21,8 +21,6 @@ physicsserver/collider.h physicsserver/collisionhandler.h physicsserver/contactjointhandler.h - physicsserver/odeobject.h - physicsserver/odewrapper.h physicsserver/physicsserver.h physicsserver/planecollider.h physicsserver/raycollider.h @@ -41,6 +39,15 @@ 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 @@ -116,8 +123,6 @@ 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 @@ -152,6 +157,16 @@ 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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/oxygen.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -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,6 +86,11 @@ 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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/oxygen.h 2009-11-17 11:29:29 UTC (rev 99) @@ -34,6 +34,7 @@ #include "gamecontrolserver/actionobject.h" #include "gamecontrolserver/behavior.h" +//abstract physics classes #include "physicsserver/body.h" #include "physicsserver/bodycontroller.h" #include "physicsserver/dragcontroller.h" @@ -42,7 +43,6 @@ #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,6 +60,13 @@ #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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/body.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -339,7 +339,7 @@ // direction: (1=x, 2=y, 3=z) int direction = 3; - dMassSetCappedCylinder (&mass, density, direction, radius, length); + dMassSetCapsule (&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; - dMassSetCappedCylinderTotal(&mass, total_mass, direction, radius, length); + dMassSetCapsuleTotal(&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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/body.h 2009-11-17 11:29:29 UTC (rev 99) @@ -23,7 +23,7 @@ #define OXYGEN_BODY_H #include <oxygen/oxygen_defines.h> -#include "odeobject.h" +#include <oxygen/physicsserver/ode/odeobject.h> namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/boxcollider.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/boxcollider.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/boxcollider.h 2009-11-17 11:29:29 UTC (rev 99) @@ -23,7 +23,7 @@ #define OXYGEN_BOXCOLLIDER_H #include <oxygen/oxygen_defines.h> -#include "collider.h" +#include <oxygen/physicsserver/collider.h> namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/collider.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/collider.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/collider.h 2009-11-17 11:29:29 UTC (rev 99) @@ -22,7 +22,7 @@ #ifndef OXYGEN_COLLIDER_H #define OXYGEN_COLLIDER_H -#include "odeobject.h" +#include <oxygen/physicsserver/ode/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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/collisionhandler.h 2009-11-17 11:29:29 UTC (rev 99) @@ -24,7 +24,7 @@ #include <oxygen/sceneserver/basenode.h> #include <oxygen/oxygen_defines.h> -#include "odewrapper.h" +#include <oxygen/physicsserver/ode/odewrapper.h> namespace oxygen { Added: trunk/spark/lib/oxygen/physicsserver/imp/worldimp.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/imp/worldimp.h (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/imp/worldimp.h 2009-11-17 11:29:29 UTC (rev 99) @@ -0,0 +1,116 @@ +/* -*- 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: world.h 56 2009-03-17 18:03:47Z hedayat $ + + 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_WORLDIMP_H +#define OXYGEN_WORLDIMP_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odeobject.h> + +namespace oxygen +{ + +/** 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 + not collide. All the objects in a world exist at the same point in + time, thus one reason to use separate worlds is to simulate + systems at different rates. +*/ +class OXYGEN_API WorldImp : public ODEObject +{ + // + // Functions + // +public: + WorldImp() : ODEObject(){}; + virtual ~WorldImp(){}; + + /** returns the ID of the managed ODE world */ + virtual dWorldID GetODEWorldImp() const = 0; + + /** sets the gravity vector of this vorld */ + virtual void SetGravityImp(const salt::Vector3f& gravity) = 0; + + /** gets the gravity vector of this world */ + virtual salt::Vector3f GetGravityImp() const = 0; + + /** sets the Error Reduction Parameter of this world. The ERP + specifies what proportion of a joint error will be fixed + during the next simulation step. if ERP=0 then no correcting + force is applied and the bodies will eventually drift apart as + the simulation proceeds. If ERP=1 then the simulation will + attempt to fix all joint error during the next time + step. However, setting ERP=1 is not recommended, as the joint + error will not be completely fixed due to various internal + approximations. A value of ERP=0.1 to 0.8 is recommended (0.2 + is the default). + */ + virtual void SetERPImp(float erp) = 0; + + /** returns the Error Reduction Parameter of this World. + */ + virtual float GetERPImp() const = 0; + + /** sets the Constraint Force mixing (CFM) value. If CFM is set to + zero, the constraint will be hard. If CFM is set to a positive + value, it will be possible to violate the constraint by + `pushing on it' (for example, for contact constraints by + forcing the two contacting objects together). In other words + the constraint will be soft, and the softness will increase as + CFM increases. Note that setting CFM to a negative value can + have undesirable bad effects, such as instability. + */ + virtual void SetCFMImp(float cfm) = 0; + + /** returns the Constraint Force mixing (CFM) value. */ + virtual float GetCFMImp() const = 0; + + /** steps the world deltatime forward, i.e. performs physics + simulation for a deltaTime seconds interval. + */ + virtual void StepImp(float deltaTime) = 0; + + virtual bool GetAutoDisableFlagImp() const = 0; + virtual void SetAutoDisableFlagImp(bool flag) = 0; + + /** 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. + */ + virtual void SetContactSurfaceLayerImp(float depth) = 0; + virtual float GetContactSurfaceLayerImp() const = 0; + + /** destroy the managed ODE object */ + virtual void DestroyODEObjectImp() = 0; + + /** creates them managed ODE world */ + virtual bool ConstructInternalImp() = 0; +}; + +DECLARE_ABSTRACTCLASS(WorldImp); + +} + +#endif //OXYGEN_WORLDIMP_H Added: trunk/spark/lib/oxygen/physicsserver/imp/worldimp_c.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/imp/worldimp_c.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/imp/worldimp_c.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -0,0 +1,29 @@ +/* -*- 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: world_c.cpp 3 2008-11-21 02:38:08Z hedayat $ + +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 <oxygen/physicsserver/imp/worldimp.h> + +using namespace oxygen; + +void CLASS(WorldImp)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/ODEObject); +} Modified: trunk/spark/lib/oxygen/physicsserver/joint.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/joint.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/joint.h 2009-11-17 11:29:29 UTC (rev 99) @@ -23,7 +23,7 @@ #define OXYGEN_JOINT_H #include <oxygen/oxygen_defines.h> -#include "odeobject.h" +#include <oxygen/physicsserver/ode/odeobject.h> namespace oxygen { Added: trunk/spark/lib/oxygen/physicsserver/ode/odeobject.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odeobject.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odeobject.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -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: odeobject.cpp 3 2008-11-21 02:38:08Z hedayat $ + + 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 <oxygen/physicsserver/ode/odeobject.h> +#include <oxygen/physicsserver/space.h> +#include <oxygen/physicsserver/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; +} Added: trunk/spark/lib/oxygen/physicsserver/ode/odeobject.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odeobject.h (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odeobject.h 2009-11-17 11:29:29 UTC (rev 99) @@ -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: odeobject.h 56 2009-03-17 18:03:47Z hedayat $ + $Id: odeobject.h 56 2009-03-17 18:03:47Z hedayat $ + + 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 <oxygen/physicsserver/ode/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(){}; + +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 Added: trunk/spark/lib/oxygen/physicsserver/ode/odeobject_c.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odeobject_c.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odeobject_c.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -0,0 +1,29 @@ +/* -*- mode: c++ -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2003 Koblenz University + $Id: odeobject_c.cpp 3 2008-11-21 02:38:08Z hedayat $ + + 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 <oxygen/physicsserver/ode/odeobject.h> + +using namespace oxygen; + +void CLASS(ODEObject)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/BaseNode); +} Added: trunk/spark/lib/oxygen/physicsserver/ode/odeworld.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odeworld.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odeworld.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -0,0 +1,138 @@ +/* -*- mode: c++ -*- + + this file is part of rcssserver3D + Fri May 9 2003 + Copyright (C) 2003 Koblenz University + $Id: world.cpp 3 2008-11-21 02:38:08Z hedayat $ + + 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 <oxygen/physicsserver/ode/odeworld.h> +#include <oxygen/physicsserver/space.h> +#include <oxygen/sceneserver/scene.h> + +using namespace boost; +using namespace oxygen; +using namespace salt; + +ODEWorld::ODEWorld() : WorldImp(), mODEWorld(0) +{ +} + +ODEWorld::~ODEWorld() +{ +} + +dWorldID ODEWorld::GetODEWorldImp() const +{ + return mODEWorld; +} + +void ODEWorld::SetGravityImp(const Vector3f& gravity) +{ + dWorldSetGravity(mODEWorld, + gravity.x(), + gravity.y(), + gravity.z() + ); +} + +salt::Vector3f ODEWorld::GetGravityImp() const +{ + dVector3 dGravity; + dWorldGetGravity(mODEWorld,dGravity); + return Vector3f(dGravity[0],dGravity[1],dGravity[2]); +} + +void ODEWorld::SetERPImp(float erp) +{ + dWorldSetERP(mODEWorld, erp); +} + +float ODEWorld::GetERPImp() const +{ + return dWorldGetERP(mODEWorld); +} + +void ODEWorld::SetCFMImp(float cfm) +{ + dWorldSetCFM(mODEWorld, cfm); +} + +float ODEWorld::GetCFMImp() const +{ + return dWorldGetCFM(mODEWorld); +} + +void ODEWorld::StepImp(float deltaTime) +{ + dWorldStep(mODEWorld, deltaTime); +} + +bool ODEWorld::GetAutoDisableFlagImp() const +{ + return (dWorldGetAutoDisableFlag(mODEWorld) == 1); +} + +void ODEWorld::SetAutoDisableFlagImp(bool flag) +{ + dWorldSetAutoDisableFlag(mODEWorld, static_cast<int>(flag)); +} + +void ODEWorld::SetContactSurfaceLayerImp(float depth) +{ + dWorldSetContactSurfaceLayer(mODEWorld, depth); +} + +float ODEWorld::GetContactSurfaceLayerImp() const +{ + return dWorldGetContactSurfaceLayer(mODEWorld); +} + +bool ODEWorld::ConstructInternalImp() +{ + // create an ode world + mODEWorld = dWorldCreate(); + + return (mODEWorld != 0); +} + +void ODEWorld::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; +} Added: trunk/spark/lib/oxygen/physicsserver/ode/odeworld.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odeworld.h (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odeworld.h 2009-11-17 11:29:29 UTC (rev 99) @@ -0,0 +1,124 @@ +/* -*- 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: world.h 56 2009-03-17 18:03:47Z hedayat $ + + 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_ODEWORLD_H +#define OXYGEN_ODEWORLD_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/imp/worldimp.h> + +namespace oxygen +{ + +/** 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 + not collide. All the objects in a world exist at the same point in + time, thus one reason to use separate worlds is to simulate + systems at different rates. +*/ +class OXYGEN_API ODEWorld : public WorldImp +{ + // + // Functions + // +public: + ODEWorld(); + virtual ~ODEWorld(); + + /** returns the ID of the managed ODE world */ + dWorldID GetODEWorldImp() const; + + /** sets the gravity vector of this vorld */ + void SetGravityImp(const salt::Vector3f& gravity); + + /** gets the gravity vector of this world */ + salt::Vector3f GetGravityImp() const; + + /** sets the Error Reduction Parameter of this world. The ERP + specifies what proportion of a joint error will be fixed + during the next simulation step. if ERP=0 then no correcting + force is applied and the bodies will eventually drift apart as + the simulation proceeds. If ERP=1 then the simulation will + attempt to fix all joint error during the next time + step. However, setting ERP=1 is not recommended, as the joint + error will not be completely fixed due to various internal + approximations. A value of ERP=0.1 to 0.8 is recommended (0.2 + is the default). + */ + void SetERPImp(float erp); + + /** returns the Error Reduction Parameter of this World. + */ + float GetERPImp() const; + + /** sets the Constraint Force mixing (CFM) value. If CFM is set to + zero, the constraint will be hard. If CFM is set to a positive + value, it will be possible to violate the constraint by + `pushing on it' (for example, for contact constraints by + forcing the two contacting objects together). In other words + the constraint will be soft, and the softness will increase as + CFM increases. Note that setting CFM to a negative value can + have undesirable bad effects, such as instability. + */ + void SetCFMImp(float cfm); + + /** returns the Constraint Force mixing (CFM) value. */ + float GetCFMImp() const; + + /** steps the world deltatime forward, i.e. performs physics + simulation for a deltaTime seconds interval. + */ + void StepImp(float deltaTime); + + bool GetAutoDisableFlagImp() const; + void SetAutoDisableFlagImp(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 SetContactSurfaceLayerImp(float depth); + float GetContactSurfaceLayerImp() const; + + /** destroy the managed ODE object */ + virtual void DestroyODEObjectImp(); + +protected: + /** creates them managed ODE world */ + virtual bool ConstructInternalImp(); + + // + // Members + // +private: + /** the dynamics world represented by this object */ + dWorldID mODEWorld; +}; + +DECLARE_CLASS(ODEWorld); + +}; + +#endif //OXYGEN_WORLD_H Added: trunk/spark/lib/oxygen/physicsserver/ode/odeworld_c.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odeworld_c.cpp (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odeworld_c.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -0,0 +1,29 @@ +/* -*- 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: world_c.cpp 3 2008-11-21 02:38:08Z hedayat $ + +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 <oxygen/physicsserver/ode/odeworld.h> + +using namespace oxygen; + +void CLASS(ODEWorld)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/WorldImp); +} Added: trunk/spark/lib/oxygen/physicsserver/ode/odewrapper.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/ode/odewrapper.h (rev 0) +++ trunk/spark/lib/oxygen/physicsserver/ode/odewrapper.h 2009-11-17 11:29:29 UTC (rev 99) @@ -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: odewrapper.h 3 2008-11-21 02:38:08Z hedayat $ + + 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 Deleted: trunk/spark/lib/oxygen/physicsserver/odeobject.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odeobject.cpp 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/odeobject.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -1,167 +0,0 @@ -/* -*- 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; -} Deleted: trunk/spark/lib/oxygen/physicsserver/odeobject.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odeobject.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/odeobject.h 2009-11-17 11:29:29 UTC (rev 99) @@ -1,83 +0,0 @@ -/* -*- 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 Deleted: trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/odeobject_c.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -1,29 +0,0 @@ -/* -*- 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); -} Deleted: trunk/spark/lib/oxygen/physicsserver/odewrapper.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/odewrapper.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/odewrapper.h 2009-11-17 11:29:29 UTC (rev 99) @@ -1,80 +0,0 @@ -/* -*- 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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/physicsserver.h 2009-11-17 11:29:29 UTC (rev 99) @@ -25,7 +25,7 @@ #include <zeitgeist/class.h> #include <zeitgeist/leaf.h> #include <oxygen/oxygen_defines.h> -#include "odewrapper.h" +#include <oxygen/physicsserver/ode/odewrapper.h> namespace oxygen { Modified: trunk/spark/lib/oxygen/physicsserver/space.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/space.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/space.h 2009-11-17 11:29:29 UTC (rev 99) @@ -22,7 +22,7 @@ #ifndef OXYGEN_SPACE_H #define OXYGEN_SPACE_H -#include "odeobject.h" +#include <oxygen/physicsserver/ode/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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/world.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -19,16 +19,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "world.h" -#include "space.h" +#include <oxygen/physicsserver/ode/odeworld.h> +#include <oxygen/physicsserver/world.h> +#include <oxygen/physicsserver/space.h> #include <oxygen/sceneserver/scene.h> using namespace boost; using namespace oxygen; using namespace salt; -World::World() : ODEObject(), mODEWorld(0) +World::World() : ODEObject() { + shared_ptr<ODEWorld> odeworld(new ODEWorld()); + mWorldImp = (shared_dynamic_cast<WorldImp>(odeworld)); } World::~World() @@ -37,102 +40,70 @@ dWorldID World::GetODEWorld() const { - return mODEWorld; + return mWorldImp->GetODEWorldImp(); } void World::SetGravity(const Vector3f& gravity) { - dWorldSetGravity(mODEWorld, - gravity.x(), - gravity.y(), - gravity.z() - ); + mWorldImp->SetGravityImp(gravity); } salt::Vector3f World::GetGravity() const { - dVector3 dGravity; - dWorldGetGravity(mODEWorld,dGravity); - return Vector3f(dGravity[0],dGravity[1],dGravity[2]); + return mWorldImp->GetGravityImp(); } void World::SetERP(float erp) { - dWorldSetERP(mODEWorld, erp); + mWorldImp->SetERPImp(erp); } float World::GetERP() const { - return dWorldGetERP(mODEWorld); + return mWorldImp->GetERPImp(); } void World::SetCFM(float cfm) { - dWorldSetCFM(mODEWorld, cfm); + mWorldImp->SetCFMImp(cfm); } float World::GetCFM() const { - return dWorldGetCFM(mODEWorld); + return mWorldImp->GetCFMImp(); } void World::Step(float deltaTime) { - dWorldStep(mODEWorld, deltaTime); + mWorldImp->StepImp(deltaTime); } bool World::GetAutoDisableFlag() const { - return (dWorldGetAutoDisableFlag(mODEWorld) == 1); + return mWorldImp->GetAutoDisableFlagImp(); } void World::SetAutoDisableFlag(bool flag) { - dWorldSetAutoDisableFlag(mODEWorld, static_cast<int>(flag)); + mWorldImp->SetAutoDisableFlagImp(flag); } void World::SetContactSurfaceLayer(float depth) { - dWorldSetContactSurfaceLayer(mODEWorld, depth); + mWorldImp->SetContactSurfaceLayerImp(depth); } float World::GetContactSurfaceLayer() const { - return dWorldGetContactSurfaceLayer(mODEWorld); + return mWorldImp->GetContactSurfaceLayerImp(); } bool World::ConstructInternal() { - // create an ode world - mODEWorld = dWorldCreate(); - - return (mODEWorld != 0); + return mWorldImp->ConstructInternalImp(); } 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; + mWorldImp->DestroyODEObjectImp(); } Modified: trunk/spark/lib/oxygen/physicsserver/world.h =================================================================== --- trunk/spark/lib/oxygen/physicsserver/world.h 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/world.h 2009-11-17 11:29:29 UTC (rev 99) @@ -23,11 +23,14 @@ #define OXYGEN_WORLD_H #include <oxygen/oxygen_defines.h> -#include "odeobject.h" +#include <oxygen/physicsserver/ode/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 @@ -113,12 +116,11 @@ // Members // private: - /** the dynamics world represented by this object */ - dWorldID mODEWorld; + boost::shared_ptr<WorldImp> mWorldImp; }; 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-16 10:24:11 UTC (rev 98) +++ trunk/spark/lib/oxygen/physicsserver/world_c.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -19,7 +19,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "world.h" +#include <oxygen/physicsserver/world.h> using namespace boost; using namespace oxygen; Modified: trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp =================================================================== --- trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp 2009-11-16 10:24:11 UTC (rev 98) +++ trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.cpp 2009-11-17 11:29:29 UTC (rev 99) @@ -21,7 +21,7 @@ */ #include "forceresistanceperceptor.h" -#include <oxygen/physicsserver/odewrapper.h> +#include <oxygen/physicsserver/ode/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-16 10:24:11 UTC (rev 98) +++ trunk/spark/plugin/collisionperceptor/forceresistanceperceptor.h 2009-11-17 11:29:29 UTC (rev 99) @@ -24,7 +24,7 @@ #define FORCERESISTANCEPERCEPTOR_H_ #include <oxygen/agentaspect/perceptor.h> -#include <oxygen/physicsserver/odewrapper.h> +#include <oxygen/physicsserver/ode/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. |