14#ifndef BOUNDINGVOLUME_H
15#define BOUNDINGVOLUME_H
41class EXPCL_PANDA_MATHUTIL BoundingVolume :
public TypedReferenceCount {
43 INLINE_MATHUTIL BoundingVolume();
46 virtual BoundingVolume *make_copy()
const=0;
48 INLINE_MATHUTIL
bool is_empty()
const;
53 INLINE_MATHUTIL
bool extend_by(
const BoundingVolume *vol);
59 bool around(
const BoundingVolume **first,
60 const BoundingVolume **last);
64 enum IntersectionFlags {
66 IF_no_intersection = 0,
90 IF_dont_understand = 0x08
93 INLINE_MATHUTIL
int contains(
const BoundingVolume *vol)
const;
95 virtual void output(std::ostream &out)
const=0;
96 virtual void write(std::ostream &out,
int indent_level = 0)
const;
132 virtual bool extend_other(BoundingVolume *other)
const=0;
133 virtual bool around_other(BoundingVolume *other,
134 const BoundingVolume **first,
135 const BoundingVolume **last)
const=0;
136 virtual int contains_other(
const BoundingVolume *other)
const=0;
140 virtual bool extend_by_sphere(
const BoundingSphere *sphere);
141 virtual bool extend_by_box(
const BoundingBox *box);
142 virtual bool extend_by_hexahedron(
const BoundingHexahedron *hexahedron);
143 virtual bool extend_by_line(
const BoundingLine *line);
144 virtual bool extend_by_plane(
const BoundingPlane *plane);
145 virtual bool extend_by_union(
const UnionBoundingVolume *unionv);
146 virtual bool extend_by_intersection(
const IntersectionBoundingVolume *intersection);
150 virtual bool around_spheres(
const BoundingVolume **first,
151 const BoundingVolume **last);
152 virtual bool around_boxes(
const BoundingVolume **first,
153 const BoundingVolume **last);
154 virtual bool around_hexahedrons(
const BoundingVolume **first,
155 const BoundingVolume **last);
156 virtual bool around_lines(
const BoundingVolume **first,
157 const BoundingVolume **last);
158 virtual bool around_planes(
const BoundingVolume **first,
159 const BoundingVolume **last);
160 virtual bool around_unions(
const BoundingVolume **first,
161 const BoundingVolume **last);
162 virtual bool around_intersections(
const BoundingVolume **first,
163 const BoundingVolume **last);
164 virtual bool around_finite(
const BoundingVolume **first,
165 const BoundingVolume **last);
166 virtual bool around_geometric(
const BoundingVolume **first,
167 const BoundingVolume **last);
169 virtual int contains_sphere(
const BoundingSphere *sphere)
const;
170 virtual int contains_box(
const BoundingBox *box)
const;
171 virtual int contains_hexahedron(
const BoundingHexahedron *hexahedron)
const;
172 virtual int contains_line(
const BoundingLine *line)
const;
173 virtual int contains_plane(
const BoundingPlane *plane)
const;
174 virtual int contains_union(
const UnionBoundingVolume *unionv)
const;
175 virtual int contains_intersection(
const IntersectionBoundingVolume *intersection)
const;
184 static void init_type() {
185 TypedReferenceCount::init_type();
187 TypedReferenceCount::get_class_type());
190 return get_class_type();
192 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
197 friend class BoundingSphere;
198 friend class BoundingBox;
199 friend class BoundingHexahedron;
200 friend class BoundingLine;
201 friend class BoundingPlane;
202 friend class UnionBoundingVolume;
203 friend class IntersectionBoundingVolume;
206INLINE_MATHUTIL std::ostream &operator << (std::ostream &out,
const BoundingVolume &bound);
210EXPCL_PANDA_MATHUTIL std::ostream &operator << (std::ostream &out, BoundingVolume::BoundsType type);
211EXPCL_PANDA_MATHUTIL std::istream &operator >> (std::istream &in, BoundingVolume::BoundsType &type);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
This defines a bounding convex hexahedron.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
This defines a bounding sphere, consisting of a center and a radius.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
virtual const BoundingPlane * as_bounding_plane() const
Virtual downcast method.
static BoundsType string_bounds_type(const std::string &str)
Returns the BoundsType corresponding to the indicated string.
bool extend_by(const BoundingVolume *vol)
Increases the size of the volume to include the given volume.
void set_infinite()
Marks the volume as infinite, even if it is normally finite.
bool is_empty() const
Any kind of volume might be empty.
virtual const BoundingSphere * as_bounding_sphere() const
Virtual downcast method.
virtual const BoundingBox * as_bounding_box() const
Virtual downcast method.
virtual GeometricBoundingVolume * as_geometric_bounding_volume()
Virtual downcast method.
int contains(const BoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...
virtual const FiniteBoundingVolume * as_finite_bounding_volume() const
Virtual downcast method.
bool is_infinite() const
The other side of the empty coin is an infinite volume.
virtual const BoundingHexahedron * as_bounding_hexahedron() const
Virtual downcast method.
virtual const BoundingLine * as_bounding_line() const
Virtual downcast method.
bool around(const BoundingVolume **first, const BoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
A special kind of GeometricBoundingVolume that is known to be finite.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
This special bounding volume is the intersection of all of its constituent bounding volumes.
TypeHandle is the identifier used to differentiate C++ class types.
This special bounding volume is the union of all of its constituent bounding volumes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.