Panda3D
 All Classes Functions Variables Enumerations
geometricBoundingVolume.h
1 // Filename: geometricBoundingVolume.h
2 // Created by: drose (07Oct99)
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 GEOMETRICBOUNDINGVOLUME_H
16 #define GEOMETRICBOUNDINGVOLUME_H
17 
18 #include "pandabase.h"
19 
20 #include "boundingVolume.h"
21 
22 #include "luse.h"
23 #include "lmatrix.h"
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : GeometricBoundingVolume
27 // Description : This is another abstract class, for a general class
28 // of bounding volumes that actually enclose points in
29 // 3-d space, such as BSP's and bounding spheres.
30 ////////////////////////////////////////////////////////////////////
31 class EXPCL_PANDA_MATHUTIL GeometricBoundingVolume : public BoundingVolume {
32 public:
33  INLINE_MATHUTIL GeometricBoundingVolume();
34 
35 PUBLISHED:
36  INLINE_MATHUTIL bool extend_by(const GeometricBoundingVolume *vol);
37  INLINE_MATHUTIL bool extend_by(const LPoint3 &point);
38 
39 public:
40  // It might be nice to make these template member functions so we
41  // could have true STL-style first/last iterators, but that's
42  // impossible for virtual functions.
43  INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first,
44  const GeometricBoundingVolume **last);
45  INLINE_MATHUTIL bool around(const LPoint3 *first, const LPoint3 *last);
46 
47 PUBLISHED:
48  INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const;
49  INLINE_MATHUTIL int contains(const LPoint3 &point) const;
50  INLINE_MATHUTIL int contains(const LPoint3 &a, const LPoint3 &b) const;
51 
52  virtual LPoint3 get_approx_center() const=0;
53  virtual void xform(const LMatrix4 &mat)=0;
54 
55 public:
56  virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const;
57 
58 protected:
59  // Some virtual functions to implement fundamental bounding
60  // operations on points in 3-d space.
61 
62  virtual bool extend_by_point(const LPoint3 &point);
63  virtual bool around_points(const LPoint3 *first,
64  const LPoint3 *last);
65  virtual int contains_point(const LPoint3 &point) const;
66  virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
67 
68 
69 public:
70  static TypeHandle get_class_type() {
71  return _type_handle;
72  }
73  static void init_type() {
74  BoundingVolume::init_type();
75  register_type(_type_handle, "GeometricBoundingVolume",
76  BoundingVolume::get_class_type());
77  }
78  virtual TypeHandle get_type() const {
79  return get_class_type();
80  }
81  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
82 
83 private:
84  static TypeHandle _type_handle;
85 };
86 
87 #include "geometricBoundingVolume.I"
88 
89 #endif
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
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 is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
virtual const GeometricBoundingVolume * as_geometric_bounding_volume() const
Virtual downcast method.
bool around(const BoundingVolume **first, const BoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
bool extend_by(const BoundingVolume *vol)
Increases the size of the volume to include the given volume.
int contains(const BoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...