|
From: <a-...@us...> - 2010-01-08 07:35:37
|
Revision: 138
http://simspark.svn.sourceforge.net/simspark/?rev=138&view=rev
Author: a-held
Date: 2010-01-08 07:35:25 +0000 (Fri, 08 Jan 2010)
Log Message:
-----------
Implemented bridge pattern for Joint superclass
Created separate file for engine-specific static methods
Modified Paths:
--------------
branches/multiphys/spark/lib/oxygen/CMakeLists.txt
branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/genericphysicsobjects.h
branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.h
branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/hinge2jointint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/hingejointint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/jointint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/sliderjointint.h
branches/multiphys/spark/lib/oxygen/physicsserver/int/universaljointint.h
branches/multiphys/spark/lib/oxygen/physicsserver/joint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/joint.h
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odefixedjoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.h
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/rigidbody.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/sliderjoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/sliderjoint.h
branches/multiphys/spark/lib/oxygen/physicsserver/universaljoint.cpp
branches/multiphys/spark/lib/oxygen/physicsserver/universaljoint.h
Added Paths:
-----------
branches/multiphys/spark/lib/oxygen/physicsserver/staticphysicsmethods.h
branches/multiphys/spark/lib/oxygen/physicsserver/staticphysicsmethods_ode.cpp
Modified: branches/multiphys/spark/lib/oxygen/CMakeLists.txt
===================================================================
--- branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/CMakeLists.txt 2010-01-08 07:35:25 UTC (rev 138)
@@ -39,6 +39,7 @@
physicsserver/recorderhandler.h
physicsserver/space.h
physicsserver/spherecollider.h
+ physicsserver/staticphysicsmethods.h
physicsserver/transformcollider.h
physicsserver/world.h
physicsserver/dragcontroller.h
@@ -89,6 +90,7 @@
physicsserver/int/worldint.h
#ode-specific files
+ physicsserver/staticphysicsmethods_ode.cpp
physicsserver/ode/odeballjoint.h
physicsserver/ode/odebody.h
physicsserver/ode/odeboxcollider.h
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -77,15 +77,12 @@
return GetLocalPos(pos);
}
-void BallJoint::SetParameter(int /*parameter*/, float /*value*/)
-{
- GetLog()->Error() <<
- "(BallJoint) WARNING: SetParameter function undefined for BallJoint, ignored\n";
+void BallJoint::SetParameter(int parameter, float value){
+ GetLog()->Warning()
+ << "(BallJoint) WARNING: SetParameter undefined for BallJoint, call ignored";
}
-float BallJoint::GetParameter(int /*parameter*/) const
-{
- GetLog()->Error() <<
- "(BallJoint) WARNING: GetParameter function undefined for BallJoint, returned zero\n";
- return 0;
+float BallJoint::GetParameter(int parameter) const{
+ GetLog()->Warning()
+ << "(BallJoint) WARNING: SetParameter undefined for BallJoint, call ignored";
}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/balljoint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -44,16 +44,16 @@
anchor point will be the same for both bodies.
*/
salt::Vector3f GetAnchor(EBodyIndex idx);
+
+ /** sets a joint parameter value */
+ virtual void SetParameter(int parameter, float value);
+ /** returns a joint parameter value */
+ virtual float GetParameter(int parameter) const;
+
protected:
/** creates a new contact joint */
virtual void OnLink();
-
- /** sets a joint parameter value */
- virtual void SetParameter(int parameter, float value);
-
- /** returns a joint parameter value */
- virtual float GetParameter(int parameter) const;
private:
boost::shared_ptr<BallJointInt> mBallJointImp;
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/collider.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -23,6 +23,7 @@
#include <oxygen/physicsserver/ode/odecollider.h>
#include <oxygen/physicsserver/collisionhandler.h>
#include <oxygen/physicsserver/space.h>
+#include <oxygen/physicsserver/staticphysicsmethods.h>
#include <oxygen/physicsserver/transformcollider.h>
#include <oxygen/physicsserver/rigidbody.h>
#include <oxygen/sceneserver/scene.h>
@@ -163,7 +164,7 @@
}
Collider* collPtr =
- ColliderInt::GetColliderPointer(geomID);
+ StaticPhysicsMethods::GetColliderPointer(geomID);
if (collPtr == 0)
{
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/genericphysicsobjects.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/genericphysicsobjects.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/genericphysicsobjects.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -37,6 +37,7 @@
class OXYGEN_API GenericPhysicsMatrix{};
class OXYGEN_API GenericContact{};
class OXYGEN_API GenericMass{};
+class OXYGEN_API GenericJointFeedback{};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -113,13 +113,3 @@
return 0;
}
}
-
-void Hinge2Joint::SetParameter(int parameter, float value)
-{
- mHinge2JointImp->SetParameter(parameter, value, mJointID);
-}
-
-float Hinge2Joint::GetParameter(int parameter) const
-{
- return mHinge2JointImp->GetParameter(parameter, mJointID);
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/hinge2joint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -57,12 +57,6 @@
protected:
/** creates a new hinge2 joint */
virtual void OnLink();
-
- /** sets a joint parameter value */
- virtual void SetParameter(int parameter, float value);
-
- /** returns a joint parameter value */
- virtual float GetParameter(int parameter) const;
private:
boost::shared_ptr<Hinge2JointInt> mHinge2JointImp;
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -125,12 +125,6 @@
return mHingeJointImp->GetAngleRate(mJointID);
}
-void HingeJoint::SetParameter(int parameter, float value)
-{
- mHingeJointImp->SetParameter(parameter, value, mJointID);
+void HingeJoint::SetParameter(int parameter, float value){
+ mJointImp->SetParameter(parameter, value, mJointID);
}
-
-float HingeJoint::GetParameter(int parameter) const
-{
- return mHingeJointImp->GetParameter(parameter, mJointID);
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/hingejoint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -68,13 +68,10 @@
/** returns the time derivate of the hinge angle */
float GetAngleRate() const;
+
+ /** Sets a parameter value of this joint*/
+ void SetParameter(int parameter, float value);
- /** sets a joint parameter value */
- virtual void SetParameter(int parameter, float value);
-
- /** returns a joint parameter value */
- virtual float GetParameter(int parameter) const;
-
protected:
/** creates a new hingejoint joint */
virtual void OnLink();
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/colliderint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -48,15 +48,6 @@
virtual void SetSpace(long spaceID, long geomID, Collider* collider) = 0;
virtual void SetBody(long bodyID, long geomID) = 0;
virtual void RemoveFromSpace(long geomID, long spaceID) = 0;
-
- // Here, we have to cheat with the preprocessor, since a static method
- // is required, and the bridge pattern requires member variables to
- // be used (so we cannot use the bridge pattern)
- static Collider* GetColliderPointer(long geomID){
- #ifdef OXYGEN_ODEWRAPPER_H
- return static_cast<Collider*>(dGeomGetData( (dGeomID) geomID));
- #endif
- }
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/hinge2jointint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/hinge2jointint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/hinge2jointint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -38,8 +38,6 @@
virtual float GetAngle(long jointID) = 0;
virtual float GetAngleRate1(long jointID) = 0;
virtual float GetAngleRate2(long jointID) = 0;
- virtual void SetParameter(int parameter, float value, long jointID) = 0;
- virtual float GetParameter(int parameter, long jointID) const = 0;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/hingejointint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/hingejointint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/hingejointint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -36,8 +36,6 @@
virtual salt::Vector3f GetAxis(long jointID) = 0;
virtual float GetAngle(long jointID) const = 0;
virtual float GetAngleRate(long jointID) const = 0;
- virtual void SetParameter(int parameter, float value, long jointID) = 0;
- virtual float GetParameter(int parameter, long jointID) const = 0;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/jointint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/jointint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/jointint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -23,6 +23,7 @@
#ifndef OXYGEN_JOINTINT_H
#define OXYGEN_JOINTINT_H
+#include <oxygen/physicsserver/genericphysicsobjects.h>
#include <oxygen/physicsserver/ode/odewrapper.h>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <salt/vector.h>
@@ -36,89 +37,47 @@
class OXYGEN_API JointInt
{
-public:
- enum EBodyIndex
- {
- BI_FIRST = 0,
- BI_SECOND = 1
- };
-
- enum EAxisIndex
- {
- AI_FIRST = 0,
- AI_SECOND = 1,
- AI_THIRD = 2
- };
-
- static Joint* GetJoint(long jointID){
+public:
- }
-
- static bool AreConnected(boost::shared_ptr<RigidBody> body1,
- boost::shared_ptr<RigidBody> body2){
-
- }
-
- static bool AreConnectedExcluding(boost::shared_ptr<RigidBody> body1,
- boost::shared_ptr<RigidBody> body2,
- int joint_type){
-
- }
-
- virtual void DestroyJoint() = 0;
- virtual void Attach(boost::shared_ptr<RigidBody> body1,
- boost::shared_ptr<RigidBody> body2) = 0;
- virtual void Attach(const std::string& path1, const std::string& path2) = 0;
- virtual int GetType() const = 0;
- virtual boost::shared_ptr<RigidBody> GetBody(EBodyIndex idx) = 0;
- virtual void EnableFeedback(bool enable) = 0;
- virtual bool FeedbackEnabled() const = 0;
- virtual salt::Vector3f GetFeedbackForce(EBodyIndex idx) const = 0;
- virtual salt::Vector3f GetFeedbackTorque(EBodyIndex idx) const = 0;
- virtual void SetFudgeFactor(EAxisIndex idx, float fudge_factor) = 0;
- virtual float GetFudgeFactor(EAxisIndex idx) const = 0;
- virtual void SetBounce(EAxisIndex idx, float bounce) = 0;
- virtual float GetBounce(EAxisIndex idx) const = 0;
- virtual void SetLowStopDeg(EAxisIndex idx, float deg) = 0;
- virtual float GetLowStopDeg(EAxisIndex idx) const = 0;
- virtual void SetHighStopDeg(EAxisIndex idx, float deg) = 0;
- virtual float GetHighStopDeg(EAxisIndex idx) const = 0;
- virtual void SetLowStopPos(EAxisIndex idx, float deg) = 0;
- virtual float GetLowStopPos(EAxisIndex idx) const = 0;
- virtual void SetHighStopPos(EAxisIndex idx, float deg) = 0;
- virtual float GetHighStopPos(EAxisIndex idx) const = 0;
- virtual void SetCFM(EAxisIndex idx, float cfm) = 0;
- virtual float GetCFM(EAxisIndex idx) const = 0;
- virtual void SetStopCFM(EAxisIndex idx, float cfm) = 0;
- virtual float GetStopCFM(EAxisIndex idx) const = 0;
- virtual void SetStopERP(EAxisIndex idx, float erp) = 0;
- virtual float GetStopERP(EAxisIndex idx) const = 0;
- virtual void SetSuspensionERP(EAxisIndex idx, float erp) = 0;
- virtual float GetSuspensionERP(EAxisIndex idx) const = 0;
- virtual void SetSuspensionCFM(EAxisIndex idx, float cfm) = 0;
- virtual float GetSuspensionCFM(EAxisIndex idx) const = 0;
- virtual void SetLinearMotorVelocity(EAxisIndex idx, float vel) = 0;
- virtual float GetLinearMotorVelocity(EAxisIndex idx) const = 0;
- virtual void SetAngularMotorVelocity(EAxisIndex idx, float deg) = 0;
- virtual float GetAngularMotorVelocity(EAxisIndex idx) const = 0;
- virtual void SetMaxMotorForce(EAxisIndex idx, float f) = 0;
- virtual float GetMaxMotorForce(EAxisIndex idx) const = 0;
- virtual void SetParameter(int parameter, float value) = 0;
- virtual float GetParameter(int parameter) const = 0;
- virtual void SetJointMaxSpeed1(float rad) = 0;
- virtual void SetJointMaxSpeed2(float rad) = 0;
- virtual float GetJointMaxSpeed1() const = 0;
- virtual float GetJointMaxSpeed2() const = 0;
- virtual bool IsLimitJointMaxSpeed1() const = 0;
- virtual bool IsLimitJointMaxSpeed2() const = 0;
- virtual void OnLink() = 0;
-
-protected:
- boost::shared_ptr<dJointFeedback> mFeedback;
- float mJointMaxSpeed1;
- bool mIsLimitJointMaxSpeed1;
- float mJointMaxSpeed2;
- bool mIsLimitJointMaxSpeed2;
+ virtual void DestroyJoint(long jointID) = 0;
+ virtual void Attach(long bodyID1, long bodiID2, long jointID) = 0;
+ virtual int GetType(long jointID) const = 0;
+ virtual long GetBodyID(int idx, long jointID) = 0;
+ virtual void EnableFeedback(bool enable, long jointID) = 0;
+ virtual bool FeedbackEnabled(long jointID) const = 0;
+ virtual salt::Vector3f GetFeedbackForce(int idx) const = 0;
+ virtual salt::Vector3f GetFeedbackTorque(int idx) const = 0;
+ virtual void SetFudgeFactor(int idx, float fudge_factor, long jointID) = 0;
+ virtual float GetFudgeFactor(int idx, long jointID) const = 0;
+ virtual void SetBounce(int idx, float bounce, long jointID) = 0;
+ virtual float GetBounce(int idx, long jointID) const = 0;
+ virtual void SetLowStopDeg(int idx, float deg, long jointID) = 0;
+ virtual float GetLowStopDeg(int idx, long jointID) const = 0;
+ virtual void SetHighStopDeg(int idx, float deg, long jointID) = 0;
+ virtual float GetHighStopDeg(int idx, long jointID) const = 0;
+ virtual void SetLowStopPos(int idx, float deg, long jointID) = 0;
+ virtual float GetLowStopPos(int idx, long jointID) const = 0;
+ virtual void SetHighStopPos(int idx, float deg, long jointID) = 0;
+ virtual float GetHighStopPos(int idx, long jointID) const = 0;
+ virtual void SetCFM(int idx, float cfm, long jointID) = 0;
+ virtual float GetCFM(int idx, long jointID) const = 0;
+ virtual void SetStopCFM(int idx, float cfm, long jointID) = 0;
+ virtual float GetStopCFM(int idx, long jointID) const = 0;
+ virtual void SetStopERP(int idx, float erp, long jointID) = 0;
+ virtual float GetStopERP(int idx, long jointID) const = 0;
+ virtual void SetSuspensionERP(int idx, float erp, long jointID) = 0;
+ virtual float GetSuspensionERP(int idx, long jointID) const = 0;
+ virtual void SetSuspensionCFM(int idx, float cfm, long jointID) = 0;
+ virtual float GetSuspensionCFM(int idx, long jointID) const = 0;
+ virtual void SetLinearMotorVelocity(int idx, float vel, long jointID) = 0;
+ virtual float GetLinearMotorVelocity(int idx, long jointID) const = 0;
+ virtual void SetAngularMotorVelocity(int idx, float deg, long jointID) = 0;
+ virtual float GetAngularMotorVelocity(int idx, long jointID) const = 0;
+ virtual void SetMaxMotorForce(int idx, float f, long jointID) = 0;
+ virtual float GetMaxMotorForce(int idx, long jointID) const = 0;
+ virtual void SetParameter(int parameter, float value, long jointID) = 0;
+ virtual float GetParameter(int parameter, long jointID) const = 0;
+ virtual void OnLink(long jointID, Joint* joint) = 0;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/rigidbodyint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -81,17 +81,7 @@
virtual void DestroyPhysicsObject(long bodyID) = 0;
virtual salt::Matrix GetSynchronisationMatrix(long bodyID) = 0;
virtual void BodySetData(RigidBody* rb, long bodyID) = 0;
- virtual RigidBody* BodyGetData(long bodyID) = 0;
-
- // Here, we have to cheat with the preprocessor, since a static method
- // is required, and the bridge pattern requires member variables to
- // be used (so we cannot use the bridge pattern)
- static RigidBody* GetBodyPointer(long bodyID){
- #ifdef OXYGEN_ODEWRAPPER_H
- return static_cast<RigidBody*>(dBodyGetData( (dBodyID) bodyID));
- #endif
- }
-
+ virtual RigidBody* BodyGetData(long bodyID) = 0;
virtual long CreateBody(long world) = 0;
};
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/sliderjointint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/sliderjointint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/sliderjointint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -37,8 +37,6 @@
virtual float GetPosition(long jointID) = 0;
virtual float GetPositionRate(long jointID) = 0;
virtual void SetSliderAxis(salt::Vector3f& up, long jointID) = 0;
- virtual void SetParameter(int parameter, float value, long jointID) = 0;
- virtual float GetParameter(int parameter, long jointID) const = 0;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/int/universaljointint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/int/universaljointint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/int/universaljointint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -45,8 +45,6 @@
virtual float GetAngle2(long jointID) const = 0;
virtual float GetAngleRate1(long jointID) const = 0;
virtual float GetAngleRate2(long jointID) const = 0;
- virtual void SetParameter(int parameter, float value, long jointID) = 0;
- virtual float GetParameter(int parameter, long jointID) const = 0;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/joint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/joint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/joint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -19,6 +19,7 @@
*/
#include <oxygen/physicsserver/joint.h>
#include <oxygen/physicsserver/rigidbody.h>
+#include <oxygen/physicsserver/staticphysicsmethods.h>
#include <oxygen/physicsserver/ode/odejoint.h>
#include <zeitgeist/logserver/logserver.h>
@@ -46,7 +47,7 @@
return;
}
- dJointSetData( (dJointID) mJointID, this);
+ mJointImp->OnLink(mJointID, this);
}
shared_ptr<Joint> Joint::GetJoint(long jointID)
@@ -56,8 +57,7 @@
return shared_ptr<Joint>();
}
- Joint* jointPtr =
- static_cast<Joint*>(dJointGetData((dJointID) jointID));
+ Joint* jointPtr = StaticPhysicsMethods::GetJoint(jointID);
if (jointPtr == 0)
{
@@ -117,7 +117,7 @@
GetLog()->Debug() << "(Joint) Attaching '" << path1 << "' to '"
<< path2 << '\n';
- dJointAttach( (dJointID) mJointID, (dBodyID) id1, (dBodyID) id2);
+ mJointImp->Attach(id1, id2, mJointID);
}
shared_ptr<RigidBody> Joint::GetBody(const std::string& path)
@@ -162,16 +162,16 @@
int Joint::GetType() const
{
- return dJointGetType( (dJointID) mJointID);
+ return mJointImp->GetType(mJointID);
}
boost::shared_ptr<RigidBody> Joint::GetBody(EBodyIndex idx)
{
- long bodyID = (long) dJointGetBody( (dJointID) mJointID, idx);
+ long bodyID = mJointImp->GetBodyID(idx, mJointID);
return RigidBody::GetBody(bodyID);
}
-bool Joint::AreConnected (shared_ptr<RigidBody> body1, shared_ptr<RigidBody> body2)
+bool Joint::AreConnected(shared_ptr<RigidBody> body1, shared_ptr<RigidBody> body2)
{
if (
(body1.get() == 0) ||
@@ -181,9 +181,7 @@
return false;
}
- const bool connected =
- (dAreConnected((dBodyID) body1->GetBodyID(), (dBodyID) body2->GetBodyID())
- == 1);
+ const bool connected = StaticPhysicsMethods::AreConnected(body1->GetBodyID(), body2->GetBodyID());
return connected;
}
@@ -200,238 +198,172 @@
return false;
}
- const bool connected =
- (dAreConnectedExcluding((dBodyID) body1->GetBodyID(),
- (dBodyID) body2->GetBodyID(),
- joint_type
- )
- == 1);
+ const bool connected =
+ StaticPhysicsMethods::AreConnectedExcluding(body1->GetBodyID(),
+ body2->GetBodyID(),
+ joint_type);
return connected;
}
void Joint::EnableFeedback(bool enable)
{
- if (enable)
- {
- if (mFeedback.get() == 0)
- {
- mFeedback = shared_ptr<dJointFeedback>(new dJointFeedback());
- memset(mFeedback.get(),0,sizeof(dJointFeedback));
- }
- } else
- {
- if (mFeedback.get() != 0)
- {
- mFeedback.reset();
- }
- }
-
- dJointSetFeedback( (dJointID) mJointID,mFeedback.get());
+ mJointImp->EnableFeedback(enable, mJointID);
}
bool Joint::FeedBackEnabled() const
{
- return (dJointGetFeedback( (dJointID) mJointID) != 0);
+ return mJointImp->FeedbackEnabled(mJointID);
}
Vector3f Joint::GetFeedbackForce(EBodyIndex idx) const
{
- dJointFeedback* fb = mFeedback.get();
- if (fb == 0)
- {
- return Vector3f(0,0,0);
- }
-
- switch (idx)
- {
- case BI_FIRST :
- return Vector3f(
- fb->f1[0],
- fb->f1[1],
- fb->f1[2]
- );
-
- case BI_SECOND :
- return Vector3f(
- fb->f2[0],
- fb->f2[1],
- fb->f2[2]
- );
-
- default:
- return Vector3f(0,0,0);
- }
+ return mJointImp->GetFeedbackForce(idx);
}
Vector3f Joint::GetFeedbackTorque(EBodyIndex idx) const
{
- dJointFeedback* fb = mFeedback.get();
- if (fb == 0)
- {
- return Vector3f(0,0,0);
- }
-
- switch (idx)
- {
- case BI_FIRST :
- return Vector3f(
- fb->t1[0],
- fb->t1[1],
- fb->t1[2]
- );
-
- case BI_SECOND :
- return Vector3f(
- fb->t2[0],
- fb->t2[1],
- fb->t2[2]
- );
-
- default:
- return Vector3f(0,0,0);
- }
+ return mJointImp->GetFeedbackTorque(idx);
}
void Joint::SetFudgeFactor(EAxisIndex idx, float fudge_factor)
{
- SetParameter(dParamFudgeFactor + (idx * dParamGroup), fudge_factor);
+ mJointImp->SetFudgeFactor(idx, fudge_factor, mJointID);
}
float Joint::GetFudgeFactor(EAxisIndex idx) const
{
- return GetParameter(dParamFudgeFactor + (idx * dParamGroup));
+ return mJointImp->GetFudgeFactor(idx, mJointID);
}
-
void Joint::SetBounce(EAxisIndex idx, float bounce)
{
- SetParameter(dParamBounce + (idx * dParamGroup),bounce);
+ mJointImp->SetBounce(idx, bounce, mJointID);
}
float Joint::GetBounce(EAxisIndex idx) const
{
- return GetParameter(dParamBounce + (idx * dParamGroup));
+ return mJointImp->GetBounce(idx, mJointID);
}
void Joint::SetLowStopPos(EAxisIndex idx, float pos)
{
- SetParameter(dParamLoStop + (idx * dParamGroup), pos);
+ mJointImp->SetLowStopPos(idx, pos, mJointID);
}
float Joint::GetLowStopPos(EAxisIndex idx) const
{
- return GetParameter(dParamLoStop + (idx * dParamGroup));
+ return mJointImp->GetLowStopPos(idx, mJointID);
}
void Joint::SetHighStopPos(EAxisIndex idx, float pos)
{
- SetParameter(dParamHiStop + (idx * dParamGroup), pos);
+ mJointImp->SetHighStopPos(idx, pos, mJointID);
}
float Joint::GetHighStopPos(EAxisIndex idx) const
{
- return GetParameter(dParamHiStop + (idx * dParamGroup));
+ return mJointImp->GetHighStopPos(idx, mJointID);
}
void Joint::SetLowStopDeg(EAxisIndex idx, float deg)
{
- SetParameter(dParamLoStop + (idx * dParamGroup), gDegToRad(deg));
+ mJointImp->SetLowStopDeg(idx, deg, mJointID);
}
float Joint::GetLowStopDeg(EAxisIndex idx) const
{
- return gRadToDeg(GetParameter(dParamLoStop + (idx * dParamGroup)));
+ return mJointImp->GetLowStopDeg(idx, mJointID);
}
void Joint::SetHighStopDeg(EAxisIndex idx, float deg)
{
- SetParameter(dParamHiStop + (idx * dParamGroup), gDegToRad(deg));
+ mJointImp->SetHighStopDeg(idx, deg, mJointID);
}
float Joint::GetHighStopDeg(EAxisIndex idx) const
{
- return gRadToDeg(GetParameter(dParamHiStop + (idx * dParamGroup)));
+ return mJointImp->GetHighStopDeg(idx, mJointID);
}
void Joint::SetCFM(EAxisIndex idx, float cfm)
{
- SetParameter(dParamCFM + (idx * dParamGroup), cfm);
+ mJointImp->SetCFM(idx, cfm, mJointID);
}
float Joint::GetCFM(EAxisIndex idx) const
{
- return GetParameter(dParamCFM + (idx * dParamGroup));
+ return mJointImp->GetCFM(idx, mJointID);
}
void Joint::SetStopCFM(EAxisIndex idx, float cfm)
{
- SetParameter(dParamStopCFM + (idx * dParamGroup), cfm);
+ mJointImp->SetStopCFM(idx, cfm, mJointID);
}
float Joint::GetStopCFM(EAxisIndex idx) const
{
- return GetParameter(dParamStopCFM + (idx * dParamGroup));
+ return mJointImp->GetStopCFM(idx, mJointID);
}
void Joint::SetStopERP(EAxisIndex idx, float erp)
{
- SetParameter(dParamStopERP + (idx * dParamGroup), erp);
+ mJointImp->SetStopERP(idx, erp, mJointID);
}
float Joint::GetStopERP(EAxisIndex idx) const
{
- return GetParameter(dParamStopERP + (idx * dParamGroup));
+ return mJointImp->GetStopERP(idx, mJointID);
}
void Joint::SetSuspensionERP(EAxisIndex idx, float erp)
{
- SetParameter(dParamSuspensionERP + (idx * dParamGroup), erp);
+ mJointImp->SetSuspensionERP(idx, erp, mJointID);
}
float Joint::GetSuspensionERP(EAxisIndex idx) const
{
- return GetParameter(dParamSuspensionERP + (idx * dParamGroup));
+ return mJointImp->GetSuspensionERP(idx, mJointID);
}
void Joint::SetSuspensionCFM(EAxisIndex idx, float cfm)
{
- SetParameter(dParamSuspensionCFM + (idx * dParamGroup), cfm);
+ mJointImp->SetSuspensionCFM(idx, cfm, mJointID);
}
float Joint::GetSuspensionCFM(EAxisIndex idx) const
{
- return GetParameter(dParamSuspensionCFM + (idx * dParamGroup));
+ return mJointImp->GetSuspensionCFM(idx, mJointID);
}
void Joint::SetLinearMotorVelocity(EAxisIndex idx, float vel)
{
- SetParameter(dParamVel + (idx * dParamGroup), vel);
+ mJointImp->SetLinearMotorVelocity(idx, vel, mJointID);
}
float Joint::GetLinearMotorVelocity(EAxisIndex idx) const
{
- return GetParameter(dParamVel + (idx * dParamGroup));
+ return mJointImp->GetLinearMotorVelocity(idx, mJointID);
}
void Joint::SetAngularMotorVelocity(EAxisIndex idx, float deg)
{
- SetParameter(dParamVel + (idx * dParamGroup), gDegToRad(deg));
+ mJointImp->SetAngularMotorVelocity(idx, deg, mJointID);
}
float Joint::GetAngularMotorVelocity(EAxisIndex idx) const
{
- return gRadToDeg(GetParameter(dParamVel + (idx * dParamGroup)));
+ return mJointImp->GetAngularMotorVelocity(idx, mJointID);
}
void Joint::SetMaxMotorForce(EAxisIndex idx, float f)
{
- SetParameter(dParamFMax + (idx * dParamGroup), f);
+ mJointImp->SetMaxMotorForce(idx, f, mJointID);
}
float Joint::GetMaxMotorForce(EAxisIndex idx) const
{
- return GetParameter(dParamFMax + (idx * dParamGroup));
+ return mJointImp->GetMaxMotorForce(idx, mJointID);
}
void Joint::DestroyPhysicsObject()
@@ -442,7 +374,7 @@
}
EnableFeedback(false);
- dJointDestroy( (dJointID) mJointID);
+ mJointImp->DestroyJoint(mJointID);
mJointID = 0;
}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/joint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/joint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/joint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -25,6 +25,7 @@
#include <oxygen/oxygen_defines.h>
#include <oxygen/physicsserver/ode/odewrapper.h>
#include <oxygen/physicsserver/physicsobject.h>
+#include <oxygen/physicsserver/genericphysicsobjects.h>
namespace oxygen
{
@@ -253,12 +254,6 @@
*/
float GetMaxMotorForce(EAxisIndex idx) const;
- /** sets a joint parameter value */
- virtual void SetParameter(int parameter, float value) = 0;
-
- /** returns a joint parameter value */
- virtual float GetParameter(int parameter) const = 0;
-
/** Set the maximum joint speed1, valid for both hingejoint and universaljoint */
virtual void SetJointMaxSpeed1(float rad);
@@ -288,9 +283,6 @@
/** the ID of the managed joint */
long mJointID;
- /** the allocated joint feedback structure */
- boost::shared_ptr<dJointFeedback> mFeedback;
-
protected:
/** The maximum joint speed in rad, valid for both hingejoint and universaljoint */
float mJointMaxSpeed1;
@@ -300,7 +292,6 @@
float mJointMaxSpeed2;
bool mIsLimitJointMaxSpeed2;
-private:
boost::shared_ptr<JointInt> mJointImp;
};
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odefixedjoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odefixedjoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odefixedjoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -30,8 +30,8 @@
long ODEFixedJoint::CreateFixedJoint(long world)
{
dWorldID ODEworld = (dWorldID) world;
- mODEJoint = dJointCreateFixed(ODEworld, 0);
- return (long) mODEJoint;
+ dJointID ODEJoint = dJointCreateFixed(ODEworld, 0);
+ return (long) ODEJoint;
}
void ODEFixedJoint::SetFixed(long jointID)
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -81,15 +81,3 @@
dJointID ODEJoint = (dJointID) jointID;
return gRadToDeg(dJointGetHinge2Angle2Rate(ODEJoint));
}
-
-void ODEHinge2Joint::SetParameter(int parameter, float value, long jointID)
-{
- dJointID ODEJoint = (dJointID) jointID;
- dJointSetHinge2Param(ODEJoint, parameter, value);
-}
-
-float ODEHinge2Joint::GetParameter(int parameter, long jointID) const
-{
- dJointID ODEJoint = (dJointID) jointID;
- return dJointGetHinge2Param(ODEJoint, parameter);
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehinge2joint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -40,8 +40,6 @@
float GetAngle(long jointID);
float GetAngleRate1(long jointID);
float GetAngleRate2(long jointID);
- void SetParameter(int parameter, float value, long jointID);
- float GetParameter(int parameter, long jointID) const;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -85,15 +85,3 @@
dJointID ODEJoint = (dJointID) jointID;
return gRadToDeg(dJointGetHingeAngleRate(ODEJoint));
}
-
-void ODEHingeJoint::SetParameter(int parameter, float value, long jointID)
-{
- dJointID ODEJoint = (dJointID) jointID;
- dJointSetHingeParam(ODEJoint, parameter, value);
-}
-
-float ODEHingeJoint::GetParameter(int parameter, long jointID) const
-{
- dJointID ODEJoint = (dJointID) jointID;
- return dJointGetHingeParam(ODEJoint, parameter);
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odehingejoint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -38,8 +38,6 @@
salt::Vector3f GetAxis(long jointID);
float GetAngle(long jointID) const;
float GetAngleRate(long jointID) const;
- void SetParameter(int parameter, float value, long jointID);
- float GetParameter(int parameter, long jointID) const;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -26,72 +26,41 @@
using namespace std;
using namespace salt;
-ODEJoint::ODEJoint() : ODEPhysicsObject(), mODEJoint(0)
+ODEJoint::ODEJoint() : ODEPhysicsObject()
{
- mJointMaxSpeed1 = mJointMaxSpeed2 = 0.0;
- mIsLimitJointMaxSpeed1 = mIsLimitJointMaxSpeed2 = false;
}
-void ODEJoint::OnLink()
+void ODEJoint::OnLink(long jointID, Joint* joint)
{
- if (mODEJoint == 0)
- {
- return;
- }
-
- dJointSetData(mODEJoint, this);
+ dJointID ODEJoint = (dJointID) jointID;
+ dJointSetData(ODEJoint, joint);
}
-void ODEJoint::Attach(shared_ptr<RigidBody> body1, shared_ptr<RigidBody> body2)
+void ODEJoint::Attach(long bodyID1, long bodyID2, long jointID)
{
- string path1,path2;
- long id1,id2;
-
- static const char strStaticEnv[] = "<static environment>";
-
- if (body1.get() == 0)
- {
- id1 = 0;
- path1 = strStaticEnv;
- } else
- {
- id1 = body1->GetBodyID();
- path1 = body1->GetFullPath();
- }
-
- if (body2.get() == 0)
- {
- id2 = 0;
- path2 = strStaticEnv;
- } else
- {
- id2 = body2->GetBodyID();
- path2 = body2->GetFullPath();
- }
-
- dJointAttach(mODEJoint, (dBodyID) id1, (dBodyID) id2);
+ dBodyID ODEBody1 = (dBodyID) bodyID1;
+ dBodyID ODEBody2 = (dBodyID) bodyID2;
+ dJointID ODEJoint = (dJointID) jointID;
+ dJointAttach(ODEJoint, ODEBody1, ODEBody2);
}
-void ODEJoint::Attach(const std::string& path1, const std::string& path2)
+int ODEJoint::GetType(long jointID) const
{
- shared_ptr<RigidBody> body1;
- shared_ptr<RigidBody> body2;
- Attach(body1,body2);
+ dJointID ODEJoint = (dJointID) jointID;
+ return dJointGetType(ODEJoint);
}
-int ODEJoint::GetType() const
+long ODEJoint::GetBodyID(int idx, long jointID)
{
- return dJointGetType(mODEJoint);
+ dJointID ODEJoint = (dJointID) jointID;
+ dBodyID ODEBodyID = dJointGetBody(ODEJoint, idx);
+ return (long) ODEBodyID;
}
-boost::shared_ptr<RigidBody> ODEJoint::GetBody(EBodyIndex idx)
+void ODEJoint::EnableFeedback(bool enable, long jointID)
{
- long bodyID = (long) dJointGetBody(mODEJoint, idx);
- return RigidBody::GetBody(bodyID);
-}
-
-void ODEJoint::EnableFeedback(bool enable)
-{
+ dJointID ODEJoint = (dJointID) jointID;
+
if (enable)
{
if (mFeedback.get() == 0)
@@ -107,15 +76,16 @@
}
}
- dJointSetFeedback(mODEJoint,mFeedback.get());
+ dJointSetFeedback(ODEJoint,mFeedback.get());
}
-bool ODEJoint::FeedbackEnabled() const
+bool ODEJoint::FeedbackEnabled(long jointID) const
{
- return (dJointGetFeedback(mODEJoint) != 0);
+ dJointID ODEJoint = (dJointID) jointID;
+ return (dJointGetFeedback(ODEJoint) != 0);
}
-Vector3f ODEJoint::GetFeedbackForce(EBodyIndex idx) const
+Vector3f ODEJoint::GetFeedbackForce(int idx) const
{
dJointFeedback* fb = mFeedback.get();
if (fb == 0)
@@ -125,14 +95,14 @@
switch (idx)
{
- case BI_FIRST :
+ case 0 :
return Vector3f(
fb->f1[0],
fb->f1[1],
fb->f1[2]
);
- case BI_SECOND :
+ case 1 :
return Vector3f(
fb->f2[0],
fb->f2[1],
@@ -144,7 +114,7 @@
}
}
-Vector3f ODEJoint::GetFeedbackTorque(EBodyIndex idx) const
+Vector3f ODEJoint::GetFeedbackTorque(int idx) const
{
dJointFeedback* fb = mFeedback.get();
if (fb == 0)
@@ -154,14 +124,14 @@
switch (idx)
{
- case BI_FIRST :
+ case 0 :
return Vector3f(
fb->t1[0],
fb->t1[1],
fb->t1[2]
);
- case BI_SECOND :
+ case 1 :
return Vector3f(
fb->t2[0],
fb->t2[1],
@@ -173,192 +143,181 @@
}
}
-void ODEJoint::SetFudgeFactor(EAxisIndex idx, float fudge_factor)
+void ODEJoint::SetFudgeFactor(int idx, float fudge_factor, long jointID)
{
- SetParameter(dParamFudgeFactor + (idx * dParamGroup), fudge_factor);
+ SetParameter(dParamFudgeFactor + (idx * dParamGroup), fudge_factor, jointID);
}
-float ODEJoint::GetFudgeFactor(EAxisIndex idx) const
+float ODEJoint::GetFudgeFactor(int idx, long jointID) const
{
- return GetParameter(dParamFudgeFactor + (idx * dParamGroup));
+ return GetParameter(dParamFudgeFactor + (idx * dParamGroup), jointID);
}
-
-void ODEJoint::SetBounce(EAxisIndex idx, float bounce)
+void ODEJoint::SetBounce(int idx, float bounce, long jointID)
{
- SetParameter(dParamBounce + (idx * dParamGroup),bounce);
+ SetParameter(dParamBounce + (idx * dParamGroup),bounce, jointID);
}
-float ODEJoint::GetBounce(EAxisIndex idx) const
+float ODEJoint::GetBounce(int idx, long jointID) const
{
- return GetParameter(dParamBounce + (idx * dParamGroup));
+ return GetParameter(dParamBounce + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetLowStopPos(EAxisIndex idx, float pos)
+void ODEJoint::SetLowStopPos(int idx, float pos, long jointID)
{
- SetParameter(dParamLoStop + (idx * dParamGroup), pos);
+ SetParameter(dParamLoStop + (idx * dParamGroup), pos, jointID);
}
-float ODEJoint::GetLowStopPos(EAxisIndex idx) const
+float ODEJoint::GetLowStopPos(int idx, long jointID) const
{
- return GetParameter(dParamLoStop + (idx * dParamGroup));
+ return GetParameter(dParamLoStop + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetHighStopPos(EAxisIndex idx, float pos)
+void ODEJoint::SetHighStopPos(int idx, float pos, long jointID)
{
- SetParameter(dParamHiStop + (idx * dParamGroup), pos);
+ SetParameter(dParamHiStop + (idx * dParamGroup), pos, jointID);
}
-float ODEJoint::GetHighStopPos(EAxisIndex idx) const
+float ODEJoint::GetHighStopPos(int idx, long jointID) const
{
- return GetParameter(dParamHiStop + (idx * dParamGroup));
+ return GetParameter(dParamHiStop + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetLowStopDeg(EAxisIndex idx, float deg)
+void ODEJoint::SetLowStopDeg(int idx, float deg, long jointID)
{
- SetParameter(dParamLoStop + (idx * dParamGroup), gDegToRad(deg));
+ SetParameter(dParamLoStop + (idx * dParamGroup), gDegToRad(deg), jointID);
}
-float ODEJoint::GetLowStopDeg(EAxisIndex idx) const
+float ODEJoint::GetLowStopDeg(int idx, long jointID) const
{
- return gRadToDeg(GetParameter(dParamLoStop + (idx * dParamGroup)));
+ return gRadToDeg(GetParameter(dParamLoStop + (idx * dParamGroup), jointID));
}
-void ODEJoint::SetHighStopDeg(EAxisIndex idx, float deg)
+void ODEJoint::SetHighStopDeg(int idx, float deg, long jointID)
{
- SetParameter(dParamHiStop + (idx * dParamGroup), gDegToRad(deg));
+ SetParameter(dParamHiStop + (idx * dParamGroup), gDegToRad(deg), jointID);
}
-float ODEJoint::GetHighStopDeg(EAxisIndex idx) const
+float ODEJoint::GetHighStopDeg(int idx, long jointID) const
{
- return gRadToDeg(GetParameter(dParamHiStop + (idx * dParamGroup)));
+ return gRadToDeg(GetParameter(dParamHiStop + (idx * dParamGroup), jointID));
}
-void ODEJoint::SetCFM(EAxisIndex idx, float cfm)
+void ODEJoint::SetCFM(int idx, float cfm, long jointID)
{
- SetParameter(dParamCFM + (idx * dParamGroup), cfm);
+ SetParameter(dParamCFM + (idx * dParamGroup), cfm, jointID);
}
-float ODEJoint::GetCFM(EAxisIndex idx) const
+float ODEJoint::GetCFM(int idx, long jointID) const
{
- return GetParameter(dParamCFM + (idx * dParamGroup));
+ return GetParameter(dParamCFM + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetStopCFM(EAxisIndex idx, float cfm)
+void ODEJoint::SetStopCFM(int idx, float cfm, long jointID)
{
- SetParameter(dParamStopCFM + (idx * dParamGroup), cfm);
+ SetParameter(dParamStopCFM + (idx * dParamGroup), cfm, jointID);
}
-float ODEJoint::GetStopCFM(EAxisIndex idx) const
+float ODEJoint::GetStopCFM(int idx, long jointID) const
{
- return GetParameter(dParamStopCFM + (idx * dParamGroup));
+ return GetParameter(dParamStopCFM + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetStopERP(EAxisIndex idx, float erp)
+void ODEJoint::SetStopERP(int idx, float erp, long jointID)
{
- SetParameter(dParamStopERP + (idx * dParamGroup), erp);
+ SetParameter(dParamStopERP + (idx * dParamGroup), erp, jointID);
}
-float ODEJoint::GetStopERP(EAxisIndex idx) const
+float ODEJoint::GetStopERP(int idx, long jointID) const
{
- return GetParameter(dParamStopERP + (idx * dParamGroup));
+ return GetParameter(dParamStopERP + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetSuspensionERP(EAxisIndex idx, float erp)
+void ODEJoint::SetSuspensionERP(int idx, float erp, long jointID)
{
- SetParameter(dParamSuspensionERP + (idx * dParamGroup), erp);
+ SetParameter(dParamSuspensionERP + (idx * dParamGroup), erp, jointID);
}
-float ODEJoint::GetSuspensionERP(EAxisIndex idx) const
+float ODEJoint::GetSuspensionERP(int idx, long jointID) const
{
- return GetParameter(dParamSuspensionERP + (idx * dParamGroup));
+ return GetParameter(dParamSuspensionERP + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetSuspensionCFM(EAxisIndex idx, float cfm)
+void ODEJoint::SetSuspensionCFM(int idx, float cfm, long jointID)
{
- SetParameter(dParamSuspensionCFM + (idx * dParamGroup), cfm);
+ SetParameter(dParamSuspensionCFM + (idx * dParamGroup), cfm, jointID);
}
-float ODEJoint::GetSuspensionCFM(EAxisIndex idx) const
+float ODEJoint::GetSuspensionCFM(int idx, long jointID) const
{
- return GetParameter(dParamSuspensionCFM + (idx * dParamGroup));
+ return GetParameter(dParamSuspensionCFM + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetLinearMotorVelocity(EAxisIndex idx, float vel)
+void ODEJoint::SetLinearMotorVelocity(int idx, float vel, long jointID)
{
- SetParameter(dParamVel + (idx * dParamGroup), vel);
+ SetParameter(dParamVel + (idx * dParamGroup), vel, jointID);
}
-float ODEJoint::GetLinearMotorVelocity(EAxisIndex idx) const
+float ODEJoint::GetLinearMotorVelocity(int idx, long jointID) const
{
- return GetParameter(dParamVel + (idx * dParamGroup));
+ return GetParameter(dParamVel + (idx * dParamGroup), jointID);
}
-void ODEJoint::SetAngularMotorVelocity(EAxisIndex idx, float deg)
+void ODEJoint::SetAngularMotorVelocity(int idx, float deg, long jointID)
{
- SetParameter(dParamVel + (idx * dParamGroup), gDegToRad(deg));
+ SetParameter(dParamVel + (idx * dParamGroup), gDegToRad(deg), jointID);
}
-float ODEJoint::GetAngularMotorVelocity(EAxisIndex idx) const
+float ODEJoint::GetAngularMotorVelocity(int idx, long jointID) const
{
- return gRadToDeg(GetParameter(dParamVel + (idx * dParamGroup)));
+ return gRadToDeg(GetParameter(dParamVel + (idx * dParamGroup), jointID));
}
-void ODEJoint::SetMaxMotorForce(EAxisIndex idx, float f)
+void ODEJoint::SetMaxMotorForce(int idx, float f, long jointID)
{
- SetParameter(dParamFMax + (idx * dParamGroup), f);
+ SetParameter(dParamFMax + (idx * dParamGroup), f, jointID);
}
-float ODEJoint::GetMaxMotorForce(EAxisIndex idx) const
+float ODEJoint::GetMaxMotorForce(int idx, long jointID) const
{
- return GetParameter(dParamFMax + (idx * dParamGroup));
+ return GetParameter(dParamFMax + (idx * dParamGroup), jointID);
}
-void ODEJoint::DestroyJoint()
+void ODEJoint::DestroyJoint(long jointID)
{
- if (! mODEJoint)
- {
- return;
- }
-
- EnableFeedback(false);
- dJointDestroy(mODEJoint);
- mODEJoint = 0;
+ dJointID ODEJoint = (dJointID) jointID;
+ EnableFeedback(false, jointID);
+ dJointDestroy(ODEJoint);
}
-void ODEJoint::SetJointMaxSpeed1(float rad)
-{
- mJointMaxSpeed1 = fabs(rad);
- mIsLimitJointMaxSpeed1 = true;
+void ODEJoint::SetParameter(int parameter, float value, long jointID){
+ dJointID ODEJoint = (dJointID) jointID;
+ int jointType = dJointGetType(ODEJoint);
+ switch (jointType){
+ case dJointTypeHinge: dJointSetHingeParam(ODEJoint, parameter, value);
+ break;
+ case dJointTypeHinge2: dJointSetHinge2Param(ODEJoint, parameter, value);
+ break;
+ case dJointTypeSlider: dJointSetSliderParam(ODEJoint, parameter, value);
+ break;
+ case dJointTypeUniversal: dJointSetUniversalParam(ODEJoint, parameter, value);
+ break;
+ default: return;
+ }
}
-void ODEJoint::SetJointMaxSpeed2(float rad)
-{
- mJointMaxSpeed2 = fabs(rad);
- mIsLimitJointMaxSpeed2 = true;
+float ODEJoint::GetParameter(int parameter, long jointID) const{
+ dJointID ODEJoint = (dJointID) jointID;
+ int jointType = dJointGetType(ODEJoint);
+ switch (jointType){
+ case dJointTypeHinge: return dJointGetHingeParam(ODEJoint, parameter);
+ break;
+ case dJointTypeHinge2: return dJointGetHinge2Param(ODEJoint, parameter);
+ break;
+ case dJointTypeSlider: return dJointGetSliderParam(ODEJoint, parameter);
+ break;
+ case dJointTypeUniversal: return dJointGetUniversalParam(ODEJoint, parameter);
+ break;
+ default: return 0;
+ }
}
-
-float ODEJoint::GetJointMaxSpeed1() const
-{
- return mJointMaxSpeed1;
-}
-
-float ODEJoint::GetJointMaxSpeed2() const
-{
- return mJointMaxSpeed2;
-}
-
-bool ODEJoint::IsLimitJointMaxSpeed1() const
-{
- return mIsLimitJointMaxSpeed1;
-}
-
-bool ODEJoint::IsLimitJointMaxSpeed2() const
-{
- return mIsLimitJointMaxSpeed2;
-}
-
-float ODEJoint::GetParameter(int parameter) const
-{
- return 0.0;
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odejoint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -33,56 +33,50 @@
public:
ODEJoint();
- virtual void DestroyJoint();
- virtual void Attach(boost::shared_ptr<RigidBody> body1,
- boost::shared_ptr<RigidBody> body2);
- void Attach(const std::string& path1, const std::string& path2);
- int GetType() const;
- boost::shared_ptr<RigidBody> GetBody(EBodyIndex idx);
- void EnableFeedback(bool enable);
- bool FeedbackEnabled() const;
- salt::Vector3f GetFeedbackForce(EBodyIndex idx) const;
- salt::Vector3f GetFeedbackTorque(EBodyIndex idx) const;
- void SetFudgeFactor(EAxisIndex idx, float fudge_factor);
- float GetFudgeFactor(EAxisIndex idx) const;
- void SetBounce(EAxisIndex idx, float bounce);
- float GetBounce(EAxisIndex idx) const;
- void SetLowStopDeg(EAxisIndex idx, float deg);
- float GetLowStopDeg(EAxisIndex idx) const;
- void SetHighStopDeg(EAxisIndex idx, float deg);
- float GetHighStopDeg(EAxisIndex idx) const;
- void SetLowStopPos(EAxisIndex idx, float deg);
- float GetLowStopPos(EAxisIndex idx) const;
- void SetHighStopPos(EAxisIndex idx, float deg);
- float GetHighStopPos(EAxisIndex idx) const;
- void SetCFM(EAxisIndex idx, float cfm);
- float GetCFM(EAxisIndex idx) const;
- void SetStopCFM(EAxisIndex idx, float cfm);
- float GetStopCFM(EAxisIndex idx) const;
- void SetStopERP(EAxisIndex idx, float erp);
- float GetStopERP(EAxisIndex idx) const;
- void SetSuspensionERP(EAxisIndex idx, float erp);
- float GetSuspensionERP(EAxisIndex idx) const;
- void SetSuspensionCFM(EAxisIndex idx, float cfm);
- float GetSuspensionCFM(EAxisIndex idx) const;
- void SetLinearMotorVelocity(EAxisIndex idx, float vel);
- float GetLinearMotorVelocity(EAxisIndex idx) const;
- void SetAngularMotorVelocity(EAxisIndex idx, float deg);
- float GetAngularMotorVelocity(EAxisIndex idx) const;
- void SetMaxMotorForce(EAxisIndex idx, float f);
- float GetMaxMotorForce(EAxisIndex idx) const;
- virtual void SetParameter(int parameter, float value){};
- virtual float GetParameter(int parameter) const;
- virtual void SetJointMaxSpeed1(float rad);
- virtual void SetJointMaxSpeed2(float rad);
- virtual float GetJointMaxSpeed1() const;
- virtual float GetJointMaxSpeed2() const;
- bool IsLimitJointMaxSpeed1() const;
- bool IsLimitJointMaxSpeed2() const;
- void OnLink();
+ virtual void DestroyJoint(long jointID);
+ virtual void Attach(long bodyID1, long bodiID2, long jointID);
+ int GetType(long jointID) const;
+ long GetBodyID(int idx, long jointID);
+ void EnableFeedback(bool enable, long jointID);
+ bool FeedbackEnabled(long jointID) const;
+ salt::Vector3f GetFeedbackForce(int idx) const;
+ salt::Vector3f GetFeedbackTorque(int idx) const;
+ void SetFudgeFactor(int idx, float fudge_factor, long jointID);
+ float GetFudgeFactor(int idx, long jointID) const;
+ void SetBounce(int idx, float bounce, long jointID);
+ float GetBounce(int idx, long jointID) const;
+ void SetLowStopDeg(int idx, float deg, long jointID);
+ float GetLowStopDeg(int idx, long jointID) const;
+ void SetHighStopDeg(int idx, float deg, long jointID);
+ float GetHighStopDeg(int idx, long jointID) const;
+ void SetLowStopPos(int idx, float deg, long jointID);
+ float GetLowStopPos(int idx, long jointID) const;
+ void SetHighStopPos(int idx, float deg, long jointID);
+ float GetHighStopPos(int idx, long jointID) const;
+ void SetCFM(int idx, float cfm, long jointID);
+ float GetCFM(int idx, long jointID) const;
+ void SetStopCFM(int idx, float cfm, long jointID);
+ float GetStopCFM(int idx, long jointID) const;
+ void SetStopERP(int idx, float erp, long jointID);
+ float GetStopERP(int idx, long jointID) const;
+ void SetSuspensionERP(int idx, float erp, long jointID);
+ float GetSuspensionERP(int idx, long jointID) const;
+ void SetSuspensionCFM(int idx, float cfm, long jointID);
+ float GetSuspensionCFM(int idx, long jointID) const;
+ void SetLinearMotorVelocity(int idx, float vel, long jointID);
+ float GetLinearMotorVelocity(int idx, long jointID) const;
+ void SetAngularMotorVelocity(int idx, float deg, long jointID);
+ float GetAngularMotorVelocity(int idx, long jointID) const;
+ void SetMaxMotorForce(int idx, float f, long jointID);
+ float GetMaxMotorForce(int idx, long jointID) const;
+ virtual void SetParameter(int parameter, float value, long jointID);
+ virtual float GetParameter(int parameter, long jointID) const;
+ void OnLink(long jointID, Joint* joint);
protected:
- dJointID mODEJoint;
+ //It is encouraged to not store any member variables in the implementation.
+ //This can cause major problems. However, here, I found no way to avoid it.
+ boost::shared_ptr<dJointFeedback> mFeedback;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -51,15 +51,3 @@
dJointID ODEJoint = (dJointID) jointID;
return dJointGetSliderPositionRate(ODEJoint);
}
-
-void ODESliderJoint::SetParameter(int parameter, float value, long jointID)
-{
- dJointID ODEJoint = (dJointID) jointID;
- dJointSetSliderParam(ODEJoint, parameter, value);
-}
-
-float ODESliderJoint::GetParameter(int parameter, long jointID) const
-{
- dJointID ODEJoint = (dJointID) jointID;
- return dJointGetSliderParam(ODEJoint, parameter);
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odesliderjoint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -38,8 +38,6 @@
float GetPosition(long jointID);
float GetPositionRate(long jointID);
void SetSliderAxis(salt::Vector3f& up, long jointID);
- void SetParameter(int parameter, float value, long jointID);
- float GetParameter(int parameter, long jointID) const;
};
} //namespace oxygen
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.cpp
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.cpp 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.cpp 2010-01-08 07:35:25 UTC (rev 138)
@@ -110,15 +110,3 @@
dJointID ODEJoint = (dJointID) jointID;
return gRadToDeg(dJointGetUniversalAngle2Rate(ODEJoint));
}
-
-void ODEUniversalJoint::SetParameter(int parameter, float value, long jointID)
-{
- dJointID ODEJoint = (dJointID) jointID;
- dJointSetUniversalParam(ODEJoint, parameter, value);
-}
-
-float ODEUniversalJoint::GetParameter(int parameter, long jointID) const
-{
- dJointID ODEJoint = (dJointID) jointID;
- return dJointGetUniversalParam(ODEJoint, parameter);
-}
Modified: branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.h
===================================================================
--- branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.h 2010-01-06 07:25:00 UTC (rev 137)
+++ branches/multiphys/spark/lib/oxygen/physicsserver/ode/odeuniversaljoint.h 2010-01-08 07:35:25 UTC (rev 138)
@@ -46,8 +46,6 @@
float GetAngle2(long jointID) const;
float GetAngleRate1(long jointID) const;
float GetAngleRat...
[truncated message content] |