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