UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
AABB Class Reference

#include <aabb.h>

Public Member Functions

 AABB ()
 
 AABB (const vec3_t mini, const vec3_t maxi)
 
 AABB (const vec_t minX, const vec_t minY, const vec_t minZ, const vec_t maxX, const vec_t maxY, const vec_t maxZ)
 
 AABB (const Line &line)
 
void set (const AABB &other)
 Copies the values from the given aabb. More...
 
void set (const vec3_t mini, const vec3_t maxi)
 
void setMins (const vec3_t mini)
 
void setMaxs (const vec3_t maxi)
 
void setMins (int x, int y, int z)
 
void setMaxs (int x, int y, int z)
 
void setMaxZ (float zVal)
 
void reset ()
 
void setFromLittleFloat (const AABB &other)
 
void setNegativeVolume ()
 Sets mins and maxs to their starting points before using addPoint. More...
 
void set (const AABB &trBox, const Line &trLine)
 Set from another box and a (trace)Line. More...
 
const vec3_tgetMins () const
 
float getMinX () const
 
float getMinY () const
 
float getMinZ () const
 
const vec3_tgetMaxs () const
 
float getMaxX () const
 
float getMaxY () const
 
float getMaxZ () const
 
float getWidthX () const
 
float getWidthY () const
 
float getWidthZ () const
 
void getCenter (vec3_t center) const
 Calculates the center of the bounding box. More...
 
void getDiagonal (vec3_t diagonal) const
 
void asIntString (char *str, size_t len)
 Prints a representation of the box. More...
 
bool isZero () const
 
bool doesIntersect (const AABB &other) const
 Checks if the aabb touches or intersects with the given aabb. More...
 
bool canBeHitBy (const Line &line) const
 Checks if the given line has a chance to hit our box. More...
 
bool contains (const vec3_t point) const
 
bool contains (const AABB &other) const
 
void add (const vec3_t point)
 If the point is outside the box, expand the box to accommodate it. More...
 
void add (const AABB &other)
 If the given box is outside our box, expand our box to accommodate it. More...
 
void rotateAround (const vec3_t origin, const vec3_t angles)
 Rotates bounding box around given origin point; note that it will expand the box unless all angles are multiples of 90 degrees. More...
 
void clipToWorld ()
 clip the box to the maximum boundaries More...
 
void expandXY (const float byVal)
 expand the box in four directions, but clip them to the maximum boundaries More...
 
void expand (const float byVal)
 expand the box in all directions, but clip them to the maximum boundaries More...
 
void shift (const vec3_t shiftVec)
 shove the whole box by the given vector More...
 

Data Fields

vec3_t mins
 
vec3_t maxs
 

Static Public Attributes

static const AABB EMPTY
 

Detailed Description

Definition at line 42 of file aabb.h.

Constructor & Destructor Documentation

AABB::AABB ( )

Definition at line 29 of file aabb.cpp.

References maxs, mins, vec3_origin, and VectorCopy.

AABB::AABB ( const vec3_t  mini,
const vec3_t  maxi 
)

Definition at line 34 of file aabb.cpp.

References maxs, mins, and VectorCopy.

AABB::AABB ( const vec_t  minX,
const vec_t  minY,
const vec_t  minZ,
const vec_t  maxX,
const vec_t  maxY,
const vec_t  maxZ 
)

Definition at line 39 of file aabb.cpp.

References maxs, and mins.

AABB::AABB ( const Line line)

Definition at line 48 of file aabb.cpp.

References maxs, mins, Line::start, Line::stop, and VectorSet.

Member Function Documentation

void AABB::add ( const AABB other)

If the given box is outside our box, expand our box to accommodate it.

Note
We only have to check min vs. min and max vs. max here. So adding a box is far more efficient than adding it's min and max as points.

Definition at line 72 of file aabb.cpp.

References i, maxs, and mins.

void AABB::asIntString ( char *  str,
size_t  len 
)
inline

Prints a representation of the box.

Parameters
[out]strThe output string, expected to be at least AABB_STRING wide
[in]lenThe length of the output buffer

Definition at line 167 of file aabb.h.

References maxs, and mins.

Referenced by LoadMapFile(), and SP_func_breakable().

bool AABB::canBeHitBy ( const Line line) const
inline

Checks if the given line has a chance to hit our box.

Parameters
[in]lineThe line that might hit us
Returns
false - impossible; true - maybe

Definition at line 192 of file aabb.h.

References getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), getMinZ(), Line::start, and Line::stop.

Referenced by CM_LineMissesModel().

void AABB::clipToWorld ( )
inline

clip the box to the maximum boundaries

Definition at line 224 of file aabb.h.

References maxs, mins, and MWW.

Referenced by expandXY(), and shift().

bool AABB::contains ( const vec3_t  point) const
inline

Definition at line 200 of file aabb.h.

References getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), and getMinZ().

Referenced by MakeBspBrushList(), MapBrushesBounds(), and SV_GridIsOnMap().

bool AABB::contains ( const AABB other) const
inline

Definition at line 205 of file aabb.h.

References getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), and getMinZ().

bool AABB::doesIntersect ( const AABB other) const
inline

Checks if the aabb touches or intersects with the given aabb.

Parameters
[in]otherThe other aabb

Definition at line 183 of file aabb.h.

References getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), and getMinZ().

Referenced by CM_CompleteBoxTrace(), CM_EntCompleteBoxTrace(), G_GetTouchingEdicts(), and SV_BoundingBoxesIntersect().

