bullet3 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +194 -0
  4. data/data/cube.urdf +22 -0
  5. data/data/plane.urdf +19 -0
  6. data/ext/bullet3/CMakeLists.txt +224 -0
  7. data/ext/bullet3/bullet3.cpp +34 -0
  8. data/ext/bullet3/collision/rb_collision.cpp +428 -0
  9. data/ext/bullet3/collision/rb_collision.hpp +87 -0
  10. data/ext/bullet3/collision/shapes/rb_collision_shape.cpp +485 -0
  11. data/ext/bullet3/collision/shapes/rb_collision_shape.hpp +5 -0
  12. data/ext/bullet3/constraints/rb_constraints.cpp +1310 -0
  13. data/ext/bullet3/constraints/rb_constraints.hpp +226 -0
  14. data/ext/bullet3/dynamics/rb_dynamics.cpp +862 -0
  15. data/ext/bullet3/dynamics/rb_dynamics.hpp +180 -0
  16. data/ext/bullet3/extconf.rb +57 -0
  17. data/ext/bullet3/io/rb_io.cpp +108 -0
  18. data/ext/bullet3/io/rb_io.hpp +40 -0
  19. data/ext/bullet3/linear_math/rb_matrix3x3.cpp +93 -0
  20. data/ext/bullet3/linear_math/rb_matrix3x3.hpp +5 -0
  21. data/ext/bullet3/linear_math/rb_quaternion.cpp +134 -0
  22. data/ext/bullet3/linear_math/rb_quaternion.hpp +5 -0
  23. data/ext/bullet3/linear_math/rb_transform.cpp +157 -0
  24. data/ext/bullet3/linear_math/rb_transform.hpp +34 -0
  25. data/ext/bullet3/linear_math/rb_vector3.cpp +123 -0
  26. data/ext/bullet3/linear_math/rb_vector3.hpp +5 -0
  27. data/ext/bullet3/multi_body/rb_multi_body.cpp +1000 -0
  28. data/ext/bullet3/multi_body/rb_multi_body.hpp +190 -0
  29. data/ext/bullet3/soft_body/rb_soft_body.cpp +720 -0
  30. data/ext/bullet3/soft_body/rb_soft_body.hpp +122 -0
  31. data/ext/bullet3/util/rb_debug_draw.cpp +250 -0
  32. data/ext/bullet3/util/rb_debug_draw.hpp +47 -0
  33. data/ext/bullet3/util/ruby_cpp_compat.hpp +29 -0
  34. data/ext/bullet3/util/type_conversions.hpp +107 -0
  35. data/ext/bullet3/vehicle/rb_vehicle.cpp +467 -0
  36. data/ext/bullet3/vehicle/rb_vehicle.hpp +115 -0
  37. data/lib/bullet3/collision.rb +6 -0
  38. data/lib/bullet3/constraints.rb +6 -0
  39. data/lib/bullet3/data.rb +39 -0
  40. data/lib/bullet3/debug_draw.rb +73 -0
  41. data/lib/bullet3/dynamics.rb +4 -0
  42. data/lib/bullet3/io.rb +110 -0
  43. data/lib/bullet3/linear_math/matrix3x3.rb +69 -0
  44. data/lib/bullet3/linear_math/quaternion.rb +187 -0
  45. data/lib/bullet3/linear_math/transform.rb +48 -0
  46. data/lib/bullet3/linear_math/vector3.rb +199 -0
  47. data/lib/bullet3/linear_math.rb +6 -0
  48. data/lib/bullet3/multi_body.rb +6 -0
  49. data/lib/bullet3/simulation.rb +1170 -0
  50. data/lib/bullet3/soft_body.rb +6 -0
  51. data/lib/bullet3/vehicle.rb +4 -0
  52. data/lib/bullet3/version.rb +5 -0
  53. data/lib/bullet3.rb +49 -0
  54. metadata +124 -0
