Panda3D

Loading...
Searching...
No Matches
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 */
17INLINE CollisionCapsule::
18CollisionCapsule(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 */
28INLINE CollisionCapsule::
29CollisionCapsule(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 */
41INLINE CollisionCapsule::
42CollisionCapsule() {
43}
44
45/**
46 *
47 */
48INLINE CollisionCapsule::
49CollisionCapsule(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 */
61INLINE void CollisionCapsule::
62 flush_level() {
63 _volume_pcollector.flush_level();
64 _test_pcollector.flush_level();
65}
66
67/**
68 *
69 */
70INLINE void CollisionCapsule::
71set_point_a(const LPoint3 &a) {
72 _a = a;
73 recalc_internals();
74}
75
76/**
77 *
78 */
79INLINE void CollisionCapsule::
80set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
81 set_point_a(LPoint3(x, y, z));
82}
83
84/**
85 *
86 */
87INLINE const LPoint3 &CollisionCapsule::
88get_point_a() const {
89 return _a;
90}
91
92/**
93 *
94 */
95INLINE void CollisionCapsule::
96set_point_b(const LPoint3 &b) {
97 _b = b;
98 recalc_internals();
99}
100
101/**
102 *
103 */
104INLINE void CollisionCapsule::
105set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) {
106 set_point_b(LPoint3(x, y, z));
107}
108
109/**
110 *
111 */
112INLINE const LPoint3 &CollisionCapsule::
113get_point_b() const {
114 return _b;
115}
116
117/**
118 *
119 */
120INLINE void CollisionCapsule::
121set_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 */
134INLINE PN_stdfloat CollisionCapsule::
135get_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