Oolite
Loading...
Searching...
No Matches
OOBoundingBox.h File Reference
#include "OOHPVector.h"
Include dependency graph for OOBoundingBox.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  BoundingBox

Functions

OOINLINE void bounding_box_add_vector (BoundingBox *box, Vector vec) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE void bounding_box_add_xyz (BoundingBox *box, GLfloat x, GLfloat y, GLfloat z) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE void bounding_box_reset (BoundingBox *box) NONNULL_FUNC
OOINLINE void bounding_box_reset_to_vector (BoundingBox *box, Vector vec) ALWAYS_INLINE_FUNC NONNULL_FUNC
OOINLINE void bounding_box_get_dimensions (BoundingBox bb, GLfloat *xSize, GLfloat *ySize, GLfloat *zSize) ALWAYS_INLINE_FUNC
OOINLINE Vector OOBoundingBoxCenter (BoundingBox bb) INLINE_CONST_FUNC
Vector OORandomPositionInBoundingBox (BoundingBox bb)
HPVector OOHPRandomPositionInBoundingBox (BoundingBox bb)

Variables

const BoundingBox kZeroBoundingBox

Function Documentation

◆ bounding_box_add_vector()

OOINLINE void bounding_box_add_vector ( BoundingBox * box,
Vector vec )

Definition at line 58 of file OOBoundingBox.h.

59{
60 assert(box != NULL);
61 box->min.x = fmin(box->min.x, vec.x);
62 box->max.x = fmax(box->max.x, vec.x);
63 box->min.y = fmin(box->min.y, vec.y);
64 box->max.y = fmax(box->max.y, vec.y);
65 box->min.z = fmin(box->min.z, vec.z);
66 box->max.z = fmax(box->max.z, vec.z);
67}
OOScalar x
Definition OOVector.h:32
OOScalar y
Definition OOVector.h:33
OOScalar z
Definition OOVector.h:34

References BoundingBox::max, BoundingBox::min, OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by OOMesh(Private)::calculateBoundingVolumes, PlayerEntity::doBookkeeping:, OOMesh::findBoundingBoxRelativeToPosition:ri:rj:rk:selfPosition:si:sj:sk:, OOMesh::findSubentityBoundingBoxWithPosition:rotMatrix:, ShipEntity::setUpOneStandardSubentity:asTurret:, and ShipEntity::update:.

Here is the caller graph for this function:

◆ bounding_box_add_xyz()

OOINLINE void bounding_box_add_xyz ( BoundingBox * box,
GLfloat x,
GLfloat y,
GLfloat z )

Definition at line 69 of file OOBoundingBox.h.

70{
71 assert(box != NULL);
72 box->min.x = fmin(box->min.x, x);
73 box->max.x = fmax(box->max.x, x);
74 box->min.y = fmin(box->min.y, y);
75 box->max.y = fmax(box->max.y, y);
76 box->min.z = fmin(box->min.z, z);
77 box->max.z = fmax(box->max.z, z);
78}
float y
float x

References BoundingBox::max, BoundingBox::min, OOINLINE, Vector::x, x, Vector::y, y, and Vector::z.

Referenced by Universe::addShips:withRole:nearPosition:withCoordinateSystem:, and Universe::addShips:withRole:nearPosition:withCoordinateSystem:withinRadius:.

Here is the caller graph for this function:

◆ bounding_box_get_dimensions()

OOINLINE void bounding_box_get_dimensions ( BoundingBox bb,
GLfloat * xSize,
GLfloat * ySize,
GLfloat * zSize )

Definition at line 93 of file OOBoundingBox.h.

94{
95 if (xSize != NULL)
96 *xSize = bb.max.x - bb.min.x;
97 if (ySize != NULL)
98 *ySize = bb.max.y - bb.min.y;
99 if (zSize != NULL)
100 *zSize = bb.max.z - bb.min.z;
101}

References BoundingBox::max, BoundingBox::min, OOINLINE, Vector::x, Vector::y, and Vector::z.

Referenced by OOMesh::octreeDepth, CollisionRegion::shadowAtPointOcclusionToValue, ShipGetProperty(), and ShipGetProperty().

