A leaf contains actual geometry, in the form of a list of triangles. More...
#include <collisionModel.h>
Public Member Functions | |
void | addTriangle (Triangle t) |
void | clearTriangles () |
void | computeBbox () |
int | getNumTriangles () const |
const std::list< Triangle > * | getTriangles () const |
bool | isLeaf () const |
Leaf () | |
Just a stub. | |
Branch * | split () |
Splits this leaf into 2 children; returns a new branch with the new children. | |
Private Member Functions | |
void | areaWeightedCovarianceMatrix (double covMat[3][3]) |
Computes the covariance matrix of all triangles weighted by triangle area. | |
void | balancedSplit (vec3 axis, double sepPoint, Leaf *child1, Leaf *child2) |
Distributes triangles between children based on projection of triangle centroid. | |
void | computeBboxAA () |
void | computeBboxOO () |
void | fitBox (const mat3 &R, vec3 ¢er, vec3 &halfSize) |
position | getMeanVertex () |
double | getMedianProjection (const vec3 &axis) |
Finds the median projection point of all vertices unto a given axis. | |
void | optimalSplit (const vec3 &x, const vec3 &y, const vec3 &z, Leaf *child1, Leaf *child2) |
Computes the split point along the given axis that ensures min volume of child bounding boxes. | |
void | randomSplit (Leaf *child1, Leaf *child2) |
Ensures equal number of triangles per child by distributing triangles randomly. | |
Private Attributes | |
std::list< Triangle > | mTriangles |
Static Private Attributes | |
static const int | MAX_LEAF_TRIANGLES = 1 |
The Bbox hierarchy is built until all leaves have at most this many triangles. | |
static const double | TOLERANCE = 1.0e-2 |
Added around bounding boxes to guarantee they enclose the contents. |
A leaf contains actual geometry, in the form of a list of triangles.
The leaf is the only type of node that contains actual geoemtry. It also knows how to compute its own bounding box and to split itself into children.
Definition at line 81 of file collisionModel.h.
Collision::Leaf::Leaf | ( | ) | [inline] |
Just a stub.
Definition at line 105 of file collisionModel.h.
void Collision::Leaf::addTriangle | ( | Triangle | t | ) | [inline] |
Definition at line 109 of file collisionModel.h.
void Collision::Leaf::areaWeightedCovarianceMatrix | ( | double | covMat[3][3] | ) | [private] |
Computes the covariance matrix of all triangles weighted by triangle area.
Formula taken from "Real Time Collision Detection" by C. Ericson
Definition at line 127 of file collisionModel.cpp.
void Collision::Leaf::balancedSplit | ( | vec3 | axis, | |
double | sepPoint, | |||
Leaf * | child1, | |||
Leaf * | child2 | |||
) | [private] |
Distributes triangles between children based on projection of triangle centroid.
Splits triangles based on the location of their centroid.
Definition at line 314 of file collisionModel.cpp.
void Collision::Leaf::clearTriangles | ( | ) | [inline] |
Definition at line 112 of file collisionModel.h.
void Collision::Leaf::computeBbox | ( | ) | [inline] |
Definition at line 110 of file collisionModel.h.
void Collision::Leaf::computeBboxAA | ( | ) | [private] |
Definition at line 223 of file collisionModel.cpp.
void Collision::Leaf::computeBboxOO | ( | ) | [private] |
Definition at line 161 of file collisionModel.cpp.
Definition at line 92 of file collisionModel.cpp.
position Collision::Leaf::getMeanVertex | ( | ) | [private] |
Definition at line 44 of file collisionModel.cpp.
double Collision::Leaf::getMedianProjection | ( | const vec3 & | axis | ) | [private] |
Finds the median projection point of all vertices unto a given axis.
Definition at line 59 of file collisionModel.cpp.
int Collision::Leaf::getNumTriangles | ( | ) | const [inline] |
Definition at line 111 of file collisionModel.h.
const std::list<Triangle>* Collision::Leaf::getTriangles | ( | ) | const [inline] |
Definition at line 113 of file collisionModel.h.
bool Collision::Leaf::isLeaf | ( | ) | const [inline, virtual] |
Implements Collision::Node.
Definition at line 106 of file collisionModel.h.
void Collision::Leaf::optimalSplit | ( | const vec3 & | x, | |
const vec3 & | y, | |||
const vec3 & | z, | |||
Leaf * | child1, | |||
Leaf * | child2 | |||
) | [private] |
Computes the split point along the given axis that ensures min volume of child bounding boxes.
The split is done along the given x axis, and the optimal child bounding boxes are aligned with the x,y,z axes. Of course, there is no guarantee that the children will actually build their own bboxes along those axes; as they will do their own principal components they might end up with boxes aligned differently.
Definition at line 361 of file collisionModel.cpp.
Ensures equal number of triangles per child by distributing triangles randomly.
Assigns triangles to the two children randomly
Definition at line 334 of file collisionModel.cpp.
Branch * Collision::Leaf::split | ( | ) | [virtual] |
Splits this leaf into 2 children; returns a new branch with the new children.
The split process goes through the followins stages:
Reimplemented from Collision::Node.
Definition at line 242 of file collisionModel.cpp.
const int Collision::Leaf::MAX_LEAF_TRIANGLES = 1 [static, private] |
The Bbox hierarchy is built until all leaves have at most this many triangles.
Definition at line 86 of file collisionModel.h.
std::list<Triangle> Collision::Leaf::mTriangles [private] |
Definition at line 88 of file collisionModel.h.
const double Collision::Leaf::TOLERANCE = 1.0e-2 [static, private] |
Added around bounding boxes to guarantee they enclose the contents.
Definition at line 84 of file collisionModel.h.