Panda3D
Loading...
Searching...
No Matches
bulletSliderConstraint.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 bulletSliderConstraint.cxx
10 * @author enn0x
11 * @date 2010-03-01
12 */
13
15
16#include "bulletRigidBodyNode.h"
17#include "bulletWorld.h"
18
19#include "deg_2_rad.h"
20
21TypeHandle BulletSliderConstraint::_type_handle;
22
23/**
24 *
25 */
26BulletSliderConstraint::
27BulletSliderConstraint(const BulletRigidBodyNode *node_a,
28 const TransformState *frame_a,
29 bool use_frame_a) {
30
31 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
32 btTransform trans_a = TransformState_to_btTrans(frame_a);
33
34 _constraint = new btSliderConstraint(*ptr_a, trans_a, use_frame_a);
35}
36
37/**
38 *
39 */
40BulletSliderConstraint::
41BulletSliderConstraint(const BulletRigidBodyNode *node_a,
42 const BulletRigidBodyNode *node_b,
43 const TransformState *frame_a,
44 const TransformState *frame_b,
45 bool use_frame_a) {
46
47 btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
48 btTransform trans_a = TransformState_to_btTrans(frame_a);
49
50 btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object());
51 btTransform trans_b = TransformState_to_btTrans(frame_b);
52
53 _constraint = new btSliderConstraint(*ptr_a, *ptr_b, trans_a, trans_b, use_frame_a);
54}
55
56/**
57 *
58 */
59btTypedConstraint *BulletSliderConstraint::
60ptr() const {
61
62 return _constraint;
63}
64
65/**
66 *
67 */
68PN_stdfloat BulletSliderConstraint::
69get_lower_linear_limit() const {
70 LightMutexHolder holder(BulletWorld::get_global_lock());
71
72 return (PN_stdfloat)_constraint->getLowerLinLimit();
73}
74
75/**
76 *
77 */
78PN_stdfloat BulletSliderConstraint::
79get_upper_linear_limit() const {
80 LightMutexHolder holder(BulletWorld::get_global_lock());
81
82 return (PN_stdfloat)_constraint->getUpperLinLimit();
83}
84
85/**
86 *
87 */
88PN_stdfloat BulletSliderConstraint::
89get_lower_angular_limit() const {
90 LightMutexHolder holder(BulletWorld::get_global_lock());
91
92 return rad_2_deg(_constraint->getLowerAngLimit());
93}
94
95/**
96 *
97 */
98PN_stdfloat BulletSliderConstraint::
99get_upper_angular_limit() const {
100 LightMutexHolder holder(BulletWorld::get_global_lock());
101
102 return rad_2_deg(_constraint->getUpperAngLimit());
103}
104
105/**
106 *
107 */
108void BulletSliderConstraint::
109set_lower_linear_limit(PN_stdfloat value) {
110 LightMutexHolder holder(BulletWorld::get_global_lock());
111
112 _constraint->setLowerLinLimit((btScalar)value);
113}
114
115/**
116 *
117 */
118void BulletSliderConstraint::
119set_upper_linear_limit(PN_stdfloat value) {
120 LightMutexHolder holder(BulletWorld::get_global_lock());
121
122 _constraint->setUpperLinLimit((btScalar)value);
123}
124
125/**
126 *
127 */
128void BulletSliderConstraint::
129set_lower_angular_limit(PN_stdfloat value) {
130 LightMutexHolder holder(BulletWorld::get_global_lock());
131
132 _constraint->setLowerAngLimit((btScalar)deg_2_rad(value));
133}
134
135/**
136 *
137 */
138void BulletSliderConstraint::
139set_upper_angular_limit(PN_stdfloat value) {
140 LightMutexHolder holder(BulletWorld::get_global_lock());
141
142 _constraint->setUpperAngLimit((btScalar)deg_2_rad(value));
143}
144
145/**
146 *
147 */
148PN_stdfloat BulletSliderConstraint::
149get_linear_pos() const {
150 LightMutexHolder holder(BulletWorld::get_global_lock());
151
152 return (PN_stdfloat)_constraint->getLinearPos();
153}
154
155/**
156 *
157 */
158PN_stdfloat BulletSliderConstraint::
159get_angular_pos() const {
160 LightMutexHolder holder(BulletWorld::get_global_lock());
161
162 return (PN_stdfloat)_constraint->getAngularPos();
163}
164
165/**
166 *
167 */
168void BulletSliderConstraint::
169set_powered_linear_motor(bool on) {
170 LightMutexHolder holder(BulletWorld::get_global_lock());
171
172 _constraint->setPoweredLinMotor(on);
173}
174
175/**
176 *
177 */
178void BulletSliderConstraint::
179set_target_linear_motor_velocity(PN_stdfloat target_velocity) {
180 LightMutexHolder holder(BulletWorld::get_global_lock());
181
182 _constraint->setTargetLinMotorVelocity((btScalar)target_velocity);
183}
184
185/**
186 *
187 */
188void BulletSliderConstraint::
189set_max_linear_motor_force(PN_stdfloat max_force) {
190 LightMutexHolder holder(BulletWorld::get_global_lock());
191
192 _constraint->setMaxLinMotorForce((btScalar)max_force);
193}
194
195/**
196 *
197 */
198bool BulletSliderConstraint::
199get_powered_linear_motor() const {
200 LightMutexHolder holder(BulletWorld::get_global_lock());
201
202 return _constraint->getPoweredLinMotor();
203}
204
205/**
206 *
207 */
208PN_stdfloat BulletSliderConstraint::
209get_target_linear_motor_velocity() const {
210 LightMutexHolder holder(BulletWorld::get_global_lock());
211
212 return (PN_stdfloat)_constraint->getTargetLinMotorVelocity();
213}
214
215/**
216 *
217 */
218PN_stdfloat BulletSliderConstraint::
219get_max_linear_motor_force() const {
220 LightMutexHolder holder(BulletWorld::get_global_lock());
221
222 return (PN_stdfloat)_constraint->getMaxLinMotorForce();
223}
224
225/**
226 *
227 */
228void BulletSliderConstraint::
229set_powered_angular_motor(bool on) {
230 LightMutexHolder holder(BulletWorld::get_global_lock());
231
232 _constraint->setPoweredAngMotor(on);
233}
234
235/**
236 *
237 */
238void BulletSliderConstraint::
239set_target_angular_motor_velocity(PN_stdfloat target_velocity) {
240 LightMutexHolder holder(BulletWorld::get_global_lock());
241
242 _constraint->setTargetAngMotorVelocity((btScalar)target_velocity);
243}
244
245/**
246 *
247 */
248void BulletSliderConstraint::
249set_max_angular_motor_force(PN_stdfloat max_force) {
250 LightMutexHolder holder(BulletWorld::get_global_lock());
251
252 _constraint->setMaxAngMotorForce((btScalar)max_force);
253}
254
255/**
256 *
257 */
258bool BulletSliderConstraint::
259get_powered_angular_motor() const {
260 LightMutexHolder holder(BulletWorld::get_global_lock());
261
262 return _constraint->getPoweredAngMotor();
263}
264
265/**
266 *
267 */
268PN_stdfloat BulletSliderConstraint::
269get_target_angular_motor_velocity() const {
270 LightMutexHolder holder(BulletWorld::get_global_lock());
271
272 return (PN_stdfloat)_constraint->getTargetAngMotorVelocity();
273}
274
275/**
276 *
277 */
278PN_stdfloat BulletSliderConstraint::
279get_max_angular_motor_force() const {
280 LightMutexHolder holder(BulletWorld::get_global_lock());
281
282 return (PN_stdfloat)_constraint->getMaxAngMotorForce();
283}
284
285/**
286 *
287 */
288void BulletSliderConstraint::
289set_frames(const TransformState *ts_a, const TransformState *ts_b) {
290 LightMutexHolder holder(BulletWorld::get_global_lock());
291
292 btTransform frame_a = TransformState_to_btTrans(ts_a);
293 btTransform frame_b = TransformState_to_btTrans(ts_b);
294
295 _constraint->setFrames(frame_a, frame_b);
296}
297
298/**
299 *
300 */
301CPT(TransformState) BulletSliderConstraint::
302get_frame_a() const {
303 LightMutexHolder holder(BulletWorld::get_global_lock());
304
305 return btTrans_to_TransformState(_constraint->getFrameOffsetA());
306}
307
308/**
309 *
310 */
311CPT(TransformState) BulletSliderConstraint::
312get_frame_b() const {
313 LightMutexHolder holder(BulletWorld::get_global_lock());
314
315 return btTrans_to_TransformState(_constraint->getFrameOffsetB());
316}
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
Indicates a coordinate-system transform on vertices.
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.