add AACube::operator<() so they can be sorted

This commit is contained in:
Andrew Meadows 2014-09-03 13:13:54 -07:00
parent a71823353b
commit 0cc6f559d4
2 changed files with 9 additions and 0 deletions

View file

@ -314,6 +314,13 @@ bool AACube::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end
return true;
}
bool AACube::operator<(const AACube& otherCube) const {
return (_corner.x < otherCube._corner.x
|| (_corner.x == otherCube._corner.x && (_corner.y < otherCube._corner.y
|| (_corner.y == otherCube._corner.y && (_corner.z < otherCube._corner.z
|| _scale < otherCube._scale)))));
}
glm::vec3 AACube::getClosestPointOnFace(const glm::vec3& point, BoxFace face) const {
switch (face) {
case MIN_X_FACE:

View file

@ -50,6 +50,8 @@ public:
bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration) const;
bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) const;
bool operator<(const AACube& otherCube) const; // for qSorted lists of AACubes
private:
glm::vec3 getClosestPointOnFace(const glm::vec3& point, BoxFace face) const;
glm::vec3 getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& direction, BoxFace face) const;