UFO: Alien Invasion
Loading...
Searching...
No Matches
AABB Class Reference

#include <aabb.h>

Collaboration diagram for AABB:
Collaboration graph

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.
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.
void set (const AABB &trBox, const Line &trLine)
 Set from another box and a (trace)Line.
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.
void getDiagonal (vec3_t diagonal) const
void asIntString (char *str, size_t len)
 Prints a representation of the box.
bool isZero () const
bool doesIntersect (const AABB &other) const
 Checks if the aabb touches or intersects with the given aabb.
bool canBeHitBy (const Line &line) const
 Checks if the given line has a chance to hit our box.
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.
void add (const AABB &other)
 If the given box is outside our box, expand our box to accommodate it.
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.
void clipToWorld ()
 clip the box to the maximum boundaries
void expandXY (const float byVal)
 expand the box in four directions, but clip them to the maximum boundaries
void expand (const float byVal)
 expand the box in all directions, but clip them to the maximum boundaries
void shift (const vec3_t shiftVec)
 shove the whole box by the given vector

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() [1/4]

AABB::AABB ( )

Definition at line 29 of file aabb.cpp.

References maxs, mins, vec3_origin, and VectorCopy.

Referenced by add(), contains(), doesIntersect(), set(), set(), and setFromLittleFloat().

◆ AABB() [2/4]

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

Definition at line 34 of file aabb.cpp.

References maxs, mins, and VectorCopy.

◆ AABB() [3/4]

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() [4/4]

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

◆ add() [1/2]

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 AABB(), i, maxs, and mins.

◆ add() [2/2]

◆ asIntString()

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 len, maxs, and mins.

Referenced by LoadMapFile(), and SP_func_breakable().

◆ canBeHitBy()

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().

◆ clipToWorld()

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().

◆ contains() [1/2]

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

Definition at line 205 of file aabb.h.

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

◆ contains() [2/2]

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(), and MapBrushesBounds().

◆ doesIntersect()

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 AABB(), getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), and getMinZ().

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

◆ expand()

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 CM_CalculateWidestBoundingBox(), CMod_LoadSubmodels(), ConstructLevelNodes_r(), G_TouchEdicts(), G_TouchSolids(), ProcessSubModel(), R_CullBspModel(), and R_Trace().

◆ expandXY()

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().

◆ getCenter()

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(), Destroy_Breakable(), G_BuildForbiddenListForEntity(), G_EventSpawnSound(), G_FindRadius(), G_SplashDamage(), Grid_RecalcRouting(), LE_FindRadius(), ParseBrush(), R_ModelAutoScale(), R_SetSurfaceExtents(), and Think_NextMapTrigger().

◆ getDiagonal()

void AABB::getDiagonal ( vec3_t diagonal) const
inline

◆ getMaxs()

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().

◆ getMaxX()

float AABB::getMaxX ( ) const
inline

◆ getMaxY()

float AABB::getMaxY ( ) const
inline

Definition at line 134 of file aabb.h.

References maxs.

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

◆ getMaxZ()

float AABB::getMaxZ ( ) const
inline

Definition at line 137 of file aabb.h.

References maxs.

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

◆ getMins()

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().

◆ getMinX()

float AABB::getMinX ( ) const
inline

◆ getMinY()

float AABB::getMinY ( ) const
inline

Definition at line 122 of file aabb.h.

References mins.

Referenced by canBeHitBy(), contains(), contains(), doesIntersect(), getWidthY(), LE_BrushModelAction(), and Weather::update().

◆ getMinZ()

float AABB::getMinZ ( ) const
inline

◆ getWidthX()

float AABB::getWidthX ( ) const
inline

Definition at line 141 of file aabb.h.

References getMaxX(), and getMinX().

Referenced by CM_CalculateWidestBoundingBox(), and R_ModelAutoScale().

◆ getWidthY()

float AABB::getWidthY ( ) const
inline

Definition at line 144 of file aabb.h.

References getMaxY(), and getMinY().

Referenced by CM_CalculateWidestBoundingBox().

◆ getWidthZ()

float AABB::getWidthZ ( ) const
inline

Definition at line 147 of file aabb.h.

References getMaxZ(), and getMinZ().

Referenced by CM_CalculateWidestBoundingBox(), and R_ModelAutoScale().

◆ isZero()

bool AABB::isZero ( ) const
inline

Definition at line 176 of file aabb.h.

References maxs, mins, and VectorEmpty.

◆ reset()

void AABB::reset ( )
inline

Definition at line 83 of file aabb.h.

References maxs, and mins.

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

◆ rotateAround()

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 m, maxs, mins, VectorAbs, VectorAdd, VectorCreateRotationMatrix(), VectorEmpty, VectorInterpolation, VectorRotate(), and VectorSubtract.

◆ set() [1/3]

◆ set() [2/3]

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 AABB(), add(), set(), shift(), shift, Line::start, and Line::stop.

◆ set() [3/3]

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.

◆ setFromLittleFloat()

void AABB::setFromLittleFloat ( const AABB & other)
inline

Definition at line 87 of file aabb.h.

References AABB(), LittleFloat, maxs, and mins.

Referenced by CMod_LoadSubmodels().

◆ setMaxs() [1/2]

◆ setMaxs() [2/2]

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

Definition at line 77 of file aabb.h.

References maxs, and VectorSet.

◆ setMaxZ()

void AABB::setMaxZ ( float zVal)
inline

Definition at line 80 of file aabb.h.

References maxs.

Referenced by G_ActorSetMaxs().

◆ setMins() [1/2]

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().

◆ setMins() [2/2]

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

Definition at line 74 of file aabb.h.

References mins, and VectorSet.

◆ setNegativeVolume()

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().

◆ shift()

void AABB::shift ( const vec3_t shiftVec)
inline

Field Documentation

◆ EMPTY

◆ maxs

◆ mins


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