Panda3D
 All Classes Functions Variables Enumerations
boundingSphere.h
1 // Filename: boundingSphere.h
2 // Created by: drose (01Oct99)
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 BOUNDINGSPHERE_H
16 #define BOUNDINGSPHERE_H
17 
18 #include "pandabase.h"
19 
20 #include "finiteBoundingVolume.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : BoundingSphere
24 // Description : This defines a bounding sphere, consisting of a
25 // center and a radius. It is always a sphere, and
26 // never an ellipsoid or other quadric.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDA_MATHUTIL BoundingSphere : public FiniteBoundingVolume {
29 PUBLISHED:
30  INLINE_MATHUTIL BoundingSphere();
31  INLINE_MATHUTIL BoundingSphere(const LPoint3 &center, PN_stdfloat radius);
32  ALLOC_DELETED_CHAIN(BoundingSphere);
33 
34 public:
35  virtual BoundingVolume *make_copy() const;
36 
37  virtual LPoint3 get_min() const;
38  virtual LPoint3 get_max() const;
39  virtual PN_stdfloat get_volume() const;
40 
41  virtual LPoint3 get_approx_center() const;
42  virtual void xform(const LMatrix4 &mat);
43 
44  virtual void output(ostream &out) const;
45 
46 PUBLISHED:
47  INLINE_MATHUTIL LPoint3 get_center() const;
48  INLINE_MATHUTIL PN_stdfloat get_radius() const;
49 
50 public:
51  virtual const BoundingSphere *as_bounding_sphere() const;
52 
53 protected:
54  virtual bool extend_other(BoundingVolume *other) const;
55  virtual bool around_other(BoundingVolume *other,
56  const BoundingVolume **first,
57  const BoundingVolume **last) const;
58  virtual int contains_other(const BoundingVolume *other) const;
59 
60 
61  virtual bool extend_by_point(const LPoint3 &point);
62  virtual bool extend_by_sphere(const BoundingSphere *sphere);
63  virtual bool extend_by_box(const BoundingBox *box);
64  virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
65  virtual bool extend_by_finite(const FiniteBoundingVolume *volume);
66 
67  virtual bool around_points(const LPoint3 *first,
68  const LPoint3 *last);
69  virtual bool around_finite(const BoundingVolume **first,
70  const BoundingVolume **last);
71 
72  virtual int contains_point(const LPoint3 &point) const;
73  virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
74  virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
75  virtual int contains_sphere(const BoundingSphere *sphere) const;
76  virtual int contains_box(const BoundingBox *box) const;
77  virtual int contains_line(const BoundingLine *line) const;
78  virtual int contains_plane(const BoundingPlane *plane) const;
79 
80 private:
81  LPoint3 _center;
82  PN_stdfloat _radius;
83 
84 
85 public:
86  static TypeHandle get_class_type() {
87  return _type_handle;
88  }
89  static void init_type() {
90  FiniteBoundingVolume::init_type();
91  register_type(_type_handle, "BoundingSphere",
92  FiniteBoundingVolume::get_class_type());
93  }
94  virtual TypeHandle get_type() const {
95  return get_class_type();
96  }
97  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
98 
99 private:
100  static TypeHandle _type_handle;
101 
102  friend class BoundingHexahedron;
103 };
104 
105 #include "boundingSphere.I"
106 
107 #endif
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
Definition: boundingBox.h:31
virtual const BoundingSphere * as_bounding_sphere() const
Virtual downcast method.
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 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