@@ -0,0 +1,1310 @@
1
+ #include "rb_constraints.hpp"
2
+
3
+ #include <stdexcept>
4
+
5
+ #include <BulletDynamics/ConstraintSolver/btFixedConstraint.h>
6
+ #include <BulletDynamics/ConstraintSolver/btGearConstraint.h>
7
+ #include <BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h>
8
+ #include <BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.h>
9
+ #include <BulletDynamics/ConstraintSolver/btHingeConstraint.h>
10
+ #include <BulletDynamics/ConstraintSolver/btHinge2Constraint.h>
11
+ #include <BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h>
12
+ #include <BulletDynamics/ConstraintSolver/btSliderConstraint.h>
13
+ #include <BulletDynamics/ConstraintSolver/btConeTwistConstraint.h>
14
+
15
+ #include "../linear_math/rb_transform.hpp"
16
+ #include "../util/type_conversions.hpp"
17
+
18
+ namespace {
19
+ bullet3::RigidBody* rigid_body_from_value(VALUE value)
20
+ {
21
+ bullet3::RigidBody* body = Rice::detail::From_Ruby<bullet3::RigidBody*>().convert(value);
22
+ if (body == nullptr) {
23
+ throw std::invalid_argument("expected Bullet3::RigidBody");
24
+ }
25
+ return body;
26
+ }
27
+
28
+ btPoint2PointConstraint* point2point_from(bullet3::TypedConstraint& constraint)
29
+ {
30
+ return static_cast<btPoint2PointConstraint*>(constraint.get());
31
+ }
32
+
33
+ const btPoint2PointConstraint* point2point_from(const bullet3::TypedConstraint& constraint)
34
+ {
35
+ return static_cast<const btPoint2PointConstraint*>(constraint.get());
36
+ }
37
+
38
+ btHingeConstraint* hinge_from(bullet3::TypedConstraint& constraint)
39
+ {
40
+ return static_cast<btHingeConstraint*>(constraint.get());
41
+ }
42
+
43
+ const btHingeConstraint* hinge_from(const bullet3::TypedConstraint& constraint)
44
+ {
45
+ return static_cast<const btHingeConstraint*>(constraint.get());
46
+ }
47
+
48
+ btSliderConstraint* slider_from(bullet3::TypedConstraint& constraint)
49
+ {
50
+ return static_cast<btSliderConstraint*>(constraint.get());
51
+ }
52
+
53
+ const btSliderConstraint* slider_from(const bullet3::TypedConstraint& constraint)
54
+ {
55
+ return static_cast<const btSliderConstraint*>(constraint.get());
56
+ }
57
+
58
+ btConeTwistConstraint* cone_twist_from(bullet3::TypedConstraint& constraint)
59
+ {
60
+ return static_cast<btConeTwistConstraint*>(constraint.get());
61
+ }
62
+
63
+ const btConeTwistConstraint* cone_twist_from(const bullet3::TypedConstraint& constraint)
64
+ {
65
+ return static_cast<const btConeTwistConstraint*>(constraint.get());
66
+ }
67
+
68
+ btGeneric6DofConstraint* generic_6dof_from(bullet3::TypedConstraint& constraint)
69
+ {
70
+ return static_cast<btGeneric6DofConstraint*>(constraint.get());
71
+ }
72
+
73
+ const btGeneric6DofConstraint* generic_6dof_from(const bullet3::TypedConstraint& constraint)
74
+ {
75
+ return static_cast<const btGeneric6DofConstraint*>(constraint.get());
76
+ }
77
+
78
+ btGeneric6DofSpring2Constraint* generic_6dof_spring2_from(bullet3::TypedConstraint& constraint)
79
+ {
80
+ return static_cast<btGeneric6DofSpring2Constraint*>(constraint.get());
81
+ }
82
+
83
+ btGeneric6DofSpring2Constraint* generic_6dof_spring2_from(const bullet3::TypedConstraint& constraint)
84
+ {
85
+ return const_cast<btGeneric6DofSpring2Constraint*>(
86
+ static_cast<const btGeneric6DofSpring2Constraint*>(constraint.get()));
87
+ }
88
+
89
+ btGearConstraint* gear_from(bullet3::TypedConstraint& constraint)
90
+ {
91
+ return static_cast<btGearConstraint*>(constraint.get());
92
+ }
93
+
94
+ const btGearConstraint* gear_from(const bullet3::TypedConstraint& constraint)
95
+ {
96
+ return static_cast<const btGearConstraint*>(constraint.get());
97
+ }
98
+
99
+ btHinge2Constraint* hinge2_from(bullet3::TypedConstraint& constraint)
100
+ {
101
+ return static_cast<btHinge2Constraint*>(constraint.get());
102
+ }
103
+
104
+ int validate_spatial_axis(int axis)
105
+ {
106
+ if (axis < 0 || axis > 2) {
107
+ throw std::out_of_range("axis must be between 0 and 2");
108
+ }
109
+ return axis;
110
+ }
111
+
112
+ int validate_dof_axis(int axis)
113
+ {
114
+ if (axis < 0 || axis > 5) {
115
+ throw std::out_of_range("axis must be between 0 and 5");
116
+ }
117
+ return axis;
118
+ }
119
+
120
+ RotateOrder rotate_order_from_int(int rotate_order)
121
+ {
122
+ if (rotate_order < RO_XYZ || rotate_order > RO_ZYX) {
123
+ throw std::out_of_range("rotate_order must be between 0 and 5");
124
+ }
125
+ return static_cast<RotateOrder>(rotate_order);
126
+ }
127
+
128
+ std::unique_ptr<btTypedConstraint> make_hinge2_constraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE anchor_value, VALUE axis1_value, VALUE axis2_value)
129
+ {
130
+ btVector3 anchor = bullet3::coerce_vector(Rice::Object(anchor_value));
131
+ btVector3 axis1 = bullet3::coerce_vector(Rice::Object(axis1_value));
132
+ btVector3 axis2 = bullet3::coerce_vector(Rice::Object(axis2_value));
133
+ return std::make_unique<btHinge2Constraint>(
134
+ *rigid_body_from_value(rigid_body_a)->get(),
135
+ *rigid_body_from_value(rigid_body_b)->get(),
136
+ anchor,
137
+ axis1,
138
+ axis2);
139
+ }
140
+ } // namespace
141
+
142
+ namespace bullet3 {
143
+ TypedConstraint::TypedConstraint(std::unique_ptr<btTypedConstraint> constraint)
144
+ : constraint_(std::move(constraint))
145
+ {
146
+ }
147
+
148
+ btTypedConstraint* TypedConstraint::get()
149
+ {
150
+ return constraint_.get();
151
+ }
152
+
153
+ const btTypedConstraint* TypedConstraint::get() const
154
+ {
155
+ return constraint_.get();
156
+ }
157
+
158
+ Rice::Symbol TypedConstraint::constraint_type() const
159
+ {
160
+ if (dynamic_cast<const btFixedConstraint*>(constraint_.get()) != nullptr) {
161
+ return Rice::Symbol("fixed");
162
+ }
163
+
164
+ switch (constraint_->getConstraintType()) {
165
+ case POINT2POINT_CONSTRAINT_TYPE:
166
+ return Rice::Symbol("point2point");
167
+ case HINGE_CONSTRAINT_TYPE:
168
+ return Rice::Symbol("hinge");
169
+ case CONETWIST_CONSTRAINT_TYPE:
170
+ return Rice::Symbol("cone_twist");
171
+ case D6_CONSTRAINT_TYPE:
172
+ return Rice::Symbol("generic_6dof");
173
+ case SLIDER_CONSTRAINT_TYPE:
174
+ return Rice::Symbol("slider");
175
+ case GEAR_CONSTRAINT_TYPE:
176
+ return Rice::Symbol("gear");
177
+ case FIXED_CONSTRAINT_TYPE:
178
+ return Rice::Symbol("fixed");
179
+ case D6_SPRING_2_CONSTRAINT_TYPE:
180
+ if (dynamic_cast<const btHinge2Constraint*>(constraint_.get()) != nullptr) {
181
+ return Rice::Symbol("hinge2");
182
+ }
183
+ return Rice::Symbol("generic_6dof_spring2");
184
+ default:
185
+ return Rice::Symbol("unknown");
186
+ }
187
+ }
188
+
189
+ bool TypedConstraint::enabled() const
190
+ {
191
+ return constraint_->isEnabled();
192
+ }
193
+
194
+ bool TypedConstraint::set_enabled(bool enabled)
195
+ {
196
+ constraint_->setEnabled(enabled);
197
+ return enabled;
198
+ }
199
+
200
+ btScalar TypedConstraint::breaking_impulse_threshold() const
201
+ {
202
+ return constraint_->getBreakingImpulseThreshold();
203
+ }
204
+
205
+ btScalar TypedConstraint::set_breaking_impulse_threshold(btScalar threshold)
206
+ {
207
+ constraint_->setBreakingImpulseThreshold(threshold);
208
+ return threshold;
209
+ }
210
+
211
+ btScalar TypedConstraint::debug_draw_size() const
212
+ {
213
+ return constraint_->getDbgDrawSize();
214
+ }
215
+
216
+ btScalar TypedConstraint::set_debug_draw_size(btScalar size)
217
+ {
218
+ constraint_->setDbgDrawSize(size);
219
+ return size;
220
+ }
221
+
222
+ void TypedConstraint::enable_feedback(bool enabled)
223
+ {
224
+ constraint_->enableFeedback(enabled);
225
+ }
226
+
227
+ bool TypedConstraint::needs_feedback() const
228
+ {
229
+ return constraint_->needsFeedback();
230
+ }
231
+
232
+ btScalar TypedConstraint::applied_impulse() const
233
+ {
234
+ return constraint_->getAppliedImpulse();
235
+ }
236
+
237
+ Point2PointConstraint::Point2PointConstraint(VALUE rigid_body_a, VALUE pivot_a)
238
+ : TypedConstraint(std::make_unique<btPoint2PointConstraint>(
239
+ *rigid_body_from_value(rigid_body_a)->get(),
240
+ coerce_vector(Rice::Object(pivot_a))))
241
+ {
242
+ }
243
+
244
+ Point2PointConstraint::Point2PointConstraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE pivot_a, VALUE pivot_b)
245
+ : TypedConstraint(std::make_unique<btPoint2PointConstraint>(
246
+ *rigid_body_from_value(rigid_body_a)->get(),
247
+ *rigid_body_from_value(rigid_body_b)->get(),
248
+ coerce_vector(Rice::Object(pivot_a)),
249
+ coerce_vector(Rice::Object(pivot_b))))
250
+ {
251
+ }
252
+
253
+ btVector3 Point2PointConstraint::pivot_in_a() const
254
+ {
255
+ return point2point_from(*this)->getPivotInA();
256
+ }
257
+
258
+ btVector3 Point2PointConstraint::set_pivot_in_a(Rice::Object pivot)
259
+ {
260
+ btVector3 vector = coerce_vector(pivot);
261
+ point2point_from(*this)->setPivotA(vector);
262
+ return vector;
263
+ }
264
+
265
+ btVector3 Point2PointConstraint::pivot_in_b() const
266
+ {
267
+ return point2point_from(*this)->getPivotInB();
268
+ }
269
+
270
+ btVector3 Point2PointConstraint::set_pivot_in_b(Rice::Object pivot)
271
+ {
272
+ btVector3 vector = coerce_vector(pivot);
273
+ point2point_from(*this)->setPivotB(vector);
274
+ return vector;
275
+ }
276
+
277
+ HingeConstraint::HingeConstraint(VALUE rigid_body_a, VALUE pivot_a, VALUE axis_a, bool use_reference_frame_a)
278
+ : TypedConstraint(std::make_unique<btHingeConstraint>(
279
+ *rigid_body_from_value(rigid_body_a)->get(),
280
+ coerce_vector(Rice::Object(pivot_a)),
281
+ coerce_vector(Rice::Object(axis_a)),
282
+ use_reference_frame_a))
283
+ {
284
+ }
285
+
286
+ HingeConstraint::HingeConstraint(VALUE rigid_body_a,
287
+ VALUE rigid_body_b,
288
+ VALUE pivot_a,
289
+ VALUE pivot_b,
290
+ VALUE axis_a,
291
+ VALUE axis_b,
292
+ bool use_reference_frame_a)
293
+ : TypedConstraint(std::make_unique<btHingeConstraint>(
294
+ *rigid_body_from_value(rigid_body_a)->get(),
295
+ *rigid_body_from_value(rigid_body_b)->get(),
296
+ coerce_vector(Rice::Object(pivot_a)),
297
+ coerce_vector(Rice::Object(pivot_b)),
298
+ coerce_vector(Rice::Object(axis_a)),
299
+ coerce_vector(Rice::Object(axis_b)),
300
+ use_reference_frame_a))
301
+ {
302
+ }
303
+
304
+ btScalar HingeConstraint::angle()
305
+ {
306
+ return hinge_from(*this)->getHingeAngle();
307
+ }
308
+
309
+ btScalar HingeConstraint::lower_limit() const
310
+ {
311
+ return hinge_from(*this)->getLowerLimit();
312
+ }
313
+
314
+ btScalar HingeConstraint::upper_limit() const
315
+ {
316
+ return hinge_from(*this)->getUpperLimit();
317
+ }
318
+
319
+ bool HingeConstraint::angular_motor_enabled()
320
+ {
321
+ return hinge_from(*this)->getEnableAngularMotor();
322
+ }
323
+
324
+ btScalar HingeConstraint::motor_target_velocity()
325
+ {
326
+ return hinge_from(*this)->getMotorTargetVelocity();
327
+ }
328
+
329
+ btScalar HingeConstraint::max_motor_impulse()
330
+ {
331
+ return hinge_from(*this)->getMaxMotorImpulse();
332
+ }
333
+
334
+ void HingeConstraint::enable_angular_motor(bool enabled, btScalar target_velocity, btScalar max_motor_impulse)
335
+ {
336
+ hinge_from(*this)->enableAngularMotor(enabled, target_velocity, max_motor_impulse);
337
+ }
338
+
339
+ void HingeConstraint::set_limit(btScalar low, btScalar high, btScalar softness, btScalar bias_factor, btScalar relaxation_factor)
340
+ {
341
+ hinge_from(*this)->setLimit(low, high, softness, bias_factor, relaxation_factor);
342
+ }
343
+
344
+ Transform HingeConstraint::frame_a() const
345
+ {
346
+ return Transform(hinge_from(*this)->getAFrame());
347
+ }
348
+
349
+ Transform HingeConstraint::frame_b() const
350
+ {
351
+ return Transform(hinge_from(*this)->getBFrame());
352
+ }
353
+
354
+ FixedConstraint::FixedConstraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE frame_a, VALUE frame_b)
355
+ : TypedConstraint(std::make_unique<btFixedConstraint>(
356
+ *rigid_body_from_value(rigid_body_a)->get(),
357
+ *rigid_body_from_value(rigid_body_b)->get(),
358
+ coerce_transform(Rice::Object(frame_a)),
359
+ coerce_transform(Rice::Object(frame_b))))
360
+ {
361
+ }
362
+
363
+ SliderConstraint::SliderConstraint(VALUE rigid_body_b, VALUE frame_b, bool use_linear_reference_frame_a)
364
+ : TypedConstraint(std::make_unique<btSliderConstraint>(
365
+ *rigid_body_from_value(rigid_body_b)->get(),
366
+ coerce_transform(Rice::Object(frame_b)),
367
+ use_linear_reference_frame_a))
368
+ {
369
+ }
370
+
371
+ SliderConstraint::SliderConstraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE frame_a, VALUE frame_b, bool use_linear_reference_frame_a)
372
+ : TypedConstraint(std::make_unique<btSliderConstraint>(
373
+ *rigid_body_from_value(rigid_body_a)->get(),
374
+ *rigid_body_from_value(rigid_body_b)->get(),
375
+ coerce_transform(Rice::Object(frame_a)),
376
+ coerce_transform(Rice::Object(frame_b)),
377
+ use_linear_reference_frame_a))
378
+ {
379
+ }
380
+
381
+ Transform SliderConstraint::frame_a() const
382
+ {
383
+ return Transform(slider_from(*this)->getFrameOffsetA());
384
+ }
385
+
386
+ Transform SliderConstraint::frame_b() const
387
+ {
388
+ return Transform(slider_from(*this)->getFrameOffsetB());
389
+ }
390
+
391
+ void SliderConstraint::set_frames(VALUE frame_a, VALUE frame_b)
392
+ {
393
+ slider_from(*this)->setFrames(coerce_transform(Rice::Object(frame_a)), coerce_transform(Rice::Object(frame_b)));
394
+ }
395
+
396
+ btScalar SliderConstraint::lower_linear_limit()
397
+ {
398
+ return slider_from(*this)->getLowerLinLimit();
399
+ }
400
+
401
+ btScalar SliderConstraint::set_lower_linear_limit(btScalar limit)
402
+ {
403
+ slider_from(*this)->setLowerLinLimit(limit);
404
+ return limit;
405
+ }
406
+
407
+ btScalar SliderConstraint::upper_linear_limit()
408
+ {
409
+ return slider_from(*this)->getUpperLinLimit();
410
+ }
411
+
412
+ btScalar SliderConstraint::set_upper_linear_limit(btScalar limit)
413
+ {
414
+ slider_from(*this)->setUpperLinLimit(limit);
415
+ return limit;
416
+ }
417
+
418
+ btScalar SliderConstraint::lower_angular_limit()
419
+ {
420
+ return slider_from(*this)->getLowerAngLimit();
421
+ }
422
+
423
+ btScalar SliderConstraint::set_lower_angular_limit(btScalar limit)
424
+ {
425
+ slider_from(*this)->setLowerAngLimit(limit);
426
+ return limit;
427
+ }
428
+
429
+ btScalar SliderConstraint::upper_angular_limit()
430
+ {
431
+ return slider_from(*this)->getUpperAngLimit();
432
+ }
433
+
434
+ btScalar SliderConstraint::set_upper_angular_limit(btScalar limit)
435
+ {
436
+ slider_from(*this)->setUpperAngLimit(limit);
437
+ return limit;
438
+ }
439
+
440
+ btScalar SliderConstraint::linear_position() const
441
+ {
442
+ return slider_from(*this)->getLinearPos();
443
+ }
444
+
445
+ btScalar SliderConstraint::angular_position() const
446
+ {
447
+ return slider_from(*this)->getAngularPos();
448
+ }
449
+
450
+ bool SliderConstraint::powered_linear_motor()
451
+ {
452
+ return slider_from(*this)->getPoweredLinMotor();
453
+ }
454
+
455
+ bool SliderConstraint::set_powered_linear_motor(bool enabled)
456
+ {
457
+ slider_from(*this)->setPoweredLinMotor(enabled);
458
+ return enabled;
459
+ }
460
+
461
+ btScalar SliderConstraint::target_linear_motor_velocity()
462
+ {
463
+ return slider_from(*this)->getTargetLinMotorVelocity();
464
+ }
465
+
466
+ btScalar SliderConstraint::set_target_linear_motor_velocity(btScalar velocity)
467
+ {
468
+ slider_from(*this)->setTargetLinMotorVelocity(velocity);
469
+ return velocity;
470
+ }
471
+
472
+ btScalar SliderConstraint::max_linear_motor_force()
473
+ {
474
+ return slider_from(*this)->getMaxLinMotorForce();
475
+ }
476
+
477
+ btScalar SliderConstraint::set_max_linear_motor_force(btScalar force)
478
+ {
479
+ slider_from(*this)->setMaxLinMotorForce(force);
480
+ return force;
481
+ }
482
+
483
+ bool SliderConstraint::powered_angular_motor()
484
+ {
485
+ return slider_from(*this)->getPoweredAngMotor();
486
+ }
487
+
488
+ bool SliderConstraint::set_powered_angular_motor(bool enabled)
489
+ {
490
+ slider_from(*this)->setPoweredAngMotor(enabled);
491
+ return enabled;
492
+ }
493
+
494
+ btScalar SliderConstraint::target_angular_motor_velocity()
495
+ {
496
+ return slider_from(*this)->getTargetAngMotorVelocity();
497
+ }
498
+
499
+ btScalar SliderConstraint::set_target_angular_motor_velocity(btScalar velocity)
500
+ {
501
+ slider_from(*this)->setTargetAngMotorVelocity(velocity);
502
+ return velocity;
503
+ }
504
+
505
+ btScalar SliderConstraint::max_angular_motor_force()
506
+ {
507
+ return slider_from(*this)->getMaxAngMotorForce();
508
+ }
509
+
510
+ btScalar SliderConstraint::set_max_angular_motor_force(btScalar force)
511
+ {
512
+ slider_from(*this)->setMaxAngMotorForce(force);
513
+ return force;
514
+ }
515
+
516
+ ConeTwistConstraint::ConeTwistConstraint(VALUE rigid_body_a, VALUE frame_a)
517
+ : TypedConstraint(std::make_unique<btConeTwistConstraint>(
518
+ *rigid_body_from_value(rigid_body_a)->get(),
519
+ coerce_transform(Rice::Object(frame_a))))
520
+ {
521
+ }
522
+
523
+ ConeTwistConstraint::ConeTwistConstraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE frame_a, VALUE frame_b)
524
+ : TypedConstraint(std::make_unique<btConeTwistConstraint>(
525
+ *rigid_body_from_value(rigid_body_a)->get(),
526
+ *rigid_body_from_value(rigid_body_b)->get(),
527
+ coerce_transform(Rice::Object(frame_a)),
528
+ coerce_transform(Rice::Object(frame_b))))
529
+ {
530
+ }
531
+
532
+ void ConeTwistConstraint::set_limit(btScalar swing_span1, btScalar swing_span2, btScalar twist_span, btScalar softness, btScalar bias_factor, btScalar relaxation_factor)
533
+ {
534
+ cone_twist_from(*this)->setLimit(swing_span1, swing_span2, twist_span, softness, bias_factor, relaxation_factor);
535
+ }
536
+
537
+ btScalar ConeTwistConstraint::swing_span1() const
538
+ {
539
+ return cone_twist_from(*this)->getSwingSpan1();
540
+ }
541
+
542
+ btScalar ConeTwistConstraint::swing_span2() const
543
+ {
544
+ return cone_twist_from(*this)->getSwingSpan2();
545
+ }
546
+
547
+ btScalar ConeTwistConstraint::twist_span() const
548
+ {
549
+ return cone_twist_from(*this)->getTwistSpan();
550
+ }
551
+
552
+ btScalar ConeTwistConstraint::limit_softness() const
553
+ {
554
+ return cone_twist_from(*this)->getLimitSoftness();
555
+ }
556
+
557
+ btScalar ConeTwistConstraint::bias_factor() const
558
+ {
559
+ return cone_twist_from(*this)->getBiasFactor();
560
+ }
561
+
562
+ btScalar ConeTwistConstraint::relaxation_factor() const
563
+ {
564
+ return cone_twist_from(*this)->getRelaxationFactor();
565
+ }
566
+
567
+ btScalar ConeTwistConstraint::twist_angle() const
568
+ {
569
+ return cone_twist_from(*this)->getTwistAngle();
570
+ }
571
+
572
+ bool ConeTwistConstraint::angular_only() const
573
+ {
574
+ return cone_twist_from(*this)->getAngularOnly();
575
+ }
576
+
577
+ bool ConeTwistConstraint::set_angular_only(bool angular_only)
578
+ {
579
+ cone_twist_from(*this)->setAngularOnly(angular_only);
580
+ return angular_only;
581
+ }
582
+
583
+ btScalar ConeTwistConstraint::damping() const
584
+ {
585
+ return cone_twist_from(*this)->getDamping();
586
+ }
587
+
588
+ btScalar ConeTwistConstraint::set_damping(btScalar damping)
589
+ {
590
+ cone_twist_from(*this)->setDamping(damping);
591
+ return damping;
592
+ }
593
+
594
+ bool ConeTwistConstraint::motor_enabled() const
595
+ {
596
+ return cone_twist_from(*this)->isMotorEnabled();
597
+ }
598
+
599
+ void ConeTwistConstraint::enable_motor(bool enabled)
600
+ {
601
+ cone_twist_from(*this)->enableMotor(enabled);
602
+ }
603
+
604
+ btScalar ConeTwistConstraint::max_motor_impulse() const
605
+ {
606
+ return cone_twist_from(*this)->getMaxMotorImpulse();
607
+ }
608
+
609
+ btScalar ConeTwistConstraint::set_max_motor_impulse(btScalar impulse)
610
+ {
611
+ cone_twist_from(*this)->setMaxMotorImpulse(impulse);
612
+ return impulse;
613
+ }
614
+
615
+ btQuaternion ConeTwistConstraint::motor_target() const
616
+ {
617
+ return cone_twist_from(*this)->getMotorTarget();
618
+ }
619
+
620
+ btQuaternion ConeTwistConstraint::set_motor_target(Rice::Object target)
621
+ {
622
+ btQuaternion quaternion = coerce_quaternion(target);
623
+ cone_twist_from(*this)->setMotorTarget(quaternion);
624
+ return quaternion;
625
+ }
626
+
627
+ Transform ConeTwistConstraint::frame_a() const
628
+ {
629
+ return Transform(cone_twist_from(*this)->getAFrame());
630
+ }
631
+
632
+ Transform ConeTwistConstraint::frame_b() const
633
+ {
634
+ return Transform(cone_twist_from(*this)->getBFrame());
635
+ }
636
+
637
+ Generic6DofConstraint::Generic6DofConstraint(VALUE rigid_body_b, VALUE frame_b, bool use_linear_reference_frame_b)
638
+ : TypedConstraint(std::make_unique<btGeneric6DofConstraint>(
639
+ *rigid_body_from_value(rigid_body_b)->get(),
640
+ coerce_transform(Rice::Object(frame_b)),
641
+ use_linear_reference_frame_b))
642
+ {
643
+ }
644
+
645
+ Generic6DofConstraint::Generic6DofConstraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE frame_a, VALUE frame_b, bool use_linear_reference_frame_a)
646
+ : TypedConstraint(std::make_unique<btGeneric6DofConstraint>(
647
+ *rigid_body_from_value(rigid_body_a)->get(),
648
+ *rigid_body_from_value(rigid_body_b)->get(),
649
+ coerce_transform(Rice::Object(frame_a)),
650
+ coerce_transform(Rice::Object(frame_b)),
651
+ use_linear_reference_frame_a))
652
+ {
653
+ }
654
+
655
+ Transform Generic6DofConstraint::frame_a() const
656
+ {
657
+ return Transform(generic_6dof_from(*this)->getFrameOffsetA());
658
+ }
659
+
660
+ Transform Generic6DofConstraint::frame_b() const
661
+ {
662
+ return Transform(generic_6dof_from(*this)->getFrameOffsetB());
663
+ }
664
+
665
+ void Generic6DofConstraint::set_frames(VALUE frame_a, VALUE frame_b)
666
+ {
667
+ generic_6dof_from(*this)->setFrames(coerce_transform(Rice::Object(frame_a)), coerce_transform(Rice::Object(frame_b)));
668
+ }
669
+
670
+ btVector3 Generic6DofConstraint::linear_lower_limit() const
671
+ {
672
+ btVector3 limit;
673
+ generic_6dof_from(*this)->getLinearLowerLimit(limit);
674
+ return limit;
675
+ }
676
+
677
+ btVector3 Generic6DofConstraint::set_linear_lower_limit(Rice::Object limit)
678
+ {
679
+ btVector3 vector = coerce_vector(limit);
680
+ generic_6dof_from(*this)->setLinearLowerLimit(vector);
681
+ return vector;
682
+ }
683
+
684
+ btVector3 Generic6DofConstraint::linear_upper_limit() const
685
+ {
686
+ btVector3 limit;
687
+ generic_6dof_from(*this)->getLinearUpperLimit(limit);
688
+ return limit;
689
+ }
690
+
691
+ btVector3 Generic6DofConstraint::set_linear_upper_limit(Rice::Object limit)
692
+ {
693
+ btVector3 vector = coerce_vector(limit);
694
+ generic_6dof_from(*this)->setLinearUpperLimit(vector);
695
+ return vector;
696
+ }
697
+
698
+ btVector3 Generic6DofConstraint::angular_lower_limit() const
699
+ {
700
+ btVector3 limit;
701
+ generic_6dof_from(*this)->getAngularLowerLimit(limit);
702
+ return limit;
703
+ }
704
+
705
+ btVector3 Generic6DofConstraint::set_angular_lower_limit(Rice::Object limit)
706
+ {
707
+ btVector3 vector = coerce_vector(limit);
708
+ generic_6dof_from(*this)->setAngularLowerLimit(vector);
709
+ return vector;
710
+ }
711
+
712
+ btVector3 Generic6DofConstraint::angular_upper_limit() const
713
+ {
714
+ btVector3 limit;
715
+ generic_6dof_from(*this)->getAngularUpperLimit(limit);
716
+ return limit;
717
+ }
718
+
719
+ btVector3 Generic6DofConstraint::set_angular_upper_limit(Rice::Object limit)
720
+ {
721
+ btVector3 vector = coerce_vector(limit);
722
+ generic_6dof_from(*this)->setAngularUpperLimit(vector);
723
+ return vector;
724
+ }
725
+
726
+ void Generic6DofConstraint::set_limit(int axis, btScalar low, btScalar high)
727
+ {
728
+ generic_6dof_from(*this)->setLimit(validate_dof_axis(axis), low, high);
729
+ }
730
+
731
+ bool Generic6DofConstraint::limited(int axis) const
732
+ {
733
+ return generic_6dof_from(*this)->isLimited(validate_dof_axis(axis));
734
+ }
735
+
736
+ btVector3 Generic6DofConstraint::axis(int axis) const
737
+ {
738
+ return generic_6dof_from(*this)->getAxis(validate_spatial_axis(axis));
739
+ }
740
+
741
+ btScalar Generic6DofConstraint::angle(int axis) const
742
+ {
743
+ return generic_6dof_from(*this)->getAngle(validate_spatial_axis(axis));
744
+ }
745
+
746
+ btScalar Generic6DofConstraint::relative_pivot_position(int axis) const
747
+ {
748
+ return generic_6dof_from(*this)->getRelativePivotPosition(validate_spatial_axis(axis));
749
+ }
750
+
751
+ bool Generic6DofConstraint::use_frame_offset() const
752
+ {
753
+ return generic_6dof_from(*this)->getUseFrameOffset();
754
+ }
755
+
756
+ bool Generic6DofConstraint::set_use_frame_offset(bool enabled)
757
+ {
758
+ generic_6dof_from(*this)->setUseFrameOffset(enabled);
759
+ return enabled;
760
+ }
761
+
762
+ bool Generic6DofConstraint::use_linear_reference_frame_a() const
763
+ {
764
+ return generic_6dof_from(*this)->getUseLinearReferenceFrameA();
765
+ }
766
+
767
+ bool Generic6DofConstraint::set_use_linear_reference_frame_a(bool enabled)
768
+ {
769
+ generic_6dof_from(*this)->setUseLinearReferenceFrameA(enabled);
770
+ return enabled;
771
+ }
772
+
773
+ void Generic6DofConstraint::set_axis(Rice::Object axis1, Rice::Object axis2)
774
+ {
775
+ generic_6dof_from(*this)->setAxis(coerce_vector(axis1), coerce_vector(axis2));
776
+ }
777
+
778
+ Generic6DofSpring2Constraint::Generic6DofSpring2Constraint(VALUE rigid_body_b, VALUE frame_b, int rotate_order)
779
+ : TypedConstraint(std::make_unique<btGeneric6DofSpring2Constraint>(
780
+ *rigid_body_from_value(rigid_body_b)->get(),
781
+ coerce_transform(Rice::Object(frame_b)),
782
+ rotate_order_from_int(rotate_order)))
783
+ {
784
+ }
785
+
786
+ Generic6DofSpring2Constraint::Generic6DofSpring2Constraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE frame_a, VALUE frame_b, int rotate_order)
787
+ : TypedConstraint(std::make_unique<btGeneric6DofSpring2Constraint>(
788
+ *rigid_body_from_value(rigid_body_a)->get(),
789
+ *rigid_body_from_value(rigid_body_b)->get(),
790
+ coerce_transform(Rice::Object(frame_a)),
791
+ coerce_transform(Rice::Object(frame_b)),
792
+ rotate_order_from_int(rotate_order)))
793
+ {
794
+ }
795
+
796
+ Transform Generic6DofSpring2Constraint::frame_a() const
797
+ {
798
+ return Transform(generic_6dof_spring2_from(*this)->getFrameOffsetA());
799
+ }
800
+
801
+ Transform Generic6DofSpring2Constraint::frame_b() const
802
+ {
803
+ return Transform(generic_6dof_spring2_from(*this)->getFrameOffsetB());
804
+ }
805
+
806
+ void Generic6DofSpring2Constraint::set_frames(VALUE frame_a, VALUE frame_b)
807
+ {
808
+ generic_6dof_spring2_from(*this)->setFrames(coerce_transform(Rice::Object(frame_a)), coerce_transform(Rice::Object(frame_b)));
809
+ }
810
+
811
+ btVector3 Generic6DofSpring2Constraint::linear_lower_limit() const
812
+ {
813
+ btVector3 limit;
814
+ generic_6dof_spring2_from(*this)->getLinearLowerLimit(limit);
815
+ return limit;
816
+ }
817
+
818
+ btVector3 Generic6DofSpring2Constraint::set_linear_lower_limit(Rice::Object limit)
819
+ {
820
+ btVector3 vector = coerce_vector(limit);
821
+ generic_6dof_spring2_from(*this)->setLinearLowerLimit(vector);
822
+ return vector;
823
+ }
824
+
825
+ btVector3 Generic6DofSpring2Constraint::linear_upper_limit() const
826
+ {
827
+ btVector3 limit;
828
+ generic_6dof_spring2_from(*this)->getLinearUpperLimit(limit);
829
+ return limit;
830
+ }
831
+
832
+ btVector3 Generic6DofSpring2Constraint::set_linear_upper_limit(Rice::Object limit)
833
+ {
834
+ btVector3 vector = coerce_vector(limit);
835
+ generic_6dof_spring2_from(*this)->setLinearUpperLimit(vector);
836
+ return vector;
837
+ }
838
+
839
+ btVector3 Generic6DofSpring2Constraint::angular_lower_limit() const
840
+ {
841
+ btVector3 limit;
842
+ generic_6dof_spring2_from(*this)->getAngularLowerLimit(limit);
843
+ return limit;
844
+ }
845
+
846
+ btVector3 Generic6DofSpring2Constraint::set_angular_lower_limit(Rice::Object limit)
847
+ {
848
+ btVector3 vector = coerce_vector(limit);
849
+ generic_6dof_spring2_from(*this)->setAngularLowerLimit(vector);
850
+ return vector;
851
+ }
852
+
853
+ btVector3 Generic6DofSpring2Constraint::angular_upper_limit() const
854
+ {
855
+ btVector3 limit;
856
+ generic_6dof_spring2_from(*this)->getAngularUpperLimit(limit);
857
+ return limit;
858
+ }
859
+
860
+ btVector3 Generic6DofSpring2Constraint::set_angular_upper_limit(Rice::Object limit)
861
+ {
862
+ btVector3 vector = coerce_vector(limit);
863
+ generic_6dof_spring2_from(*this)->setAngularUpperLimit(vector);
864
+ return vector;
865
+ }
866
+
867
+ void Generic6DofSpring2Constraint::set_limit(int axis, btScalar low, btScalar high)
868
+ {
869
+ generic_6dof_spring2_from(*this)->setLimit(validate_dof_axis(axis), low, high);
870
+ }
871
+
872
+ bool Generic6DofSpring2Constraint::limited(int axis)
873
+ {
874
+ return generic_6dof_spring2_from(*this)->isLimited(validate_dof_axis(axis));
875
+ }
876
+
877
+ btVector3 Generic6DofSpring2Constraint::axis(int axis) const
878
+ {
879
+ return generic_6dof_spring2_from(*this)->getAxis(validate_spatial_axis(axis));
880
+ }
881
+
882
+ btScalar Generic6DofSpring2Constraint::angle(int axis) const
883
+ {
884
+ return generic_6dof_spring2_from(*this)->getAngle(validate_spatial_axis(axis));
885
+ }
886
+
887
+ btScalar Generic6DofSpring2Constraint::relative_pivot_position(int axis) const
888
+ {
889
+ return generic_6dof_spring2_from(*this)->getRelativePivotPosition(validate_spatial_axis(axis));
890
+ }
891
+
892
+ int Generic6DofSpring2Constraint::rotation_order()
893
+ {
894
+ return static_cast<int>(generic_6dof_spring2_from(*this)->getRotationOrder());
895
+ }
896
+
897
+ int Generic6DofSpring2Constraint::set_rotation_order(int rotate_order)
898
+ {
899
+ generic_6dof_spring2_from(*this)->setRotationOrder(rotate_order_from_int(rotate_order));
900
+ return rotate_order;
901
+ }
902
+
903
+ void Generic6DofSpring2Constraint::set_axis(Rice::Object axis1, Rice::Object axis2)
904
+ {
905
+ generic_6dof_spring2_from(*this)->setAxis(coerce_vector(axis1), coerce_vector(axis2));
906
+ }
907
+
908
+ void Generic6DofSpring2Constraint::enable_motor(int axis, bool enabled)
909
+ {
910
+ generic_6dof_spring2_from(*this)->enableMotor(validate_dof_axis(axis), enabled);
911
+ }
912
+
913
+ void Generic6DofSpring2Constraint::set_servo(int axis, bool enabled)
914
+ {
915
+ generic_6dof_spring2_from(*this)->setServo(validate_dof_axis(axis), enabled);
916
+ }
917
+
918
+ void Generic6DofSpring2Constraint::set_target_velocity(int axis, btScalar velocity)
919
+ {
920
+ generic_6dof_spring2_from(*this)->setTargetVelocity(validate_dof_axis(axis), velocity);
921
+ }
922
+
923
+ void Generic6DofSpring2Constraint::set_servo_target(int axis, btScalar target)
924
+ {
925
+ generic_6dof_spring2_from(*this)->setServoTarget(validate_dof_axis(axis), target);
926
+ }
927
+
928
+ void Generic6DofSpring2Constraint::set_max_motor_force(int axis, btScalar force)
929
+ {
930
+ generic_6dof_spring2_from(*this)->setMaxMotorForce(validate_dof_axis(axis), force);
931
+ }
932
+
933
+ void Generic6DofSpring2Constraint::enable_spring(int axis, bool enabled)
934
+ {
935
+ generic_6dof_spring2_from(*this)->enableSpring(validate_dof_axis(axis), enabled);
936
+ }
937
+
938
+ void Generic6DofSpring2Constraint::set_stiffness(int axis, btScalar stiffness, bool limit_if_needed)
939
+ {
940
+ generic_6dof_spring2_from(*this)->setStiffness(validate_dof_axis(axis), stiffness, limit_if_needed);
941
+ }
942
+
943
+ void Generic6DofSpring2Constraint::set_damping(int axis, btScalar damping, bool limit_if_needed)
944
+ {
945
+ generic_6dof_spring2_from(*this)->setDamping(validate_dof_axis(axis), damping, limit_if_needed);
946
+ }
947
+
948
+ void Generic6DofSpring2Constraint::set_equilibrium_point()
949
+ {
950
+ generic_6dof_spring2_from(*this)->setEquilibriumPoint();
951
+ }
952
+
953
+ void Generic6DofSpring2Constraint::set_axis_equilibrium_point(int axis)
954
+ {
955
+ generic_6dof_spring2_from(*this)->setEquilibriumPoint(validate_dof_axis(axis));
956
+ }
957
+
958
+ void Generic6DofSpring2Constraint::set_axis_equilibrium_point_value(int axis, btScalar value)
959
+ {
960
+ generic_6dof_spring2_from(*this)->setEquilibriumPoint(validate_dof_axis(axis), value);
961
+ }
962
+
963
+ GearConstraint::GearConstraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE axis_a, VALUE axis_b, btScalar ratio)
964
+ : TypedConstraint(std::make_unique<btGearConstraint>(
965
+ *rigid_body_from_value(rigid_body_a)->get(),
966
+ *rigid_body_from_value(rigid_body_b)->get(),
967
+ coerce_vector(Rice::Object(axis_a)),
968
+ coerce_vector(Rice::Object(axis_b)),
969
+ ratio))
970
+ {
971
+ }
972
+
973
+ btVector3 GearConstraint::axis_a() const
974
+ {
975
+ return gear_from(*this)->getAxisA();
976
+ }
977
+
978
+ btVector3 GearConstraint::set_axis_a(Rice::Object axis)
979
+ {
980
+ btVector3 vector = coerce_vector(axis);
981
+ gear_from(*this)->setAxisA(vector);
982
+ return vector;
983
+ }
984
+
985
+ btVector3 GearConstraint::axis_b() const
986
+ {
987
+ return gear_from(*this)->getAxisB();
988
+ }
989
+
990
+ btVector3 GearConstraint::set_axis_b(Rice::Object axis)
991
+ {
992
+ btVector3 vector = coerce_vector(axis);
993
+ gear_from(*this)->setAxisB(vector);
994
+ return vector;
995
+ }
996
+
997
+ btScalar GearConstraint::ratio() const
998
+ {
999
+ return gear_from(*this)->getRatio();
1000
+ }
1001
+
1002
+ btScalar GearConstraint::set_ratio(btScalar ratio)
1003
+ {
1004
+ gear_from(*this)->setRatio(ratio);
1005
+ return ratio;
1006
+ }
1007
+
1008
+ Hinge2Constraint::Hinge2Constraint(VALUE rigid_body_a, VALUE rigid_body_b, VALUE anchor, VALUE axis1, VALUE axis2)
1009
+ : TypedConstraint(make_hinge2_constraint(rigid_body_a, rigid_body_b, anchor, axis1, axis2))
1010
+ {
1011
+ }
1012
+
1013
+ btVector3 Hinge2Constraint::anchor()
1014
+ {
1015
+ return hinge2_from(*this)->getAnchor();
1016
+ }
1017
+
1018
+ btVector3 Hinge2Constraint::anchor2()
1019
+ {
1020
+ return hinge2_from(*this)->getAnchor2();
1021
+ }
1022
+
1023
+ btVector3 Hinge2Constraint::axis1()
1024
+ {
1025
+ return hinge2_from(*this)->getAxis1();
1026
+ }
1027
+
1028
+ btVector3 Hinge2Constraint::axis2()
1029
+ {
1030
+ return hinge2_from(*this)->getAxis2();
1031
+ }
1032
+
1033
+ btScalar Hinge2Constraint::angle1()
1034
+ {
1035
+ return hinge2_from(*this)->getAngle1();
1036
+ }
1037
+
1038
+ btScalar Hinge2Constraint::angle2()
1039
+ {
1040
+ return hinge2_from(*this)->getAngle2();
1041
+ }
1042
+
1043
+ void Hinge2Constraint::set_upper_limit(btScalar limit)
1044
+ {
1045
+ hinge2_from(*this)->setUpperLimit(limit);
1046
+ }
1047
+
1048
+ void Hinge2Constraint::set_lower_limit(btScalar limit)
1049
+ {
1050
+ hinge2_from(*this)->setLowerLimit(limit);
1051
+ }
1052
+ } // namespace bullet3
1053
+
1054
+ void Init_Constraints(Rice::Module rb_mBullet)
1055
+ {
1056
+ Rice::Module rb_mConstraints = Rice::define_module_under(rb_mBullet, "Constraints");
1057
+
1058
+ Rice::define_class_under<bullet3::TypedConstraint>(rb_mConstraints, "TypedConstraint")
1059
+ .define_method("constraint_type", &bullet3::TypedConstraint::constraint_type)
1060
+ .define_method("enabled?", &bullet3::TypedConstraint::enabled)
1061
+ .define_method("enabled=", &bullet3::TypedConstraint::set_enabled)
1062
+ .define_method("breaking_impulse_threshold", &bullet3::TypedConstraint::breaking_impulse_threshold)
1063
+ .define_method("breaking_impulse_threshold=", &bullet3::TypedConstraint::set_breaking_impulse_threshold)
1064
+ .define_method("debug_draw_size", &bullet3::TypedConstraint::debug_draw_size)
1065
+ .define_method("debug_draw_size=", &bullet3::TypedConstraint::set_debug_draw_size)
1066
+ .define_method("enable_feedback", &bullet3::TypedConstraint::enable_feedback)
1067
+ .define_method("needs_feedback?", &bullet3::TypedConstraint::needs_feedback)
1068
+ .define_method("applied_impulse", &bullet3::TypedConstraint::applied_impulse);
1069
+
1070
+ Rice::define_class_under<bullet3::Point2PointConstraint, bullet3::TypedConstraint>(rb_mConstraints, "Point2PointConstraint")
1071
+ .define_constructor(Rice::Constructor<bullet3::Point2PointConstraint, VALUE, VALUE>(),
1072
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1073
+ Rice::Arg("pivot_a").setValue())
1074
+ .define_constructor(Rice::Constructor<bullet3::Point2PointConstraint, VALUE, VALUE, VALUE, VALUE>(),
1075
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1076
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1077
+ Rice::Arg("pivot_a").setValue(),
1078
+ Rice::Arg("pivot_b").setValue())
1079
+ .define_method("pivot_in_a", &bullet3::Point2PointConstraint::pivot_in_a)
1080
+ .define_method("pivot_in_a=", &bullet3::Point2PointConstraint::set_pivot_in_a)
1081
+ .define_method("pivot_in_b", &bullet3::Point2PointConstraint::pivot_in_b)
1082
+ .define_method("pivot_in_b=", &bullet3::Point2PointConstraint::set_pivot_in_b);
1083
+
1084
+ Rice::define_class_under<bullet3::HingeConstraint, bullet3::TypedConstraint>(rb_mConstraints, "HingeConstraint")
1085
+ .define_constructor(Rice::Constructor<bullet3::HingeConstraint, VALUE, VALUE, VALUE, bool>(),
1086
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1087
+ Rice::Arg("pivot_a").setValue(),
1088
+ Rice::Arg("axis_a").setValue(),
1089
+ Rice::Arg("use_reference_frame_a") = false)
1090
+ .define_constructor(Rice::Constructor<bullet3::HingeConstraint, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, bool>(),
1091
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1092
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1093
+ Rice::Arg("pivot_a").setValue(),
1094
+ Rice::Arg("pivot_b").setValue(),
1095
+ Rice::Arg("axis_a").setValue(),
1096
+ Rice::Arg("axis_b").setValue(),
1097
+ Rice::Arg("use_reference_frame_a") = false)
1098
+ .define_method("angle", &bullet3::HingeConstraint::angle)
1099
+ .define_method("lower_limit", &bullet3::HingeConstraint::lower_limit)
1100
+ .define_method("upper_limit", &bullet3::HingeConstraint::upper_limit)
1101
+ .define_method("angular_motor_enabled?", &bullet3::HingeConstraint::angular_motor_enabled)
1102
+ .define_method("motor_target_velocity", &bullet3::HingeConstraint::motor_target_velocity)
1103
+ .define_method("max_motor_impulse", &bullet3::HingeConstraint::max_motor_impulse)
1104
+ .define_method("enable_angular_motor", &bullet3::HingeConstraint::enable_angular_motor)
1105
+ .define_method("set_limit", &bullet3::HingeConstraint::set_limit,
1106
+ Rice::Arg("low"),
1107
+ Rice::Arg("high"),
1108
+ Rice::Arg("softness") = btScalar(0.9),
1109
+ Rice::Arg("bias_factor") = btScalar(0.3),
1110
+ Rice::Arg("relaxation_factor") = btScalar(1.0))
1111
+ .define_method("frame_a", &bullet3::HingeConstraint::frame_a)
1112
+ .define_method("frame_b", &bullet3::HingeConstraint::frame_b);
1113
+
1114
+ Rice::define_class_under<bullet3::FixedConstraint, bullet3::TypedConstraint>(rb_mConstraints, "FixedConstraint")
1115
+ .define_constructor(Rice::Constructor<bullet3::FixedConstraint, VALUE, VALUE, VALUE, VALUE>(),
1116
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1117
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1118
+ Rice::Arg("frame_a").setValue(),
1119
+ Rice::Arg("frame_b").setValue());
1120
+
1121
+ Rice::define_class_under<bullet3::SliderConstraint, bullet3::TypedConstraint>(rb_mConstraints, "SliderConstraint")
1122
+ .define_constructor(Rice::Constructor<bullet3::SliderConstraint, VALUE, VALUE, bool>(),
1123
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1124
+ Rice::Arg("frame_b").setValue(),
1125
+ Rice::Arg("use_linear_reference_frame_a") = true)
1126
+ .define_constructor(Rice::Constructor<bullet3::SliderConstraint, VALUE, VALUE, VALUE, VALUE, bool>(),
1127
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1128
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1129
+ Rice::Arg("frame_a").setValue(),
1130
+ Rice::Arg("frame_b").setValue(),
1131
+ Rice::Arg("use_linear_reference_frame_a") = true)
1132
+ .define_method("frame_a", &bullet3::SliderConstraint::frame_a)
1133
+ .define_method("frame_b", &bullet3::SliderConstraint::frame_b)
1134
+ .define_method("set_frames", &bullet3::SliderConstraint::set_frames,
1135
+ Rice::Arg("frame_a").setValue(),
1136
+ Rice::Arg("frame_b").setValue())
1137
+ .define_method("lower_linear_limit", &bullet3::SliderConstraint::lower_linear_limit)
1138
+ .define_method("lower_linear_limit=", &bullet3::SliderConstraint::set_lower_linear_limit)
1139
+ .define_method("upper_linear_limit", &bullet3::SliderConstraint::upper_linear_limit)
1140
+ .define_method("upper_linear_limit=", &bullet3::SliderConstraint::set_upper_linear_limit)
1141
+ .define_method("lower_angular_limit", &bullet3::SliderConstraint::lower_angular_limit)
1142
+ .define_method("lower_angular_limit=", &bullet3::SliderConstraint::set_lower_angular_limit)
1143
+ .define_method("upper_angular_limit", &bullet3::SliderConstraint::upper_angular_limit)
1144
+ .define_method("upper_angular_limit=", &bullet3::SliderConstraint::set_upper_angular_limit)
1145
+ .define_method("linear_position", &bullet3::SliderConstraint::linear_position)
1146
+ .define_method("angular_position", &bullet3::SliderConstraint::angular_position)
1147
+ .define_method("powered_linear_motor?", &bullet3::SliderConstraint::powered_linear_motor)
1148
+ .define_method("powered_linear_motor=", &bullet3::SliderConstraint::set_powered_linear_motor)
1149
+ .define_method("target_linear_motor_velocity", &bullet3::SliderConstraint::target_linear_motor_velocity)
1150
+ .define_method("target_linear_motor_velocity=", &bullet3::SliderConstraint::set_target_linear_motor_velocity)
1151
+ .define_method("max_linear_motor_force", &bullet3::SliderConstraint::max_linear_motor_force)
1152
+ .define_method("max_linear_motor_force=", &bullet3::SliderConstraint::set_max_linear_motor_force)
1153
+ .define_method("powered_angular_motor?", &bullet3::SliderConstraint::powered_angular_motor)
1154
+ .define_method("powered_angular_motor=", &bullet3::SliderConstraint::set_powered_angular_motor)
1155
+ .define_method("target_angular_motor_velocity", &bullet3::SliderConstraint::target_angular_motor_velocity)
1156
+ .define_method("target_angular_motor_velocity=", &bullet3::SliderConstraint::set_target_angular_motor_velocity)
1157
+ .define_method("max_angular_motor_force", &bullet3::SliderConstraint::max_angular_motor_force)
1158
+ .define_method("max_angular_motor_force=", &bullet3::SliderConstraint::set_max_angular_motor_force);
1159
+
1160
+ Rice::define_class_under<bullet3::ConeTwistConstraint, bullet3::TypedConstraint>(rb_mConstraints, "ConeTwistConstraint")
1161
+ .define_constructor(Rice::Constructor<bullet3::ConeTwistConstraint, VALUE, VALUE>(),
1162
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1163
+ Rice::Arg("frame_a").setValue())
1164
+ .define_constructor(Rice::Constructor<bullet3::ConeTwistConstraint, VALUE, VALUE, VALUE, VALUE>(),
1165
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1166
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1167
+ Rice::Arg("frame_a").setValue(),
1168
+ Rice::Arg("frame_b").setValue())
1169
+ .define_method("set_limit", &bullet3::ConeTwistConstraint::set_limit,
1170
+ Rice::Arg("swing_span1"),
1171
+ Rice::Arg("swing_span2"),
1172
+ Rice::Arg("twist_span"),
1173
+ Rice::Arg("softness") = btScalar(1.0),
1174
+ Rice::Arg("bias_factor") = btScalar(0.3),
1175
+ Rice::Arg("relaxation_factor") = btScalar(1.0))
1176
+ .define_method("swing_span1", &bullet3::ConeTwistConstraint::swing_span1)
1177
+ .define_method("swing_span2", &bullet3::ConeTwistConstraint::swing_span2)
1178
+ .define_method("twist_span", &bullet3::ConeTwistConstraint::twist_span)
1179
+ .define_method("limit_softness", &bullet3::ConeTwistConstraint::limit_softness)
1180
+ .define_method("bias_factor", &bullet3::ConeTwistConstraint::bias_factor)
1181
+ .define_method("relaxation_factor", &bullet3::ConeTwistConstraint::relaxation_factor)
1182
+ .define_method("twist_angle", &bullet3::ConeTwistConstraint::twist_angle)
1183
+ .define_method("angular_only?", &bullet3::ConeTwistConstraint::angular_only)
1184
+ .define_method("angular_only=", &bullet3::ConeTwistConstraint::set_angular_only)
1185
+ .define_method("damping", &bullet3::ConeTwistConstraint::damping)
1186
+ .define_method("damping=", &bullet3::ConeTwistConstraint::set_damping)
1187
+ .define_method("motor_enabled?", &bullet3::ConeTwistConstraint::motor_enabled)
1188
+ .define_method("enable_motor", &bullet3::ConeTwistConstraint::enable_motor)
1189
+ .define_method("max_motor_impulse", &bullet3::ConeTwistConstraint::max_motor_impulse)
1190
+ .define_method("max_motor_impulse=", &bullet3::ConeTwistConstraint::set_max_motor_impulse)
1191
+ .define_method("motor_target", &bullet3::ConeTwistConstraint::motor_target)
1192
+ .define_method("motor_target=", &bullet3::ConeTwistConstraint::set_motor_target)
1193
+ .define_method("frame_a", &bullet3::ConeTwistConstraint::frame_a)
1194
+ .define_method("frame_b", &bullet3::ConeTwistConstraint::frame_b);
1195
+
1196
+ Rice::define_class_under<bullet3::Generic6DofConstraint, bullet3::TypedConstraint>(rb_mConstraints, "Generic6DofConstraint")
1197
+ .define_constructor(Rice::Constructor<bullet3::Generic6DofConstraint, VALUE, VALUE, bool>(),
1198
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1199
+ Rice::Arg("frame_b").setValue(),
1200
+ Rice::Arg("use_linear_reference_frame_b") = true)
1201
+ .define_constructor(Rice::Constructor<bullet3::Generic6DofConstraint, VALUE, VALUE, VALUE, VALUE, bool>(),
1202
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1203
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1204
+ Rice::Arg("frame_a").setValue(),
1205
+ Rice::Arg("frame_b").setValue(),
1206
+ Rice::Arg("use_linear_reference_frame_a") = true)
1207
+ .define_method("frame_a", &bullet3::Generic6DofConstraint::frame_a)
1208
+ .define_method("frame_b", &bullet3::Generic6DofConstraint::frame_b)
1209
+ .define_method("set_frames", &bullet3::Generic6DofConstraint::set_frames,
1210
+ Rice::Arg("frame_a").setValue(),
1211
+ Rice::Arg("frame_b").setValue())
1212
+ .define_method("linear_lower_limit", &bullet3::Generic6DofConstraint::linear_lower_limit)
1213
+ .define_method("linear_lower_limit=", &bullet3::Generic6DofConstraint::set_linear_lower_limit)
1214
+ .define_method("linear_upper_limit", &bullet3::Generic6DofConstraint::linear_upper_limit)
1215
+ .define_method("linear_upper_limit=", &bullet3::Generic6DofConstraint::set_linear_upper_limit)
1216
+ .define_method("angular_lower_limit", &bullet3::Generic6DofConstraint::angular_lower_limit)
1217
+ .define_method("angular_lower_limit=", &bullet3::Generic6DofConstraint::set_angular_lower_limit)
1218
+ .define_method("angular_upper_limit", &bullet3::Generic6DofConstraint::angular_upper_limit)
1219
+ .define_method("angular_upper_limit=", &bullet3::Generic6DofConstraint::set_angular_upper_limit)
1220
+ .define_method("set_limit", &bullet3::Generic6DofConstraint::set_limit)
1221
+ .define_method("limited?", &bullet3::Generic6DofConstraint::limited)
1222
+ .define_method("axis", &bullet3::Generic6DofConstraint::axis)
1223
+ .define_method("angle", &bullet3::Generic6DofConstraint::angle)
1224
+ .define_method("relative_pivot_position", &bullet3::Generic6DofConstraint::relative_pivot_position)
1225
+ .define_method("use_frame_offset?", &bullet3::Generic6DofConstraint::use_frame_offset)
1226
+ .define_method("use_frame_offset=", &bullet3::Generic6DofConstraint::set_use_frame_offset)
1227
+ .define_method("use_linear_reference_frame_a?", &bullet3::Generic6DofConstraint::use_linear_reference_frame_a)
1228
+ .define_method("use_linear_reference_frame_a=", &bullet3::Generic6DofConstraint::set_use_linear_reference_frame_a)
1229
+ .define_method("set_axis", &bullet3::Generic6DofConstraint::set_axis);
1230
+
1231
+ Rice::define_class_under<bullet3::Generic6DofSpring2Constraint, bullet3::TypedConstraint>(rb_mConstraints, "Generic6DofSpring2Constraint")
1232
+ .define_constructor(Rice::Constructor<bullet3::Generic6DofSpring2Constraint, VALUE, VALUE, int>(),
1233
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1234
+ Rice::Arg("frame_b").setValue(),
1235
+ Rice::Arg("rotate_order") = 0)
1236
+ .define_constructor(Rice::Constructor<bullet3::Generic6DofSpring2Constraint, VALUE, VALUE, VALUE, VALUE, int>(),
1237
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1238
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1239
+ Rice::Arg("frame_a").setValue(),
1240
+ Rice::Arg("frame_b").setValue(),
1241
+ Rice::Arg("rotate_order") = 0)
1242
+ .define_method("frame_a", &bullet3::Generic6DofSpring2Constraint::frame_a)
1243
+ .define_method("frame_b", &bullet3::Generic6DofSpring2Constraint::frame_b)
1244
+ .define_method("set_frames", &bullet3::Generic6DofSpring2Constraint::set_frames,
1245
+ Rice::Arg("frame_a").setValue(),
1246
+ Rice::Arg("frame_b").setValue())
1247
+ .define_method("linear_lower_limit", &bullet3::Generic6DofSpring2Constraint::linear_lower_limit)
1248
+ .define_method("linear_lower_limit=", &bullet3::Generic6DofSpring2Constraint::set_linear_lower_limit)
1249
+ .define_method("linear_upper_limit", &bullet3::Generic6DofSpring2Constraint::linear_upper_limit)
1250
+ .define_method("linear_upper_limit=", &bullet3::Generic6DofSpring2Constraint::set_linear_upper_limit)
1251
+ .define_method("angular_lower_limit", &bullet3::Generic6DofSpring2Constraint::angular_lower_limit)
1252
+ .define_method("angular_lower_limit=", &bullet3::Generic6DofSpring2Constraint::set_angular_lower_limit)
1253
+ .define_method("angular_upper_limit", &bullet3::Generic6DofSpring2Constraint::angular_upper_limit)
1254
+ .define_method("angular_upper_limit=", &bullet3::Generic6DofSpring2Constraint::set_angular_upper_limit)
1255
+ .define_method("set_limit", &bullet3::Generic6DofSpring2Constraint::set_limit)
1256
+ .define_method("limited?", &bullet3::Generic6DofSpring2Constraint::limited)
1257
+ .define_method("axis", &bullet3::Generic6DofSpring2Constraint::axis)
1258
+ .define_method("angle", &bullet3::Generic6DofSpring2Constraint::angle)
1259
+ .define_method("relative_pivot_position", &bullet3::Generic6DofSpring2Constraint::relative_pivot_position)
1260
+ .define_method("rotation_order", &bullet3::Generic6DofSpring2Constraint::rotation_order)
1261
+ .define_method("rotation_order=", &bullet3::Generic6DofSpring2Constraint::set_rotation_order)
1262
+ .define_method("set_axis", &bullet3::Generic6DofSpring2Constraint::set_axis)
1263
+ .define_method("enable_motor", &bullet3::Generic6DofSpring2Constraint::enable_motor)
1264
+ .define_method("set_servo", &bullet3::Generic6DofSpring2Constraint::set_servo)
1265
+ .define_method("set_target_velocity", &bullet3::Generic6DofSpring2Constraint::set_target_velocity)
1266
+ .define_method("set_servo_target", &bullet3::Generic6DofSpring2Constraint::set_servo_target)
1267
+ .define_method("set_max_motor_force", &bullet3::Generic6DofSpring2Constraint::set_max_motor_force)
1268
+ .define_method("enable_spring", &bullet3::Generic6DofSpring2Constraint::enable_spring)
1269
+ .define_method("set_stiffness", &bullet3::Generic6DofSpring2Constraint::set_stiffness,
1270
+ Rice::Arg("axis"),
1271
+ Rice::Arg("stiffness"),
1272
+ Rice::Arg("limit_if_needed") = true)
1273
+ .define_method("set_damping", &bullet3::Generic6DofSpring2Constraint::set_damping,
1274
+ Rice::Arg("axis"),
1275
+ Rice::Arg("damping"),
1276
+ Rice::Arg("limit_if_needed") = true)
1277
+ .define_method("set_equilibrium_point", &bullet3::Generic6DofSpring2Constraint::set_equilibrium_point)
1278
+ .define_method("set_axis_equilibrium_point", &bullet3::Generic6DofSpring2Constraint::set_axis_equilibrium_point)
1279
+ .define_method("set_axis_equilibrium_point_value", &bullet3::Generic6DofSpring2Constraint::set_axis_equilibrium_point_value);
1280
+
1281
+ Rice::define_class_under<bullet3::GearConstraint, bullet3::TypedConstraint>(rb_mConstraints, "GearConstraint")
1282
+ .define_constructor(Rice::Constructor<bullet3::GearConstraint, VALUE, VALUE, VALUE, VALUE, btScalar>(),
1283
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1284
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1285
+ Rice::Arg("axis_a").setValue(),
1286
+ Rice::Arg("axis_b").setValue(),
1287
+ Rice::Arg("ratio") = btScalar(1.0))
1288
+ .define_method("axis_a", &bullet3::GearConstraint::axis_a)
1289
+ .define_method("axis_a=", &bullet3::GearConstraint::set_axis_a)
1290
+ .define_method("axis_b", &bullet3::GearConstraint::axis_b)
1291
+ .define_method("axis_b=", &bullet3::GearConstraint::set_axis_b)
1292
+ .define_method("ratio", &bullet3::GearConstraint::ratio)
1293
+ .define_method("ratio=", &bullet3::GearConstraint::set_ratio);
1294
+
1295
+ Rice::define_class_under<bullet3::Hinge2Constraint, bullet3::TypedConstraint>(rb_mConstraints, "Hinge2Constraint")
1296
+ .define_constructor(Rice::Constructor<bullet3::Hinge2Constraint, VALUE, VALUE, VALUE, VALUE, VALUE>(),
1297
+ Rice::Arg("rigid_body_a").setValue().keepAlive(),
1298
+ Rice::Arg("rigid_body_b").setValue().keepAlive(),
1299
+ Rice::Arg("anchor").setValue(),
1300
+ Rice::Arg("axis1").setValue(),
1301
+ Rice::Arg("axis2").setValue())
1302
+ .define_method("anchor", &bullet3::Hinge2Constraint::anchor)
1303
+ .define_method("anchor2", &bullet3::Hinge2Constraint::anchor2)
1304
+ .define_method("axis1", &bullet3::Hinge2Constraint::axis1)
1305
+ .define_method("axis2", &bullet3::Hinge2Constraint::axis2)
1306
+ .define_method("angle1", &bullet3::Hinge2Constraint::angle1)
1307
+ .define_method("angle2", &bullet3::Hinge2Constraint::angle2)
1308
+ .define_method("set_upper_limit", &bullet3::Hinge2Constraint::set_upper_limit)
1309
+ .define_method("set_lower_limit", &bullet3::Hinge2Constraint::set_lower_limit);
1310
+ }