Panda3D
collisionSphere.I
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 collisionSphere.I
10  * @author drose
11  * @date 2000-04-24
12  */
13 
14 /**
15  *
16  */
17 INLINE CollisionSphere::
18 CollisionSphere(const LPoint3 &center, PN_stdfloat radius) :
19  _center(center), _radius(radius)
20 {
21  nassertv(_radius >= 0.0f);
22 }
23 
24 /**
25  *
26  */
27 INLINE CollisionSphere::
28 CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) :
29  _center(cx, cy, cz), _radius(radius)
30 {
31  nassertv(_radius >= 0.0f);
32 }
33 
34 /**
35  * Creates an invalid sphere. Only used when reading from a bam file.
36  */
37 INLINE CollisionSphere::
38 CollisionSphere() {
39 }
40 
41 /**
42  *
43  */
44 INLINE CollisionSphere::
45 CollisionSphere(const CollisionSphere &copy) :
46  CollisionSolid(copy),
47  _center(copy._center),
48  _radius(copy._radius)
49 {
50 }
51 
52 /**
53  * Flushes the PStatCollectors used during traversal.
54  */
55 INLINE void CollisionSphere::
57  _volume_pcollector.flush_level();
58  _test_pcollector.flush_level();
59 }
60 
61 /**
62  *
63  */
64 INLINE void CollisionSphere::
65 set_center(const LPoint3 &center) {
66  _center = center;
67  mark_internal_bounds_stale();
68  mark_viz_stale();
69 }
70 
71 /**
72  *
73  */
74 INLINE void CollisionSphere::
75 set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
76  set_center(LPoint3(x, y, z));
77 }
78 
79 /**
80  *
81  */
82 INLINE const LPoint3 &CollisionSphere::
83 get_center() const {
84  return _center;
85 }
86 
87 /**
88  *
89  */
90 INLINE void CollisionSphere::
91 set_radius(PN_stdfloat radius) {
92  nassertv(radius >= 0.0f);
93  _radius = radius;
94  mark_internal_bounds_stale();
95  mark_viz_stale();
96 }
97 
98 /**
99  *
100  */
101 INLINE PN_stdfloat CollisionSphere::
102 get_radius() const {
103  return _radius;
104 }
The abstract base class for all things that can collide with other things in the world,...
A spherical collision volume or object.
static void flush_level()
Flushes the PStatCollectors used during traversal.