Panda3D
unionBoundingVolume.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file unionBoundingVolume.h
10  * @author drose
11  * @date 2012-02-08
12  */
13 
14 #ifndef UNIONBOUNDINGVOLUME_H
15 #define UNIONBOUNDINGVOLUME_H
16 
17 #include "pandabase.h"
18 
20 #include "pvector.h"
21 
22 /**
23  * This special bounding volume is the union of all of its constituent
24  * bounding volumes.
25  *
26  * A point is defined to be within a UnionBoundingVolume if it is within any
27  * one or more of its component bounding volumes.
28  */
29 class EXPCL_PANDA_MATHUTIL UnionBoundingVolume : public GeometricBoundingVolume {
30 PUBLISHED:
31  INLINE_MATHUTIL UnionBoundingVolume();
32  ALLOC_DELETED_CHAIN(UnionBoundingVolume);
33 
34 public:
36 
37  virtual BoundingVolume *make_copy() const;
38 
39  virtual LPoint3 get_approx_center() const;
40  virtual void xform(const LMatrix4 &mat);
41 
42  virtual void output(std::ostream &out) const;
43  virtual void write(std::ostream &out, int indent_level) const;
44 
45 PUBLISHED:
46  INLINE_MATHUTIL int get_num_components() const;
47  INLINE_MATHUTIL const GeometricBoundingVolume *get_component(int n) const;
48  MAKE_SEQ(get_components, get_num_components, get_component);
49  MAKE_SEQ_PROPERTY(components, get_num_components, get_component);
50 
51  void clear_components();
52  void add_component(const GeometricBoundingVolume *component);
53 
54  void filter_intersection(const BoundingVolume *volume);
55 
56 protected:
57  virtual bool extend_other(BoundingVolume *other) const;
58  virtual bool around_other(BoundingVolume *other,
59  const BoundingVolume **first,
60  const BoundingVolume **last) const;
61  virtual int contains_other(const BoundingVolume *other) const;
62 
63  virtual bool extend_by_geometric(const GeometricBoundingVolume *volume);
64  virtual bool around_geometric(const BoundingVolume **first,
65  const BoundingVolume **last);
66 
67  virtual int contains_point(const LPoint3 &point) const;
68  virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
69  virtual int contains_sphere(const BoundingSphere *sphere) const;
70  virtual int contains_box(const BoundingBox *box) const;
71  virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
72  virtual int contains_line(const BoundingLine *line) const;
73  virtual int contains_plane(const BoundingPlane *plane) const;
74  virtual int contains_union(const UnionBoundingVolume *unionv) const;
75  virtual int contains_intersection(const IntersectionBoundingVolume *intersection) const;
76  virtual int contains_finite(const FiniteBoundingVolume *volume) const;
77  virtual int contains_geometric(const GeometricBoundingVolume *volume) const;
78  int other_contains_union(const BoundingVolume *other) const;
79 
80 private:
82  Components _components;
83 
84 public:
85  static TypeHandle get_class_type() {
86  return _type_handle;
87  }
88  static void init_type() {
89  GeometricBoundingVolume::init_type();
90  register_type(_type_handle, "UnionBoundingVolume",
91  GeometricBoundingVolume::get_class_type());
92  }
93  virtual TypeHandle get_type() const {
94  return get_class_type();
95  }
96  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
97 
98 private:
99  static TypeHandle _type_handle;
100 
101  friend class BoundingVolume;
102 };
103 
104 #include "unionBoundingVolume.I"
105 
106 #endif
pvector
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
BoundingSphere
This defines a bounding sphere, consisting of a center and a radius.
Definition: boundingSphere.h:25
FiniteBoundingVolume
A special kind of GeometricBoundingVolume that is known to be finite.
Definition: finiteBoundingVolume.h:27
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
unionBoundingVolume.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BoundingBox
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
Definition: boundingBox.h:29
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
UnionBoundingVolume
This special bounding volume is the union of all of its constituent bounding volumes.
Definition: unionBoundingVolume.h:29
GeometricBoundingVolume
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
Definition: geometricBoundingVolume.h:29
BoundingLine
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
Definition: boundingLine.h:29
BoundingHexahedron
This defines a bounding convex hexahedron.
Definition: boundingHexahedron.h:32
BoundingVolume
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
Definition: boundingVolume.h:41
IntersectionBoundingVolume
This special bounding volume is the intersection of all of its constituent bounding volumes.
Definition: intersectionBoundingVolume.h:29
BoundingPlane
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
Definition: boundingPlane.h:28
geometricBoundingVolume.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.