From 04d5903f575e569baad8c6c46a89d02292e06811 Mon Sep 17 00:00:00 2001 From: curaga Date: Mon, 12 Aug 2013 12:46:10 +0000 Subject: [PATCH] irr: aabbox intersection support git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13465 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- lib/irrlicht/changes.stk | 1 + lib/irrlicht/include/aabbox3d.h | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/irrlicht/changes.stk b/lib/irrlicht/changes.stk index 22f21c60d..8979ca204 100644 --- a/lib/irrlicht/changes.stk +++ b/lib/irrlicht/changes.stk @@ -7,3 +7,4 @@ The following changes have been made: - skies respect Z - partial backport to expose setCurrentRendertime in the scene mgr - a workaround for every other RTTs flipping +- aabbox intersection support diff --git a/lib/irrlicht/include/aabbox3d.h b/lib/irrlicht/include/aabbox3d.h index afaf12dcd..bdcae4803 100644 --- a/lib/irrlicht/include/aabbox3d.h +++ b/lib/irrlicht/include/aabbox3d.h @@ -245,6 +245,25 @@ class aabbox3d (T)(line.getLength() * 0.5)); } + //! Returns the intersection of this box with another, if possible. + aabbox3d intersect(const aabbox3d& other) const + { + aabbox3d out; + + if (!intersectsWithBox(other)) + return out; + + out.MaxEdge.X = min_(MaxEdge.X, other.MaxEdge.X); + out.MaxEdge.Y = min_(MaxEdge.Y, other.MaxEdge.Y); + out.MaxEdge.Z = min_(MaxEdge.Z, other.MaxEdge.Z); + + out.MinEdge.X = max_(MinEdge.X, other.MinEdge.X); + out.MinEdge.Y = max_(MinEdge.Y, other.MinEdge.Y); + out.MinEdge.Z = max_(MinEdge.Z, other.MinEdge.Z); + + return out; + } + //! Tests if the box intersects with a line /** \param linemiddle Center of the line. \param linevect Vector of the line.