Panda3D
Loading...
Searching...
No Matches
boundingSphere.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 boundingSphere.h
10 * @author drose
11 * @date 1999-10-01
12 */
13
14#ifndef BOUNDINGSPHERE_H
15#define BOUNDINGSPHERE_H
16
17#include "pandabase.h"
18
20
21/**
22 * This defines a bounding sphere, consisting of a center and a radius. It is
23 * always a sphere, and never an ellipsoid or other quadric.
24 */
25class EXPCL_PANDA_MATHUTIL BoundingSphere : public FiniteBoundingVolume {
26PUBLISHED:
27 INLINE_MATHUTIL BoundingSphere();
28 INLINE_MATHUTIL explicit BoundingSphere(const LPoint3 &center, PN_stdfloat radius);
29 ALLOC_DELETED_CHAIN(BoundingSphere);
30
31public:
32 virtual BoundingVolume *make_copy() const;
33
34 virtual LPoint3 get_min() const;
35 virtual LPoint3 get_max() const;
36 virtual PN_stdfloat get_volume() const;
37
38 virtual LPoint3 get_approx_center() const;
39 virtual void xform(const LMatrix4 &mat);
40
41 virtual void output(std::ostream &out) const;
42
43PUBLISHED:
44 INLINE_MATHUTIL LPoint3 get_center() const;
45 INLINE_MATHUTIL PN_stdfloat get_radius() const;
46
47 INLINE_MATHUTIL void set_center(const LPoint3 &center);
48 INLINE_MATHUTIL void set_radius(PN_stdfloat radius);
49
50 MAKE_PROPERTY(center, get_center, set_center);
51 MAKE_PROPERTY(radius, get_radius, set_radius);
52
53public:
54 virtual const BoundingSphere *as_bounding_sphere() const;
55
56protected:
57 virtual bool extend_other(BoundingVolume *other) const;
58 virtual bool around_other(BoundingVolume *other,
59 const BoundingVolume **first,
60 const BoundingVolume **last) const;
61 virtual int contains_other(const BoundingVolume *other) const;
62
63
64 virtual bool extend_by_point(const LPoint3 &point);
65 virtual bool extend_by_sphere(const BoundingSphere *sphere);
66 virtual bool extend_by_box(const BoundingBox *box);
67 virtual bool extend_by_hexahedron(const BoundingHexahedron *hexahedron);
68 virtual bool extend_by_finite(const FiniteBoundingVolume *volume);
69
70 virtual bool around_points(const LPoint3 *first,
71 const LPoint3 *last);
72 virtual bool around_finite(const BoundingVolume **first,
73 const BoundingVolume **last);
74
75 virtual int contains_point(const LPoint3 &point) const;
76 virtual int contains_lineseg(const LPoint3 &a, const LPoint3 &b) const;
77 virtual int contains_hexahedron(const BoundingHexahedron *hexahedron) const;
78 virtual int contains_sphere(const BoundingSphere *sphere) const;
79 virtual int contains_box(const BoundingBox *box) const;
80 virtual int contains_line(const BoundingLine *line) const;
81 virtual int contains_plane(const BoundingPlane *plane) const;
82
83private:
84 LPoint3 _center;
85 PN_stdfloat _radius;
86
87
88public:
89 static TypeHandle get_class_type() {
90 return _type_handle;
91 }
92 static void init_type() {
93 FiniteBoundingVolume::init_type();
94 register_type(_type_handle, "BoundingSphere",
95 FiniteBoundingVolume::get_class_type());
96 }
97 virtual TypeHandle get_type() const {
98 return get_class_type();
99 }
100 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
101
102private:
103 static TypeHandle _type_handle;
104
105 friend class BoundingHexahedron;
106};
107
108#include "boundingSphere.I"
109
110#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BoundingSphere()
Constructs an empty sphere.
set_radius
Sets the radius of the sphere.
set_center
Sets the center point of the sphere.
virtual const BoundingSphere * as_bounding_sphere() 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.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...