Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
BoundingVolume Class Referenceabstract

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 MemoryBase MemoryBase GeometricBoundingVolume BoundingLine BoundingPlane FiniteBoundingVolume IntersectionBoundingVolume OmniBoundingVolume UnionBoundingVolume BoundingBox BoundingHexahedron BoundingSphere

Public Types

enum  BoundsType {
  BT_default, BT_best, BT_sphere, BT_box,
  BT_fastest
}
 
enum  IntersectionFlags {
  IF_no_intersection = 0, IF_possible = 0x01, IF_some = 0x02, IF_all = 0x04,
  IF_dont_understand = 0x08
}
 

Public Member Functions

bool around (const BoundingVolume **first, const BoundingVolume **last)
 Resets the volume to enclose only the volumes indicated. More...
 
virtual const BoundingBoxas_bounding_box () const
 Virtual downcast method. More...
 
virtual const BoundingHexahedronas_bounding_hexahedron () const
 Virtual downcast method. More...
 
virtual const BoundingLineas_bounding_line () const
 Virtual downcast method. More...
 
virtual const BoundingPlaneas_bounding_plane () const
 Virtual downcast method. More...
 
virtual const BoundingSphereas_bounding_sphere () const
 Virtual downcast method. More...
 
virtual const FiniteBoundingVolumeas_finite_bounding_volume () const
 Virtual downcast method. More...
 
virtual const GeometricBoundingVolumeas_geometric_bounding_volume () const
 Virtual downcast method. More...
 
int contains (const BoundingVolume *vol) const
 Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indicated volume. More...
 
bool extend_by (const BoundingVolume *vol)
 Increases the size of the volume to include the given volume. More...
 
virtual TypeHandle force_init_type ()
 
virtual TypeHandle get_type () const
 
bool is_empty () const
 Any kind of volume might be empty. More...
 
bool is_infinite () const
 The other side of the empty coin is an infinite volume. More...
 
virtual BoundingVolumemake_copy () const =0
 
virtual void output (ostream &out) const =0
 
void set_infinite ()
 Marks the volume as infinite, even if it is normally finite. More...
 
virtual void write (ostream &out, int indent_level=0) const
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
void operator= (const TypedObject &copy)
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 Returns the current reference count. More...
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
void weak_ref (WeakPointerToVoid *ptv)
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref (WeakPointerToVoid *ptv)
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
static BoundsType string_bounds_type (const string &str)
 Returns the BoundsType corresponding to the indicated string. More...
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
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. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 

Friends

class BoundingBox
 
class BoundingHexahedron
 
class BoundingLine
 
class BoundingPlane
 
class BoundingSphere
 
class IntersectionBoundingVolume
 
class UnionBoundingVolume
 

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 45 of file boundingVolume.h.

Member Function Documentation

◆ around()

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 39 of file boundingVolume.cxx.

References as_geometric_bounding_volume(), and is_empty().

Referenced by GeometricBoundingVolume::around(), and PandaNode::r_prepare_scene().

◆ as_bounding_box()

const BoundingBox * BoundingVolume::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 in BoundingBox.

Definition at line 131 of file boundingVolume.cxx.

References as_bounding_hexahedron().

Referenced by as_bounding_sphere(), and PandaNode::r_prepare_scene().

◆ as_bounding_hexahedron()

const BoundingHexahedron * BoundingVolume::as_bounding_hexahedron ( ) 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 in BoundingHexahedron.

Definition at line 143 of file boundingVolume.cxx.

References as_bounding_line().

Referenced by as_bounding_box().

◆ as_bounding_line()

const BoundingLine * BoundingVolume::as_bounding_line ( ) 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 in BoundingLine.

Definition at line 155 of file boundingVolume.cxx.

References as_bounding_plane().

Referenced by as_bounding_hexahedron().

◆ as_bounding_plane()

const BoundingPlane * BoundingVolume::as_bounding_plane ( ) 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 in BoundingPlane.

Definition at line 167 of file boundingVolume.cxx.

References string_bounds_type().

Referenced by as_bounding_line().

◆ as_bounding_sphere()

const BoundingSphere * BoundingVolume::as_bounding_sphere ( ) 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 in BoundingSphere.

Definition at line 119 of file boundingVolume.cxx.

References as_bounding_box().

Referenced by as_finite_bounding_volume().

◆ as_finite_bounding_volume()

const FiniteBoundingVolume * BoundingVolume::as_finite_bounding_volume ( ) 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 in FiniteBoundingVolume.

Definition at line 107 of file boundingVolume.cxx.

References as_bounding_sphere().

Referenced by as_geometric_bounding_volume().

◆ as_geometric_bounding_volume()

const GeometricBoundingVolume * BoundingVolume::as_geometric_bounding_volume ( ) 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 in GeometricBoundingVolume.

Definition at line 95 of file boundingVolume.cxx.

References as_finite_bounding_volume().

Referenced by around().

◆ contains()

int BoundingVolume::contains ( const BoundingVolume vol) const
inline

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

Definition at line 101 of file boundingVolume.I.

References is_empty(), and is_infinite().

Referenced by IntersectionBoundingVolume::add_component(), GeometricBoundingVolume::contains(), extend_by(), and UnionBoundingVolume::filter_intersection().

◆ extend_by()

bool BoundingVolume::extend_by ( const BoundingVolume vol)
inline

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

Definition at line 79 of file boundingVolume.I.

References contains(), is_empty(), is_infinite(), and set_infinite().

Referenced by GeometricBoundingVolume::extend_by(), and set_infinite().

◆ is_empty()

bool BoundingVolume::is_empty ( ) const
inline

◆ is_infinite()

bool BoundingVolume::is_infinite ( ) const
inline

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 56 of file boundingVolume.I.

References set_infinite().

Referenced by UnionBoundingVolume::add_component(), IntersectionBoundingVolume::add_component(), BoundingBox::as_bounding_box(), BoundingHexahedron::as_bounding_hexahedron(), BoundingLine::as_bounding_line(), BoundingPlane::as_bounding_plane(), BoundingSphere::as_bounding_sphere(), BoundingPlane::BoundingPlane(), BoundingSphere::BoundingSphere(), SceneGraphReducer::check_live_flatten(), contains(), CullTraverser::draw_bounding_volume(), extend_by(), BoundingBox::get_maxq(), BoundingBox::get_minq(), BoundingLine::get_point_a(), BoundingLine::get_point_b(), PipeOcclusionCullTraverser::get_texture(), is_empty(), and LODNode::verify_child_bounds().

◆ set_infinite()

void BoundingVolume::set_infinite ( )
inline

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 68 of file boundingVolume.I.

References extend_by().

Referenced by BoundingSphere::as_bounding_sphere(), extend_by(), and is_infinite().

◆ string_bounds_type()

BoundingVolume::BoundsType BoundingVolume::string_bounds_type ( const string &  str)
static

Returns the BoundsType corresponding to the indicated string.

Definition at line 178 of file boundingVolume.cxx.

Referenced by as_bounding_plane().


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