Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

BoundingVolume Class Reference

This is an abstract class for any volume in any sense which can be said to define the locality of reference of a node in a graph, along with all of its descendants. More...

#include <boundingVolume.h>

Inheritance diagram for BoundingVolume:

TypedReferenceCount TypedObject ReferenceCount GeometricBoundingVolume BoundingLine FiniteBoundingVolume OmniBoundingVolume BoundingHexahedron BoundingSphere List of all members.

Public Types

enum  IntersectionFlags {
  IF_no_intersection = 0, IF_possible = 0x01, IF_some = 0x02, IF_all = 0x04,
  IF_dont_understand = 0x08
}

Public Member Functions

INLINE_MATHUTIL BoundingVolume ()
virtual BoundingVolume * make_copy () const=0
INLINE_MATHUTIL bool is_empty () const
 Any kind of volume might be empty.

INLINE_MATHUTIL bool is_infinite () const
 The other side of the empty coin is an infinite volume.

INLINE_MATHUTIL void set_infinite ()
 Marks the volume as infinite, even if it is normally finite.

INLINE_MATHUTIL bool extend_by (const BoundingVolume *vol)
 Increases the size of the volume to include the given volume.

bool around (const BoundingVolume **first, const BoundingVolume **last)
 Resets the volume to enclose only the volumes indicated.

INLINE_MATHUTIL int contains (const BoundingVolume *vol) const
 Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indicated volume.

virtual void output (ostream &out) const=0
virtual void write (ostream &out, int indent_level=0) const
virtual TypeHandle get_type () const
virtual TypeHandle force_init_type ()
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type.

bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly.

int get_ref_count () const
 Returns the current reference count.

int ref () const
 Explicitly increments the reference count.

int unref () const
 Explicitly decrements the reference count.

void test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus.


Static Public Member Functions

TypeHandle get_class_type ()
void init_type ()

Protected Types

enum  Flags { F_empty = 0x01, F_infinite = 0x02 }

Protected Member Functions

virtual bool extend_other (BoundingVolume *other) const=0
virtual bool around_other (BoundingVolume *other, const BoundingVolume **first, const BoundingVolume **last) const=0
virtual int contains_other (const BoundingVolume *other) const=0
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_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_line (const BoundingLine *line)
 Double-dispatch support: called by extend_other() when the type we're extending by is known to be a line.

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 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_lines (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 line.

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


Protected Attributes

int _flags

Static Private Attributes

TypeHandle _type_handle

Friends

class BoundingSphere
class BoundingHexahedron
class BoundingLine

Detailed Description

This is an abstract class for any volume in any sense which can be said to define the locality of reference of a node in a graph, along with all of its descendants.

It is not necessarily a geometric volume (although see GeometricBoundingVolume); this is simply an abstract interface for bounds of any sort.

Definition at line 54 of file boundingVolume.h.


Member Enumeration Documentation

enum BoundingVolume::Flags [protected]
 

Enumeration values:
F_empty 
F_infinite 

Definition at line 110 of file boundingVolume.h.

enum BoundingVolume::IntersectionFlags
 

Enumeration values:
IF_no_intersection 
IF_possible 
IF_some 
IF_all 
IF_dont_understand 

Definition at line 74 of file boundingVolume.h.


Constructor & Destructor Documentation

INLINE_MATHUTIL BoundingVolume::BoundingVolume  ) 
 

Definition at line 30 of file boundingVolume.I.

References _flags, F_empty, and INLINE_MATHUTIL.


Member Function Documentation

bool BoundingVolume::around const BoundingVolume **  first,
const BoundingVolume **  last
 

Resets the volume to enclose only the volumes indicated.

Returns true if successful, false if the volume doesn't know how to do that or can't do that.

Definition at line 43 of file boundingVolume.cxx.

References _flags, and F_infinite.

Referenced by GeomNode::add_geoms_from().

bool BoundingVolume::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 in BoundingHexahedron, BoundingSphere, and OmniBoundingVolume.

Definition at line 178 of file boundingVolume.cxx.

References IF_dont_understand.

bool BoundingVolume::around_lines 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 line.

Definition at line 196 of file boundingVolume.cxx.

References IF_dont_understand.

virtual bool BoundingVolume::around_other BoundingVolume *  other,
const BoundingVolume **  first,
const BoundingVolume **  last
const [protected, pure virtual]
 

Implemented in BoundingHexahedron, BoundingLine, BoundingSphere, and OmniBoundingVolume.

bool BoundingVolume::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 in BoundingHexahedron, BoundingSphere, and OmniBoundingVolume.

Definition at line 160 of file boundingVolume.cxx.

INLINE_MATHUTIL int BoundingVolume::contains const BoundingVolume *  vol  )  const
 

Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indicated volume.

Definition at line 145 of file boundingVolume.I.