void AABB::expand ( const float  byVal)
inline

expand the box in all directions, but clip them to the maximum boundaries

Definition at line 240 of file aabb.h.

References expandXY(), maxs, and mins.

Referenced by MoveClip::calcBounds(), CM_CalculateWidestBoundingBox(), CMod_LoadSubmodels(), ConstructLevelNodes_r(), G_TouchEdicts(), G_TouchSolids(), ProcessSubModel(), R_CullBspModel(), and R_Trace().

void AABB::expandXY ( const float  byVal)
inline

expand the box in four directions, but clip them to the maximum boundaries

Definition at line 232 of file aabb.h.

References clipToWorld(), maxs, and mins.

Referenced by expand(), G_TriggerSpawn(), SV_LinkEdict(), and Weather::update().

void AABB::getCenter ( vec3_t  center) const
inline

Calculates the center of the bounding box.

Parameters
[out]centerThe target center vector

Definition at line 155 of file aabb.h.

References maxs, mins, VectorAdd, and VectorScale.

Referenced by CalculateMinsMaxs(), CL_CenterCameraIntoMap_f(), G_BuildForbiddenListForEntity(), G_EventSpawnSound(), G_FindRadius(), G_SplashDamage(), Grid_RecalcRouting(), LE_FindRadius(), ParseBrush(), R_ModelAutoScale(), R_SetSurfaceExtents(), and boxtrace_s::setLineAndBox().

void AABB::getDiagonal ( vec3_t  diagonal) const
inline
const vec3_t& AABB::getMaxs ( ) const
inline

Definition at line 128 of file aabb.h.

References maxs.

Referenced by GridBox::GridBox(), R_CullBspModel(), and GridBox::set().

float AABB::getMaxX ( ) const
inline
float AABB::getMaxZ ( ) const
inline

Definition at line 137 of file aabb.h.

References maxs.

Referenced by canBeHitBy(), CM_EntCompleteBoxTrace(), contains(), doesIntersect(), getWidthZ(), and Weather::update().

const vec3_t& AABB::getMins ( ) const
inline

Definition at line 116 of file aabb.h.

References mins.

Referenced by GridBox::GridBox(), R_CullBspModel(), and GridBox::set().

float AABB::getMinY ( ) const
inline
float AABB::getMinZ ( ) const
inline
float AABB::getWidthZ ( ) const
inline

Definition at line 147 of file aabb.h.

References getMaxZ(), and getMinZ().

Referenced by CM_CalculateWidestBoundingBox(), and R_ModelAutoScale().

bool AABB::isZero ( ) const
inline

Definition at line 176 of file aabb.h.

References maxs, mins, and VectorEmpty.

void AABB::reset ( void  )
inline

Definition at line 83 of file aabb.h.

References maxs, and mins.

Referenced by MakeBrushWindings(), ProcessSubModel(), and SV_LoadModelAABB().

void AABB::rotateAround ( const vec3_t  origin,
const vec3_t  angles 
)

Rotates bounding box around given origin point; note that it will expand the box unless all angles are multiples of 90 degrees.

Rotates AABB around given origin point; note that it will expand the box unless all angles are multiples of 90 degrees.

Note
Not fully verified so far

Definition at line 86 of file aabb.cpp.

References f, m, maxs, mins, VectorAbs, VectorAdd, VectorCreateRotationMatrix(), VectorEmpty, VectorInterpolation, VectorRotate(), and VectorSubtract.

void AABB::set ( const vec3_t  mini,
const vec3_t  maxi 
)
inline

Definition at line 64 of file aabb.h.

References maxs, mins, and VectorCopy.

void AABB::set ( const AABB trBox,
const Line trLine 
)
inline

Set from another box and a (trace)Line.

Definition at line 105 of file aabb.h.

References add(), set(), shift(), Line::start, and Line::stop.

void AABB::setFromLittleFloat ( const AABB other)
inline

Definition at line 87 of file aabb.h.

References LittleFloat, maxs, and mins.

Referenced by CMod_LoadSubmodels().

void AABB::setMaxs ( int  x,
int  y,
int  z 
)
inline

Definition at line 77 of file aabb.h.

References maxs, and VectorSet.

void AABB::setMaxZ ( float  zVal)
inline

Definition at line 80 of file aabb.h.

References maxs.

Referenced by G_ActorSetMaxs().

void AABB::setMins ( const vec3_t  mini)
inline

Definition at line 68 of file aabb.h.

References mins, and VectorCopy.

Referenced by CL_ActorAppear(), G_Actor2x2Spawn(), G_ActorSpawn(), G_SpawnField(), SP_2x2_start(), and SP_misc_mission().

void AABB::setMins ( int  x,
int  y,
int  z 
)
inline

Definition at line 74 of file aabb.h.

References mins, and VectorSet.

void AABB::setNegativeVolume ( )
inline

Sets mins and maxs to their starting points before using addPoint.

Definition at line 98 of file aabb.h.

References maxs, and mins.

Referenced by AllocTree(), BeginModel(), BoundBrush(), BuildNodeChildren(), BuildTree(), CalcNodeBounds(), Check_MapSize(), LoadMapFile(), MakeBrushWindings(), MapBrushesBounds(), R_ModLoadAliasMD2Model(), R_ModLoadAliasMD3Model(), and SV_LoadModelAABB().

void AABB::shift ( const vec3_t  shiftVec)
inline

Field Documentation


The documentation for this class was generated from the following files: