28#ifndef __AxisAlignedBox_H_
29#define __AxisAlignedBox_H_
251 assert( (min.
x <= max.
x && min.
y <= max.
y && min.
z <= max.
z) &&
252 "The minimum corner of the box must be less than or equal to maximum corner" );
263 assert( (mx <= Mx && my <= My && mz <= Mz) &&
264 "The minimum corner of the box must be less than or equal to maximum corner" );
359 o <<
"AxisAlignedBox(null)";
363 o <<
"AxisAlignedBox(min=" << aab.
mMinimum <<
", max=" << aab.
mMaximum <<
")";
367 o <<
"AxisAlignedBox(infinite)";
371 assert(
false &&
"Never reached" );
428 assert(
false &&
"Never reached" );
446 Vector3 oldMin, oldMax, currentCorner;
464 currentCorner = oldMin;
465 merge( matrix * currentCorner );
468 currentCorner.
z = oldMax.
z;
469 merge( matrix * currentCorner );
472 currentCorner.
y = oldMax.
y;
473 merge( matrix * currentCorner );
476 currentCorner.
z = oldMin.
z;
477 merge( matrix * currentCorner );
480 currentCorner.
x = oldMax.
x;
481 merge( matrix * currentCorner );
484 currentCorner.
z = oldMax.
z;
485 merge( matrix * currentCorner );
488 currentCorner.
y = oldMin.
y;
489 merge( matrix * currentCorner );
492 currentCorner.
z = oldMin.
z;
493 merge( matrix * currentCorner );
524 setExtents(newCentre - newHalfSize, newCentre + newHalfSize);
616 if (intMin.
x < intMax.
x &&
617 intMin.
y < intMax.
y &&
637 return diff.
x * diff.
y * diff.
z;
644 assert(
false &&
"Never reached" );
689 assert(
false &&
"Never reached" );
721 assert(
false &&
"Never reached" );
743 assert(
false &&
"Never reached" );
802 if (other.
isNull() || this->isInfinite())
808 return this->mMinimum.
x <= other.
mMinimum.
x &&
820 if (this->mExtent != rhs.
mExtent)
826 return this->mMinimum == rhs.
mMinimum &&
834 return !(*
this == rhs);
bool intersects(const Vector3 &v) const
Tests whether the vector point is within this box.
void transformAffine(const Matrix4 &m)
Transforms the box according to the affine matrix supplied.
void setInfinite()
Sets the box to 'infinite'.
Vector3 & getMaximum(void)
Gets a modifiable version of the maximum corner of the box.
void setMaximumX(Real x)
Changes one of the components of the maximum corner of the box used to resize only one dimension of t...
bool isNull(void) const
Returns true if the box is null i.e.
void setExtents(Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
AxisAlignedBox & operator=(const AxisAlignedBox &rhs)
void setMinimumX(Real x)
Changes one of the components of the minimum corner of the box used to resize only one dimension of t...
AxisAlignedBox(const Vector3 &min, const Vector3 &max)
AxisAlignedBox(const AxisAlignedBox &rkBox)
Vector3 & getMinimum(void)
Gets a modifiable version of the minimum corner of the box.
static const AxisAlignedBox BOX_NULL
Real volume(void) const
Calculate the volume of this box.
void merge(const AxisAlignedBox &rhs)
Merges the passed in box into the current box.
bool intersects(const Sphere &s) const
Tests whether this box intersects a sphere.
void setExtents(const Vector3 &min, const Vector3 &max)
Sets both minimum and maximum extents at once.
Real squaredDistance(const Vector3 &v) const
Returns the squared minimum distance between a given point and any part of the box.
Vector3 getHalfSize(void) const
Gets the half-size of the box.
void setMaximum(const Vector3 &vec)
Sets the maximum corner of the box.
Vector3 getCenter(void) const
Gets the centre of the box.
const Vector3 & getMaximum(void) const
Gets the maximum corner of the box.
bool intersects(const AxisAlignedBox &b2) const
Returns whether or not this box intersects another.
Real distance(const Vector3 &v) const
Returns the minimum distance between a given point and any part of the box.
void setNull()
Sets the box to a 'null' value i.e.
AxisAlignedBox intersection(const AxisAlignedBox &b2) const
Calculate the area of intersection of this box and another.
const Vector3 * getAllCorners(void) const
Returns a pointer to an array of 8 corner points, useful for collision vs.
bool isInfinite(void) const
Returns true if the box is infinite.
const Vector3 & getMinimum(void) const
Gets the minimum corner of the box.
AxisAlignedBox(Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
bool intersects(const Plane &p) const
Tests whether this box intersects a plane.
void setMinimum(const Vector3 &vec)
Sets the minimum corner of the box.
static const AxisAlignedBox BOX_INFINITE
void scale(const Vector3 &s)
Scales the AABB by the vector given.
bool isFinite(void) const
Returns true if the box is finite.
bool contains(const Vector3 &v) const
Tests whether the given point contained by this box.
void transform(const Matrix4 &matrix)
Transforms the box according to the matrix supplied.
void setMaximum(Real x, Real y, Real z)
Vector3 getCorner(CornerEnum cornerToGet) const
Gets the position of one of the corners.
void setMinimum(Real x, Real y, Real z)
bool contains(const AxisAlignedBox &other) const
Tests whether another box contained by this box.
void merge(const Vector3 &point)
Extends the box to encompass the specified point (if needed).
Vector3 getSize(void) const
Gets the size of the box.
_OgreExport friend std::ostream & operator<<(std::ostream &o, const AxisAlignedBox &aab)
static std::pair< bool, Real > intersects(const Ray &ray, const Plane &plane)
Ray / plane intersection, returns boolean result and distance.
static const Real POS_INFINITY
static Real Sqrt(Real fValue)
Square root function.
static Real Abs(Real fValue)
Absolute value function.
Class encapsulating a standard 4x4 homogeneous matrix.
bool isAffine(void) const
Check whether or not the matrix is affine matrix.
Vector3 transformAffine(const Vector3 &v) const
3-D Vector transformation specially for an affine matrix.
Defines a plane in 3D space.
A sphere primitive, mostly used for bounds checking.
Standard 3-dimensional vector.
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
static const Vector3 ZERO
void makeCeil(const Vector3 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector.
void makeFloor(const Vector3 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector.
#define OGRE_ALLOC_T(T, count, category)
Allocate a block of memory for a primitive type, and indicate the category of usage.
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
@ MEMCATEGORY_SCENE_CONTROL
Nodes, control data.
float Real
Software floating point type.