git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@328 92aac97c-a6ce-11dd-a772-7fcde58d38e6

This commit is contained in:
chappuis.daniel 2010-06-08 21:03:11 +00:00
parent 903e543695
commit 99de21bcaa
5 changed files with 16 additions and 10 deletions

View File

@ -154,7 +154,7 @@ inline void BodyState::setMassInverse(Kilogram massInverse) {
} }
// Get the inverse of the inertia tensor // Get the inverse of the inertia tensor
Matrix3x3 BodyState::getInertiaTensorInverse() const { inline Matrix3x3 BodyState::getInertiaTensorInverse() const {
return inertiaTensorInverse; return inertiaTensorInverse;
} }

View File

@ -66,7 +66,7 @@ class RigidBody : public Body {
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 setLinearVelocity(const Vector3D& linearVelocity); // Set the linear velocity of the rigid body
void updatePreviousBodyState(); // Update the previous body state of the 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 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 // Return the oriented bounding box of the rigid body
inline OBB RigidBody::getOBB() const { inline const OBB* const RigidBody::getOBB() const {
return obb; return &obb;
} }
// Update the rigid body in order to reflect a change in the body state // Update the rigid body in order to reflect a change in the body state

View File

@ -76,13 +76,13 @@ void CollisionDetection::computeBroadPhase() {
RigidBody* rigidBody2 = dynamic_cast<RigidBody*>(*it2); RigidBody* rigidBody2 = dynamic_cast<RigidBody*>(*it2);
if(rigidBody1 && rigidBody2 && rigidBody1 != rigidBody2) { if(rigidBody1 && rigidBody2 && rigidBody1 != rigidBody2) {
// Get the oriented bounding boxes of the two bodies // Get the oriented bounding boxes of the two bodies
OBB obb1 = rigidBody1->getOBB(); const OBB* obb1 = rigidBody1->getOBB();
OBB obb2 = rigidBody2->getOBB(); const OBB* obb2 = rigidBody2->getOBB();
// Use the broad-phase algorithm to decide if the two bodies can collide // 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 // If the broad-phase thinks that the two bodies collide, we add the in the possible collision pair list
possibleCollisionPairs.push_back(std::pair<const OBB*, const OBB*>(&obb1, &obb2)); possibleCollisionPairs.push_back(std::pair<const OBB*, const OBB*>(obb1, obb2));
} }
} }
} }

View File

@ -20,6 +20,8 @@
// Libraries // Libraries
#include "ContactInfo.h" #include "ContactInfo.h"
using namespace reactphysics3d;
// Constructor // Constructor
ContactInfo::ContactInfo(const OBB* const obb1, const OBB* const obb2, const Vector3D& normal, double penetrationDepth) ContactInfo::ContactInfo(const OBB* const obb1, const OBB* const obb2, const Vector3D& normal, double penetrationDepth)
: obb1(obb1), obb2(obb2), normal(normal), penetrationDepth(penetrationDepth) { : obb1(obb1), obb2(obb2), normal(normal), penetrationDepth(penetrationDepth) {

View File

@ -25,6 +25,7 @@
#include <algorithm> #include <algorithm>
#include <cfloat> #include <cfloat>
#include <cassert> #include <cassert>
#include <iostream> // TODO : Delete this
// We want to use the ReactPhysics3D namespace // We want to use the ReactPhysics3D namespace
using namespace reactphysics3d; using namespace reactphysics3d;
@ -49,6 +50,8 @@ bool SATAlgorithm::testCollision(const BoundingVolume* const boundingVolume1, co
assert(boundingVolume1 != boundingVolume2); assert(boundingVolume1 != boundingVolume2);
// If the two bounding volumes are OBB // If the two bounding volumes are OBB
//const OBB* const obb1 = dynamic_cast<const OBB* const>(boundingVolume1);
//const OBB* const obb2 = dynamic_cast<const OBB* const>(boundingVolume2);
const OBB* const obb1 = dynamic_cast<const OBB* const>(boundingVolume1); const OBB* const obb1 = dynamic_cast<const OBB* const>(boundingVolume1);
const OBB* const obb2 = dynamic_cast<const OBB* const>(boundingVolume2); const OBB* const obb2 = dynamic_cast<const OBB* const>(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. // 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 { bool SATAlgorithm::computeCollisionTest(const OBB* const obb1, const OBB* const obb2, ContactInfo*& contactInfo) const {
double center; // Center of a projection interval double center; // Center of a projection interval
double radius1; // Radius of projection interval [min1, max1] double radius1; // Radius of projection interval [min1, max1]
double radius2; // Radius of projection interval [min2, max2] double radius2; // Radius of projection interval [min2, max2]