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