From 009a11e33451e541d9e52c7ca324dee744da1b99 Mon Sep 17 00:00:00 2001 From: "chappuis.daniel" Date: Wed, 8 Jul 2009 14:53:58 +0000 Subject: [PATCH] git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@170 92aac97c-a6ce-11dd-a772-7fcde58d38e6 --- .../collision/CollisionDetection.cpp | 54 +++++++++++++++++ .../collision/CollisionDetection.h | 60 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 sources/reactphysics3d/collision/CollisionDetection.cpp create mode 100644 sources/reactphysics3d/collision/CollisionDetection.h diff --git a/sources/reactphysics3d/collision/CollisionDetection.cpp b/sources/reactphysics3d/collision/CollisionDetection.cpp new file mode 100644 index 00000000..53981aaf --- /dev/null +++ b/sources/reactphysics3d/collision/CollisionDetection.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** +* Copyright (C) 2009 Daniel Chappuis * +**************************************************************************** +* This file is part of ReactPhysics3D. * +* * +* ReactPhysics3D is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* ReactPhysics3D is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with ReactPhysics3D. If not, see . * +***************************************************************************/ + +// Libraries +#include "CollisionDetection.h" + +// We want to use the ReactPhysics3D namespace +using namespace reactphysics3d; + +// Constructor +CollisionDetection::CollisionDetection() { + + // Construct the broad-phase algorithm that will be used + broadPhaseAlgorithm = + + // Construct the narrow-phase algorithm that will be used + narrowPhaseAlgorithm = new SeparatingAxis(); +} + +// Destructor +~CollisionDetection() { + +} + +// Compute all the possible collisions pairs of bodies (broad-phase) +void CollisionDetection::computePossibleCollisionPairs() { + // TODO : Implement this method +} + +// Compute all collision contacts between bodies (narrow-phase) +void CollisionDetection::computeCollisionContacts() { + // TODO : Implement this method +} + +// Compute the collision detection +void CollisionDetection::computeCollisionDetection(CollisionWorld& collisionWorld) { + // TODO : Implement this method +} diff --git a/sources/reactphysics3d/collision/CollisionDetection.h b/sources/reactphysics3d/collision/CollisionDetection.h new file mode 100644 index 00000000..4b516585 --- /dev/null +++ b/sources/reactphysics3d/collision/CollisionDetection.h @@ -0,0 +1,60 @@ +/*************************************************************************** +* Copyright (C) 2009 Daniel Chappuis * +**************************************************************************** +* This file is part of ReactPhysics3D. * +* * +* ReactPhysics3D is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Lesser General Public License as published * +* by the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* ReactPhysics3D is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Lesser General Public License for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with ReactPhysics3D. If not, see . * +***************************************************************************/ + +#ifndef COLLISIONDETECTION_H +#define COLLISIONDETECTION_H + +// Libraries +#include "BroadPhaseAlgorithm.h" +#include "NarrowPhaseAlgorithm.h" +#include "../body/Body.h" +#include "../engine/CollisionWorld.h" +#include +#include + +// ReactPhysics3D namespace +namespace reactphysics3d { + +/* ------------------------------------------------------------------- + Class CollisionDetection : + This class computes the collision detection algorithms. We first + perfom a broad-phase algorithm to know wich pairs of bodies can + collide and then we run a narrow-phase algorithm to compute the + collision contacts between bodies. + ------------------------------------------------------------------- +*/ +class CollisionDetection { + private : + std::vector<(std::pair)> possibleCollisionPairList; // List that contains the possible collision pairs of bodies + BroadPhaseAlgorithm* broadPhaseAlgorithm; // Broad-phase algorithm + NarrowPhaseAlgorithm* narrowPhaseAlgorithm; // Narrow-phase algorithm + + void computePossibleCollisionPairs(); // Compute all the possible collisions pairs of bodies (broad-phase) + void computeCollisionContacts(); // Compute all collision contacts between bodies (narrow-phase) + + public : + CollisionDetection(); // Constructor + ~CollisionDetection(); // Destructor + + void computeCollisionDetection(CollisionWorld& collisionWorld); // Compute the collision detection +}; + +} // End of the ReactPhysics3D namespace + +#endif