From: <a-...@us...> - 2009-11-19 06:49:34
|
Revision: 104 http://simspark.svn.sourceforge.net/simspark/?rev=104&view=rev Author: a-held Date: 2009-11-19 06:49:26 +0000 (Thu, 19 Nov 2009) Log Message: ----------- removed unnecessary Imp suffixes and redundant documentation changed name of Imp folder to Int (since they are INTerfaces) prepared bridge pattern for spaces Modified Paths: -------------- branches/multiphys/spark/lib/oxygen/CMakeLists.txt branches/multiphys/spark/lib/oxygen/oxygen.cpp branches/multiphys/spark/lib/oxygen/oxygen.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.h branches/multiphys/spark/lib/oxygen/physicsserver/world.cpp branches/multiphys/spark/lib/oxygen/physicsserver/world.h Added Paths: ----------- branches/multiphys/spark/lib/oxygen/physicsserver/imp/ branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint.h branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint_c.cpp branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint.h branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint_c.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.cpp branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.h branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace_c.cpp Removed Paths: ------------- branches/multiphys/spark/lib/oxygen/physicsserver/imp/ Modified: branches/multiphys/spark/lib/oxygen/CMakeLists.txt =================================================================== --- branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2009-11-19 06:49:26 UTC (rev 104) @@ -41,7 +41,7 @@ physicsserver/angularmotor.h #interfaces - physicsserver/imp/worldimp.h + physicsserver/int/worldint.h #ode-specific files physicsserver/ode/odeobject.h @@ -159,9 +159,12 @@ physicsserver/angularmotor_c.cpp #interfaces - physicsserver/imp/worldimp_c.cpp + physicsserver/int/worldint_c.cpp + physicsserver/int/spaceint_c.cpp #ODE-specific files + physicsserver/ode/odespace.cpp + physicsserver/ode/odespace_c.cpp physicsserver/ode/odeworld.cpp physicsserver/ode/odeworld_c.cpp physicsserver/ode/odeobject.cpp Modified: branches/multiphys/spark/lib/oxygen/oxygen.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/oxygen.cpp 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/oxygen.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -59,7 +59,6 @@ zg.GetCore()->RegisterClassObject(new CLASS(VelocityController), "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/"); @@ -89,7 +88,6 @@ //ODE-specific classes zg.GetCore()->RegisterClassObject(new CLASS(ODEObject), "oxygen/"); - zg.GetCore()->RegisterClassObject(new CLASS(ODEWorld), "oxygen/"); #ifdef HAVE_SPADES_HEADERS Modified: branches/multiphys/spark/lib/oxygen/oxygen.h =================================================================== --- branches/multiphys/spark/lib/oxygen/oxygen.h 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/oxygen.h 2009-11-19 06:49:26 UTC (rev 104) @@ -60,12 +60,8 @@ #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" Added: branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint.h 2009-11-19 06:49:26 UTC (rev 104) @@ -0,0 +1,68 @@ +/* -*- 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: space.h 102 2009-11-18 07:24:29Z a-held $ + + 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_SPACEINT_H +#define OXYGEN_SPACEINT_H + +#include <oxygen/physicsserver/ode/odeobject.h> +#include <set> +#include <oxygen/oxygen_defines.h> + +namespace oxygen +{ +class Transform; +class Body; +class Collider; + +class OXYGEN_API SpaceInt : public ODEObject +{ + +public: + typedef std::set<dSpaceID> TSpaceIdSet; + + SpaceInt() : ODEObject(){}; + virtual ~SpaceInt(){}; + + //virtual void collisionNearCallback (void *data, dGeomID obj1, dGeomID obj2) = 0; + virtual dSpaceID GetODESpace() const = 0; + virtual dJointGroupID GetODEJointGroup() const = 0; + virtual void Collide() = 0; + virtual void DestroyODEObject() = 0; + virtual dSpaceID GetParentSpaceID() = 0; + virtual bool IsGlobalSpace() = 0; + virtual void DisableInnerCollision(bool disable) = 0; + virtual bool GetDisableInnerCollision() const = 0; + virtual void OnUnlink() = 0; + virtual void OnLink() = 0; + virtual void Collide(dSpaceID space) = 0; + virtual void HandleCollide(dGeomID obj1, dGeomID obj2) = 0; + virtual void HandleSpaceCollide(dGeomID obj1, dGeomID obj2) = 0; + virtual bool ConstructInternal() = 0; + virtual void PostPhysicsUpdateInternal() = 0; + virtual void DestroySpaceObjects() = 0; +}; + +DECLARE_ABSTRACTCLASS(SpaceInt); + +} //namespace oxygen + +#endif //OXYGEN_SPACEINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint_c.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint_c.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/imp/spaceint_c.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -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/int/spaceint.h> + +using namespace oxygen; + +void CLASS(SpaceInt)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/ODEObject); +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint.h 2009-11-19 06:49:26 UTC (rev 104) @@ -0,0 +1,58 @@ +/* -*- 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_WORLDINT_H +#define OXYGEN_WORLDINT_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/ode/odeobject.h> + +namespace oxygen +{ + +class OXYGEN_API WorldInt : public ODEObject +{ + +public: + WorldInt() : ODEObject(){}; + virtual ~WorldInt(){}; + + virtual dWorldID GetODEWorld() const = 0; + virtual void SetGravity(const salt::Vector3f& gravity) = 0; + virtual salt::Vector3f GetGravity() const = 0; + virtual void SetERP(float erp) = 0; + virtual float GetERP() const = 0; + virtual void SetCFM(float cfm) = 0; + virtual float GetCFM() const = 0; + virtual void Step(float deltaTime) = 0; + virtual bool GetAutoDisableFlag() const = 0; + virtual void SetAutoDisableFlag(bool flag) = 0; + virtual void SetContactSurfaceLayer(float depth) = 0; + virtual float GetContactSurfaceLayer() const = 0; + virtual void DestroyODEObject() = 0; + virtual bool ConstructInternal() = 0; +}; + +DECLARE_ABSTRACTCLASS(WorldInt); + +} + +#endif //OXYGEN_WORLDINT_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint_c.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint_c.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/imp/worldint_c.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -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/int/worldint.h> + +using namespace oxygen; + +void CLASS(WorldInt)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/ODEObject); +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -0,0 +1,332 @@ +/* -*- 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: space.cpp 80 2009-07-30 17:25:42Z 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/odespace.h> +#include <oxygen/physicsserver/world.h> +#include <oxygen/physicsserver/collider.h> +#include <oxygen/physicsserver/space.h> +#include <oxygen/sceneserver/scene.h> +#include <zeitgeist/logserver/logserver.h> + +using namespace boost; +using namespace oxygen; + +/** set of spaces with disabled inner collision */ +ODESpace::TSpaceIdSet ODESpace::gDisabledInnerCollisionSet; + +//void ODESpace::collisionNearCallback (void *data, dGeomID obj1, dGeomID obj2) +//{ + // Space *space = (Space*)data; + // space->HandleCollide(obj1, obj2); +//} + +ODESpace::ODESpace() : SpaceInt(), mODESpace(0), mODEContactGroup(0) +{ +} + +ODESpace::~ODESpace() +{ +} + +dSpaceID ODESpace::GetODESpace() const +{ + return mODESpace; +} + +dJointGroupID ODESpace::GetODEJointGroup() const +{ + return mODEContactGroup; +} + +void ODESpace::Collide() +{ + // bind collision callback function to this object + Collide(mODESpace); +} + +void ODESpace::Collide(dSpaceID space) +{ + if (gDisabledInnerCollisionSet.find(space) == gDisabledInnerCollisionSet.end()) + { + //dSpaceCollide(space, this, Space::collisionNearCallback); + } +} + +void ODESpace::HandleSpaceCollide(dGeomID obj1, dGeomID obj2) +{ + // collide all geoms internal to the space(s) + //dSpaceCollide2 (obj1,obj2,this,&Space::collisionNearCallback); + + if (dGeomIsSpace (obj1)) + { + Collide((dSpaceID)obj1); + } + + if (dGeomIsSpace (obj2)) + { + Collide((dSpaceID)obj2); + } +} + +void ODESpace::HandleCollide(dGeomID obj1, dGeomID obj2) +{ + if ( + (dGeomIsSpace (obj1)) || + (dGeomIsSpace (obj2)) + ) + { + // colliding a space with something + HandleSpaceCollide(obj1, obj2); + return; + } + + // colliding two non-space geoms; reject collisions + // between bodies that are connected with joints + const dBodyID b1 = dGeomGetBody(obj1); + const dBodyID b2 = dGeomGetBody(obj2); + + if ( + (b1) && (b2) && + (dAreConnectedExcluding(b1,b2,dJointTypeContact)) + ) + { + return; + } + + // if obj1 and obj2 are in a space that disabled inner collision, + // reject the collision + const dSpaceID s1 = dGeomGetSpace(obj1); + const dSpaceID s2 = dGeomGetSpace(obj2); + + // NOTICE: this should not happen since it is checked in Collide(dSpaceID) +// if ( +// (s1 == s2) && +// (gDisabledInnerCollisionSet.find(s1) != gDisabledInnerCollisionSet.end()) +// ) +// { +// return; +// } + + + // if obj1 and obj2 are in the same space, and + // obj1 is in obj2's "mNotCollideWithSet" or ojb2 is in obj1's + // reject the collision + + // get shared pointers to the two corresponding Collider nodes first + shared_ptr<Collider> collider = Collider::GetCollider(obj1); + shared_ptr<Collider> collidee = Collider::GetCollider(obj2); + + if ( + (collider.get() == 0) || + (collidee.get() == 0) + ) + { + return; + } + + if (s1 == s2) + { + const oxygen::Collider::TColliderNameSet & collider_set = collider->GetNotCollideWithSet(); + const oxygen::Collider::TColliderNameSet & collidee_set = collidee->GetNotCollideWithSet(); + if ( + (collider_set.find(collidee->GetName()) != collider_set.end()) || + (collidee_set.find(collider->GetName()) != collidee_set.end()) + ) + { + return; + } + } + + // dSpaceCollide(), is guaranteed to pass all potentially + // intersecting geom pairs to the callback function, but depending + // on the internal algorithms used by the space it may also make + // mistakes and pass non-intersecting pairs. Thus we can not + // expect that dCollide() will return contacts for every pair + // passed to the callback. + static const int nContacts = 4; + static dContact contacts[nContacts]; + + int n = dCollide (obj1, obj2, nContacts, + &contacts[0].geom, sizeof(dContact)); + + if (n == 0) + { + return; + } + + + for (int i=0;i<n;++i) + { + // notify the collider nodes + collider->OnCollision(collidee,contacts[i],Collider::CT_DIRECT); + collidee->OnCollision(collider,contacts[i],Collider::CT_SYMMETRIC); + } +} + +void ODESpace::OnUnlink() +{ + DisableInnerCollision(false); + ODEObject::OnUnlink(); +} + +void ODESpace::OnLink() +{ + ODEObject::OnLink(); + + shared_ptr<Space> space = GetSpace(); + dSpaceID spaceId = 0; + + if (space.get() != 0) + { + spaceId = space->GetODESpace(); + } + + mODESpace = dHashSpaceCreate(spaceId); +} + +dSpaceID ODESpace::GetParentSpaceID() +{ + if (mODESpace == 0) + { + return 0; + } + + return dGeomGetSpace((dGeomID)mODESpace); +} + +bool ODESpace::IsGlobalSpace() +{ + return + ( + (mODESpace != 0) && + (GetParentSpaceID() == 0) + ); +} + +bool ODESpace::ConstructInternal() +{ + // create a joint group for the contacts + mODEContactGroup = dJointGroupCreate(0); + + return (mODEContactGroup != 0); +} + +void ODESpace::PostPhysicsUpdateInternal() +{ + // remove all contact joints + dJointGroupEmpty (mODEContactGroup); +} + +void ODESpace::DestroySpaceObjects() +{ + shared_ptr<Scene> scene = GetScene(); + if (scene.get() == 0) + { + return; + } + + TLeafList objects; + const bool recursive = true; + scene->ListChildrenSupportingClass<ODEObject>(objects, recursive); + + bool globalSpace = IsGlobalSpace(); + shared_ptr<Space> self = shared_static_cast<Space>(GetSelf().lock()); + + for ( + TLeafList::iterator iter = objects.begin(); + iter != objects.end(); + ++iter + ) + { + shared_ptr<ODEObject> object = shared_static_cast<ODEObject>(*iter); + if (object == self) + { + continue; + } + + // destroy objects registered to this space; the top level + // space object also destroy any other ODE object + const dSpaceID parentSpace = object->GetParentSpaceID(); + if ( + ( + (globalSpace) && + (parentSpace == 0) + ) || + (parentSpace == mODESpace) + ) + { + object->DestroyODEObject(); + } + } +} + +void ODESpace::DestroyODEObject() +{ + if (! mODESpace) + { + return; + } + + // make sure that all objects registered to this space are destroyed + // before this space. Any other order provokes a segfault in ODE. + DestroySpaceObjects(); + + if (mODEContactGroup) + { + dJointGroupDestroy(mODEContactGroup); + mODEContactGroup = 0; + } + + // release the ODE space + dSpaceDestroy(mODESpace); + mODESpace = 0; +} + +void ODESpace::DisableInnerCollision(bool disable) +{ + if (mODESpace == 0) + { + //assert(false); + return; + } + + if (disable) + { + gDisabledInnerCollisionSet.insert(mODESpace); + return; + } + + TSpaceIdSet::iterator iter = gDisabledInnerCollisionSet.find(mODESpace); + if (iter == gDisabledInnerCollisionSet.end()) + { + return; + } + + gDisabledInnerCollisionSet.erase(iter); +} + +bool ODESpace::GetDisableInnerCollision() const +{ + TSpaceIdSet::const_iterator iter + = gDisabledInnerCollisionSet.find(mODESpace); + + return (iter != gDisabledInnerCollisionSet.end()); +} Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.h (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace.h 2009-11-19 06:49:26 UTC (rev 104) @@ -0,0 +1,74 @@ +/* -*- 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_ODESPACE_H +#define OXYGEN_ODESPACE_H + +#include <oxygen/oxygen_defines.h> +#include <oxygen/physicsserver/int/spaceint.h> + +namespace oxygen +{ + +class OXYGEN_API ODESpace : public SpaceInt +{ + +public: + typedef std::set<dSpaceID> TSpaceIdSet; + +public: + ODESpace(); + virtual ~ODESpace(); + + dSpaceID GetODESpace() const; + dJointGroupID GetODEJointGroup() const; + void Collide(); + virtual void DestroyODEObject(); + virtual dSpaceID GetParentSpaceID(); + bool IsGlobalSpace(); + void DisableInnerCollision(bool disable); + bool GetDisableInnerCollision() const; + + dSpaceID mODESpace; + +protected: + //void collisionNearCallback (void *data, dGeomID obj1, dGeomID obj2); + virtual void OnUnlink(); + virtual void OnLink(); + void Collide(dSpaceID space); + void HandleCollide(dGeomID obj1, dGeomID obj2); + void HandleSpaceCollide(dGeomID obj1, dGeomID obj2); + virtual bool ConstructInternal(); + virtual void PostPhysicsUpdateInternal(); + void DestroySpaceObjects(); + +private: + dJointGroupID mODEContactGroup; + +private: + static TSpaceIdSet gDisabledInnerCollisionSet; +}; + +DECLARE_CLASS(ODESpace); + +} + +#endif //OXYGEN_ODESPACE_H Added: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace_c.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace_c.cpp (rev 0) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odespace_c.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -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/odespace.h> + +using namespace oxygen; + +void CLASS(ODESpace)::DefineClass() +{ + DEFINE_BASECLASS(oxygen/SpaceInt); +} Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.cpp 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -27,7 +27,7 @@ using namespace oxygen; using namespace salt; -ODEWorld::ODEWorld() : WorldImp(), mODEWorld(0) +ODEWorld::ODEWorld() : WorldInt(), mODEWorld(0) { } @@ -35,12 +35,12 @@ { } -dWorldID ODEWorld::GetODEWorldImp() const +dWorldID ODEWorld::GetODEWorld() const { return mODEWorld; } -void ODEWorld::SetGravityImp(const Vector3f& gravity) +void ODEWorld::SetGravity(const Vector3f& gravity) { dWorldSetGravity(mODEWorld, gravity.x(), @@ -49,59 +49,59 @@ ); } -salt::Vector3f ODEWorld::GetGravityImp() const +salt::Vector3f ODEWorld::GetGravity() const { dVector3 dGravity; dWorldGetGravity(mODEWorld,dGravity); return Vector3f(dGravity[0],dGravity[1],dGravity[2]); } -void ODEWorld::SetERPImp(float erp) +void ODEWorld::SetERP(float erp) { dWorldSetERP(mODEWorld, erp); } -float ODEWorld::GetERPImp() const +float ODEWorld::GetERP() const { return dWorldGetERP(mODEWorld); } -void ODEWorld::SetCFMImp(float cfm) +void ODEWorld::SetCFM(float cfm) { dWorldSetCFM(mODEWorld, cfm); } -float ODEWorld::GetCFMImp() const +float ODEWorld::GetCFM() const { return dWorldGetCFM(mODEWorld); } -void ODEWorld::StepImp(float deltaTime) +void ODEWorld::Step(float deltaTime) { dWorldStep(mODEWorld, deltaTime); } -bool ODEWorld::GetAutoDisableFlagImp() const +bool ODEWorld::GetAutoDisableFlag() const { return (dWorldGetAutoDisableFlag(mODEWorld) == 1); } -void ODEWorld::SetAutoDisableFlagImp(bool flag) +void ODEWorld::SetAutoDisableFlag(bool flag) { dWorldSetAutoDisableFlag(mODEWorld, static_cast<int>(flag)); } -void ODEWorld::SetContactSurfaceLayerImp(float depth) +void ODEWorld::SetContactSurfaceLayer(float depth) { dWorldSetContactSurfaceLayer(mODEWorld, depth); } -float ODEWorld::GetContactSurfaceLayerImp() const +float ODEWorld::GetContactSurfaceLayer() const { return dWorldGetContactSurfaceLayer(mODEWorld); } -bool ODEWorld::ConstructInternalImp() +bool ODEWorld::ConstructInternal() { // create an ode world mODEWorld = dWorldCreate(); @@ -109,7 +109,7 @@ return (mODEWorld != 0); } -void ODEWorld::DestroyODEObjectImp() +void ODEWorld::DestroyODEObject() { static bool recurseLock = false; if (recurseLock) Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.h 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeworld.h 2009-11-19 06:49:26 UTC (rev 104) @@ -23,102 +23,41 @@ #define OXYGEN_ODEWORLD_H #include <oxygen/oxygen_defines.h> -#include <oxygen/physicsserver/imp/worldimp.h> +#include <oxygen/physicsserver/int/worldint.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 +class OXYGEN_API ODEWorld : public WorldInt { - // - // Functions - // + public: ODEWorld(); virtual ~ODEWorld(); - /** returns the ID of the managed ODE world */ - dWorldID GetODEWorldImp() const; + dWorldID GetODEWorld() const; + void SetGravity(const salt::Vector3f& gravity); + salt::Vector3f GetGravity() const; + void SetERP(float erp); + float GetERP() const; + void SetCFM(float cfm); + float GetCFM() const; + void Step(float deltaTime); + bool GetAutoDisableFlag() const; + void SetAutoDisableFlag(bool flag); + void SetContactSurfaceLayer(float depth); + float GetContactSurfaceLayer() const; + virtual void DestroyODEObject(); - /** 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(); + virtual bool ConstructInternal(); - // - // Members - // private: - /** the dynamics world represented by this object */ dWorldID mODEWorld; }; DECLARE_CLASS(ODEWorld); -}; +} -#endif //OXYGEN_WORLD_H +#endif //OXYGEN_ODEWORLD_H Modified: branches/multiphys/spark/lib/oxygen/physicsserver/world.cpp =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/world.cpp 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/physicsserver/world.cpp 2009-11-19 06:49:26 UTC (rev 104) @@ -30,8 +30,7 @@ World::World() : ODEObject() { - shared_ptr<ODEWorld> odeworld(new ODEWorld()); - mWorldImp = (shared_dynamic_cast<WorldImp>(odeworld)); + mWorldImp = shared_ptr<ODEWorld>(new ODEWorld()); } World::~World() @@ -40,70 +39,70 @@ dWorldID World::GetODEWorld() const { - return mWorldImp->GetODEWorldImp(); + return mWorldImp->GetODEWorld(); } void World::SetGravity(const Vector3f& gravity) { - mWorldImp->SetGravityImp(gravity); + mWorldImp->SetGravity(gravity); } salt::Vector3f World::GetGravity() const { - return mWorldImp->GetGravityImp(); + return mWorldImp->GetGravity(); } void World::SetERP(float erp) { - mWorldImp->SetERPImp(erp); + mWorldImp->SetERP(erp); } float World::GetERP() const { - return mWorldImp->GetERPImp(); + return mWorldImp->GetERP(); } void World::SetCFM(float cfm) { - mWorldImp->SetCFMImp(cfm); + mWorldImp->SetCFM(cfm); } float World::GetCFM() const { - return mWorldImp->GetCFMImp(); + return mWorldImp->GetCFM(); } void World::Step(float deltaTime) { - mWorldImp->StepImp(deltaTime); + mWorldImp->Step(deltaTime); } bool World::GetAutoDisableFlag() const { - return mWorldImp->GetAutoDisableFlagImp(); + return mWorldImp->GetAutoDisableFlag(); } void World::SetAutoDisableFlag(bool flag) { - mWorldImp->SetAutoDisableFlagImp(flag); + mWorldImp->SetAutoDisableFlag(flag); } void World::SetContactSurfaceLayer(float depth) { - mWorldImp->SetContactSurfaceLayerImp(depth); + mWorldImp->SetContactSurfaceLayer(depth); } float World::GetContactSurfaceLayer() const { - return mWorldImp->GetContactSurfaceLayerImp(); + return mWorldImp->GetContactSurfaceLayer(); } bool World::ConstructInternal() { - return mWorldImp->ConstructInternalImp(); + return mWorldImp->ConstructInternal(); } void World::DestroyODEObject() { - mWorldImp->DestroyODEObjectImp(); + mWorldImp->DestroyODEObject(); } Modified: branches/multiphys/spark/lib/oxygen/physicsserver/world.h =================================================================== --- branches/multiphys/spark/lib/oxygen/physicsserver/world.h 2009-11-18 07:42:23 UTC (rev 103) +++ branches/multiphys/spark/lib/oxygen/physicsserver/world.h 2009-11-19 06:49:26 UTC (rev 104) @@ -28,7 +28,7 @@ namespace oxygen { -class WorldImp; +class WorldInt; class ODEWorld; /** World encapsulates an ODE world object. It is a container for @@ -116,7 +116,7 @@ // Members // private: - boost::shared_ptr<WorldImp> mWorldImp; + boost::shared_ptr<WorldInt> mWorldImp; }; DECLARE_CLASS(World); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |