Panda3D
 All Classes Functions Variables Enumerations
collisionSphere.I
1 // Filename: collisionSphere.I
2 // Created by: drose (24Apr00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: CollisionSphere::Constructor
18 // Access: Public
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE CollisionSphere::
22 CollisionSphere(const LPoint3 &center, PN_stdfloat radius) :
23  _center(center), _radius(radius)
24 {
25  nassertv(_radius >= 0.0f);
26 }
27 
28 ////////////////////////////////////////////////////////////////////
29 // Function: CollisionSphere::Constructor
30 // Access: Public
31 // Description:
32 ////////////////////////////////////////////////////////////////////
33 INLINE CollisionSphere::
34 CollisionSphere(PN_stdfloat cx, PN_stdfloat cy, PN_stdfloat cz, PN_stdfloat radius) :
35  _center(cx, cy, cz), _radius(radius)
36 {
37  nassertv(_radius >= 0.0f);
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: CollisionSphere::Default constructor
42 // Access: Protected
43 // Description: Creates an invalid sphere. Only used when reading
44 // from a bam file.
45 ////////////////////////////////////////////////////////////////////
46 INLINE CollisionSphere::
47 CollisionSphere() {
48 }
49 
50 ////////////////////////////////////////////////////////////////////
51 // Function: CollisionSphere::Copy Constructor
52 // Access: Public
53 // Description:
54 ////////////////////////////////////////////////////////////////////
55 INLINE CollisionSphere::
56 CollisionSphere(const CollisionSphere &copy) :
57  CollisionSolid(copy),
58  _center(copy._center),
59  _radius(copy._radius)
60 {
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: CollisionSphere::flush_level
65 // Access: Public, Static
66 // Description: Flushes the PStatCollectors used during traversal.
67 ////////////////////////////////////////////////////////////////////
68 INLINE void CollisionSphere::
70  _volume_pcollector.flush_level();
71  _test_pcollector.flush_level();
72 }
73 
74 ////////////////////////////////////////////////////////////////////
75 // Function: CollisionSphere::set_center
76 // Access: Published
77 // Description:
78 ////////////////////////////////////////////////////////////////////
79 INLINE void CollisionSphere::
80 set_center(const LPoint3 &center) {
81  _center = center;
82  mark_internal_bounds_stale();
83  mark_viz_stale();
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: CollisionSphere::set_center
88 // Access: Published
89 // Description:
90 ////////////////////////////////////////////////////////////////////
91 INLINE void CollisionSphere::
92 set_center(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
93  set_center(LPoint3(x, y, z));
94 }
95 
96 ////////////////////////////////////////////////////////////////////
97 // Function: CollisionSphere::get_center
98 // Access: Published
99 // Description:
100 ////////////////////////////////////////////////////////////////////
101 INLINE const LPoint3 &CollisionSphere::
102 get_center() const {
103  return _center;
104 }
105 
106 ////////////////////////////////////////////////////////////////////
107 // Function: CollisionSphere::set_radius
108 // Access: Published
109 // Description:
110 ////////////////////////////////////////////////////////////////////
111 INLINE void CollisionSphere::
112 set_radius(PN_stdfloat radius) {
113  nassertv(radius >= 0.0f);
114  _radius = radius;
115  mark_internal_bounds_stale();
116  mark_viz_stale();
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: CollisionSphere::get_radius
121 // Access: Published
122 // Description:
123 ////////////////////////////////////////////////////////////////////
124 INLINE PN_stdfloat CollisionSphere::
125 get_radius() const {
126  return _radius;
127 }
128 
The abstract base class for all things that can collide with other things in the world, and all the things they can collide with (except geometry).
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A spherical collision volume or object.
static void flush_level()
Flushes the PStatCollectors used during traversal.