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 GeometricBoundingVolumeas_geometric_bounding_volume ()
 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 (std::ostream &out) const =0
 
void set_infinite ()
 Marks the volume as infinite, even if it is normally finite. More...
 
virtual void write (std::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)=default
 
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...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
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 ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. 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...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 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 std::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
 

Additional Inherited Members

- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 

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

References is_empty().

Referenced by GeometricBoundingVolume::around().

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

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

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

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

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

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

◆ as_geometric_bounding_volume() [1/2]

GeometricBoundingVolume * BoundingVolume::as_geometric_bounding_volume ( )
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 90 of file boundingVolume.cxx.

◆ as_geometric_bounding_volume() [2/2]

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

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

References is_empty(), and is_infinite().

Referenced by GeometricBoundingVolume::contains().

◆ extend_by()

bool BoundingVolume::extend_by ( const BoundingVolume vol)
inline

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

Definition at line 61 of file boundingVolume.I.

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

Referenced by GeometricBoundingVolume::extend_by().

◆ is_empty()

bool BoundingVolume::is_empty ( ) const
inline

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

Referenced by UnionBoundingVolume::add_component(), around(), GeometricBoundingVolume::contains(), contains(), extend_by(), and PT().

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

Referenced by UnionBoundingVolume::add_component(), contains(), extend_by(), and PT().

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

Referenced by extend_by().

◆ string_bounds_type()

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

Returns the BoundsType corresponding to the indicated string.

Definition at line 161 of file boundingVolume.cxx.


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