From 0de337cfe58ba14e03678463f9f6ad542a4d79a6 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Sun, 10 Jul 2011 17:56:00 +0000 Subject: [PATCH] changes in the code structure git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@433 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- src/body/Body.cpp | 2 +- src/body/Body.h | 4 +- src/body/RigidBody.cpp | 2 +- src/body/RigidBody.h | 2 +- src/collision/CollisionDetection.cpp | 2 +- src/collision/ContactInfo.h | 2 +- src/collision/EPA/EPAAlgorithm.h | 2 +- src/collision/GJK/GJKAlgorithm.h | 2 +- src/collision/SAPAlgorithm.h | 2 +- src/collision/SATAlgorithm.cpp | 2 +- src/collision/SATAlgorithm.h | 2 +- src/engine/ContactCachingInfo.h | 2 +- src/reactphysics3d.h | 11 +++--- src/shapes/ConeShape.h | 58 ++-------------------------- src/shapes/SphereShape.h | 2 +- 15 files changed, 22 insertions(+), 75 deletions(-) diff --git a/src/body/Body.cpp b/src/body/Body.cpp index 8ef260c5..2219949f 100644 --- a/src/body/Body.cpp +++ b/src/body/Body.cpp @@ -24,7 +24,7 @@ // Libraries #include "Body.h" -#include "Shape.h" +#include "../shapes/Shape.h" // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; diff --git a/src/body/Body.h b/src/body/Body.h index 6ea5dab8..185892aa 100644 --- a/src/body/Body.h +++ b/src/body/Body.h @@ -29,8 +29,8 @@ #include #include #include "../mathematics/Transform.h" -#include "../body/AABB.h" -#include "../body/Shape.h" +#include "../shapes/AABB.h" +#include "../shapes/Shape.h" // Namespace reactphysics3d namespace reactphysics3d { diff --git a/src/body/RigidBody.cpp b/src/body/RigidBody.cpp index 336b8c01..bf10b9c6 100644 --- a/src/body/RigidBody.cpp +++ b/src/body/RigidBody.cpp @@ -24,7 +24,7 @@ // Libraries #include "RigidBody.h" -#include "Shape.h" +#include "../shapes/Shape.h" // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; diff --git a/src/body/RigidBody.h b/src/body/RigidBody.h index 494f182b..02b264bb 100644 --- a/src/body/RigidBody.h +++ b/src/body/RigidBody.h @@ -28,7 +28,7 @@ // Libraries #include #include "Body.h" -#include "Shape.h" +#include "../shapes/Shape.h" #include "../mathematics/mathematics.h" // Namespace reactphysics3d diff --git a/src/collision/CollisionDetection.cpp b/src/collision/CollisionDetection.cpp index 930c681d..03bb7ff9 100644 --- a/src/collision/CollisionDetection.cpp +++ b/src/collision/CollisionDetection.cpp @@ -28,7 +28,7 @@ #include "GJK/GJKAlgorithm.h" #include "SATAlgorithm.h" #include "../body/Body.h" -#include "../body/BoxShape.h" +#include "../shapes/BoxShape.h" #include "../body/RigidBody.h" #include #include diff --git a/src/collision/ContactInfo.h b/src/collision/ContactInfo.h index 20ea156f..53735b8f 100644 --- a/src/collision/ContactInfo.h +++ b/src/collision/ContactInfo.h @@ -26,7 +26,7 @@ #define CONTACT_INFO_H // Libraries -#include "../body/BoxShape.h" +#include "../shapes/BoxShape.h" #include "../mathematics/mathematics.h" // ReactPhysics3D namespace diff --git a/src/collision/EPA/EPAAlgorithm.h b/src/collision/EPA/EPAAlgorithm.h index 8fdeddd4..1650f0c7 100644 --- a/src/collision/EPA/EPAAlgorithm.h +++ b/src/collision/EPA/EPAAlgorithm.h @@ -27,7 +27,7 @@ // Libraries #include "../GJK/Simplex.h" -#include "../../body/Shape.h" +#include "../../shapes/Shape.h" #include "../ContactInfo.h" #include "../../mathematics/mathematics.h" #include "TriangleEPA.h" diff --git a/src/collision/GJK/GJKAlgorithm.h b/src/collision/GJK/GJKAlgorithm.h index bf3b5a25..bdb326de 100644 --- a/src/collision/GJK/GJKAlgorithm.h +++ b/src/collision/GJK/GJKAlgorithm.h @@ -28,7 +28,7 @@ // Libraries #include "../NarrowPhaseAlgorithm.h" #include "../ContactInfo.h" -#include "../../body/Shape.h" +#include "../../shapes/Shape.h" #include "../EPA/EPAAlgorithm.h" diff --git a/src/collision/SAPAlgorithm.h b/src/collision/SAPAlgorithm.h index 2fe7859f..107064d2 100644 --- a/src/collision/SAPAlgorithm.h +++ b/src/collision/SAPAlgorithm.h @@ -27,7 +27,7 @@ // Libraries #include "BroadPhaseAlgorithm.h" -#include "../body/AABB.h" +#include "../shapes/AABB.h" // Namespace ReactPhysics3D namespace reactphysics3d { diff --git a/src/collision/SATAlgorithm.cpp b/src/collision/SATAlgorithm.cpp index 0bb1971e..27bb4dd9 100644 --- a/src/collision/SATAlgorithm.cpp +++ b/src/collision/SATAlgorithm.cpp @@ -24,7 +24,7 @@ // Libraries #include "SATAlgorithm.h" -#include "../body/BoxShape.h" +#include "../shapes/BoxShape.h" #include "../body/RigidBody.h" #include "../constraint/Contact.h" #include "../mathematics/Transform.h" diff --git a/src/collision/SATAlgorithm.h b/src/collision/SATAlgorithm.h index ea9249e2..dfc37e00 100644 --- a/src/collision/SATAlgorithm.h +++ b/src/collision/SATAlgorithm.h @@ -28,7 +28,7 @@ // Libraries #include "NarrowPhaseAlgorithm.h" #include "../constraint/Contact.h" -#include "../body/BoxShape.h" +#include "../shapes/BoxShape.h" #include "../mathematics/Transform.h" // ReactPhysics3D namespace diff --git a/src/engine/ContactCachingInfo.h b/src/engine/ContactCachingInfo.h index 52af8365..29eb0c56 100644 --- a/src/engine/ContactCachingInfo.h +++ b/src/engine/ContactCachingInfo.h @@ -26,7 +26,7 @@ #define CONTACT_CACHING_INFO_H // Libraries -#include "../body/BoxShape.h" +#include "../shapes/BoxShape.h" // ReactPhysics3D namespace namespace reactphysics3d { diff --git a/src/reactphysics3d.h b/src/reactphysics3d.h index 2982dc73..7ae39519 100644 --- a/src/reactphysics3d.h +++ b/src/reactphysics3d.h @@ -38,16 +38,15 @@ #include "body/RigidBody.h" #include "engine/PhysicsWorld.h" #include "engine/PhysicsEngine.h" -#include "body/Shape.h" -#include "body/BoxShape.h" -#include "body/SphereShape.h" -#include "body/AABB.h" +#include "shapes/Shape.h" +#include "shapes/BoxShape.h" +#include "shapes/SphereShape.h" +#include "shapes/ConeShape.h" +#include "shapes/AABB.h" // Alias to the ReactPhysics3D namespace namespace rp3d = reactphysics3d; // TODO : Use using namespace std in every possible cpp files to increase readability - - #endif diff --git a/src/shapes/ConeShape.h b/src/shapes/ConeShape.h index b87d58f9..c0cd1afe 100644 --- a/src/shapes/ConeShape.h +++ b/src/shapes/ConeShape.h @@ -38,70 +38,18 @@ namespace reactphysics3d { ------------------------------------------------------------------- */ class ConeShape : public Shape { - protected : - Vector3D center; // Center point of the sphere - double radius; // Radius of the sphere + private : public : - ConeShape(const Vector3D& center, double radius); // Constructor - virtual ~ConeShape(); // Destructor + ConeShape(); // Constructor + virtual ~ConeShape(); // Destructor - Vector3D getCenter() const; // Return the center point of the sphere - void setCenter(const Vector3D& center); // Set the center point of the sphere - double getRadius() const; // Return the radius of the sphere - void setRadius(double radius); // Set the radius of the sphere - virtual void update(const Vector3D& newCenter, - const Quaternion& rotationQuaternion); // Update the sphere orientation according to a new orientation of the rigid body - virtual AABB* computeAABB() const; // Return the corresponding AABB - virtual Vector3D getSupportPoint(const Vector3D& direction, double margin=0.0) const; // Return a support point in a given direction #ifdef VISUAL_DEBUG virtual void draw() const; // Draw the sphere (only for testing purpose) #endif }; -// Return the center point of the sphere -inline Vector3D SphereShape::getCenter() const { - return center; -} - -// Set the center point of the sphere -inline void SphereShape::setCenter(const Vector3D& center) { - this->center = center; -} - -// Get the radius of the sphere -inline double SphereShape::getRadius() const { - return radius; -} - -// Set the radius of the sphere -inline void SphereShape::setRadius(double radius) { - this->radius = radius; -} - -// Update the orientation of the shere according to the orientation of the rigid body -inline void SphereShape::update(const Vector3D& newCenter, const Quaternion& rotationQuaternion) { - // Update the center of the sphere - center = newCenter; -} - -// Return a support point in a given direction -inline Vector3D SphereShape::getSupportPoint(const Vector3D& direction, double margin) const { - assert(margin >= 0.0); - double length = direction.length(); - - // If the direction vector is not the zero vector - if (length > EPSILON) { - // Return the support point of the sphere in the given direction - return center + (radius + margin) * direction.getUnit(); - } - - // If the direction vector is the zero vector we return a point on the - // boundary of the sphere - return center + Vector3D(radius + margin, 0.0, 0.0); -} - }; // End of the ReactPhysics3D namespace #endif \ No newline at end of file diff --git a/src/shapes/SphereShape.h b/src/shapes/SphereShape.h index 49c1c6cb..dc07935d 100644 --- a/src/shapes/SphereShape.h +++ b/src/shapes/SphereShape.h @@ -38,7 +38,7 @@ namespace reactphysics3d { ------------------------------------------------------------------- */ class SphereShape : public Shape { - protected : + private : Vector3D center; // Center point of the sphere double radius; // Radius of the sphere