Panda3D
bulletRotationalLimitMotor.cxx
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 bulletRotationalLimitMotor.cxx
10  * @author enn0x
11  * @date 2013-03-03
12  */
13 
15 
16 #include "bulletWorld.h"
17 
18 /**
19  *
20  */
21 BulletRotationalLimitMotor::
22 BulletRotationalLimitMotor(btRotationalLimitMotor &motor)
23  : _motor(motor) {
24 
25 }
26 
27 /**
28  *
29  */
30 BulletRotationalLimitMotor::
31 BulletRotationalLimitMotor(const BulletRotationalLimitMotor &copy)
32  : _motor(copy._motor) {
33 
34 }
35 
36 /**
37  *
38  */
39 bool BulletRotationalLimitMotor::
40 is_limited() const {
41  LightMutexHolder holder(BulletWorld::get_global_lock());
42 
43  return _motor.isLimited();
44 }
45 
46 /**
47  *
48  */
49 void BulletRotationalLimitMotor::
50 set_motor_enabled(bool enabled) {
51  LightMutexHolder holder(BulletWorld::get_global_lock());
52 
53  _motor.m_enableMotor = enabled;
54 }
55 
56 /**
57  *
58  */
59 bool BulletRotationalLimitMotor::
60 get_motor_enabled() const {
61  LightMutexHolder holder(BulletWorld::get_global_lock());
62 
63  return _motor.m_enableMotor;
64 }
65 /**
66  *
67  */
68 void BulletRotationalLimitMotor::
69 set_low_limit(PN_stdfloat limit) {
70  LightMutexHolder holder(BulletWorld::get_global_lock());
71 
72  _motor.m_loLimit = (btScalar)limit;
73 }
74 
75 /**
76  *
77  */
78 void BulletRotationalLimitMotor::
79 set_high_limit(PN_stdfloat limit) {
80  LightMutexHolder holder(BulletWorld::get_global_lock());
81 
82  _motor.m_hiLimit = (btScalar)limit;
83 }
84 
85 /**
86  *
87  */
88 void BulletRotationalLimitMotor::
89 set_target_velocity(PN_stdfloat velocity) {
90  LightMutexHolder holder(BulletWorld::get_global_lock());
91 
92  _motor.m_targetVelocity = (btScalar)velocity;
93 }
94 
95 /**
96  *
97  */
98 void BulletRotationalLimitMotor::
99 set_max_motor_force(PN_stdfloat force) {
100  LightMutexHolder holder(BulletWorld::get_global_lock());
101 
102  _motor.m_maxMotorForce = (btScalar)force;
103 }
104 
105 /**
106  *
107  */
108 void BulletRotationalLimitMotor::
109 set_max_limit_force(PN_stdfloat force) {
110  LightMutexHolder holder(BulletWorld::get_global_lock());
111 
112  _motor.m_maxLimitForce = (btScalar)force;
113 }
114 
115 /**
116  *
117  */
118 void BulletRotationalLimitMotor::
119 set_damping(PN_stdfloat damping) {
120  LightMutexHolder holder(BulletWorld::get_global_lock());
121 
122  _motor.m_damping = (btScalar)damping;
123 }
124 
125 /**
126  *
127  */
128 void BulletRotationalLimitMotor::
129 set_softness(PN_stdfloat softness) {
130  LightMutexHolder holder(BulletWorld::get_global_lock());
131 
132  _motor.m_limitSoftness = (btScalar)softness;
133 }
134 
135 /**
136  *
137  */
138 void BulletRotationalLimitMotor::
139 set_bounce(PN_stdfloat bounce) {
140  LightMutexHolder holder(BulletWorld::get_global_lock());
141 
142  _motor.m_bounce = (btScalar)bounce;
143 }
144 
145 /**
146  *
147  */
148 void BulletRotationalLimitMotor::
149 set_normal_cfm(PN_stdfloat cfm) {
150  LightMutexHolder holder(BulletWorld::get_global_lock());
151 
152  _motor.m_normalCFM = (btScalar)cfm;
153 }
154 
155 /**
156  *
157  */
158 void BulletRotationalLimitMotor::
159 set_stop_cfm(PN_stdfloat cfm) {
160  LightMutexHolder holder(BulletWorld::get_global_lock());
161 
162  _motor.m_stopCFM = (btScalar)cfm;
163 }
164 
165 /**
166  *
167  */
168 void BulletRotationalLimitMotor::
169 set_stop_erp(PN_stdfloat erp) {
170  LightMutexHolder holder(BulletWorld::get_global_lock());
171 
172  _motor.m_stopERP = (btScalar)erp;
173 }
174 
175 /**
176  * Retrieves the current value of angle: 0 = free, 1 = at low limit, 2 = at
177  * high limit.
178  */
179 int BulletRotationalLimitMotor::
180 get_current_limit() const {
181  LightMutexHolder holder(BulletWorld::get_global_lock());
182 
183  return _motor.m_currentLimit;
184 }
185 
186 /**
187  *
188  */
189 PN_stdfloat BulletRotationalLimitMotor::
190 get_current_error() const {
191  LightMutexHolder holder(BulletWorld::get_global_lock());
192 
193  return (PN_stdfloat)_motor.m_currentLimitError;
194 }
195 
196 /**
197  *
198  */
199 PN_stdfloat BulletRotationalLimitMotor::
200 get_current_position() const {
201  LightMutexHolder holder(BulletWorld::get_global_lock());
202 
203  return (PN_stdfloat)_motor.m_currentPosition;
204 }
205 
206 /**
207  *
208  */
209 PN_stdfloat BulletRotationalLimitMotor::
210 get_accumulated_impulse() const {
211  LightMutexHolder holder(BulletWorld::get_global_lock());
212 
213  return (PN_stdfloat)_motor.m_accumulatedImpulse;
214 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Rotation Limit structure for generic joints.
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.