OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::Aabb Struct Reference

AoS (array of structures) version of ArrayAabb. More...

#include <OgreAabbC.h>

Public Member Functions

 Aabb ()
 
 Aabb (const Vector3 &center, const Vector3 &halfSize)
 
bool contains (const Aabb &other) const
 Tests whether another box contained by this box. More...
 
bool contains (const Vector3 &v) const
 Tests whether the given point contained by this box. More...
 
Real distance (const Vector3 &v) const
 Returns the minimum distance between a given point and any part of the box. More...
 
Vector3 getMaximum () const
 Gets the maximum corner of the box. More...
 
Vector3 getMinimum () const
 Gets the minimum corner of the box. More...
 
Real getRadius () const
 Returns the radius of a sphere enclosing the aabb from the outside at center mCenter. More...
 
Real getRadiusOrigin () const
 Returns the radius of a sphere enclosing the aabb from origin as center. More...
 
Vector3 getSize () const
 Gets the size of the box. More...
 
Aabb intersection (const Aabb &b2) const
 Calculate the area of intersection of this box and another. More...
 
bool intersects (const Aabb &b2) const
 Returns whether or not this box intersects another. More...
 
void merge (const Aabb &rhs)
 Merges the passed in box into the current box. More...
 
void merge (const Vector3 &points)
 Extends the box to encompass the specified point (if needed). More...
 
bool operator!= (const Aabb &_r) const
 
bool operator== (const Aabb &_r) const
 
void setExtents (const Vector3 &min, const Vector3 &max)
 Sets both minimum and maximum extents at once. More...
 
Real squaredDistance (const Vector3 &v) const
 Returns the square of the minimum distance between a given point and any part of the box. More...
 
void transformAffine (const Matrix4 &matrix)
 Transforms the box according to the matrix supplied. More...
 
Real volume () const
 Calculate the volume of this box. More...
 

Static Public Member Functions

static Aabb newFromExtents (const Vector3 &min, const Vector3 &max)
 Sets both minimum and maximum extents at once (static version). More...
 

Public Attributes

Ogre::Vector3 mCenter
 
Ogre::Vector3 mHalfSize
 

Static Public Attributes

static const Aabb BOX_INFINITE
 
static const Aabb BOX_NULL
 
static const Aabb BOX_ZERO
 

Detailed Description

AoS (array of structures) version of ArrayAabb.

This class also deprecates AxisAlignedBox. It's A 3D box aligned with the x/y/z axes.

For performance reasons given the mathematical properties, this version stores the box in the form "center + halfSize" instead of the form "minimum, maximum" that is present in AxisAlignedBox:
  • Merging is slightly more expensive
  • intersects() is much cheaper
  • Naturally deals with infinite boxes (no need for branches)
  • Transform is cheaper (a common operation)
This class represents a simple box which is aligned with the axes. Internally it only stores 2 points as the center of the box, and the half of the width, height, and depth. This class is typically used for an axis-aligned bounding box (AABB) for collision and visibility determination.
Main differences with AxisAlignedBox:
  • Aabb doesn't support null boxes as AxisAlignedBox did. Although if the center iszero and half size is set to negative infinity, it may mimic the behavior. Another possibility is to just use NaNs, because they would cause false on all tests. However this would be horrible slow.
  • BOX_INFINITE represents a truly infinite box and behaves exactly the same as an infinite AxisAlignedBox. However, setting the latter to infinite still holds information in min & max variables, while aabb destroys all information present.
Note
This is a POD data structure.

Constructor & Destructor Documentation

◆ Aabb() [1/2]

Ogre::Aabb::Aabb ( )
inline

◆ Aabb() [2/2]

Ogre::Aabb::Aabb ( const Vector3 center,
const Vector3 halfSize 
)
inline

Member Function Documentation

◆ contains() [1/2]

bool Ogre::Aabb::contains ( const Aabb other) const
inline

Tests whether another box contained by this box.

◆ contains() [2/2]

bool Ogre::Aabb::contains ( const Vector3 v) const
inline

Tests whether the given point contained by this box.

◆ distance()

Real Ogre::Aabb::distance ( const Vector3 v) const
inline

Returns the minimum distance between a given point and any part of the box.

◆ getMaximum()

Vector3 Ogre::Aabb::getMaximum ( ) const
inline

Gets the maximum corner of the box.

◆ getMinimum()

Vector3 Ogre::Aabb::getMinimum ( ) const
inline

Gets the minimum corner of the box.

◆ getRadius()

Real Ogre::Aabb::getRadius ( ) const
inline

Returns the radius of a sphere enclosing the aabb from the outside at center mCenter.

◆ getRadiusOrigin()

Real Ogre::Aabb::getRadiusOrigin ( ) const
inline

Returns the radius of a sphere enclosing the aabb from origin as center.

◆ getSize()

Vector3 Ogre::Aabb::getSize ( ) const
inline

Gets the size of the box.

◆ intersection()

Aabb Ogre::Aabb::intersection ( const Aabb b2) const
inline

Calculate the area of intersection of this box and another.

◆ intersects()

bool Ogre::Aabb::intersects ( const Aabb b2) const
inline

Returns whether or not this box intersects another.

◆ merge() [1/2]

void Ogre::Aabb::merge ( const Aabb rhs)
inline

Merges the passed in box into the current box.

The result is the box which encompasses both.

◆ merge() [2/2]

void Ogre::Aabb::merge ( const Vector3 points)
inline

Extends the box to encompass the specified point (if needed).

◆ newFromExtents()

static Aabb Ogre::Aabb::newFromExtents ( const Vector3 min,
const Vector3 max 
)
inlinestatic

Sets both minimum and maximum extents at once (static version).

◆ operator!=()

bool Ogre::Aabb::operator!= ( const Aabb _r) const
inline

◆ operator==()

bool Ogre::Aabb::operator== ( const Aabb _r) const
inline

◆ setExtents()

void Ogre::Aabb::setExtents ( const Vector3 min,
const Vector3 max 
)
inline

Sets both minimum and maximum extents at once.

◆ squaredDistance()

Real Ogre::Aabb::squaredDistance ( const Vector3 v) const
inline

Returns the square of the minimum distance between a given point and any part of the box.

◆ transformAffine()

void Ogre::Aabb::transformAffine ( const Matrix4 matrix)
inline

Transforms the box according to the matrix supplied.

Remarks
By calling this method you get the axis-aligned box which surrounds the transformed version of this box. Therefore each corner of the box is transformed by the matrix, then the extents are mapped back onto the axes to produce another AABB. Useful when you have a local AABB for an object which is then transformed.
Note
The matrix must be an affine matrix.
See also
Matrix4::isAffine.

◆ volume()

Real Ogre::Aabb::volume ( ) const
inline

Calculate the volume of this box.

Member Data Documentation

◆ BOX_INFINITE

const Aabb Ogre::Aabb::BOX_INFINITE
static

◆ BOX_NULL

const Aabb Ogre::Aabb::BOX_NULL
static

◆ BOX_ZERO

const Aabb Ogre::Aabb::BOX_ZERO
static

◆ mCenter

◆ mHalfSize


The documentation for this struct was generated from the following file: