Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
|
#include <opbox.h>
Classes | |
struct | bEdge |
Public Member Functions | |
float | MinX () const |
Get the minimum X value of the box. More... | |
float | MinY () const |
Get the minimum Y value of the box. More... | |
float | MinZ () const |
Get the minimum Z value of the box. More... | |
float | MaxX () const |
Get the maximum X value of the box. More... | |
float | MaxY () const |
Get the maximum Y value of the box. More... | |
float | MaxZ () const |
Get the maximum Z value of the box. More... | |
float | Min (int idx) const |
Get Min component for 0 (x), 1 (y), or 2 (z). More... | |
float | Max (int idx) const |
Get Max component for 0 (x), 1 (y), or 2 (z). More... | |
const csVector3 & | Min () const |
Get the 3d vector of minimum (x, y, z) values. More... | |
const csVector3 & | Max () const |
Get the 3d vector of maximum (x, y, z) values. More... | |
csVector3 | GetCorner (int corner) const |
void | GetEdgeInfo (int edge, int &v1, int &v2, int &fleft, int &fright) const |
uint8 * | GetFaceEdges (int face) const |
csVector3 | GetCenter () const |
void | SetCenter (const csVector3 &c) |
void | SetSize (const csVector3 &s) |
int | GetVisibleSides (const csVector3 &pos, int *visible_sides) const |
bool | In (float x, float y, float z) const |
Test if the given coordinate is in this box. More... | |
bool | In (const csVector3 &v) const |
Test if the given coordinate is in this box. More... | |
bool | Overlap (const csBox3 &box) const |
Test if this box overlaps with the given box. More... | |
bool | Contains (const csBox3 &box) const |
Test if this box contains the other box. More... | |
bool | Empty () const |
Test if this box is empty. More... | |
void | StartBoundingBox () |
Initialize this box to empty. More... | |
void | StartBoundingBox (const csVector3 &v) |
Initialize this box to one vertex. More... | |
void | AddBoundingVertex (float x, float y, float z) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertex (const csVector3 &v) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertexSmart (float x, float y, float z) |
void | AddBoundingVertexSmart (const csVector3 &v) |
csBox3 () | |
Initialize this box to empty. More... | |
csBox3 (const csVector3 &v) | |
Initialize this box with one point. More... | |
csBox3 (const csVector3 &v1, const csVector3 &v2) | |
Initialize this box with two points. More... | |
csBox3 (float x1, float y1, float z1, float x2, float y2, float z2) | |
Initialize this box with the given values. More... | |
void | Set (const csVector3 &bmin, const csVector3 &bmax) |
Sets the bounds of the box with the given values. More... | |
void | Set (float x1, float y1, float z1, float x2, float y2, float z2) |
Sets the bounds of the box with the given values. More... | |
bool | AdjacentX (const csBox3 &other) const |
bool | AdjacentY (const csBox3 &other) const |
bool | AdjacentZ (const csBox3 &other) const |
int | Adjacent (const csBox3 &other) const |
void | GetConvexOutline (const csVector3 &pos, csVector3 *array, int &num_array, bool bVisible=false) const |
bool | Between (const csBox3 &box1, const csBox3 &box2) const |
void | ManhattanDistance (const csBox3 &other, csVector3 &dist) const |
float | SquaredOriginDist () const |
float | SquaredOriginMaxDist () const |
csBox3 & | operator+= (const csBox3 &box) |
Compute the union of two bounding boxes. More... | |
csBox3 & | operator+= (const csVector3 &point) |
Compute the union of a point with this bounding box. More... | |
csBox3 & | operator*= (const csBox3 &box) |
Compute the intersection of two bounding boxes. More... | |
Static Public Member Functions | |
static int | OtherSide (int side) |
Protected Types | |
typedef uint8 | bFace [4] |
Protected Attributes | |
csVector3 | minbox |
The top-left of this bounding box. More... | |
csVector3 | maxbox |
The bottom-right. More... | |
Static Protected Attributes | |
static bEdge | edges [24] |
static bFace | faces [6] |
Friends | |
csBox3 | operator+ (const csBox3 &box1, const csBox3 &box2) |
Compute the union of two bounding boxes. More... | |
csBox3 | operator+ (const csBox3 &box, const csVector3 &point) |
Compute the union of a bounding box and a point. More... | |
csBox3 | operator* (const csBox3 &box1, const csBox3 &box2) |
Compute the intersection of two bounding boxes. More... | |
bool | operator== (const csBox3 &box1, const csBox3 &box2) |
Tests if two bounding boxes are equal. More... | |
bool | operator!= (const csBox3 &box1, const csBox3 &box2) |
Tests if two bounding boxes are unequal. More... | |
bool | operator< (const csBox3 &box1, const csBox3 &box2) |
Tests if box1 is a subset of box2. More... | |
bool | operator> (const csBox3 &box1, const csBox3 &box2) |
Tests if box1 is a superset of box2. More... | |
bool | operator< (const csVector3 &point, const csBox3 &box) |
Tests if a point is contained in a box. More... | |
A bounding box in 3D space. In order to operate correctly, this bounding box assumes that all values entered or compared against lie within the range (-CS_BOUNDINGBOX_MAXVALUE, CS_BOUNDINGBOX_MAXVALUE). It is not recommended to use points outside of this range.
|
inline |
Initialize this box with two points.
Definition at line 352 of file opbox.h.
References Empty(), and StartBoundingBox().
Initialize this box with the given values.
Definition at line 357 of file opbox.h.
References Empty(), and StartBoundingBox().
Add a new vertex and recalculate the bounding box.
Definition at line 290 of file opbox.h.
References maxbox, minbox, csVector3::x, x, csVector3::y, y, and csVector3::z.
Referenced by AddBoundingVertex().
|
inline |
Add a new vertex and recalculate the bounding box.
Definition at line 298 of file opbox.h.
References AddBoundingVertex(), csVector3::x, csVector3::y, and csVector3::z.
Add a new vertex and recalculate the bounding box. This version is a little more optimal. It assumes however that at least one point has been added to the bounding box.
Definition at line 308 of file opbox.h.
References maxbox, minbox, csVector3::x, x, csVector3::y, y, and csVector3::z.
Referenced by AddBoundingVertexSmart().
|
inline |
Add a new vertex and recalculate the bounding box. This version is a little more optimal. It assumes however that at least one point has been added to the bounding box.
Definition at line 320 of file opbox.h.
References AddBoundingVertexSmart(), csVector3::x, csVector3::y, and csVector3::z.
Test if this box is adjacent to the other one. Return -1 if not adjacent or else any of the BOX_SIDE_??? flags to indicate the side of this box that the other box is adjacent with.
Definition at line 191 of file opbox.cpp.
References AdjacentX(), AdjacentY(), AdjacentZ(), BOX_SIDE_x, BOX_SIDE_X, BOX_SIDE_y, BOX_SIDE_Y, BOX_SIDE_z, BOX_SIDE_Z, MaxX(), MaxY(), and MaxZ().
Test if this box is between two others.
Definition at line 274 of file opbox.cpp.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Test if this box contains the other box.
Definition at line 256 of file opbox.h.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
|
inline |
Test if this box is empty.
Definition at line 264 of file opbox.h.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Referenced by csBox3().
|
inline |
void csBox3::GetConvexOutline | ( | const csVector3 & | pos, |
csVector3 * | array, | ||
int & | num_array, | ||
bool | bVisible = false |
||
) | const |
Get a convex outline (not a polygon unless projected to 2D) for for this box as seen from the given position. The coordinates returned are world space coordinates. Note that you need place for at least six vectors in the array. If you set bVisible true, you will get all visible corners - this could be up to 7.
Definition at line 236 of file opbox.cpp.
References i, Max(), MIN, Min(), Outline::num, Outline::vertices, csVector3::x, csVector3::y, and csVector3::z.
Return every corner of this bounding box from 0 to 7. This contrasts with Min() and Max() because those are only the min and max corners. Corner 0 = xyz, 1 = xyZ, 2 = xYz, 3 = xYZ, 4 = Xyz, 5 = XyZ, 6 = XYz, 7 = XYZ. Use BOX_CORNER_??? defines.
Definition at line 124 of file opbox.cpp.
References BOX_CORNER_xyz, BOX_CORNER_xyZ, BOX_CORNER_xYz, BOX_CORNER_xYZ, BOX_CORNER_Xyz, BOX_CORNER_XyZ, BOX_CORNER_XYz, BOX_CORNER_XYZ, Max(), MaxX(), MaxY(), MaxZ(), Min(), MinX(), MinY(), and MinZ().
Given an edge index (BOX_EDGE_???) return the two vertices (index BOX_CORNER_???) and left/right faces (BOX_SIDE_???).
Definition at line 154 of file opbox.h.
References edges, csBox3::bEdge::fl, csBox3::bEdge::fr, csBox3::bEdge::v1, and csBox3::bEdge::v2.
Get a side of this box as a 2D box. Use BOX_SIDE_??? defines.
csBox2 GetSide (int side) const; Fill the array (which should be three long at least) with all visible sides (BOX_SIDE_??? defines) as seen from the given point. Returns the number of visible sides.
Definition at line 211 of file opbox.cpp.
References i, Max(), Min(), Outline::num_sides, Outline::sides, csVector3::x, csVector3::y, and csVector3::z.
Test if the given coordinate is in this box.
Return every edge (segment) of this bounding box from 0 to 23 (use one of the BOX_EDGE_??? indices). The returned edge is undefined for any other index.
csSegment3 GetEdge (int edge) const { return csSegment3 (GetCorner (edges[edge].v1), GetCorner (edges[edge].v2)); } Return every edge (segment) of this bounding box from 0 to 23 (use one of the BOX_EDGE_??? indices). The returned edge is undefined for any other index.
void GetEdge (int edge, csSegment3& e) const { e.SetStart (GetCorner (edges[edge].v1)); e.SetEnd (GetCorner (edges[edge].v2)); }
Definition at line 232 of file opbox.h.
Referenced by In().
Test if the given coordinate is in this box.
Definition at line 241 of file opbox.h.
References In(), csVector3::x, csVector3::y, and csVector3::z.
Calculate the minimum manhattan distance between this box and another one.
Definition at line 292 of file opbox.cpp.
References MaxX(), MaxY(), MaxZ(), MinX(), MinY(), MinZ(), csVector3::x, csVector3::y, and csVector3::z.
Get Max component for 0 (x), 1 (y), or 2 (z).
Definition at line 133 of file opbox.h.
References maxbox, csVector3::x, csVector3::y, and csVector3::z.
|
inline |
Get the 3d vector of maximum (x, y, z) values.
Definition at line 138 of file opbox.h.
References maxbox.
Referenced by GetConvexOutline(), GetCorner(), and GetVisibleSides().
|
inline |
Get the maximum X value of the box.
Definition at line 124 of file opbox.h.
References maxbox, and csVector3::x.
Referenced by Adjacent(), AdjacentX(), AdjacentY(), AdjacentZ(), GetCorner(), and ManhattanDistance().
|
inline |
Get the maximum Y value of the box.
Definition at line 126 of file opbox.h.
References maxbox, and csVector3::y.
Referenced by Adjacent(), AdjacentX(), AdjacentY(), AdjacentZ(), GetCorner(), and ManhattanDistance().
|
inline |
Get the maximum Z value of the box.
Definition at line 128 of file opbox.h.
References maxbox, and csVector3::z.
Referenced by Adjacent(), AdjacentX(), AdjacentY(), AdjacentZ(), GetCorner(), and ManhattanDistance().
Get Min component for 0 (x), 1 (y), or 2 (z).
Definition at line 130 of file opbox.h.
References minbox, csVector3::x, csVector3::y, and csVector3::z.
|
inline |
Get the 3d vector of minimum (x, y, z) values.
Definition at line 136 of file opbox.h.
References minbox.
Referenced by GetConvexOutline(), GetCorner(), and GetVisibleSides().
|
inline |
Get the minimum X value of the box.
Definition at line 118 of file opbox.h.
References minbox, and csVector3::x.
Referenced by AdjacentX(), AdjacentY(), AdjacentZ(), GetCorner(), and ManhattanDistance().
|
inline |
Get the minimum Y value of the box.
Definition at line 120 of file opbox.h.
References minbox, and csVector3::y.
Referenced by AdjacentX(), AdjacentY(), AdjacentZ(), GetCorner(), and ManhattanDistance().
|
inline |
Get the minimum Z value of the box.
Definition at line 122 of file opbox.h.
References minbox, and csVector3::z.
Referenced by AdjacentX(), AdjacentY(), AdjacentZ(), GetCorner(), and ManhattanDistance().
Compute the intersection of two bounding boxes.
Definition at line 360 of file opbox.cpp.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Compute the union of two bounding boxes.
Definition at line 338 of file opbox.cpp.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Compute the union of a point with this bounding box.
Definition at line 349 of file opbox.cpp.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Test if this box overlaps with the given box.
Definition at line 247 of file opbox.h.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Sets the bounds of the box with the given values.
Definition at line 369 of file opbox.h.
References maxbox, minbox, StartBoundingBox(), csVector3::x, csVector3::y, and csVector3::z.
void csBox3::SetCenter | ( | const csVector3 & | c) |
void csBox3::SetSize | ( | const csVector3 & | s) |
float csBox3::SquaredOriginDist | ( | ) | const |
Calculate the squared distance between (0,0,0) and the box This routine is extremely efficient.
Definition at line 306 of file opbox.cpp.
References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
float csBox3::SquaredOriginMaxDist | ( | ) | const |
Calculate the squared distance between (0,0,0) and the point on the box which is furthest away from (0,0,0). This routine is extremely efficient.
Definition at line 320 of file opbox.cpp.
References MAX, maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
|
inline |
Initialize this box to empty.
Definition at line 273 of file opbox.h.
References CS_BOUNDINGBOX_MAXVALUE, maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z.
Referenced by csBox3(), and Set().
|
inline |
Tests if two bounding boxes are unequal.
Compute the intersection of two bounding boxes.
Compute the union of two bounding boxes.
Compute the union of a bounding box and a point.
Tests if box1 is a subset of box2.
Tests if a point is contained in a box.
Tests if two bounding boxes are equal.
Tests if box1 is a superset of box2.
|
staticprotected |
|
staticprotected |
|
protected |
The bottom-right.
Definition at line 103 of file opbox.h.
Referenced by AddBoundingVertex(), AddBoundingVertexSmart(), Between(), Contains(), Empty(), GetCenter(), Max(), MaxX(), MaxY(), MaxZ(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator<(), operator==(), operator>(), Overlap(), Set(), SetCenter(), SetSize(), SquaredOriginDist(), SquaredOriginMaxDist(), and StartBoundingBox().
|
protected |
The top-left of this bounding box.
Definition at line 101 of file opbox.h.
Referenced by AddBoundingVertex(), AddBoundingVertexSmart(), Between(), Contains(), Empty(), GetCenter(), Min(), MinX(), MinY(), MinZ(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator<(), operator==(), operator>(), Overlap(), Set(), SetCenter(), SetSize(), SquaredOriginDist(), SquaredOriginMaxDist(), and StartBoundingBox().