Here is the caller graph for this function:

◆ bounding_box_reset()

OOINLINE void bounding_box_reset ( BoundingBox * box)

Definition at line 80 of file OOBoundingBox.h.

81{
82 assert(box != NULL);
83 *box = kZeroBoundingBox;
84}
const BoundingBox kZeroBoundingBox
Definition OOVector.m:36

References kZeroBoundingBox, and OOINLINE.

Referenced by OOMesh(Private)::calculateBoundingVolumes.

Here is the caller graph for this function:

◆ bounding_box_reset_to_vector()

OOINLINE void bounding_box_reset_to_vector ( BoundingBox * box,
Vector vec )

Definition at line 86 of file OOBoundingBox.h.

87{
88 assert(box != NULL);
89 box->min = vec;
90 box->max = vec;
91}

References BoundingBox::max, BoundingBox::min, and OOINLINE.

Referenced by Universe::addShips:withRole:nearPosition:withCoordinateSystem:, Universe::addShips:withRole:nearPosition:withCoordinateSystem:withinRadius:, OOMesh(Private)::calculateBoundingVolumes, OOMesh::findBoundingBoxRelativeToPosition:ri:rj:rk:selfPosition:si:sj:sk:, and OOMesh::findSubentityBoundingBoxWithPosition:rotMatrix:.

Here is the caller graph for this function:

◆ OOBoundingBoxCenter()

OOINLINE Vector OOBoundingBoxCenter ( BoundingBox bb)

Definition at line 103 of file OOBoundingBox.h.

104{
105 return vector_multiply_scalar(vector_add(bb.min, bb.max), 0.5f);
106}
OOINLINE Vector vector_add(Vector a, Vector b) INLINE_CONST_FUNC
Definition OOVector.h:195
OOINLINE Vector vector_multiply_scalar(Vector v, OOScalar s) INLINE_CONST_FUNC
Definition OOVector.h:180

References BoundingBox::max, BoundingBox::min, OOINLINE, vector_add(), and vector_multiply_scalar().

Referenced by OOLaserShotEntity::initLaserFromShip:direction:offset:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OOHPRandomPositionInBoundingBox()

HPVector OOHPRandomPositionInBoundingBox ( BoundingBox bb)

Definition at line 93 of file OOHPVector.m.

94{
95 HPVector result;
96 result.x = (OOHPScalar)(bb.min.x + randf() * (bb.max.x - bb.min.x));
97 result.y = (OOHPScalar)(bb.min.y + randf() * (bb.max.y - bb.min.y));
98 result.z = (OOHPScalar)(bb.min.z + randf() * (bb.max.z - bb.min.z));
99 return result;
100}
double OOHPScalar
Definition OOMaths.h:51
float randf(void)
OOHPScalar x
Definition OOHPVector.h:36
OOHPScalar y
Definition OOHPVector.h:37
OOHPScalar z
Definition OOHPVector.h:38

References BoundingBox::max, BoundingBox::min, randf(), HPVector::x, Vector::x, HPVector::y, Vector::y, HPVector::z, and Vector::z.

Here is the call graph for this function:

◆ OORandomPositionInBoundingBox()

Vector OORandomPositionInBoundingBox ( BoundingBox bb)

Definition at line 107 of file OOVector.m.

108{
109 Vector result;
110 result.x = bb.min.x + randf() * (bb.max.x - bb.min.x);
111 result.y = bb.min.y + randf() * (bb.max.y - bb.min.y);
112 result.z = bb.min.z + randf() * (bb.max.z - bb.min.z);
113 return result;
114}

References BoundingBox::max, BoundingBox::min, randf(), Vector::x, Vector::y, and Vector::z.

Referenced by ShipEntity::becomeExplosion, and ShipEntity::releaseCargoPodsDebris.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ kZeroBoundingBox

const BoundingBox kZeroBoundingBox
extern

Definition at line 36 of file OOVector.m.

36{ { 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 0.0f } };

Referenced by bounding_box_reset(), OODrawable::boundingBox, and OOMesh::init.