git-svn-id: https://reactphysics3d.googlecode.com/svn/trunk@232 92aac97c-a6ce-11dd-a772-7fcde58d38e6
This commit is contained in:
parent
2bd9701164
commit
902f3ab2b4
|
@ -162,7 +162,7 @@ inline Vector3D BodyState::getForce() const {
|
|||
|
||||
// Set the force over the body
|
||||
inline void BodyState::setForce(const Vector3D& force) {
|
||||
this->force;
|
||||
this->force = force;
|
||||
}
|
||||
|
||||
// Return the current torque of the body
|
||||
|
|
|
@ -134,30 +134,46 @@ void OBB::draw() const {
|
|||
|
||||
// Return all the vertices that are projected at the extreme of the projection of the bouding volume on the axis.
|
||||
// Be careful when this method returns vertices of a polygonal face because vertices are not necessarly ordered.
|
||||
std::vector<Vector3D> OBB::getExtremeVertices(const Vector3D axis) const {
|
||||
assert(axis.length() != 0);
|
||||
std::vector<Vector3D> OBB::getExtremeVertices(const Vector3D& directionAxis) const {
|
||||
assert(directionAxis.length() != 0);
|
||||
|
||||
std::vector<Vector3D> extremeVertices;
|
||||
|
||||
// Check if the given axis is parallel to an axis on the OBB
|
||||
if (axis[0].isParallelWith(axis)) {
|
||||
// TODO : Complete this
|
||||
if (axis[0].isParallelWith(directionAxis)) {
|
||||
if (axis[0].scalarProduct(directionAxis) >= 0) { // If both axis are in the same direction
|
||||
extremeVertices = getFace(0); // The extreme is the face 0
|
||||
}
|
||||
else {
|
||||
extremeVertices = getFace(1); // The extreme is the face 1
|
||||
}
|
||||
}
|
||||
else if(axis[1].isParallelWith(axis) {
|
||||
// TODO : Complete this
|
||||
else if(axis[1].isParallelWith(directionAxis)) {
|
||||
if (axis[1].scalarProduct(directionAxis) >= 0) { // If both axis are in the same direction
|
||||
extremeVertices = getFace(2); // The extreme is the face 2
|
||||
}
|
||||
else {
|
||||
extremeVertices = getFace(3); // The extreme is the face 3
|
||||
}
|
||||
|
||||
}
|
||||
else if(axis[2].isParallelWith(axis) {
|
||||
// TODO : Complete this
|
||||
else if(axis[2].isParallelWith(directionAxis)) {
|
||||
if (axis[2].scalarProduct(directionAxis) >= 0) { // If both axis are in the same direction
|
||||
extremeVertices = getFace(4); // The extreme is the face 4
|
||||
}
|
||||
else {
|
||||
extremeVertices = getFace(5); // The extreme is the face 5
|
||||
}
|
||||
}
|
||||
else { // The extreme is made of an unique vertex or an edge
|
||||
double maxProjectionLength = 0.0; // Longest projection length of a vertex onto the projection axis
|
||||
double maxProjectionLength = 0.0; // Longest projection length of a vertex onto the projection axis
|
||||
|
||||
// For each vertex of the OBB
|
||||
for (unsigned int i=0; i<8; ++i) {
|
||||
Vector3D vertex = getVertex(i);
|
||||
|
||||
// Compute the projection length of the current vertex onto the projection axis
|
||||
double projectionLength = axis.scalarProduct(vertex-center) / axis.length();
|
||||
double projectionLength = directionAxis.scalarProduct(vertex-center) / directionAxis.length();
|
||||
|
||||
// If we found a bigger projection length
|
||||
if (projectionLength > maxProjectionLength + EPSILON) {
|
||||
|
|
|
@ -58,7 +58,7 @@ class OBB : public BoundingVolume {
|
|||
std::vector<Vector3D> getFace(int index) const throw(std::invalid_argument); // Return the 4 vertices the OBB's face in the direction of a given axis
|
||||
double getExtent(unsigned int index) const throw(std::invalid_argument); // Return an extent value
|
||||
void setExtent(unsigned int index, double extent) throw(std::invalid_argument); // Set an extent value
|
||||
virtual std::vector<Vector3D> getExtremeVertices(const Vector3D axis) const; // Return all the vertices that are projected at the extreme of the projection of the bouding volume on the axis
|
||||
virtual std::vector<Vector3D> getExtremeVertices(const Vector3D& axis) const; // Return all the vertices that are projected at the extreme of the projection of the bouding volume on the axis
|
||||
virtual void updateOrientation(const Vector3D& newCenter, const Quaternion& rotationQuaternion); // Update the oriented bounding box orientation according to a new orientation of the rigid body
|
||||
virtual void draw() const; // Draw the OBB (only for testing purpose)
|
||||
};
|
||||
|
@ -74,7 +74,7 @@ inline void OBB::setCenter(const Vector3D& center) {
|
|||
}
|
||||
|
||||
// Return an axis of the OBB
|
||||
inline Vector3D OBB::getAxis(unsigned int index) const throw(std::invalid_argument) const {
|
||||
inline Vector3D OBB::getAxis(unsigned int index) const throw(std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <3) {
|
||||
return axis[index];
|
||||
|
@ -98,7 +98,7 @@ inline void OBB::setAxis(unsigned int index, const Vector3D& axis) throw(std::in
|
|||
}
|
||||
|
||||
// Return a vertex of the OBB
|
||||
inline Vector3D OBB::getVertex(unsigned int index) const throw (std::invalid_argument) const {
|
||||
inline Vector3D OBB::getVertex(unsigned int index) const throw (std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <8) {
|
||||
Vector3D vertex;
|
||||
|
@ -133,7 +133,7 @@ inline Vector3D OBB::getVertex(unsigned int index) const throw (std::invalid_arg
|
|||
|
||||
|
||||
// Return an extent value
|
||||
inline double OBB::getExtent(unsigned int index) const throw(std::invalid_argument) const {
|
||||
inline double OBB::getExtent(unsigned int index) const throw(std::invalid_argument) {
|
||||
// Check if the index value is valid
|
||||
if (index >= 0 && index <3) {
|
||||
return extent[index];
|
||||
|
|
Loading…
Reference in New Issue
Block a user