Remove files that are not used anymore and rename the SweepAndPrune class
git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@453 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
d762312d68
commit
55c1168b5d
|
@ -25,7 +25,7 @@
|
|||
|
||||
// Libraries
|
||||
#include "CollisionDetection.h"
|
||||
#include "broadphase/SAPAlgorithm.h"
|
||||
#include "broadphase/SweepAndPruneAlgorithm.h"
|
||||
#include "narrowphase/GJK/GJKAlgorithm.h"
|
||||
#include "../body/Body.h"
|
||||
#include "../shapes/BoxShape.h"
|
||||
|
@ -45,7 +45,7 @@ CollisionDetection::CollisionDetection(PhysicsWorld* world)
|
|||
: world(world), memoryPoolContacts(NB_MAX_CONTACTS), memoryPoolOverlappingPairs(NB_MAX_COLLISION_PAIRS) {
|
||||
|
||||
// Create the broad-phase algorithm that will be used (Sweep and Prune with AABB)
|
||||
broadPhaseAlgorithm = new SAPAlgorithm(*this);
|
||||
broadPhaseAlgorithm = new SweepAndPruneAlgorithm(*this);
|
||||
|
||||
// Create the narrow-phase algorithm that will be used (Separating axis algorithm)
|
||||
narrowPhaseAlgorithm = new GJKAlgorithm(*this);
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
********************************************************************************/
|
||||
|
||||
// Libraries
|
||||
#include "SAPAlgorithm.h"
|
||||
#include "SweepAndPruneAlgorithm.h"
|
||||
#include "../CollisionDetection.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -33,22 +33,22 @@ using namespace reactphysics3d;
|
|||
using namespace std;
|
||||
|
||||
// Initialize the static attributes
|
||||
unsigned short int SAPAlgorithm::sortAxis = 0;
|
||||
unsigned short int SweepAndPruneAlgorithm::sortAxis = 0;
|
||||
|
||||
// Constructor
|
||||
SAPAlgorithm::SAPAlgorithm(CollisionDetection& collisionDetection)
|
||||
SweepAndPruneAlgorithm::SweepAndPruneAlgorithm(CollisionDetection& collisionDetection)
|
||||
:BroadPhaseAlgorithm(collisionDetection) {
|
||||
|
||||
}
|
||||
|
||||
// Destructor
|
||||
SAPAlgorithm::~SAPAlgorithm() {
|
||||
SweepAndPruneAlgorithm::~SweepAndPruneAlgorithm() {
|
||||
|
||||
}
|
||||
|
||||
// Notify the broad-phase algorithm about new bodies in the physics world
|
||||
// This method removes the AABB representation of a given set of bodies from the sortedAABBs set
|
||||
void SAPAlgorithm::notifyRemovedBodies(vector<RigidBody*> bodies) {
|
||||
void SweepAndPruneAlgorithm::notifyRemovedBodies(vector<RigidBody*> bodies) {
|
||||
vector<const AABB*>::iterator elemToRemove;
|
||||
const AABB* aabb;
|
||||
|
||||
|
@ -64,7 +64,7 @@ void SAPAlgorithm::notifyRemovedBodies(vector<RigidBody*> bodies) {
|
|||
|
||||
// Notify the broad-phase algorithm about new bodies in the physics world
|
||||
// This method adds the AABB representation of a given body in the sortedAABBs set
|
||||
void SAPAlgorithm::notifyAddedBodies(vector<RigidBody*> bodies) {
|
||||
void SweepAndPruneAlgorithm::notifyAddedBodies(vector<RigidBody*> bodies) {
|
||||
const AABB* aabb;
|
||||
|
||||
for (vector<RigidBody*>::iterator it = bodies.begin(); it != bodies.end(); ++it) {
|
||||
|
@ -78,7 +78,7 @@ void SAPAlgorithm::notifyAddedBodies(vector<RigidBody*> bodies) {
|
|||
// This method computes the possible collision pairs of bodies and notify
|
||||
// the collision detection object about overlapping pairs using the
|
||||
// broadPhaseNotifyOverlappingPair() method from the CollisionDetection class
|
||||
void SAPAlgorithm::computePossibleCollisionPairs() {
|
||||
void SweepAndPruneAlgorithm::computePossibleCollisionPairs() {
|
||||
double variance[3]; // Variance of the distribution of the AABBs on the three x, y and z axis
|
||||
double esperance[] = {0.0, 0.0, 0.0}; // Esperance of the distribution of the AABBs on the three x, y and z axis
|
||||
double esperanceSquare[] = {0.0, 0.0, 0.0}; // Esperance of the square of the distribution values of the AABBs on the three x, y and z axis
|
|
@ -51,7 +51,7 @@ namespace reactphysics3d {
|
|||
broad-phase computation.
|
||||
--------------------------------------------------------------------
|
||||
*/
|
||||
class SAPAlgorithm : public BroadPhaseAlgorithm {
|
||||
class SweepAndPruneAlgorithm : public BroadPhaseAlgorithm {
|
||||
protected :
|
||||
std::vector<const AABB*> sortedAABBs; // Sorted set of AABB of the bodies on one of the x.y or z axis
|
||||
static unsigned short int sortAxis; // Current sorting axis (0 for x, 1 for y, 2 for z axis)
|
||||
|
@ -60,8 +60,8 @@ class SAPAlgorithm : public BroadPhaseAlgorithm {
|
|||
|
||||
|
||||
public :
|
||||
SAPAlgorithm(CollisionDetection& collisionDetection); // Constructor
|
||||
virtual ~SAPAlgorithm(); // Destructor
|
||||
SweepAndPruneAlgorithm(CollisionDetection& collisionDetection); // Constructor
|
||||
virtual ~SweepAndPruneAlgorithm(); // Destructor
|
||||
|
||||
virtual void computePossibleCollisionPairs(); // Compute the possible collision pairs of bodies
|
||||
virtual void notifyAddedBodies(std::vector<RigidBody*> bodies); // Notify the broad-phase algorithm about new bodies in the physics world
|
||||
|
@ -74,7 +74,7 @@ class SAPAlgorithm : public BroadPhaseAlgorithm {
|
|||
// consider that "a" goes before "b" if the minimum value of "a" on the current
|
||||
// sorting axis (sortAxis) is smaller than the minimum value of "b" on this same
|
||||
// axis.
|
||||
inline bool SAPAlgorithm::compareAABBs(const AABB* a, const AABB* b) {
|
||||
inline bool SweepAndPruneAlgorithm::compareAABBs(const AABB* a, const AABB* b) {
|
||||
return (a->getMinCoordinates()[sortAxis] < b->getMinCoordinates()[sortAxis]);
|
||||
}
|
||||
|
|
@ -30,7 +30,6 @@
|
|||
#include <cmath>
|
||||
#include "Vector3.h"
|
||||
#include "Matrix3x3.h"
|
||||
#include "exceptions.h"
|
||||
|
||||
// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
@ -49,31 +48,31 @@ class Quaternion {
|
|||
double w; // Component w of the quaternion
|
||||
|
||||
public :
|
||||
Quaternion(); // Constructor
|
||||
Quaternion(double x, double y, double z, double w); // Constructor with arguments
|
||||
Quaternion(double w, const Vector3& v); // Constructor with the component w and the vector v=(x y z)
|
||||
Quaternion(const Quaternion& quaternion); // Copy-constructor
|
||||
Quaternion(const Matrix3x3& matrix); // Create a unit quaternion from a rotation matrix
|
||||
~Quaternion(); // Destructor
|
||||
double getX() const; // Return the component x of the quaternion
|
||||
double getY() const; // Return the component y of the quaternion
|
||||
double getZ() const; // Return the component z of the quaternion
|
||||
double getW() const; // Return the component w of the quaternion
|
||||
void setX(double x); // Set the value x
|
||||
void setY(double y); // Set the value y
|
||||
void setZ(double z); // Set the value z
|
||||
void setW(double w); // Set the value w
|
||||
Vector3 vectorV() const; // Return the vector v=(x y z) of the quaternion
|
||||
double length() const; // Return the length of the quaternion
|
||||
Quaternion getUnit() const; // Return the unit quaternion
|
||||
Quaternion getConjugate() const; // Return the conjugate quaternion
|
||||
Quaternion getInverse() const throw (MathematicsException); // Return the inverse of the quaternion
|
||||
Matrix3x3 getMatrix() const; // Return the orientation matrix corresponding to this quaternion
|
||||
static Quaternion identity(); // Return the identity quaternion
|
||||
double dot(const Quaternion& quaternion) const; // Dot product between two quaternions
|
||||
void getRotationAngleAxis(double& angle, Vector3& axis) const; // Compute the rotation angle (in radians) and the axis
|
||||
Quaternion(); // Constructor
|
||||
Quaternion(double x, double y, double z, double w); // Constructor with arguments
|
||||
Quaternion(double w, const Vector3& v); // Constructor with the component w and the vector v=(x y z)
|
||||
Quaternion(const Quaternion& quaternion); // Copy-constructor
|
||||
Quaternion(const Matrix3x3& matrix); // Create a unit quaternion from a rotation matrix
|
||||
~Quaternion(); // Destructor
|
||||
double getX() const; // Return the component x of the quaternion
|
||||
double getY() const; // Return the component y of the quaternion
|
||||
double getZ() const; // Return the component z of the quaternion
|
||||
double getW() const; // Return the component w of the quaternion
|
||||
void setX(double x); // Set the value x
|
||||
void setY(double y); // Set the value y
|
||||
void setZ(double z); // Set the value z
|
||||
void setW(double w); // Set the value w
|
||||
Vector3 vectorV() const; // Return the vector v=(x y z) of the quaternion
|
||||
double length() const; // Return the length of the quaternion
|
||||
Quaternion getUnit() const; // Return the unit quaternion
|
||||
Quaternion getConjugate() const; // Return the conjugate quaternion
|
||||
Quaternion getInverse() const; // Return the inverse of the quaternion
|
||||
Matrix3x3 getMatrix() const; // Return the orientation matrix corresponding to this quaternion
|
||||
static Quaternion identity(); // Return the identity quaternion
|
||||
double dot(const Quaternion& quaternion) const; // Dot product between two quaternions
|
||||
void getRotationAngleAxis(double& angle, Vector3& axis) const; // Compute the rotation angle (in radians) and the axis
|
||||
static Quaternion slerp(const Quaternion& quaternion1,
|
||||
const Quaternion& quaternion2, double t); // Compute the spherical linear interpolation between two quaternions
|
||||
const Quaternion& quaternion2, double t); // Compute the spherical linear interpolation between two quaternions
|
||||
|
||||
// --- Overloaded operators --- //
|
||||
Quaternion operator+(const Quaternion& quaternion) const; // Overloaded operator for the addition
|
||||
|
@ -159,20 +158,14 @@ inline Quaternion Quaternion::getConjugate() const {
|
|||
}
|
||||
|
||||
// Return the inverse of the quaternion (inline)
|
||||
inline Quaternion Quaternion::getInverse() const throw(MathematicsException) {
|
||||
inline Quaternion Quaternion::getInverse() const {
|
||||
double lengthQuaternion = length();
|
||||
lengthQuaternion = lengthQuaternion * lengthQuaternion;
|
||||
|
||||
// Check if the length is not equal to zero
|
||||
if (lengthQuaternion != 0.0) {
|
||||
assert (lengthQuaternion != 0.0);
|
||||
|
||||
// Compute and return the inverse quaternion
|
||||
return Quaternion(-x/lengthQuaternion, -y/lengthQuaternion, -z/lengthQuaternion, w/lengthQuaternion);
|
||||
}
|
||||
else {
|
||||
// Throw an exception because the inverse cannot be computed
|
||||
throw MathematicsException("MathematicsException : Impossible to compute the inverse of the quaternion because it's length is zero");
|
||||
}
|
||||
// Compute and return the inverse quaternion
|
||||
return Quaternion(-x/lengthQuaternion, -y/lengthQuaternion, -z/lengthQuaternion, w/lengthQuaternion);
|
||||
}
|
||||
|
||||
// Scalar product between two quaternions
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
// Libraries
|
||||
#include <cmath>
|
||||
#include "exceptions.h"
|
||||
#include "mathematics_functions.h"
|
||||
|
||||
|
||||
|
@ -45,11 +44,10 @@ class Vector3 {
|
|||
double values[3]; // Values of the 3D vector
|
||||
|
||||
public :
|
||||
Vector3(); // Constructor of the class Vector3D
|
||||
Vector3(double x, double y, double z); // Constructor with arguments
|
||||
Vector3(const Vector3& vector); // Copy-constructor
|
||||
virtual ~Vector3(); // Destructor
|
||||
void setValue(int index, double value) throw(std::invalid_argument); // Set a component of the vector
|
||||
Vector3(); // Constructor of the class Vector3D
|
||||
Vector3(double x, double y, double z); // Constructor with arguments
|
||||
Vector3(const Vector3& vector); // Copy-constructor
|
||||
virtual ~Vector3(); // Destructor
|
||||
double getX() const; // Get the x component of the vector
|
||||
double getY() const; // Get the y component of the vector
|
||||
double getZ() const; // Get the z component of the vector
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/********************************************************************************
|
||||
* ReactPhysics3D physics library, http://code.google.com/p/reactphysics3d/ *
|
||||
* Copyright (c) 2010-2012 Daniel Chappuis *
|
||||
*********************************************************************************
|
||||
* *
|
||||
* This software is provided 'as-is', without any express or implied warranty. *
|
||||
* In no event will the authors be held liable for any damages arising from the *
|
||||
* use of this software. *
|
||||
* *
|
||||
* Permission is granted to anyone to use this software for any purpose, *
|
||||
* including commercial applications, and to alter it and redistribute it *
|
||||
* freely, subject to the following restrictions: *
|
||||
* *
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim *
|
||||
* that you wrote the original software. If you use this software in a *
|
||||
* product, an acknowledgment in the product documentation would be *
|
||||
* appreciated but is not required. *
|
||||
* *
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be *
|
||||
* misrepresented as being the original software. *
|
||||
* *
|
||||
* 3. This notice may not be removed or altered from any source distribution. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
// Libraries
|
||||
#include "exceptions.h"
|
||||
|
||||
// Namespaces
|
||||
using namespace reactphysics3d;
|
||||
|
||||
|
||||
// Constructor of the MathematicsException class
|
||||
MathematicsException::MathematicsException(const std::string& msg)
|
||||
:std::runtime_error(msg) {
|
||||
|
||||
}
|
||||
|
||||
// Destructor of the MathException class
|
||||
MathematicsException::~MathematicsException() throw() {
|
||||
|
||||
}
|
||||
|
||||
// Overriden exception base class method
|
||||
const char* MathematicsException::what() const throw() {
|
||||
return std::runtime_error::what();
|
||||
}
|
||||
|
||||
// Constructor of the DivisionByZeroException class
|
||||
DivisionByZeroException::DivisionByZeroException(const std::string& msg)
|
||||
:MathematicsException(msg) {
|
||||
|
||||
}
|
||||
|
||||
// Destructor of the DivisionByZeroException class
|
||||
DivisionByZeroException::~DivisionByZeroException() throw() {
|
||||
|
||||
}
|
||||
|
||||
// Overriden exception base class method
|
||||
const char* DivisionByZeroException::what() const throw() {
|
||||
return MathematicsException::what();
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/********************************************************************************
|
||||
* ReactPhysics3D physics library, http://code.google.com/p/reactphysics3d/ *
|
||||
* Copyright (c) 2010-2012 Daniel Chappuis *
|
||||
*********************************************************************************
|
||||
* *
|
||||
* This software is provided 'as-is', without any express or implied warranty. *
|
||||
* In no event will the authors be held liable for any damages arising from the *
|
||||
* use of this software. *
|
||||
* *
|
||||
* Permission is granted to anyone to use this software for any purpose, *
|
||||
* including commercial applications, and to alter it and redistribute it *
|
||||
* freely, subject to the following restrictions: *
|
||||
* *
|
||||
* 1. The origin of this software must not be misrepresented; you must not claim *
|
||||
* that you wrote the original software. If you use this software in a *
|
||||
* product, an acknowledgment in the product documentation would be *
|
||||
* appreciated but is not required. *
|
||||
* *
|
||||
* 2. Altered source versions must be plainly marked as such, and must not be *
|
||||
* misrepresented as being the original software. *
|
||||
* *
|
||||
* 3. This notice may not be removed or altered from any source distribution. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef EXCEPTIONS_H
|
||||
#define EXCEPTIONS_H
|
||||
|
||||
// Libraries
|
||||
#include <stdexcept>
|
||||
|
||||
// ReactPhysics3D namespace
|
||||
namespace reactphysics3d {
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
Exception class for the mathematics library
|
||||
-------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Class MathematicsException
|
||||
class MathematicsException : public std::runtime_error {
|
||||
public:
|
||||
MathematicsException(const std::string& msg="MathException"); // Constructor
|
||||
virtual ~MathematicsException() throw(); // Destructor
|
||||
virtual const char* what() const throw(); // Overriding the base exception method
|
||||
};
|
||||
|
||||
// Class DivisionByZeroException
|
||||
class DivisionByZeroException : public MathematicsException {
|
||||
public:
|
||||
DivisionByZeroException(const std::string& msg="DivisionByZeroException : Division by zero !"); // Constructor
|
||||
virtual ~DivisionByZeroException() throw(); // Destructor
|
||||
virtual const char* what() const throw(); // Overriding the base exception method
|
||||
};
|
||||
|
||||
} // End of the ReactPhysics3D namespace
|
||||
|
||||
#endif
|
|
@ -32,7 +32,6 @@
|
|||
#include "Vector3.h"
|
||||
#include "Transform.h"
|
||||
#include "../constants.h"
|
||||
#include "exceptions.h"
|
||||
#include "mathematics_functions.h"
|
||||
#include <vector>
|
||||
#include <cstdio>
|
||||
|
|
Loading…
Reference in New Issue
Block a user