Panda3D
|
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple. More...
#include "boundingBox.h"
Public Member Functions | |
BoundingBox () | |
Constructs an empty box object. | |
BoundingBox (const LPoint3f &min, const LPoint3f &max) | |
Constructs a specific box object. | |
virtual const BoundingBox * | as_bounding_box () const |
Virtual downcast method. | |
virtual TypeHandle | force_init_type () |
virtual LPoint3f | get_approx_center () const |
virtual LPoint3f | get_max () const |
const LPoint3f & | get_maxq () const |
An inline accessor for the maximum value. | |
virtual LPoint3f | get_min () const |
const LPoint3f & | get_minq () const |
An inline accessor for the minimum value. | |
int | get_num_planes () const |
Returns 6: the number of faces of a rectangular solid. | |
int | get_num_points () const |
Returns 8: the number of vertices of a rectangular solid. | |
Planef | get_plane (int n) const |
Returns the nth face of the rectangular solid. | |
LPoint3f | get_point (int n) const |
Returns the nth vertex of the rectangular solid. | |
virtual TypeHandle | get_type () const |
virtual float | get_volume () const |
virtual BoundingVolume * | make_copy () const |
MAKE_SEQ (get_planes, get_num_planes, get_plane) | |
MAKE_SEQ (get_points, get_num_points, get_point) | |
virtual void | output (ostream &out) const |
virtual void | xform (const LMatrix4f &mat) |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Protected Member Functions | |
virtual bool | around_boxes (const BoundingVolume **first, const BoundingVolume **last) |
Double-dispatch support: called by around_other() when the type of the first element in the list is known to be a nonempty box. | |
bool | around_finite (const BoundingVolume **first, const BoundingVolume **last) |
virtual bool | around_hexahedrons (const BoundingVolume **first, const BoundingVolume **last) |
Double-dispatch support: called by around_other() when the type of the first element in the list is known to be a nonempty hexahedron. | |
virtual bool | around_other (BoundingVolume *other, const BoundingVolume **first, const BoundingVolume **last) const |
virtual bool | around_points (const LPoint3f *first, const LPoint3f *last) |
Puts the volume around the indicated list of points, identified by an STL-style begin/end list. | |
virtual bool | around_spheres (const BoundingVolume **first, const BoundingVolume **last) |
Double-dispatch support: called by around_other() when the type of the first element in the list is known to be a nonempty sphere. | |
virtual int | contains_box (const BoundingBox *box) const |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a box. | |
int | contains_finite (const FiniteBoundingVolume *volume) const |
virtual int | contains_hexahedron (const BoundingHexahedron *hexahedron) const |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a hexahedron. | |
virtual int | contains_line (const BoundingLine *line) const |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a line. | |
virtual int | contains_lineseg (const LPoint3f &a, const LPoint3f &b) const |
Tests whether the volume contains the indicated line segment. | |
virtual int | contains_other (const BoundingVolume *other) const |
virtual int | contains_plane (const BoundingPlane *plane) const |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a plane. | |
virtual int | contains_point (const LPoint3f &point) const |
Tests whether the volume contains the indicated point. | |
virtual int | contains_sphere (const BoundingSphere *sphere) const |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a sphere. | |
virtual bool | extend_by_box (const BoundingBox *box) |
Double-dispatch support: called by extend_other() when the type we're extending by is known to be a box. | |
bool | extend_by_finite (const FiniteBoundingVolume *volume) |
virtual bool | extend_by_hexahedron (const BoundingHexahedron *hexahedron) |
Double-dispatch support: called by extend_other() when the type we're extending by is known to be a hexahedron. | |
virtual bool | extend_by_point (const LPoint3f &point) |
Extends the volume to include the indicated point. | |
virtual bool | extend_by_sphere (const BoundingSphere *sphere) |
Double-dispatch support: called by extend_other() when the type we're extending by is known to be a sphere. | |
virtual bool | extend_other (BoundingVolume *other) const |
Friends | |
class | BoundingSphere |
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
This box is always axis-aligned. If you need a more general bounding box, try BoundingHexahedron.
Definition at line 31 of file boundingBox.h.
BoundingBox::BoundingBox | ( | ) | [inline] |
Constructs an empty box object.
Definition at line 22 of file boundingBox.I.
Constructs a specific box object.
Definition at line 31 of file boundingBox.I.
References LVecBase3f::is_nan().
bool BoundingBox::around_boxes | ( | const BoundingVolume ** | first, |
const BoundingVolume ** | last | ||
) | [protected, virtual] |
Double-dispatch support: called by around_other() when the type of the first element in the list is known to be a nonempty box.
Reimplemented from BoundingVolume.
Definition at line 367 of file boundingBox.cxx.
bool BoundingBox::around_hexahedrons | ( | const BoundingVolume ** | first, |
const BoundingVolume ** | last | ||
) | [protected, virtual] |
Double-dispatch support: called by around_other() when the type of the first element in the list is known to be a nonempty hexahedron.
Reimplemented from BoundingVolume.
Definition at line 378 of file boundingBox.cxx.
bool BoundingBox::around_points | ( | const LPoint3f * | first, |
const LPoint3f * | last | ||
) | [protected, virtual] |
Puts the volume around the indicated list of points, identified by an STL-style begin/end list.
Reimplemented from GeometricBoundingVolume.
Definition at line 287 of file boundingBox.cxx.
References LVecBase3f::is_nan().
bool BoundingBox::around_spheres | ( | const BoundingVolume ** | first, |
const BoundingVolume ** | last | ||
) | [protected, virtual] |
Double-dispatch support: called by around_other() when the type of the first element in the list is known to be a nonempty sphere.
Reimplemented from BoundingVolume.
Definition at line 356 of file boundingBox.cxx.
const BoundingBox * BoundingBox::as_bounding_box | ( | ) | const [virtual] |
Virtual downcast method.
Returns this object as a pointer of the indicated type, if it is in fact that type. Returns NULL if it is not that type.
Reimplemented from BoundingVolume.
Definition at line 147 of file boundingBox.cxx.
int BoundingBox::contains_box | ( | const BoundingBox * | box | ) | const [protected, virtual] |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a box.
Reimplemented from BoundingVolume.
Definition at line 561 of file boundingBox.cxx.
References get_maxq(), get_minq(), BoundingVolume::is_empty(), and BoundingVolume::is_infinite().
int BoundingBox::contains_hexahedron | ( | const BoundingHexahedron * | hexahedron | ) | const [protected, virtual] |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a hexahedron.
Reimplemented from BoundingVolume.
Definition at line 594 of file boundingBox.cxx.
References BoundingHexahedron::contains_box().
int BoundingBox::contains_line | ( | const BoundingLine * | line | ) | const [protected, virtual] |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a line.
Reimplemented from BoundingVolume.
Definition at line 615 of file boundingBox.cxx.
References BoundingLine::contains_box().
int BoundingBox::contains_lineseg | ( | const LPoint3f & | a, |
const LPoint3f & | b | ||
) | const [protected, virtual] |
Tests whether the volume contains the indicated line segment.
Reimplemented from GeometricBoundingVolume.
Definition at line 456 of file boundingBox.cxx.
References contains_point(), BoundingVolume::is_empty(), BoundingVolume::is_infinite(), and LVecBase3f::is_nan().
int BoundingBox::contains_plane | ( | const BoundingPlane * | plane | ) | const [protected, virtual] |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a plane.
Reimplemented from BoundingVolume.
Definition at line 627 of file boundingBox.cxx.
References BoundingPlane::contains_box().
int BoundingBox::contains_point | ( | const LPoint3f & | point | ) | const [protected, virtual] |
Tests whether the volume contains the indicated point.
Reimplemented from GeometricBoundingVolume.
Definition at line 430 of file boundingBox.cxx.
References BoundingVolume::is_empty(), BoundingVolume::is_infinite(), and LVecBase3f::is_nan().
Referenced by contains_lineseg().
int BoundingBox::contains_sphere | ( | const BoundingSphere * | sphere | ) | const [protected, virtual] |
Double-dispatch support: called by contains_other() when the type we're testing for intersection is known to be a sphere.
Reimplemented from BoundingVolume.
Definition at line 549 of file boundingBox.cxx.
Referenced by BoundingSphere::contains_box().
bool BoundingBox::extend_by_box | ( | const BoundingBox * | box | ) | [protected, virtual] |
Double-dispatch support: called by extend_other() when the type we're extending by is known to be a box.
Reimplemented from BoundingVolume.
Definition at line 222 of file boundingBox.cxx.
References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().
bool BoundingBox::extend_by_hexahedron | ( | const BoundingHexahedron * | hexahedron | ) | [protected, virtual] |
Double-dispatch support: called by extend_other() when the type we're extending by is known to be a hexahedron.
Reimplemented from BoundingVolume.
Definition at line 248 of file boundingBox.cxx.
bool BoundingBox::extend_by_point | ( | const LPoint3f & | point | ) | [protected, virtual] |
Extends the volume to include the indicated point.
Returns true if possible, false if not.
Reimplemented from GeometricBoundingVolume.
Definition at line 190 of file boundingBox.cxx.
References BoundingVolume::is_empty(), BoundingVolume::is_infinite(), and LVecBase3f::is_nan().
bool BoundingBox::extend_by_sphere | ( | const BoundingSphere * | sphere | ) | [protected, virtual] |
Double-dispatch support: called by extend_other() when the type we're extending by is known to be a sphere.
Reimplemented from BoundingVolume.
Definition at line 212 of file boundingBox.cxx.
const LPoint3f & BoundingBox::get_maxq | ( | ) | const [inline] |
An inline accessor for the maximum value.
get_max() would also work, but it is a virtual non-inline method.
Definition at line 64 of file boundingBox.I.
References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().
Referenced by BoundingLine::contains_box(), BoundingHexahedron::contains_box(), contains_box(), BoundingPlane::contains_box(), and BoundingSphere::extend_by_box().
const LPoint3f & BoundingBox::get_minq | ( | ) | const [inline] |
An inline accessor for the minimum value.
get_min() would also work, but it is a virtual non-inline method.
Definition at line 50 of file boundingBox.I.
References BoundingVolume::is_empty(), and BoundingVolume::is_infinite().
Referenced by BoundingLine::contains_box(), BoundingHexahedron::contains_box(), contains_box(), BoundingPlane::contains_box(), and BoundingSphere::extend_by_box().
int BoundingBox::get_num_planes | ( | ) | const [inline] |
Returns 6: the number of faces of a rectangular solid.
Definition at line 101 of file boundingBox.I.
int BoundingBox::get_num_points | ( | ) | const [inline] |
Returns 8: the number of vertices of a rectangular solid.
Definition at line 76 of file boundingBox.I.
Planef BoundingBox::get_plane | ( | int | n | ) | const [inline] |
Returns the nth face of the rectangular solid.
Definition at line 111 of file boundingBox.I.
References get_point().
LPoint3f BoundingBox::get_point | ( | int | n | ) | const [inline] |
Returns the nth vertex of the rectangular solid.
Definition at line 86 of file boundingBox.I.
References LPoint3f::zero().
Referenced by BoundingPlane::contains_box(), BoundingHexahedron::contains_box(), BoundingSphere::extend_by_box(), and get_plane().
static void BoundingBox::init_type | ( | ) | [inline, static] |
This function is declared non-inline to work around a compiler bug in g++ 2.96.
Making it inline seems to cause problems in the optimizer.
Reimplemented from FiniteBoundingVolume.
Definition at line 109 of file boundingBox.h.
References FiniteBoundingVolume::init_type().