Adding AABox::touches(box)

This commit is contained in:
Andrew Meadows 2014-01-24 13:59:03 -08:00
parent dbde1a29fe
commit 52511b2baf
2 changed files with 8 additions and 0 deletions

View file

@ -117,6 +117,13 @@ bool AABox::contains(const AABox& otherBox) const {
return true;
}
bool AABox::touches(const AABox& otherBox) const {
glm::vec3 relativeCenter = _corner - otherBox._corner + (glm::vec3(_scale - otherBox._scale) * 0.5f);
float totalScale = _scale + otherBox._scale;
return fabs(relativeCenter.x) <= totalScale &&
fabs(relativeCenter.y) <= totalScale &&
fabs(relativeCenter.z) <= totalScale;
}
// determines whether a value is within the expanded extents
static bool isWithinExpanded(float value, float corner, float size, float expansion) {

View file

@ -61,6 +61,7 @@ public:
bool contains(const glm::vec3& point) const;
bool contains(const AABox& otherBox) const;
bool touches(const AABox& otherBox) const;
bool expandedContains(const glm::vec3& point, float expansion) const;
bool expandedIntersectsSegment(const glm::vec3& start, const glm::vec3& end, float expansion) const;
bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face) const;