Commit e7dd1767 authored by hybrid's avatar hybrid

Add intersect method to create intersect box, provided by hendu

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4572 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 13de7240
......@@ -234,6 +234,25 @@ class aabbox3d
MaxEdge.X <= other.MaxEdge.X && MaxEdge.Y <= other.MaxEdge.Y && MaxEdge.Z <= other.MaxEdge.Z);
}
//! 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;
}
//! Determines if the axis-aligned box intersects with another axis-aligned box.
/** \param other: Other box to check a intersection with.
\return True if there is an intersection with the other box,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment