Panda3D
boundingLine.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 boundingLine.h
10  * @author drose
11  * @date 2000-07-04
12  */
13 
14 #ifndef BOUNDINGLINE_H
15 #define BOUNDINGLINE_H
16 
17 #include "pandabase.h"
18 
20 
21 /**
22  * This funny bounding volume is an infinite line with no thickness and
23  * extending to infinity in both directions.
24  *
25  * Note that it *always* extends in both directions, despite the fact that you
26  * specify two points to the constructor. These are not endpoints, they are
27  * two arbitrary points on the line.
28  */
29 class EXPCL_PANDA_MATHUTIL BoundingLine : public GeometricBoundingVolume {
30 public:
31  INLINE_MATHUTIL BoundingLine();
32 
33 PUBLISHED:
34  INLINE_MATHUTIL explicit BoundingLine(const LPoint3 &a, const LPoint3 &b);
35  ALLOC_DELETED_CHAIN(BoundingLine);
36 
37 public:
38  virtual BoundingVolume *make_copy() const;
39 
40  virtual LPoint3 get_approx_center() const;
41  virtual void xform(const LMatrix4 &mat);
42 
43  virtual void output(std::ostream &out) const;
44 
45 PUBLISHED:
46  INLINE_MATHUTIL const LPoint3 &get_point_a() const;
47  INLINE_MATHUTIL LPoint3 get_point_b() const;
48 
49 public:
50  virtual const BoundingLine *as_bounding_line() const;
51 
52 protected:
53  virtual bool extend_other(BoundingVolume *other) const;
54  virtual bool around_other(BoundingVolume *other,
55  const BoundingVolume **first,
56  const BoundingVolume **last) const;
57  virtual int contains_other(const BoundingVolume *other) const;
58 
59  virtual bool extend_by_line(const BoundingLine *line);
60 
61  virtual int contains_sphere(const BoundingSphere *sphere) const;
62  virtual int contains_box(const BoundingBox *box) const;
63 
64  PN_stdfloat sqr_dist_to_line(const LPoint3 &point) const;
65 
66 private:
67  LPoint3 _origin;
68  LVector3 _vector;
69 
70 
71 public:
72  static TypeHandle get_class_type() {
73  return _type_handle;
74  }
75  static void init_type() {
76  GeometricBoundingVolume::init_type();
77  register_type(_type_handle, "BoundingLine",
78  GeometricBoundingVolume::get_class_type());
79  }
80  virtual TypeHandle get_type() const {
81  return get_class_type();
82  }
83  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
84 
85 private:
86  static TypeHandle _type_handle;
87 
88  friend class BoundingSphere;
89  friend class BoundingBox;
90 };
91 
92 #include "boundingLine.I"
93 
94 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
Definition: boundingBox.h:29
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
Definition: boundingLine.h:29
This defines a bounding sphere, consisting of a center and a radius.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
virtual const BoundingLine * as_bounding_line() const
Virtual downcast method.
This is another abstract class, for a general class of bounding volumes that actually enclose points ...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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