From 99de21bcaac0bc27de87db621c18012bc2f7a1d0 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Tue, 8 Jun 2010 21:03:11 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@328 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- sources/reactphysics3d/body/BodyState.h | 2 +- sources/reactphysics3d/body/RigidBody.h | 8 ++++---- sources/reactphysics3d/collision/CollisionDetection.cpp | 8 ++++---- sources/reactphysics3d/collision/ContactInfo.cpp | 2 ++ sources/reactphysics3d/collision/SATAlgorithm.cpp | 6 +++++- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sources/reactphysics3d/body/BodyState.h b/sources/reactphysics3d/body/BodyState.h index b922d7e7..51c9b113 100644 --- a/sources/reactphysics3d/body/BodyState.h +++ b/sources/reactphysics3d/body/BodyState.h @@ -154,7 +154,7 @@ inline void BodyState::setMassInverse(Kilogram massInverse) { } // Get the inverse of the inertia tensor -Matrix3x3 BodyState::getInertiaTensorInverse() const { +inline Matrix3x3 BodyState::getInertiaTensorInverse() const { return inertiaTensorInverse; } diff --git a/sources/reactphysics3d/body/RigidBody.h b/sources/reactphysics3d/body/RigidBody.h index f435ee22..7e3d07f7 100644 --- a/sources/reactphysics3d/body/RigidBody.h +++ b/sources/reactphysics3d/body/RigidBody.h @@ -63,10 +63,10 @@ class RigidBody : public Body { void setInterpolationFactor(double factor); // Set the interpolation factor of the body BodyState getInterpolatedState() const; // Compute and return the interpolated state bool getIsMotionEnabled() const; // Return if the rigid body can move - void setIsMotionEnabled(bool isMotionEnabled); // Set the value to true if the body can move + void setIsMotionEnabled(bool isMotionEnabled); // Set the value to true if the body can move void setLinearVelocity(const Vector3D& linearVelocity); // Set the linear velocity of the rigid body void updatePreviousBodyState(); // Update the previous body state of the body - OBB getOBB() const; // Return the oriented bounding box of the rigid body + const OBB* const getOBB() const; // Return the oriented bounding box of the rigid body void update(); // Update the rigid body in order to reflect a change in the body state }; @@ -128,8 +128,8 @@ inline void RigidBody::updatePreviousBodyState() { } // Return the oriented bounding box of the rigid body -inline OBB RigidBody::getOBB() const { - return obb; +inline const OBB* const RigidBody::getOBB() const { + return &obb; } // Update the rigid body in order to reflect a change in the body state diff --git a/sources/reactphysics3d/collision/CollisionDetection.cpp b/sources/reactphysics3d/collision/CollisionDetection.cpp index 05dcf859..45c8ae80 100644 --- a/sources/reactphysics3d/collision/CollisionDetection.cpp +++ b/sources/reactphysics3d/collision/CollisionDetection.cpp @@ -76,13 +76,13 @@ void CollisionDetection::computeBroadPhase() { RigidBody* rigidBody2 = dynamic_cast(*it2); if(rigidBody1 && rigidBody2 && rigidBody1 != rigidBody2) { // Get the oriented bounding boxes of the two bodies - OBB obb1 = rigidBody1->getOBB(); - OBB obb2 = rigidBody2->getOBB(); + const OBB* obb1 = rigidBody1->getOBB(); + const OBB* obb2 = rigidBody2->getOBB(); // Use the broad-phase algorithm to decide if the two bodies can collide - if(broadPhaseAlgorithm->testCollisionPair(&obb1, &obb2)) { + if(broadPhaseAlgorithm->testCollisionPair(obb1, obb2)) { // If the broad-phase thinks that the two bodies collide, we add the in the possible collision pair list - possibleCollisionPairs.push_back(std::pair(&obb1, &obb2)); + possibleCollisionPairs.push_back(std::pair(obb1, obb2)); } } } diff --git a/sources/reactphysics3d/collision/ContactInfo.cpp b/sources/reactphysics3d/collision/ContactInfo.cpp index 5edaeb19..7520300a 100644 --- a/sources/reactphysics3d/collision/ContactInfo.cpp +++ b/sources/reactphysics3d/collision/ContactInfo.cpp @@ -20,6 +20,8 @@ // Libraries #include "ContactInfo.h" +using namespace reactphysics3d; + // Constructor ContactInfo::ContactInfo(const OBB* const obb1, const OBB* const obb2, const Vector3D& normal, double penetrationDepth) : obb1(obb1), obb2(obb2), normal(normal), penetrationDepth(penetrationDepth) { diff --git a/sources/reactphysics3d/collision/SATAlgorithm.cpp b/sources/reactphysics3d/collision/SATAlgorithm.cpp index 1a75e63f..e1e600b0 100644 --- a/sources/reactphysics3d/collision/SATAlgorithm.cpp +++ b/sources/reactphysics3d/collision/SATAlgorithm.cpp @@ -25,6 +25,7 @@ #include #include #include +#include // TODO : Delete this // We want to use the ReactPhysics3D namespace using namespace reactphysics3d; @@ -45,10 +46,12 @@ SATAlgorithm::~SATAlgorithm() { // Return true and compute a contact info if the two bounding volume collide. // The method returns false if there is no collision between the two bounding volumes. bool SATAlgorithm::testCollision(const BoundingVolume* const boundingVolume1, const BoundingVolume* const boundingVolume2, ContactInfo*& contactInfo) { - + assert(boundingVolume1 != boundingVolume2); // If the two bounding volumes are OBB + //const OBB* const obb1 = dynamic_cast(boundingVolume1); + //const OBB* const obb2 = dynamic_cast(boundingVolume2); const OBB* const obb1 = dynamic_cast(boundingVolume1); const OBB* const obb2 = dynamic_cast(boundingVolume2); @@ -72,6 +75,7 @@ bool SATAlgorithm::testCollision(const BoundingVolume* const boundingVolume1, co // normal of OBB 1 and Bj for the jth face normal of OBB 2. bool SATAlgorithm::computeCollisionTest(const OBB* const obb1, const OBB* const obb2, ContactInfo*& contactInfo) const { + double center; // Center of a projection interval double radius1; // Radius of projection interval [min1, max1] double radius2; // Radius of projection interval [min2, max2]