diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2013-02-21 22:30:11 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2013-02-21 22:30:11 +0400 |
commit | 815e00917dcb4137f9687ab602f527920fa8c41d (patch) | |
tree | 4c089bc7f19a9249f59428268c8aa99edad1b438 /source/gameengine/Physics | |
parent | 6b600d079351fa5490d74d5661c47346196e57f3 (diff) |
BGE cleanup: Removing the PHY__Vector classes and replacing them with MT_Vectors. The PHY__Vectors didn't offer anything (not even any real abstraction) and they required annoying MT_Vector <-> PHY_Vector conversions all over the place. No functional changes.
Diffstat (limited to 'source/gameengine/Physics')
16 files changed, 43 insertions, 106 deletions
diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp index 36e7b0d482f..3cb80e53e12 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.cpp +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.cpp @@ -55,7 +55,7 @@ void CcdGraphicController::setLocalAabb(const MT_Point3& aabbMin,const MT_Point3 SetGraphicTransform(); } -void CcdGraphicController::setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax) +void CcdGraphicController::setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax) { m_localAabbMin.setValue(aabbMin[0],aabbMin[1],aabbMin[2]); m_localAabbMax.setValue(aabbMax[0],aabbMax[1],aabbMax[2]); diff --git a/source/gameengine/Physics/Bullet/CcdGraphicController.h b/source/gameengine/Physics/Bullet/CcdGraphicController.h index 72eb699ce5b..064f86040f6 100644 --- a/source/gameengine/Physics/Bullet/CcdGraphicController.h +++ b/source/gameengine/Physics/Bullet/CcdGraphicController.h @@ -42,7 +42,7 @@ public: void setLocalAabb(const btVector3& aabbMin,const btVector3& aabbMax); void setLocalAabb(const MT_Point3& aabbMin,const MT_Point3& aabbMax); - virtual void setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax); + virtual void setLocalAabb(const MT_Vector3& aabbMin,const MT_Vector3& aabbMax); virtual void setLocalAabb(const float aabbMin[3],const float aabbMax[3]); PHY_IMotionState* GetMotionState() { return m_motionState; } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 0de21e33eff..ef43e094e6d 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1092,7 +1092,7 @@ void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvel { } -void CcdPhysicsController::getPosition(PHY__Vector3& pos) const +void CcdPhysicsController::getPosition(MT_Vector3& pos) const { const btTransform& xform = m_object->getWorldTransform(); pos[0] = xform.getOrigin().x(); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h index b271b9c424f..f1f0ca31419 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h @@ -524,7 +524,7 @@ protected: virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal); virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal); virtual void setPosition(float posX,float posY,float posZ); - virtual void getPosition(PHY__Vector3& pos) const; + virtual void getPosition(MT_Vector3& pos) const; virtual void setScaling(float scaleX,float scaleY,float scaleZ); diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 254624cd8a0..702452bc77e 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -97,9 +97,9 @@ public: virtual void AddWheel( PHY_IMotionState* motionState, - PHY__Vector3 connectionPoint, - PHY__Vector3 downDirection, - PHY__Vector3 axleDirection, + MT_Vector3 connectionPoint, + MT_Vector3 downDirection, + MT_Vector3 axleDirection, float suspensionRestLength, float wheelRadius, bool hasSteering @@ -311,20 +311,16 @@ public: return m_controller->getJumpCount(); } - virtual void SetWalkDirection(PHY__Vector3 dir) + virtual void SetWalkDirection(const MT_Vector3& dir) { btVector3 vec = btVector3(dir[0], dir[1], dir[2]); m_controller->setWalkDirection(vec); } - virtual PHY__Vector3 GetWalkDirection() + virtual MT_Vector3 GetWalkDirection() { btVector3 vec = m_controller->getWalkDirection(); - PHY__Vector3 retval; - retval[0] = vec[0]; - retval[1] = vec[1]; - retval[2] = vec[2]; - return retval; + return MT_Vector3(vec[0], vec[1], vec[2]); } }; @@ -951,7 +947,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType) -void CcdPhysicsEnvironment::getGravity(PHY__Vector3& grav) +void CcdPhysicsEnvironment::getGravity(MT_Vector3& grav) { const btVector3& gravity = m_dynamicsWorld->getGravity(); grav[0] = gravity.getX(); @@ -1851,7 +1847,7 @@ struct DbvtCullingCallback : btDbvt::ICollide }; static OcclusionBuffer gOcb; -bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) +bool CcdPhysicsEnvironment::cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4 *planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { if (!m_cullingTree) return false; @@ -2362,7 +2358,7 @@ int numController = 0; -PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position) +PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radius,const MT_Vector3& position) { CcdConstructionInfo cinfo; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h index 18ce0550498..8cf88526969 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h @@ -140,7 +140,7 @@ protected: virtual void setDebugMode(int debugMode); virtual void setGravity(float x,float y,float z); - virtual void getGravity(PHY__Vector3& grav); + virtual void getGravity(MT_Vector3& grav); virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, @@ -190,7 +190,7 @@ protected: btTypedConstraint* getConstraintById(int constraintId); virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]); + virtual bool cullingTest(PHY_CullingCallback callback, void* userData, MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]); //Methods for gamelogic collision/physics callbacks @@ -200,7 +200,7 @@ protected: virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl); virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl); //These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else - virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position); + virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position); virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight); diff --git a/source/gameengine/Physics/Dummy/CMakeLists.txt b/source/gameengine/Physics/Dummy/CMakeLists.txt index 6a21fc6fcb7..529a75b2a62 100644 --- a/source/gameengine/Physics/Dummy/CMakeLists.txt +++ b/source/gameengine/Physics/Dummy/CMakeLists.txt @@ -26,6 +26,7 @@ set(INC . ../common + ../../../../intern/moto/include ) set(INC_SYS diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp index d1fabba18f9..72450e4307c 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp @@ -85,7 +85,7 @@ void DummyPhysicsEnvironment::setGravity(float x,float y,float z) { } -void DummyPhysicsEnvironment::getGravity(PHY__Vector3& grav) +void DummyPhysicsEnvironment::getGravity(class MT_Vector3& grav) { } diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h index 5ce34bdf7cf..9f6bc85fced 100644 --- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h +++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h @@ -56,7 +56,7 @@ public: virtual float getFixedTimeStep(); virtual void setGravity(float x,float y,float z); - virtual void getGravity(PHY__Vector3& grav); + virtual void getGravity(class MT_Vector3& grav); virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, @@ -80,7 +80,7 @@ public: } virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ); - virtual bool cullingTest(PHY_CullingCallback callback, void* userData, PHY__Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; } + virtual bool cullingTest(PHY_CullingCallback callback, void* userData, class MT_Vector4* planes, int nplanes, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) { return false; } //gamelogic callbacks @@ -91,7 +91,7 @@ public: } virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl) { return false; } virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl) { return false;} - virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;} + virtual PHY_IPhysicsController* CreateSphereController(float radius,const class MT_Vector3& position) {return 0;} virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;} virtual void setConstraintParam(int constraintId,int param,float value,float value1) diff --git a/source/gameengine/Physics/common/CMakeLists.txt b/source/gameengine/Physics/common/CMakeLists.txt index 400e475f8a2..5e0e5964ca0 100644 --- a/source/gameengine/Physics/common/CMakeLists.txt +++ b/source/gameengine/Physics/common/CMakeLists.txt @@ -26,6 +26,7 @@ set(INC . ../Dummy + ../../../../intern/moto/include ) set(INC_SYS diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h index 0fe2533cf93..d10f48ad7a4 100644 --- a/source/gameengine/Physics/common/PHY_DynamicTypes.h +++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h @@ -20,69 +20,9 @@ subject to the following restrictions: #ifndef __PHY_DYNAMICTYPES_H__ #define __PHY_DYNAMICTYPES_H__ - +#include "MT_Vector3.h" struct KX_ClientObjectInfo; -class PHY_Shape; - -struct PHY__Vector2 -{ - float m_vec[2]; - - operator const float* () const - { - return &m_vec[0]; - } - operator float* () - { - return &m_vec[0]; - } -}; - -struct PHY__Vector3 -{ - float m_vec[4]; - - operator const float* () const - { - return &m_vec[0]; - } - operator float* () - { - return &m_vec[0]; - } -}; - -struct PHY__Vector4 -{ - float m_vec[4]; - PHY__Vector4() {} - void setValue(const float *value) - { - m_vec[0] = *value++; - m_vec[1] = *value++; - m_vec[2] = *value++; - m_vec[3] = *value++; - } - void setValue(const double *value) - { - m_vec[0] = (float)(*value++); - m_vec[1] = (float)(*value++); - m_vec[2] = (float)(*value++); - m_vec[3] = (float)(*value++); - } - - operator const float* () const - { - return &m_vec[0]; - } - operator float* () - { - return &m_vec[0]; - } -}; - -//typedef float PHY__Vector3[4]; enum { @@ -97,9 +37,9 @@ enum }; typedef struct PHY_CollData { - PHY__Vector3 m_point1; /* Point in object1 in world coordinates */ - PHY__Vector3 m_point2; /* Point in object2 in world coordinates */ - PHY__Vector3 m_normal; /* point2 - point1 */ + MT_Vector3 m_point1; /* Point in object1 in world coordinates */ + MT_Vector3 m_point2; /* Point in object2 in world coordinates */ + MT_Vector3 m_normal; /* point2 - point1 */ } PHY_CollData; @@ -148,7 +88,4 @@ typedef enum PHY_ShapeType { PHY_SHAPE_PROXY } PHY_ShapeType; - -typedef float PHY_Vector3[3]; - #endif /* __PHY_DYNAMICTYPES_H__ */ diff --git a/source/gameengine/Physics/common/PHY_ICharacter.h b/source/gameengine/Physics/common/PHY_ICharacter.h index 8a599452816..a3d3000a143 100644 --- a/source/gameengine/Physics/common/PHY_ICharacter.h +++ b/source/gameengine/Physics/common/PHY_ICharacter.h @@ -28,8 +28,8 @@ public: virtual int GetJumpCount()= 0; - virtual void SetWalkDirection(PHY__Vector3 dir)=0; - virtual PHY__Vector3 GetWalkDirection()=0; + virtual void SetWalkDirection(const class MT_Vector3& dir)=0; + virtual MT_Vector3 GetWalkDirection()=0; #ifdef WITH_CXX_GUARDEDALLOC MEM_CXX_CLASS_ALLOC_FUNCS("GE:PHY_ICharacter") diff --git a/source/gameengine/Physics/common/PHY_IGraphicController.h b/source/gameengine/Physics/common/PHY_IGraphicController.h index fb36481ddbc..8c38eebe283 100644 --- a/source/gameengine/Physics/common/PHY_IGraphicController.h +++ b/source/gameengine/Physics/common/PHY_IGraphicController.h @@ -48,7 +48,7 @@ class PHY_IGraphicController : public PHY_IController */ virtual bool SetGraphicTransform()=0; virtual void Activate(bool active=true)=0; - virtual void setLocalAabb(const PHY__Vector3& aabbMin,const PHY__Vector3& aabbMax)=0; + virtual void setLocalAabb(const class MT_Vector3& aabbMin,const class MT_Vector3& aabbMax)=0; virtual void setLocalAabb(const float* aabbMin,const float* aabbMax)=0; virtual PHY_IGraphicController* GetReplica(class PHY_IMotionState* motionstate) {return 0;} diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h index 871edeec752..e6f26bc5b1b 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsController.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h @@ -66,7 +66,7 @@ class PHY_IPhysicsController : public PHY_IController virtual void getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)=0; virtual void setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)=0; virtual void setPosition(float posX,float posY,float posZ)=0; - virtual void getPosition(PHY__Vector3& pos) const=0; + virtual void getPosition(class MT_Vector3& pos) const=0; virtual void setScaling(float scaleX,float scaleY,float scaleZ)=0; // physics methods @@ -100,7 +100,7 @@ class PHY_IPhysicsController : public PHY_IController virtual float GetLinVelocityMax() const=0; virtual void SetLinVelocityMax(float val) = 0; - PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos); + class MT_Vector3 GetWorldPosition(class MT_Vector3& localpos); #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h index 6a76745c7ca..e7560ea02cc 100644 --- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h +++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h @@ -32,8 +32,10 @@ #ifndef __PHY_IPHYSICSENVIRONMENT_H__ #define __PHY_IPHYSICSENVIRONMENT_H__ -#include <vector> #include "PHY_DynamicTypes.h" +#include "MT_Vector2.h" +#include "MT_Vector3.h" +#include "MT_Vector4.h" #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" @@ -50,13 +52,13 @@ class PHY_IPhysicsController; struct PHY_RayCastResult { PHY_IPhysicsController* m_controller; - PHY__Vector3 m_hitPoint; - PHY__Vector3 m_hitNormal; + MT_Vector3 m_hitPoint; + MT_Vector3 m_hitNormal; const RAS_MeshObject* m_meshObject; // !=NULL for mesh object (only for Bullet controllers) int m_polygon; // index of the polygon hit by the ray, // only if m_meshObject != NULL int m_hitUVOK; // !=0 if UV coordinate in m_hitUV is valid - PHY__Vector2 m_hitUV; // UV coordinates of hit point + MT_Vector2 m_hitUV; // UV coordinates of hit point }; /** @@ -144,7 +146,7 @@ class PHY_IPhysicsEnvironment virtual void setUseEpa(bool epa) {} virtual void setGravity(float x,float y,float z)=0; - virtual void getGravity(PHY__Vector3& grav) = 0; + virtual void getGravity(MT_Vector3& grav) = 0; virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type, float pivotX,float pivotY,float pivotZ, @@ -167,7 +169,7 @@ class PHY_IPhysicsEnvironment //culling based on physical broad phase // the plane number must be set as follow: near, far, left, right, top, botton // the near plane must be the first one and must always be present, it is used to get the direction of the view - virtual bool cullingTest(PHY_CullingCallback callback, void *userData, PHY__Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0; + virtual bool cullingTest(PHY_CullingCallback callback, void *userData, MT_Vector4* planeNormals, int planeNumber, int occlusionRes, const int *viewport, double modelview[16], double projection[16]) = 0; //Methods for gamelogic collision/physics callbacks //todo: @@ -177,7 +179,7 @@ class PHY_IPhysicsEnvironment virtual bool requestCollisionCallback(PHY_IPhysicsController* ctrl)=0; virtual bool removeCollisionCallback(PHY_IPhysicsController* ctrl)=0; //These two methods are *solely* used to create controllers for sensor! Don't use for anything else - virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) =0; + virtual PHY_IPhysicsController* CreateSphereController(float radius,const MT_Vector3& position) =0; virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0; virtual void setConstraintParam(int constraintId,int param,float value,float value1) = 0; diff --git a/source/gameengine/Physics/common/PHY_IVehicle.h b/source/gameengine/Physics/common/PHY_IVehicle.h index ecf7a87c40f..624f435c9f0 100644 --- a/source/gameengine/Physics/common/PHY_IVehicle.h +++ b/source/gameengine/Physics/common/PHY_IVehicle.h @@ -22,9 +22,9 @@ public: virtual void AddWheel( PHY_IMotionState* motionState, - PHY__Vector3 connectionPoint, - PHY__Vector3 downDirection, - PHY__Vector3 axleDirection, + MT_Vector3 connectionPoint, + MT_Vector3 downDirection, + MT_Vector3 axleDirection, float suspensionRestLength, float wheelRadius, bool hasSteering |