summaryrefslogtreecommitdiff
path: root/core/math/aabb.h
diff options
context:
space:
mode:
authorsheepandshepherd <sheepandshepherd@hotmail.com>2016-02-17 20:06:40 +0100
committersheepandshepherd <sheepandshepherd@hotmail.com>2016-02-17 20:06:40 +0100
commitc88c60d08e589baa54e5aa75b947f3b69c40a904 (patch)
tree7ad2d77b8eb6ed072de8cf434b741d2bf3b9c2da /core/math/aabb.h
parent39f69cbfc33255edc3067372fa31fb2e8fa6f356 (diff)
Correct octree's AABB intersect test, fixes #3576 and #3253
Diffstat (limited to 'core/math/aabb.h')
-rw-r--r--core/math/aabb.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/math/aabb.h b/core/math/aabb.h
index 7c9c3081ac..0fada859c0 100644
--- a/core/math/aabb.h
+++ b/core/math/aabb.h
@@ -66,6 +66,7 @@ public:
bool operator!=(const AABB& p_rval) const;
_FORCE_INLINE_ bool intersects(const AABB& p_aabb) const; /// Both AABBs overlap
+ _FORCE_INLINE_ bool intersects_inclusive(const AABB& p_aabb) const; /// Both AABBs (or their faces) overlap
_FORCE_INLINE_ bool encloses(const AABB & p_aabb) const; /// p_aabb is completely inside this
AABB merge(const AABB& p_with) const;
@@ -126,6 +127,23 @@ inline bool AABB::intersects(const AABB& p_aabb) const {
return true;
}
+inline bool AABB::intersects_inclusive(const AABB& p_aabb) const {
+
+ if ( pos.x > (p_aabb.pos.x + p_aabb.size.x) )
+ return false;
+ if ( (pos.x+size.x) < p_aabb.pos.x )
+ return false;
+ if ( pos.y > (p_aabb.pos.y + p_aabb.size.y) )
+ return false;
+ if ( (pos.y+size.y) < p_aabb.pos.y )
+ return false;
+ if ( pos.z > (p_aabb.pos.z + p_aabb.size.z) )
+ return false;
+ if ( (pos.z+size.z) < p_aabb.pos.z )
+ return false;
+
+ return true;
+}
inline bool AABB::encloses(const AABB & p_aabb) const {