int BoundingVolume::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 in BoundingHexahedron, BoundingSphere, and OmniBoundingVolume.

Definition at line 240 of file boundingVolume.cxx.

int BoundingVolume::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 in BoundingSphere.

Definition at line 257 of file boundingVolume.cxx.

virtual int BoundingVolume::contains_other const BoundingVolume *  other  )  const [protected, pure virtual]
 

Implemented in BoundingHexahedron, BoundingLine, BoundingSphere, and OmniBoundingVolume.

int BoundingVolume::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 in BoundingHexahedron, BoundingLine, BoundingSphere, and OmniBoundingVolume.

Definition at line 223 of file boundingVolume.cxx.

INLINE_MATHUTIL bool BoundingVolume::extend_by const BoundingVolume *  vol  ) 
 

Increases the size of the volume to include the given volume.

Definition at line 118 of file boundingVolume.I.

Referenced by GeometricBoundingVolume::GeometricBoundingVolume(), and CollisionSphere::get_collision_origin().

bool BoundingVolume::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 in BoundingHexahedron, BoundingSphere, and OmniBoundingVolume.

Definition at line 124 of file boundingVolume.cxx.

References _flags, and F_infinite.

bool BoundingVolume::extend_by_line const BoundingLine line  )  [protected, virtual]
 

Double-dispatch support: called by extend_other() when the type we're extending by is known to be a line.

Reimplemented in BoundingLine.

Definition at line 142 of file boundingVolume.cxx.

References _flags, and F_infinite.

bool BoundingVolume::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 in BoundingHexahedron, BoundingSphere, and OmniBoundingVolume.

Definition at line 106 of file boundingVolume.cxx.

virtual bool BoundingVolume::extend_other BoundingVolume *  other  )  const [protected, pure virtual]
 

Implemented in BoundingHexahedron, BoundingLine, BoundingSphere, and OmniBoundingVolume.

virtual TypeHandle BoundingVolume::force_init_type void   )  [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Reimplemented in BoundingHexahedron, BoundingLine, BoundingSphere, FiniteBoundingVolume, GeometricBoundingVolume, and OmniBoundingVolume.

Definition at line 158 of file boundingVolume.h.

TypeHandle BoundingVolume::get_class_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Reimplemented in BoundingHexahedron, BoundingLine, BoundingSphere, FiniteBoundingVolume, GeometricBoundingVolume, and OmniBoundingVolume.

Definition at line 147 of file boundingVolume.h.

Referenced by GeometricBoundingVolume::get_class_type(), and GeometricBoundingVolume::init_type().

int ReferenceCount::get_ref_count  )  const [inline, inherited]
 

Returns the current reference count.

Definition at line 183 of file referenceCount.I.

Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture().

virtual TypeHandle BoundingVolume::get_type void   )  const [inline, virtual]
 

Reimplemented from TypedReferenceCount.

Reimplemented in BoundingHexahedron, BoundingLine, BoundingSphere, FiniteBoundingVolume, GeometricBoundingVolume, and OmniBoundingVolume.

Definition at line 155 of file boundingVolume.h.

References INLINE_MATHUTIL.

int TypedObject::get_type_index  )  const [inline, inherited]
 

Returns the internal index number associated with this object's TypeHandle, a unique number for each different type.

This is equivalent to get_type().get_index().

Definition at line 71 of file typedObject.I.

References TypeHandle::get_name(), TypedObject::get_type(), and INLINE.

void BoundingVolume::init_type void   )  [inline, static]
 

Reimplemented from TypedReferenceCount.

Reimplemented in BoundingHexahedron, BoundingLine, BoundingSphere, FiniteBoundingVolume, GeometricBoundingVolume, and OmniBoundingVolume.

Definition at line 150 of file boundingVolume.h.

Referenced by GeometricBoundingVolume::init_type().

INLINE_MATHUTIL bool BoundingVolume::is_empty  )  const
 

Any kind of volume might be empty.

This is a degenerate volume that contains no points; it's not the same as, for instance, a sphere with radius zero, since that contains one point (the center). It intersects with no other volumes.

Definition at line 51 of file boundingVolume.I.

References _flags, F_infinite, and INLINE_MATHUTIL.

Referenced by GeometricBoundingVolume::around(), GeometricBoundingVolume::contains(), BoundingLine::contains_other(), BoundingSphere::extend_by_hexahedron(), BoundingSphere::make_copy(), BoundingLine::make_copy(), BoundingHexahedron::make_copy(), and set_infinite().

bool TypedObject::is_exact_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is the indicated type exactly.

Definition at line 101 of file typedObject.I.

Referenced by PT(), and CollisionNode::xform().

INLINE_MATHUTIL bool BoundingVolume::is_infinite  )  const
 

The other side of the empty coin is an infinite volume.

