OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreAxisAlignedBox.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __AxisAlignedBox_H_
29 #define __AxisAlignedBox_H_
30 
31 // Precompiler options
32 #include "OgrePrerequisites.h"
33 
34 #include "OgreMatrix4.h"
35 
36 namespace Ogre {
54  {
55  public:
56  enum Extent
57  {
60  EXTENT_INFINITE
61  };
62  protected:
63 
67  mutable Vector3* mCorners;
68 
69  public:
70  /*
71  1-------2
72  /| /|
73  / | / |
74  5-------4 |
75  | 0----|--3
76  | / | /
77  |/ |/
78  6-------7
79  */
80  typedef enum {
81  FAR_LEFT_BOTTOM = 0,
82  FAR_LEFT_TOP = 1,
83  FAR_RIGHT_TOP = 2,
84  FAR_RIGHT_BOTTOM = 3,
85  NEAR_RIGHT_BOTTOM = 7,
86  NEAR_LEFT_BOTTOM = 6,
87  NEAR_LEFT_TOP = 5,
88  NEAR_RIGHT_TOP = 4
89  } CornerEnum;
90  inline AxisAlignedBox() : mMinimum(Vector3::ZERO), mMaximum(Vector3::UNIT_SCALE), mCorners(0)
91  {
92  // Default to a null box
93  setMinimum( -0.5, -0.5, -0.5 );
94  setMaximum( 0.5, 0.5, 0.5 );
95  mExtent = EXTENT_NULL;
96  }
97  inline AxisAlignedBox(Extent e) : mMinimum(Vector3::ZERO), mMaximum(Vector3::UNIT_SCALE), mCorners(0)
98  {
99  setMinimum( -0.5, -0.5, -0.5 );
100  setMaximum( 0.5, 0.5, 0.5 );
101  mExtent = e;
102  }
103 
104  inline AxisAlignedBox(const AxisAlignedBox & rkBox) : mMinimum(Vector3::ZERO), mMaximum(Vector3::UNIT_SCALE), mCorners(0)
105 
106  {
107  if (rkBox.isNull())
108  setNull();
109  else if (rkBox.isInfinite())
110  setInfinite();
111  else
112  setExtents( rkBox.mMinimum, rkBox.mMaximum );
113  }
114 
115  inline AxisAlignedBox( const Vector3& min, const Vector3& max ) : mMinimum(Vector3::ZERO), mMaximum(Vector3::UNIT_SCALE), mCorners(0)
116  {
117  setExtents( min, max );
118  }
119 
121  Real mx, Real my, Real mz,
122  Real Mx, Real My, Real Mz ) : mMinimum(Vector3::ZERO), mMaximum(Vector3::UNIT_SCALE), mCorners(0)
123  {
124  setExtents( mx, my, mz, Mx, My, Mz );
125  }
126 
128  {
129  // Specifically override to avoid copying mCorners
130  if (rhs.isNull())
131  setNull();
132  else if (rhs.isInfinite())
133  setInfinite();
134  else
135  setExtents(rhs.mMinimum, rhs.mMaximum);
136 
137  return *this;
138  }
139 
141  {
142  if (mCorners)
144  }
145 
146 
149  inline const Vector3& getMinimum(void) const
150  {
151  return mMinimum;
152  }
153 
157  inline Vector3& getMinimum(void)
158  {
159  return mMinimum;
160  }
161 
164  inline const Vector3& getMaximum(void) const
165  {
166  return mMaximum;
167  }
168 
172  inline Vector3& getMaximum(void)
173  {
174  return mMaximum;
175  }
176 
177 
180  inline void setMinimum( const Vector3& vec )
181  {
182  mExtent = EXTENT_FINITE;
183  mMinimum = vec;
184  }
185 
186  inline void setMinimum( Real x, Real y, Real z )
187  {
188  mExtent = EXTENT_FINITE;
189  mMinimum.x = x;
190  mMinimum.y = y;
191  mMinimum.z = z;
192  }
193 
197  inline void setMinimumX(Real x)
198  {
199  mMinimum.x = x;
200  }
201 
202  inline void setMinimumY(Real y)
203  {
204  mMinimum.y = y;
205  }
206 
207  inline void setMinimumZ(Real z)
208  {
209  mMinimum.z = z;
210  }
211 
214  inline void setMaximum( const Vector3& vec )
215  {
216  mExtent = EXTENT_FINITE;
217  mMaximum = vec;
218  }
219 
220  inline void setMaximum( Real x, Real y, Real z )
221  {
222  mExtent = EXTENT_FINITE;
223  mMaximum.x = x;
224  mMaximum.y = y;
225  mMaximum.z = z;
226  }
227 
231  inline void setMaximumX( Real x )
232  {
233  mMaximum.x = x;
234  }
235 
236  inline void setMaximumY( Real y )
237  {
238  mMaximum.y = y;
239  }
240 
241  inline void setMaximumZ( Real z )
242  {
243  mMaximum.z = z;
244  }
245 
248  inline void setExtents( const Vector3& min, const Vector3& max )
249  {
250  assert( (min.x <= max.x && min.y <= max.y && min.z <= max.z) &&
251  "The minimum corner of the box must be less than or equal to maximum corner" );
252 
253  mExtent = EXTENT_FINITE;
254  mMinimum = min;
255  mMaximum = max;
256  }
257 
258  inline void setExtents(
259  Real mx, Real my, Real mz,
260  Real Mx, Real My, Real Mz )
261  {
262  assert( (mx <= Mx && my <= My && mz <= Mz) &&
263  "The minimum corner of the box must be less than or equal to maximum corner" );
264 
265  mExtent = EXTENT_FINITE;
266 
267  mMinimum.x = mx;
268  mMinimum.y = my;
269  mMinimum.z = mz;
270 
271  mMaximum.x = Mx;
272  mMaximum.y = My;
273  mMaximum.z = Mz;
274 
275  }
276 
300  inline const Vector3* getAllCorners(void) const
301  {
302  assert( (mExtent == EXTENT_FINITE) && "Can't get corners of a null or infinite AAB" );
303 
304  // The order of these items is, using right-handed co-ordinates:
305  // Minimum Z face, starting with Min(all), then anticlockwise
306  // around face (looking onto the face)
307  // Maximum Z face, starting with Max(all), then anticlockwise
308  // around face (looking onto the face)
309  // Only for optimization/compatibility.
310  if (!mCorners)
312 
313  mCorners[0] = mMinimum;
314  mCorners[1].x = mMinimum.x; mCorners[1].y = mMaximum.y; mCorners[1].z = mMinimum.z;
315  mCorners[2].x = mMaximum.x; mCorners[2].y = mMaximum.y; mCorners[2].z = mMinimum.z;
316  mCorners[3].x = mMaximum.x; mCorners[3].y = mMinimum.y; mCorners[3].z = mMinimum.z;
317 
318  mCorners[4] = mMaximum;
319  mCorners[5].x = mMinimum.x; mCorners[5].y = mMaximum.y; mCorners[5].z = mMaximum.z;
320  mCorners[6].x = mMinimum.x; mCorners[6].y = mMinimum.y; mCorners[6].z = mMaximum.z;
321  mCorners[7].x = mMaximum.x; mCorners[7].y = mMinimum.y; mCorners[7].z = mMaximum.z;
322 
323  return mCorners;
324  }
325 
328  Vector3 getCorner(CornerEnum cornerToGet) const
329  {
330  switch(cornerToGet)
331  {
332  case FAR_LEFT_BOTTOM:
333  return mMinimum;
334  case FAR_LEFT_TOP:
335  return Vector3(mMinimum.x, mMaximum.y, mMinimum.z);
336  case FAR_RIGHT_TOP:
337  return Vector3(mMaximum.x, mMaximum.y, mMinimum.z);
338  case FAR_RIGHT_BOTTOM:
339  return Vector3(mMaximum.x, mMinimum.y, mMinimum.z);
340  case NEAR_RIGHT_BOTTOM:
341  return Vector3(mMaximum.x, mMinimum.y, mMaximum.z);
342  case NEAR_LEFT_BOTTOM:
343  return Vector3(mMinimum.x, mMinimum.y, mMaximum.z);
344  case NEAR_LEFT_TOP:
345  return Vector3(mMinimum.x, mMaximum.y, mMaximum.z);
346  case NEAR_RIGHT_TOP:
347  return mMaximum;
348  default:
349  return Vector3();
350  }
351  }
352 
353  _OgreExport friend std::ostream& operator<<( std::ostream& o, const AxisAlignedBox &aab )
354  {
355  switch (aab.mExtent)
356  {
357  case EXTENT_NULL:
358  o << "AxisAlignedBox(null)";
359  return o;
360 
361  case EXTENT_FINITE:
362  o << "AxisAlignedBox(min=" << aab.mMinimum << ", max=" << aab.mMaximum << ")";
363  return o;
364 
365  case EXTENT_INFINITE:
366  o << "AxisAlignedBox(infinite)";
367  return o;
368 
369  default: // shut up compiler
370  assert( false && "Never reached" );
371  return o;
372  }
373  }
374 
378  void merge( const AxisAlignedBox& rhs )
379  {
380  // Do nothing if rhs null, or this is infinite
381  if ((rhs.mExtent == EXTENT_NULL) || (mExtent == EXTENT_INFINITE))
382  {
383  return;
384  }
385  // Otherwise if rhs is infinite, make this infinite, too
386  else if (rhs.mExtent == EXTENT_INFINITE)
387  {
388  mExtent = EXTENT_INFINITE;
389  }
390  // Otherwise if current null, just take rhs
391  else if (mExtent == EXTENT_NULL)
392  {
393  setExtents(rhs.mMinimum, rhs.mMaximum);
394  }
395  // Otherwise merge
396  else
397  {
398  Vector3 min = mMinimum;
399  Vector3 max = mMaximum;
400  max.makeCeil(rhs.mMaximum);
401  min.makeFloor(rhs.mMinimum);
402 
403  setExtents(min, max);
404  }
405 
406  }
407 
410  inline void merge( const Vector3& point )
411  {
412  switch (mExtent)
413  {
414  case EXTENT_NULL: // if null, use this point
415  setExtents(point, point);
416  return;
417 
418  case EXTENT_FINITE:
419  mMaximum.makeCeil(point);
420  mMinimum.makeFloor(point);
421  return;
422 
423  case EXTENT_INFINITE: // if infinite, makes no difference
424  return;
425  }
426 
427  assert( false && "Never reached" );
428  }
429 
439  inline void transform( const Matrix4& matrix )
440  {
441  // Do nothing if current null or infinite
442  if( mExtent != EXTENT_FINITE )
443  return;
444 
445  Vector3 oldMin, oldMax, currentCorner;
446 
447  // Getting the old values so that we can use the existing merge method.
448  oldMin = mMinimum;
449  oldMax = mMaximum;
450 
451  // reset
452  setNull();
453 
454  // We sequentially compute the corners in the following order :
455  // 0, 6, 5, 1, 2, 4 ,7 , 3
456  // This sequence allows us to only change one member at a time to get at all corners.
457 
458  // For each one, we transform it using the matrix
459  // Which gives the resulting point and merge the resulting point.
460 
461  // First corner
462  // min min min
463  currentCorner = oldMin;
464  merge( matrix * currentCorner );
465 
466  // min,min,max
467  currentCorner.z = oldMax.z;
468  merge( matrix * currentCorner );
469 
470  // min max max
471  currentCorner.y = oldMax.y;
472  merge( matrix * currentCorner );
473 
474  // min max min
475  currentCorner.z = oldMin.z;
476  merge( matrix * currentCorner );
477 
478  // max max min
479  currentCorner.x = oldMax.x;
480  merge( matrix * currentCorner );
481 
482  // max max max
483  currentCorner.z = oldMax.z;
484  merge( matrix * currentCorner );
485 
486  // max min max
487  currentCorner.y = oldMin.y;
488  merge( matrix * currentCorner );
489 
490  // max min min
491  currentCorner.z = oldMin.z;
492  merge( matrix * currentCorner );
493  }
494 
506  void transformAffine(const Matrix4& m)
507  {
508  assert(m.isAffine());
509 
510  // Do nothing if current null or infinite
511  if ( mExtent != EXTENT_FINITE )
512  return;
513 
514  Vector3 centre = getCenter();
515  Vector3 halfSize = getHalfSize();
516 
517  Vector3 newCentre = m.transformAffine(centre);
518  Vector3 newHalfSize(
519  Math::Abs(m[0][0]) * halfSize.x + Math::Abs(m[0][1]) * halfSize.y + Math::Abs(m[0][2]) * halfSize.z,
520  Math::Abs(m[1][0]) * halfSize.x + Math::Abs(m[1][1]) * halfSize.y + Math::Abs(m[1][2]) * halfSize.z,
521  Math::Abs(m[2][0]) * halfSize.x + Math::Abs(m[2][1]) * halfSize.y + Math::Abs(m[2][2]) * halfSize.z);
522 
523  setExtents(newCentre - newHalfSize, newCentre + newHalfSize);
524  }
525 
528  inline void setNull()
529  {
530  mExtent = EXTENT_NULL;
531  }
532 
535  inline bool isNull(void) const
536  {
537  return (mExtent == EXTENT_NULL);
538  }
539 
542  bool isFinite(void) const
543  {
544  return (mExtent == EXTENT_FINITE);
545  }
546 
549  inline void setInfinite()
550  {
551  mExtent = EXTENT_INFINITE;
552  }
553 
556  bool isInfinite(void) const
557  {
558  return (mExtent == EXTENT_INFINITE);
559  }
560 
562  inline bool intersects(const AxisAlignedBox& b2) const
563  {
564  // Early-fail for nulls
565  if (this->isNull() || b2.isNull())
566  return false;
567 
568  // Early-success for infinites
569  if (this->isInfinite() || b2.isInfinite())
570  return true;
571 
572  // Use up to 6 separating planes
573  if (mMaximum.x < b2.mMinimum.x)
574  return false;
575  if (mMaximum.y < b2.mMinimum.y)
576  return false;
577  if (mMaximum.z < b2.mMinimum.z)
578  return false;
579 
580  if (mMinimum.x > b2.mMaximum.x)
581  return false;
582  if (mMinimum.y > b2.mMaximum.y)
583  return false;
584  if (mMinimum.z > b2.mMaximum.z)
585  return false;
586 
587  // otherwise, must be intersecting
588  return true;
589 
590  }
591 
594  {
595  if (this->isNull() || b2.isNull())
596  {
597  return AxisAlignedBox();
598  }
599  else if (this->isInfinite())
600  {
601  return b2;
602  }
603  else if (b2.isInfinite())
604  {
605  return *this;
606  }
607 
608  Vector3 intMin = mMinimum;
609  Vector3 intMax = mMaximum;
610 
611  intMin.makeCeil(b2.getMinimum());
612  intMax.makeFloor(b2.getMaximum());
613 
614  // Check intersection isn't null
615  if (intMin.x < intMax.x &&
616  intMin.y < intMax.y &&
617  intMin.z < intMax.z)
618  {
619  return AxisAlignedBox(intMin, intMax);
620  }
621 
622  return AxisAlignedBox();
623  }
624 
626  Real volume(void) const
627  {
628  switch (mExtent)
629  {
630  case EXTENT_NULL:
631  return 0.0f;
632 
633  case EXTENT_FINITE:
634  {
635  Vector3 diff = mMaximum - mMinimum;
636  return diff.x * diff.y * diff.z;
637  }
638 
639  case EXTENT_INFINITE:
640  return Math::POS_INFINITY;
641 
642  default: // shut up compiler
643  assert( false && "Never reached" );
644  return 0.0f;
645  }
646  }
647 
649  inline void scale(const Vector3& s)
650  {
651  // Do nothing if current null or infinite
652  if (mExtent != EXTENT_FINITE)
653  return;
654 
655  // NB assumes centered on origin
656  Vector3 min = mMinimum * s;
657  Vector3 max = mMaximum * s;
658  setExtents(min, max);
659  }
660 
662  bool intersects(const Sphere& s) const
663  {
664  return Math::intersects(s, *this);
665  }
667  bool intersects(const Plane& p) const
668  {
669  return Math::intersects(p, *this);
670  }
672  bool intersects(const Vector3& v) const
673  {
674  switch (mExtent)
675  {
676  case EXTENT_NULL:
677  return false;
678 
679  case EXTENT_FINITE:
680  return(v.x >= mMinimum.x && v.x <= mMaximum.x &&
681  v.y >= mMinimum.y && v.y <= mMaximum.y &&
682  v.z >= mMinimum.z && v.z <= mMaximum.z);
683 
684  case EXTENT_INFINITE:
685  return true;
686 
687  default: // shut up compiler
688  assert( false && "Never reached" );
689  return false;
690  }
691  }
693  Vector3 getCenter(void) const
694  {
695  assert( (mExtent == EXTENT_FINITE) && "Can't get center of a null or infinite AAB" );
696 
697  return Vector3(
698  (mMaximum.x + mMinimum.x) * 0.5f,
699  (mMaximum.y + mMinimum.y) * 0.5f,
700  (mMaximum.z + mMinimum.z) * 0.5f);
701  }
703  Vector3 getSize(void) const
704  {
705  switch (mExtent)
706  {
707  case EXTENT_NULL:
708  return Vector3::ZERO;
709 
710  case EXTENT_FINITE:
711  return mMaximum - mMinimum;
712 
713  case EXTENT_INFINITE:
714  return Vector3(
718 
719  default: // shut up compiler
720  assert( false && "Never reached" );
721  return Vector3::ZERO;
722  }
723  }
725  Vector3 getHalfSize(void) const
726  {
727  switch (mExtent)
728  {
729  case EXTENT_NULL:
730  return Vector3::ZERO;
731 
732  case EXTENT_FINITE:
733  return (mMaximum - mMinimum) * 0.5;
734 
735  case EXTENT_INFINITE:
736  return Vector3(
740 
741  default: // shut up compiler
742  assert( false && "Never reached" );
743  return Vector3::ZERO;
744  }
745  }
746 
749  bool contains(const Vector3& v) const
750  {
751  if (isNull())
752  return false;
753  if (isInfinite())
754  return true;
755 
756  return mMinimum.x <= v.x && v.x <= mMaximum.x &&
757  mMinimum.y <= v.y && v.y <= mMaximum.y &&
758  mMinimum.z <= v.z && v.z <= mMaximum.z;
759  }
760 
763  Real squaredDistance(const Vector3& v) const
764  {
765 
766  if (this->contains(v))
767  return 0;
768  else
769  {
770  Vector3 maxDist(0,0,0);
771 
772  if (v.x < mMinimum.x)
773  maxDist.x = mMinimum.x - v.x;
774  else if (v.x > mMaximum.x)
775  maxDist.x = v.x - mMaximum.x;
776 
777  if (v.y < mMinimum.y)
778  maxDist.y = mMinimum.y - v.y;
779  else if (v.y > mMaximum.y)
780  maxDist.y = v.y - mMaximum.y;
781 
782  if (v.z < mMinimum.z)
783  maxDist.z = mMinimum.z - v.z;
784  else if (v.z > mMaximum.z)
785  maxDist.z = v.z - mMaximum.z;
786 
787  return maxDist.squaredLength();
788  }
789  }
790 
792  Real distance (const Vector3& v) const
793  {
794  return Ogre::Math::Sqrt(squaredDistance(v));
795  }
796 
799  bool contains(const AxisAlignedBox& other) const
800  {
801  if (other.isNull() || this->isInfinite())
802  return true;
803 
804  if (this->isNull() || other.isInfinite())
805  return false;
806 
807  return this->mMinimum.x <= other.mMinimum.x &&
808  this->mMinimum.y <= other.mMinimum.y &&
809  this->mMinimum.z <= other.mMinimum.z &&
810  other.mMaximum.x <= this->mMaximum.x &&
811  other.mMaximum.y <= this->mMaximum.y &&
812  other.mMaximum.z <= this->mMaximum.z;
813  }
814 
817  bool operator== (const AxisAlignedBox& rhs) const
818  {
819  if (this->mExtent != rhs.mExtent)
820  return false;
821 
822  if (!this->isFinite())
823  return true;
824 
825  return this->mMinimum == rhs.mMinimum &&
826  this->mMaximum == rhs.mMaximum;
827  }
828 
831  bool operator!= (const AxisAlignedBox& rhs) const
832  {
833  return !(*this == rhs);
834  }
835 
836  // special values
837  static const AxisAlignedBox BOX_NULL;
839 
840 
841  };
842 
845 } // namespace Ogre
846 
847 #endif
Real squaredDistance(const Vector3 &v) const
Returns the squared minimum distance between a given point and any part of the box.
#define OGRE_ALLOC_T(T, count, category)
Allocate a block of memory for a primitive type, and indicate the category of usage.
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: OgreMatrix4.h:79
AxisAlignedBox(const AxisAlignedBox &rkBox)
float Real
Software floating point type.
#define _OgreExport
Definition: OgrePlatform.h:255
void merge(const Vector3 &point)
Extends the box to encompass the specified point (if needed).
void setExtents(Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
Real volume(void) const
Calculate the volume of this box.
Defines a plane in 3D space.
Definition: OgrePlane.h:61
const float & max(const float &a, const float &b)
Definition: OgreCommon.h:851
static const AxisAlignedBox BOX_NULL
Vector3 getCenter(void) const
Gets the centre of the box.
static const Vector3 ZERO
Definition: OgreVector3.h:807
void transformAffine(const Matrix4 &m)
Transforms the box according to the affine matrix supplied.
A 3D box aligned with the x/y/z axes.
static std::pair< bool, Real > intersects(const Ray &ray, const Plane &plane)
Ray / plane intersection, returns boolean result and distance.
void makeFloor(const Vector3 &cmp)
Sets this vector's components to the minimum of its own and the ones of the passed in vector...
Definition: OgreVector3.h:537
_OgreExport friend std::ostream & operator<<(std::ostream &o, const AxisAlignedBox &aab)
AxisAlignedBox(const Vector3 &min, const Vector3 &max)
void transform(const Matrix4 &matrix)
Transforms the box according to the matrix supplied.
AxisAlignedBox intersection(const AxisAlignedBox &b2) const
Calculate the area of intersection of this box and another.
void setMaximumX(Real x)
Changes one of the components of the maximum corner of the box used to resize only one dimension of t...
const Vector3 & getMaximum(void) const
Gets the maximum corner of the box.
Vector3 getCorner(CornerEnum cornerToGet) const
Gets the position of one of the corners.
Real distance(const Vector3 &v) const
Returns the minimum distance between a given point and any part of the box.
bool isAffine(void) const
Check whether or not the matrix is affine matrix.
Definition: OgreMatrix4.h:617
static const Real POS_INFINITY
Definition: OgreMath.h:726
bool intersects(const Vector3 &v) const
Tests whether the vector point is within this box.
Vector3 & getMaximum(void)
Gets a modifiable version of the maximum corner of the box.
static Real Abs(Real fValue)
Absolute value function.
Definition: OgreMath.h:260
void merge(const AxisAlignedBox &rhs)
Merges the passed in box into the current box.
static const AxisAlignedBox BOX_INFINITE
Vector3 transformAffine(const Vector3 &v) const
3-D Vector transformation specially for an affine matrix.
Definition: OgreMatrix4.h:662
void setExtents(const Vector3 &min, const Vector3 &max)
Sets both minimum and maximum extents at once.
static Real Sqrt(Real fValue)
Square root function.
Definition: OgreMath.h:423
A sphere primitive, mostly used for bounds checking.
Definition: OgreSphere.h:51
bool intersects(const AxisAlignedBox &b2) const
Returns whether or not this box intersects another.
Vector3 & getMinimum(void)
Gets a modifiable version of the minimum corner of the box.
const float & min(const float &a, const float &b)
Definition: OgreCommon.h:846
void setMaximum(Real x, Real y, Real z)
void scale(const Vector3 &s)
Scales the AABB by the vector given.
Real squaredLength() const
Returns the square of the length(magnitude) of the vector.
Definition: OgreVector3.h:370
bool isNull(void) const
Returns true if the box is null i.e.
Standard 3-dimensional vector.
Definition: OgreVector3.h:50
const Vector3 * getAllCorners(void) const
Returns a pointer to an array of 8 corner points, useful for collision vs.
void setNull()
Sets the box to a 'null' value i.e.
Vector3 getSize(void) const
Gets the size of the box.
bool isFinite(void) const
Returns true if the box is finite.
void setMaximum(const Vector3 &vec)
Sets the maximum corner of the box.
void setMinimum(const Vector3 &vec)
Sets the minimum corner of the box.
bool isInfinite(void) const
Returns true if the box is infinite.
bool intersects(const Sphere &s) const
Tests whether this box intersects a sphere.
void setInfinite()
Sets the box to 'infinite'.
const Vector3 & getMinimum(void) const
Gets the minimum corner of the box.
void makeCeil(const Vector3 &cmp)
Sets this vector's components to the maximum of its own and the ones of the passed in vector...
Definition: OgreVector3.h:551
#define OGRE_FREE(ptr, category)
Free the memory allocated with OGRE_MALLOC or OGRE_ALLOC_T. Category is required to be restated to en...
bool contains(const Vector3 &v) const
Tests whether the given point contained by this box.
AxisAlignedBox & operator=(const AxisAlignedBox &rhs)
AxisAlignedBox(Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
void setMinimumX(Real x)
Changes one of the components of the minimum corner of the box used to resize only one dimension of t...
bool contains(const AxisAlignedBox &other) const
Tests whether another box contained by this box.
bool intersects(const Plane &p) const
Tests whether this box intersects a plane.
void setMinimum(Real x, Real y, Real z)
Vector3 getHalfSize(void) const
Gets the half-size of the box.
bool operator==(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)
bool operator!=(STLAllocator< T, P > const &, STLAllocator< T2, P > const &)
determine equality, can memory from another allocator be released by this allocator, (ISO C++)