irr: aabbox intersection support

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@13465 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
curaga 2013-08-12 12:46:10 +00:00
parent 4ac3f6f728
commit 04d5903f57
2 changed files with 20 additions and 0 deletions

View File

@ -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

View File

@ -245,6 +245,25 @@ class aabbox3d
(T)(line.getLength() * 0.5));
}
//! Returns the intersection of this box with another, if possible.
aabbox3d<T> intersect(const aabbox3d<T>& other) const
{
aabbox3d<T> 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.