This is a degenerate state of a normally finite volume that contains all points. (Note that some kinds of infinite bounding volumes, like binary separating planes, do not contain all points and thus correctly return is_infinite() == false, even though they are technically infinite. This is a special case of the word 'infinite' meaning the volume covers all points in space.)

It completely intersects with all other volumes except empty volumes.

Definition at line 86 of file boundingVolume.I.

Referenced by BoundingLine::contains_other(), BoundingSphere::make_copy(), BoundingLine::make_copy(), BoundingHexahedron::make_copy(), and set_infinite().

bool TypedObject::is_of_type TypeHandle  handle  )  const [inline, inherited]
 

Returns true if the current object is or derives from the indicated type.

Definition at line 86 of file typedObject.I.

Referenced by EggMaterialCollection::collapse_equivalent_materials(), EggTextureCollection::collapse_equivalent_textures(), DeferredNodeProperty::compose(), AnimBundleMaker::create_s_channel(), CharacterMaker::create_slider(), ProjectionScreen::cull_callback(), DataNode::define_output(), EggNode::determine_draw_order(), CharacterMaker::egg_to_index(), EggGroupUniquifier::EggGroupUniquifier(), EggPoolUniquifier::EggPoolUniquifier(), EggGroupNode::find_textures(), StaticTextFont::get_glyph(), EggMaterialCollection::insert_materials(), EggTextureCollection::insert_textures(), CharacterJoint::make_copy(), PT(), EggGroupNode::r_flatten_transforms(), EggGroupNode::r_transform_vertices(), EggGroupNode::recompute_polygon_normals(), CollisionLevelState::reserve(), PandaFramework::reset_frame_rate(), PandaFramework::set_texture(), EggGroupNode::steal_children(), and DataGraphTraverser::traverse().

virtual BoundingVolume* BoundingVolume::make_copy  )  const [pure virtual]
 

Implemented in BoundingHexahedron, BoundingLine, BoundingSphere, and OmniBoundingVolume.

Referenced by CollisionLevelState::reserve().

virtual void BoundingVolume::output ostream &  out  )  const [pure virtual]
 

Implemented in BoundingHexahedron, BoundingLine, BoundingSphere, and OmniBoundingVolume.

int ReferenceCount::ref  )  const [inline, inherited]
 

Explicitly increments the reference count.

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 225 of file referenceCount.I.

Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering().

INLINE_MATHUTIL void BoundingVolume::set_infinite  ) 
 

Marks the volume as infinite, even if it is normally finite.

You can think of this as an infinite extend_by() operation.

Definition at line 103 of file boundingVolume.I.

References IF_all, IF_no_intersection, IF_possible, IF_some, INLINE_MATHUTIL, is_empty(), and is_infinite().

Referenced by OmniBoundingVolume::extend_other().

void ReferenceCount::test_ref_count_integrity  )  const [inline, inherited]
 

Does some easy checks to make sure that the reference count isn't completely bogus.

Definition at line 328 of file referenceCount.I.

References INLINE.

Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount().

int ReferenceCount::unref  )  const [inline, inherited]
 

Explicitly decrements the reference count.

Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete().

User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.

This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.

The return value is the new reference count.

Definition at line 293 of file referenceCount.I.

References INLINE.

Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds().

void BoundingVolume::write ostream &  out,
int  indent_level = 0
const [virtual]
 

Reimplemented in BoundingHexahedron.

Definition at line 89 of file boundingVolume.cxx.

References _flags, and F_infinite.


Friends And Related Function Documentation

friend class BoundingHexahedron [friend]
 

Reimplemented in BoundingSphere, and OmniBoundingVolume.

Definition at line 164 of file boundingVolume.h.

friend class BoundingLine [friend]
 

Definition at line 165 of file boundingVolume.h.

friend class BoundingSphere [friend]
 

Reimplemented in BoundingHexahedron, and BoundingLine.

Definition at line 163 of file boundingVolume.h.


Member Data Documentation

int BoundingVolume::_flags [protected]
 

Definition at line 114 of file boundingVolume.h.

Referenced by around(), BoundingHexahedron::BoundingHexahedron(), BoundingLine::BoundingLine(), BoundingSphere::BoundingSphere(), BoundingVolume(), BoundingSphere::extend_by_finite(), extend_by_hexahedron(), extend_by_line(), BoundingLine::extend_by_line(), GeometricBoundingVolume::extend_by_point(), BoundingSphere::extend_by_point(), BoundingSphere::extend_by_sphere(), is_empty(), write(), and BoundingLine::xform().

TypeHandle BoundingVolume::_type_handle [static, private]
 

Reimplemented from TypedReferenceCount.

Reimplemented in BoundingHexahedron, BoundingLine, BoundingSphere, FiniteBoundingVolume, GeometricBoundingVolume, and OmniBoundingVolume.

Definition at line 27 of file boundingVolume.cxx.


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:47:48 2003 for Panda by doxygen1.3