Panda3D

collisionCapsule.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 collisionCapsule.I
10 * @author drose
11 * @date 2003-09-25
12 */
13
14 /**
15 *
16 */
17 INLINE CollisionCapsule::
18 CollisionCapsule(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) :
19 _a(a), _b(b), _radius(radius)
20 {
21 recalc_internals();
22 nassertv(_radius >= 0.0f);
23 }
24
25 /**
26 *
27 */
28 INLINE CollisionCapsule::
29 CollisionCapsule(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az,
30 PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz,
31 PN_stdfloat radius) :
32 _a(ax, ay, az), _b(bx, by, bz), _radius(radius)
33 {
34 recalc_internals();
35 nassertv(_radius >= 0.0f);
36 }
37
38 /**
39 * Creates an invalid capsule. Only used when reading from a bam file.
40 */
41 INLINE CollisionCapsule::
42 CollisionCapsule() {
43 }
44
45 /**
46 *
47 */
48 INLINE CollisionCapsule::
49 CollisionCapsule(const CollisionCapsule &copy) :
50 CollisionSolid(copy),
51 _a(copy._a),
52 _b(copy._b),
53 _radius(copy._radius)
54 {
55 recalc_internals();
56 }
57
58 /**
59 * Flushes the PStatCollectors used during traversal.
60 */
61 INLINE void CollisionCapsule::
62 flush_level() {
63 _volume_pcollector.flush_level();
64 _test_pcollector.flush_level();
65 }
66
67 /**
68 *
69 */
70 INLINE void CollisionCapsule::
71 set_point_a(const LPoint3 &a) {
72 _a = a;
73 recalc_internals();
74 }
75
76 /**
77 *
78 */
79 INLINE void CollisionCapsule::
80 set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
81 set_point_a(LPoint3(x, y, z));
82 }
83
84 /**
85 *
86 */
87 INLINE const LPoint3 &CollisionCapsule::
88 get_point_a() const {
89 return _a;
90 }
91
92 /**
93 *
94 */
95 INLINE void CollisionCapsule::
96 set_point_b(const LPoint3 &b) {
97 _b = b;
98 recalc_internals();
99 }
100
101 /**
102 *
103 */
104 INLINE void CollisionCapsule::
105 set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
106 set_point_b(LPoint3(x, y, z));
107 }
108
109 /**
110 *
111 */
112 INLINE const LPoint3 &CollisionCapsule::
113 get_point_b() const {
114 return _b;
115 }
116
117 /**
118 *
119 */
120 INLINE void CollisionCapsule::
121 set_radius(PN_stdfloat radius) {
122 nassertv(radius >= 0.0f);
123 _radius = radius;
124
125 // We don't need to call recalc_internals(), since the radius doesn't change
126 // either of those properties.
127 mark_internal_bounds_stale();
128 mark_viz_stale();
129 }
130
131 /**
132 *
133 */
134 INLINE PN_stdfloat CollisionCapsule::
135 get_radius() const {
136 return _radius;
137 }
CollisionCapsule
This implements a solid consisting of a cylinder with hemispherical endcaps, also known as a capsule ...
Definition: collisionCapsule.h:27
CollisionCapsule::flush_level
static void flush_level()
Flushes the PStatCollectors used during traversal.
Definition: collisionCapsule.I:62
CollisionSolid
The abstract base class for all things that can collide with other things in the world,...
Definition: collisionSolid.h:45