Panda3D
geometricBoundingVolume.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 geometricBoundingVolume.h
10  * @author drose
11  * @date 1999-10-07
12  */
13 
14 #ifndef GEOMETRICBOUNDINGVOLUME_H
15 #define GEOMETRICBOUNDINGVOLUME_H
16 
17 #include "pandabase.h"
18 
19 #include "boundingVolume.h"
20 
21 #include "luse.h"
22 #include "lmatrix.h"
23 
24 /**
25  * This is another abstract class, for a general class of bounding volumes
26  * that actually enclose points in 3-d space, such as BSP's and bounding
27  * spheres.
28  */
29 class EXPCL_PANDA_MATHUTIL GeometricBoundingVolume : public BoundingVolume {
30 public:
31  INLINE_MATHUTIL GeometricBoundingVolume();
32 
33 PUBLISHED:
34  INLINE_MATHUTIL bool extend_by(const GeometricBoundingVolume *vol);
35  INLINE_MATHUTIL bool extend_by(const LPoint3 &point);
36 
37 public:
38  // It might be nice to make these template member functions so we could have
39  // true STL-style firstlast iterators, but that's impossible for virtual
40  // functions.
41  INLINE_MATHUTIL bool around(const GeometricBoundingVolume **first,
42  const GeometricBoundingVolume **last);
43  INLINE_MATHUTIL bool around(const LPoint3 *first, const LPoint3 *last);
44 
45 PUBLISHED:
46  INLINE_MATHUTIL int contains(const GeometricBoundingVolume *vol) const;
47  INLINE_MATHUTIL int contains(const LPoint3 &point) const;
48  INLINE_MATHUTIL int contains(const LPoint3 &a, const LPoint3 &b) const;
49 
50  virtual LPoint3 get_approx_center() const=0;
51  virtual void xform(const LMatrix4 &mat)=0;
52 
53 public:
55  virtual const GeometricBoundingVolume *as_geometric_bounding_volume() const final;
56 
57 protected:
58  // Some virtual functions to implement fundamental bounding operations on
59  // points in 3-d space.
60 
61  virtual bool extend_by_point(const LPoint3 &point);
62  virtual bool around_points(const LPoint3 *first,
63  const LPoint3 *last);
64  virtual int contains_point(const LPoint3 &point) const;
65  virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
66 
67 
68 public:
69  static TypeHandle get_class_type() {
70  return _type_handle;
71  }
72  static void init_type() {
73  BoundingVolume::init_type();
74  register_type(_type_handle, "GeometricBoundingVolume",
75  BoundingVolume::get_class_type());
76  }
77  virtual TypeHandle get_type() const {
78  return get_class_type();
79  }
80  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
81 
82 private:
83  static TypeHandle _type_handle;
84 };
85 
86 // We can safely redefine this as a no-op.
87 template<>
89 
91 
92 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int contains(const BoundingVolume *vol) const
Returns the appropriate set of IntersectionFlags to indicate the amount of intersection with the indi...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the base class for PointerTo and ConstPointerTo.
Definition: pointerToBase.h:29
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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 ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool around(const BoundingVolume **first, const BoundingVolume **last)
Resets the volume to enclose only the volumes indicated.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
bool extend_by(const BoundingVolume *vol)
Increases the size of the volume to include the given volume.
virtual GeometricBoundingVolume * as_geometric_bounding_volume()
Virtual downcast method.