Panda3D
Loading...
Searching...
No Matches
boundingBox.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 boundingBox.h
10 * @author drose
11 * @date 2007-05-31
12 */
13
14#ifndef BOUNDINGBOX_H
15#define BOUNDINGBOX_H
16
17#include "pandabase.h"
18
20#include "plane.h"
21
22/**
23 * An axis-aligned bounding box; that is, a minimum and maximum coordinate
24 * triple.
25 *
26 * This box is always axis-aligned. If you need a more general bounding box,
27 * try BoundingHexahedron.
28 */
29class EXPCL_PANDA_MATHUTIL BoundingBox : public FiniteBoundingVolume {
30PUBLISHED:
31 INLINE_MATHUTIL BoundingBox();
32 INLINE_MATHUTIL explicit BoundingBox(const LPoint3 &min, const LPoint3 &max);
33 ALLOC_DELETED_CHAIN(BoundingBox);
34
35public:
36 virtual BoundingVolume *make_copy() const;
37
38 virtual LPoint3 get_min() const;
39 virtual LPoint3 get_max() const;
40 virtual PN_stdfloat get_volume() const;
41
42 virtual LPoint3 get_approx_center() const;
43 virtual void xform(const LMatrix4 &mat);
44
45 virtual void output(std::ostream &out) const;
46
47
48PUBLISHED:
49 INLINE_MATHUTIL int get_num_points() const;
50 INLINE_MATHUTIL LPoint3 get_point(int n) const;
51 MAKE_SEQ(get_points, get_num_points, get_point);
52 INLINE_MATHUTIL int get_num_planes() const;
53 INLINE_MATHUTIL LPlane get_plane(int n) const;
54 MAKE_SEQ(get_planes, get_num_planes, get_plane);
55
56 MAKE_SEQ_PROPERTY(points, get_num_points, get_point);
57 MAKE_SEQ_PROPERTY(planes, get_num_planes, get_plane);
58
59 INLINE_MATHUTIL void set_min_max(const LPoint3 &min, const LPoint3 &max);
60
61public:
62 // Inline accessors for speed.
63 INLINE_MATHUTIL const LPoint3 &get_minq() const;
64 INLINE_MATHUTIL const LPoint3 &get_maxq() const;
65
66public:
67 virtual const BoundingBox *as_bounding_box() const;
68
69protected:
70 virtual bool extend_other(BoundingVolume *other) const;
71 virtual bool around_other(BoundingVolume *other,
72 const BoundingVolume **first,
73 const BoundingVolume **last) const;
74 virtual int contains_other(const BoundingVolume *other) const;
75
76
77 virtual bool extend_by_point(const LPoint3 &point);
78 virtual bool extend_by_box(const BoundingBox *box);
79 virtual bool extend_by_finite(const FiniteBoundingVolume *volume);
80
81 virtual bool around_points(const LPoint3 *first,
82 const LPoint3 *last);
83 virtual bool around_finite(const BoundingVolume **first,
84 const BoundingVolume **last);
85
86 virtual int contains_point(const LPoint3 &point) const;
87 virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
88 virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
89 virtual int contains_box(const BoundingBox *box) const;
90 virtual int contains_line(const BoundingLine *line) const;
91 virtual int contains_plane(const BoundingPlane *plane) const;
92 virtual int contains_finite(const FiniteBoundingVolume *volume) const;
93
94private:
95 LPoint3 _min;
96 LPoint3 _max;
97
98 static const int plane_def[6][3];
99
100public:
101 static TypeHandle get_class_type() {
102 return _type_handle;
103 }
104 static void init_type() {
105 FiniteBoundingVolume::init_type();
106 register_type(_type_handle, "BoundingBox",
107 FiniteBoundingVolume::get_class_type());
108 }
109 virtual TypeHandle get_type() const {
110 return get_class_type();
111 }
112 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
113
114private:
115 static TypeHandle _type_handle;
116
117 friend class BoundingSphere;
118};
119
120#include "boundingBox.I"
121
122#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 defines a bounding convex hexahedron.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
This funny bounding volume is an infinite plane that divides space into two regions: the part behind ...
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 BoundingBox * as_bounding_box() const
Virtual downcast method.
A special kind of GeometricBoundingVolume that is known to be finite.
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.
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(),...