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.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +194 -0
- data/data/cube.urdf +22 -0
- data/data/plane.urdf +19 -0
- data/ext/bullet3/CMakeLists.txt +224 -0
- data/ext/bullet3/bullet3.cpp +34 -0
- data/ext/bullet3/collision/rb_collision.cpp +428 -0
- data/ext/bullet3/collision/rb_collision.hpp +87 -0
- data/ext/bullet3/collision/shapes/rb_collision_shape.cpp +485 -0
- data/ext/bullet3/collision/shapes/rb_collision_shape.hpp +5 -0
- data/ext/bullet3/constraints/rb_constraints.cpp +1310 -0
- data/ext/bullet3/constraints/rb_constraints.hpp +226 -0
- data/ext/bullet3/dynamics/rb_dynamics.cpp +862 -0
- data/ext/bullet3/dynamics/rb_dynamics.hpp +180 -0
- data/ext/bullet3/extconf.rb +57 -0
- data/ext/bullet3/io/rb_io.cpp +108 -0
- data/ext/bullet3/io/rb_io.hpp +40 -0
- data/ext/bullet3/linear_math/rb_matrix3x3.cpp +93 -0
- data/ext/bullet3/linear_math/rb_matrix3x3.hpp +5 -0
- data/ext/bullet3/linear_math/rb_quaternion.cpp +134 -0
- data/ext/bullet3/linear_math/rb_quaternion.hpp +5 -0
- data/ext/bullet3/linear_math/rb_transform.cpp +157 -0
- data/ext/bullet3/linear_math/rb_transform.hpp +34 -0
- data/ext/bullet3/linear_math/rb_vector3.cpp +123 -0
- data/ext/bullet3/linear_math/rb_vector3.hpp +5 -0
- data/ext/bullet3/multi_body/rb_multi_body.cpp +1000 -0
- data/ext/bullet3/multi_body/rb_multi_body.hpp +190 -0
- data/ext/bullet3/soft_body/rb_soft_body.cpp +720 -0
- data/ext/bullet3/soft_body/rb_soft_body.hpp +122 -0
- data/ext/bullet3/util/rb_debug_draw.cpp +250 -0
- data/ext/bullet3/util/rb_debug_draw.hpp +47 -0
- data/ext/bullet3/util/ruby_cpp_compat.hpp +29 -0
- data/ext/bullet3/util/type_conversions.hpp +107 -0
- data/ext/bullet3/vehicle/rb_vehicle.cpp +467 -0
- data/ext/bullet3/vehicle/rb_vehicle.hpp +115 -0
- data/lib/bullet3/collision.rb +6 -0
- data/lib/bullet3/constraints.rb +6 -0
- data/lib/bullet3/data.rb +39 -0
- data/lib/bullet3/debug_draw.rb +73 -0
- data/lib/bullet3/dynamics.rb +4 -0
- data/lib/bullet3/io.rb +110 -0
- data/lib/bullet3/linear_math/matrix3x3.rb +69 -0
- data/lib/bullet3/linear_math/quaternion.rb +187 -0
- data/lib/bullet3/linear_math/transform.rb +48 -0
- data/lib/bullet3/linear_math/vector3.rb +199 -0
- data/lib/bullet3/linear_math.rb +6 -0
- data/lib/bullet3/multi_body.rb +6 -0
- data/lib/bullet3/simulation.rb +1170 -0
- data/lib/bullet3/soft_body.rb +6 -0
- data/lib/bullet3/vehicle.rb +4 -0
- data/lib/bullet3/version.rb +5 -0
- data/lib/bullet3.rb +49 -0
- metadata +124 -0
|
@@ -0,0 +1,1000 @@
|
|
|
1
|
+
#include "rb_multi_body.hpp"
|
|
2
|
+
|
|
3
|
+
#include <stdexcept>
|
|
4
|
+
|
|
5
|
+
#include <ruby/thread.h>
|
|
6
|
+
|
|
7
|
+
#include "../util/type_conversions.hpp"
|
|
8
|
+
|
|
9
|
+
namespace {
|
|
10
|
+
bullet3::MultiBody* multi_body_from_value(VALUE value)
|
|
11
|
+
{
|
|
12
|
+
bullet3::MultiBody* body = Rice::detail::From_Ruby<bullet3::MultiBody*>().convert(value);
|
|
13
|
+
if (body == nullptr) {
|
|
14
|
+
throw std::invalid_argument("expected Bullet3::MultiBody::MultiBody");
|
|
15
|
+
}
|
|
16
|
+
return body;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bullet3::MultiBodyConstraint* multi_body_constraint_from_value(VALUE value)
|
|
20
|
+
{
|
|
21
|
+
bullet3::MultiBodyConstraint* constraint = Rice::detail::From_Ruby<bullet3::MultiBodyConstraint*>().convert(value);
|
|
22
|
+
if (constraint == nullptr) {
|
|
23
|
+
throw std::invalid_argument("expected Bullet3::MultiBody::MultiBodyConstraint");
|
|
24
|
+
}
|
|
25
|
+
return constraint;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
bullet3::MultiBodyLinkCollider* multi_body_collider_from_value(VALUE value)
|
|
29
|
+
{
|
|
30
|
+
bullet3::MultiBodyLinkCollider* collider = Rice::detail::From_Ruby<bullet3::MultiBodyLinkCollider*>().convert(value);
|
|
31
|
+
if (collider == nullptr) {
|
|
32
|
+
throw std::invalid_argument("expected Bullet3::MultiBody::MultiBodyLinkCollider");
|
|
33
|
+
}
|
|
34
|
+
return collider;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
bullet3::RigidBody* rigid_body_from_value(VALUE value)
|
|
38
|
+
{
|
|
39
|
+
bullet3::RigidBody* body = Rice::detail::From_Ruby<bullet3::RigidBody*>().convert(value);
|
|
40
|
+
if (body == nullptr) {
|
|
41
|
+
throw std::invalid_argument("expected Bullet3::RigidBody");
|
|
42
|
+
}
|
|
43
|
+
return body;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
btCollisionShape* collision_shape_from_value(VALUE value)
|
|
47
|
+
{
|
|
48
|
+
btCollisionShape* shape = Rice::detail::From_Ruby<btCollisionShape*>().convert(value);
|
|
49
|
+
if (shape == nullptr) {
|
|
50
|
+
throw std::invalid_argument("expected Bullet3::Shapes::CollisionShape");
|
|
51
|
+
}
|
|
52
|
+
return shape;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
btMultiBodyJointMotor* joint_motor_from(bullet3::MultiBodyConstraint& constraint)
|
|
56
|
+
{
|
|
57
|
+
return static_cast<btMultiBodyJointMotor*>(constraint.get());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const btMultiBodyJointMotor* joint_motor_from(const bullet3::MultiBodyConstraint& constraint)
|
|
61
|
+
{
|
|
62
|
+
return static_cast<const btMultiBodyJointMotor*>(constraint.get());
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
btMultiBodyJointLimitConstraint* joint_limit_from(bullet3::MultiBodyConstraint& constraint)
|
|
66
|
+
{
|
|
67
|
+
return static_cast<btMultiBodyJointLimitConstraint*>(constraint.get());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const btMultiBodyJointLimitConstraint* joint_limit_from(const bullet3::MultiBodyConstraint& constraint)
|
|
71
|
+
{
|
|
72
|
+
return static_cast<const btMultiBodyJointLimitConstraint*>(constraint.get());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
btMultiBodyPoint2Point* point2point_from(bullet3::MultiBodyConstraint& constraint)
|
|
76
|
+
{
|
|
77
|
+
return static_cast<btMultiBodyPoint2Point*>(constraint.get());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const btMultiBodyPoint2Point* point2point_from(const bullet3::MultiBodyConstraint& constraint)
|
|
81
|
+
{
|
|
82
|
+
return static_cast<const btMultiBodyPoint2Point*>(constraint.get());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
struct StepSimulationArgs {
|
|
86
|
+
btMultiBodyDynamicsWorld* world;
|
|
87
|
+
btScalar time_step;
|
|
88
|
+
int max_sub_steps;
|
|
89
|
+
btScalar fixed_time_step;
|
|
90
|
+
int result;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
void* step_simulation_without_gvl(void* pointer)
|
|
94
|
+
{
|
|
95
|
+
auto* args = static_cast<StepSimulationArgs*>(pointer);
|
|
96
|
+
args->result = args->world->stepSimulation(args->time_step, args->max_sub_steps, args->fixed_time_step);
|
|
97
|
+
return nullptr;
|
|
98
|
+
}
|
|
99
|
+
} // namespace
|
|
100
|
+
|
|
101
|
+
namespace bullet3 {
|
|
102
|
+
MultiBody::MultiBody(int link_count, btScalar base_mass, Rice::Object base_inertia, bool fixed_base, bool can_sleep, bool deprecated_multi_dof)
|
|
103
|
+
: multi_body_(std::make_unique<btMultiBody>(
|
|
104
|
+
link_count,
|
|
105
|
+
base_mass,
|
|
106
|
+
coerce_vector(base_inertia),
|
|
107
|
+
fixed_base,
|
|
108
|
+
can_sleep,
|
|
109
|
+
deprecated_multi_dof))
|
|
110
|
+
{
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
btMultiBody* MultiBody::get()
|
|
114
|
+
{
|
|
115
|
+
return multi_body_.get();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const btMultiBody* MultiBody::get() const
|
|
119
|
+
{
|
|
120
|
+
return multi_body_.get();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
int MultiBody::validate_link_index(int link) const
|
|
124
|
+
{
|
|
125
|
+
if (link < 0 || link >= multi_body_->getNumLinks()) {
|
|
126
|
+
throw std::out_of_range("link index is out of range");
|
|
127
|
+
}
|
|
128
|
+
return link;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
int MultiBody::num_links() const
|
|
132
|
+
{
|
|
133
|
+
return multi_body_->getNumLinks();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
int MultiBody::num_dofs() const
|
|
137
|
+
{
|
|
138
|
+
return multi_body_->getNumDofs();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
int MultiBody::num_pos_vars() const
|
|
142
|
+
{
|
|
143
|
+
return multi_body_->getNumPosVars();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
btScalar MultiBody::base_mass() const
|
|
147
|
+
{
|
|
148
|
+
return multi_body_->getBaseMass();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
btScalar MultiBody::set_base_mass(btScalar mass)
|
|
152
|
+
{
|
|
153
|
+
multi_body_->setBaseMass(mass);
|
|
154
|
+
return mass;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
btVector3 MultiBody::base_inertia() const
|
|
158
|
+
{
|
|
159
|
+
return multi_body_->getBaseInertia();
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
btVector3 MultiBody::set_base_inertia(Rice::Object inertia)
|
|
163
|
+
{
|
|
164
|
+
btVector3 vector = coerce_vector(inertia);
|
|
165
|
+
multi_body_->setBaseInertia(vector);
|
|
166
|
+
return vector;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
btVector3 MultiBody::base_position() const
|
|
170
|
+
{
|
|
171
|
+
return multi_body_->getBasePos();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
btVector3 MultiBody::set_base_position(Rice::Object position)
|
|
175
|
+
{
|
|
176
|
+
btVector3 vector = coerce_vector(position);
|
|
177
|
+
multi_body_->setBasePos(vector);
|
|
178
|
+
return vector;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
btVector3 MultiBody::base_velocity() const
|
|
182
|
+
{
|
|
183
|
+
return multi_body_->getBaseVel();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
btVector3 MultiBody::set_base_velocity(Rice::Object velocity)
|
|
187
|
+
{
|
|
188
|
+
btVector3 vector = coerce_vector(velocity);
|
|
189
|
+
multi_body_->setBaseVel(vector);
|
|
190
|
+
return vector;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
btVector3 MultiBody::base_omega() const
|
|
194
|
+
{
|
|
195
|
+
return multi_body_->getBaseOmega();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
btVector3 MultiBody::set_base_omega(Rice::Object omega)
|
|
199
|
+
{
|
|
200
|
+
btVector3 vector = coerce_vector(omega);
|
|
201
|
+
multi_body_->setBaseOmega(vector);
|
|
202
|
+
return vector;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
btQuaternion MultiBody::world_to_base_rotation() const
|
|
206
|
+
{
|
|
207
|
+
return multi_body_->getWorldToBaseRot();
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
btQuaternion MultiBody::set_world_to_base_rotation(Rice::Object rotation)
|
|
211
|
+
{
|
|
212
|
+
btQuaternion quaternion = coerce_quaternion(rotation);
|
|
213
|
+
multi_body_->setWorldToBaseRot(quaternion);
|
|
214
|
+
return quaternion;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Transform MultiBody::base_world_transform() const
|
|
218
|
+
{
|
|
219
|
+
return Transform(multi_body_->getBaseWorldTransform());
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
Transform MultiBody::set_base_world_transform(Rice::Object transform)
|
|
223
|
+
{
|
|
224
|
+
btTransform value = coerce_transform(transform);
|
|
225
|
+
multi_body_->setBaseWorldTransform(value);
|
|
226
|
+
return Transform(value);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
bool MultiBody::fixed_base() const
|
|
230
|
+
{
|
|
231
|
+
return multi_body_->hasFixedBase();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
bool MultiBody::can_sleep() const
|
|
235
|
+
{
|
|
236
|
+
return multi_body_->getCanSleep();
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
bool MultiBody::set_can_sleep(bool can_sleep)
|
|
240
|
+
{
|
|
241
|
+
multi_body_->setCanSleep(can_sleep);
|
|
242
|
+
return can_sleep;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
bool MultiBody::awake() const
|
|
246
|
+
{
|
|
247
|
+
return multi_body_->isAwake();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
void MultiBody::wake_up()
|
|
251
|
+
{
|
|
252
|
+
multi_body_->wakeUp();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
void MultiBody::go_to_sleep()
|
|
256
|
+
{
|
|
257
|
+
multi_body_->goToSleep();
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
btScalar MultiBody::linear_damping() const
|
|
261
|
+
{
|
|
262
|
+
return multi_body_->getLinearDamping();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
btScalar MultiBody::set_linear_damping(btScalar damping)
|
|
266
|
+
{
|
|
267
|
+
multi_body_->setLinearDamping(damping);
|
|
268
|
+
return damping;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
btScalar MultiBody::angular_damping() const
|
|
272
|
+
{
|
|
273
|
+
return multi_body_->getAngularDamping();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
btScalar MultiBody::set_angular_damping(btScalar damping)
|
|
277
|
+
{
|
|
278
|
+
multi_body_->setAngularDamping(damping);
|
|
279
|
+
return damping;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
bool MultiBody::self_collision() const
|
|
283
|
+
{
|
|
284
|
+
return multi_body_->hasSelfCollision();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
bool MultiBody::set_self_collision(bool enabled)
|
|
288
|
+
{
|
|
289
|
+
multi_body_->setHasSelfCollision(enabled);
|
|
290
|
+
return enabled;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
btScalar MultiBody::joint_position(int link) const
|
|
294
|
+
{
|
|
295
|
+
return multi_body_->getJointPos(validate_link_index(link));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
btScalar MultiBody::set_joint_position(int link, btScalar position)
|
|
299
|
+
{
|
|
300
|
+
multi_body_->setJointPos(validate_link_index(link), position);
|
|
301
|
+
return position;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
btScalar MultiBody::joint_velocity(int link) const
|
|
305
|
+
{
|
|
306
|
+
return multi_body_->getJointVel(validate_link_index(link));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
btScalar MultiBody::set_joint_velocity(int link, btScalar velocity)
|
|
310
|
+
{
|
|
311
|
+
multi_body_->setJointVel(validate_link_index(link), velocity);
|
|
312
|
+
return velocity;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
void MultiBody::setup_fixed(int link, btScalar mass, Rice::Object inertia, int parent, Rice::Object parent_to_this_rotation, Rice::Object parent_pivot, Rice::Object child_pivot, bool disable_parent_collision)
|
|
316
|
+
{
|
|
317
|
+
multi_body_->setupFixed(
|
|
318
|
+
validate_link_index(link),
|
|
319
|
+
mass,
|
|
320
|
+
coerce_vector(inertia),
|
|
321
|
+
parent,
|
|
322
|
+
coerce_quaternion(parent_to_this_rotation),
|
|
323
|
+
coerce_vector(parent_pivot),
|
|
324
|
+
coerce_vector(child_pivot),
|
|
325
|
+
disable_parent_collision);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
void MultiBody::setup_revolute(int link, btScalar mass, Rice::Object inertia, int parent, Rice::Object parent_to_this_rotation, Rice::Object joint_axis, Rice::Object parent_pivot, Rice::Object child_pivot, bool disable_parent_collision)
|
|
329
|
+
{
|
|
330
|
+
multi_body_->setupRevolute(
|
|
331
|
+
validate_link_index(link),
|
|
332
|
+
mass,
|
|
333
|
+
coerce_vector(inertia),
|
|
334
|
+
parent,
|
|
335
|
+
coerce_quaternion(parent_to_this_rotation),
|
|
336
|
+
coerce_vector(joint_axis),
|
|
337
|
+
coerce_vector(parent_pivot),
|
|
338
|
+
coerce_vector(child_pivot),
|
|
339
|
+
disable_parent_collision);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
void MultiBody::setup_prismatic(int link, btScalar mass, Rice::Object inertia, int parent, Rice::Object parent_to_this_rotation, Rice::Object joint_axis, Rice::Object parent_pivot, Rice::Object child_pivot, bool disable_parent_collision)
|
|
343
|
+
{
|
|
344
|
+
multi_body_->setupPrismatic(
|
|
345
|
+
validate_link_index(link),
|
|
346
|
+
mass,
|
|
347
|
+
coerce_vector(inertia),
|
|
348
|
+
parent,
|
|
349
|
+
coerce_quaternion(parent_to_this_rotation),
|
|
350
|
+
coerce_vector(joint_axis),
|
|
351
|
+
coerce_vector(parent_pivot),
|
|
352
|
+
coerce_vector(child_pivot),
|
|
353
|
+
disable_parent_collision);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
void MultiBody::finalize_multi_dof()
|
|
357
|
+
{
|
|
358
|
+
multi_body_->finalizeMultiDof();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
void MultiBody::clear_forces_and_torques()
|
|
362
|
+
{
|
|
363
|
+
multi_body_->clearForcesAndTorques();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
void MultiBody::clear_velocities()
|
|
367
|
+
{
|
|
368
|
+
multi_body_->clearVelocities();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
void MultiBody::add_base_force(Rice::Object force)
|
|
372
|
+
{
|
|
373
|
+
multi_body_->addBaseForce(coerce_vector(force));
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
void MultiBody::add_base_torque(Rice::Object torque)
|
|
377
|
+
{
|
|
378
|
+
multi_body_->addBaseTorque(coerce_vector(torque));
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
void MultiBody::add_link_force(int link, Rice::Object force)
|
|
382
|
+
{
|
|
383
|
+
multi_body_->addLinkForce(validate_link_index(link), coerce_vector(force));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
void MultiBody::add_link_torque(int link, Rice::Object torque)
|
|
387
|
+
{
|
|
388
|
+
multi_body_->addLinkTorque(validate_link_index(link), coerce_vector(torque));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
void MultiBody::add_joint_torque(int link, btScalar torque)
|
|
392
|
+
{
|
|
393
|
+
multi_body_->addJointTorque(validate_link_index(link), torque);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
int MultiBody::parent(int link) const
|
|
397
|
+
{
|
|
398
|
+
return multi_body_->getParent(validate_link_index(link));
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
void MultiBody::set_base_collider(MultiBodyLinkCollider& collider)
|
|
402
|
+
{
|
|
403
|
+
multi_body_->setBaseCollider(collider.get());
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
void MultiBody::set_link_collider(int link, MultiBodyLinkCollider& collider)
|
|
407
|
+
{
|
|
408
|
+
multi_body_->getLink(validate_link_index(link)).m_collider = collider.get();
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
MultiBodyLinkCollider::MultiBodyLinkCollider(MultiBody& multi_body, int link)
|
|
412
|
+
: collider_(std::make_unique<btMultiBodyLinkCollider>(multi_body.get(), link))
|
|
413
|
+
{
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
btMultiBodyLinkCollider* MultiBodyLinkCollider::get()
|
|
417
|
+
{
|
|
418
|
+
return collider_.get();
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const btMultiBodyLinkCollider* MultiBodyLinkCollider::get() const
|
|
422
|
+
{
|
|
423
|
+
return collider_.get();
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
int MultiBodyLinkCollider::link() const
|
|
427
|
+
{
|
|
428
|
+
return collider_->m_link;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
Transform MultiBodyLinkCollider::world_transform() const
|
|
432
|
+
{
|
|
433
|
+
return Transform(collider_->getWorldTransform());
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
Transform MultiBodyLinkCollider::set_world_transform(Rice::Object transform)
|
|
437
|
+
{
|
|
438
|
+
btTransform value = coerce_transform(transform);
|
|
439
|
+
collider_->setWorldTransform(value);
|
|
440
|
+
return Transform(value);
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
void MultiBodyLinkCollider::set_collision_shape(VALUE collision_shape)
|
|
444
|
+
{
|
|
445
|
+
collider_->setCollisionShape(collision_shape_from_value(collision_shape));
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
btCollisionShape* MultiBodyLinkCollider::collision_shape() const
|
|
449
|
+
{
|
|
450
|
+
return collider_->getCollisionShape();
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
int MultiBodyLinkCollider::collision_flags() const
|
|
454
|
+
{
|
|
455
|
+
return collider_->getCollisionFlags();
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
int MultiBodyLinkCollider::set_collision_flags(int flags)
|
|
459
|
+
{
|
|
460
|
+
collider_->setCollisionFlags(flags);
|
|
461
|
+
return flags;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
bool MultiBodyLinkCollider::kinematic() const
|
|
465
|
+
{
|
|
466
|
+
return collider_->isKinematic();
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
bool MultiBodyLinkCollider::static_or_kinematic() const
|
|
470
|
+
{
|
|
471
|
+
return collider_->isStaticOrKinematic();
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
MultiBodyConstraint::MultiBodyConstraint(std::unique_ptr<btMultiBodyConstraint> constraint)
|
|
475
|
+
: constraint_(std::move(constraint))
|
|
476
|
+
{
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
btMultiBodyConstraint* MultiBodyConstraint::get()
|
|
480
|
+
{
|
|
481
|
+
return constraint_.get();
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const btMultiBodyConstraint* MultiBodyConstraint::get() const
|
|
485
|
+
{
|
|
486
|
+
return constraint_.get();
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
Rice::Symbol MultiBodyConstraint::constraint_type() const
|
|
490
|
+
{
|
|
491
|
+
switch (constraint_->getConstraintType()) {
|
|
492
|
+
case MULTIBODY_CONSTRAINT_LIMIT:
|
|
493
|
+
return Rice::Symbol("joint_limit");
|
|
494
|
+
case MULTIBODY_CONSTRAINT_1DOF_JOINT_MOTOR:
|
|
495
|
+
return Rice::Symbol("joint_motor");
|
|
496
|
+
case MULTIBODY_CONSTRAINT_POINT_TO_POINT:
|
|
497
|
+
return Rice::Symbol("point2point");
|
|
498
|
+
default:
|
|
499
|
+
return Rice::Symbol("unknown");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
int MultiBodyConstraint::num_rows() const
|
|
504
|
+
{
|
|
505
|
+
return constraint_->getNumRows();
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
btScalar MultiBodyConstraint::max_applied_impulse() const
|
|
509
|
+
{
|
|
510
|
+
return constraint_->getMaxAppliedImpulse();
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
btScalar MultiBodyConstraint::set_max_applied_impulse(btScalar impulse)
|
|
514
|
+
{
|
|
515
|
+
constraint_->setMaxAppliedImpulse(impulse);
|
|
516
|
+
return impulse;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
btScalar MultiBodyConstraint::applied_impulse(int row)
|
|
520
|
+
{
|
|
521
|
+
return constraint_->getAppliedImpulse(row);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
btScalar MultiBodyConstraint::position(int row) const
|
|
525
|
+
{
|
|
526
|
+
return constraint_->getPosition(row);
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
MultiBodyJointMotor::MultiBodyJointMotor(VALUE multi_body, int link, btScalar desired_velocity, btScalar max_motor_impulse)
|
|
530
|
+
: MultiBodyConstraint(std::make_unique<btMultiBodyJointMotor>(
|
|
531
|
+
multi_body_from_value(multi_body)->get(),
|
|
532
|
+
link,
|
|
533
|
+
desired_velocity,
|
|
534
|
+
max_motor_impulse))
|
|
535
|
+
{
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
MultiBodyJointMotor::MultiBodyJointMotor(VALUE multi_body, int link, int link_dof, btScalar desired_velocity, btScalar max_motor_impulse)
|
|
539
|
+
: MultiBodyConstraint(std::make_unique<btMultiBodyJointMotor>(
|
|
540
|
+
multi_body_from_value(multi_body)->get(),
|
|
541
|
+
link,
|
|
542
|
+
link_dof,
|
|
543
|
+
desired_velocity,
|
|
544
|
+
max_motor_impulse))
|
|
545
|
+
{
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
void MultiBodyJointMotor::set_velocity_target(btScalar velocity, btScalar kd)
|
|
549
|
+
{
|
|
550
|
+
joint_motor_from(*this)->setVelocityTarget(velocity, kd);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
void MultiBodyJointMotor::set_position_target(btScalar position, btScalar kp)
|
|
554
|
+
{
|
|
555
|
+
joint_motor_from(*this)->setPositionTarget(position, kp);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
btScalar MultiBodyJointMotor::erp() const
|
|
559
|
+
{
|
|
560
|
+
return joint_motor_from(*this)->getErp();
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
btScalar MultiBodyJointMotor::set_erp(btScalar erp)
|
|
564
|
+
{
|
|
565
|
+
joint_motor_from(*this)->setErp(erp);
|
|
566
|
+
return erp;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
void MultiBodyJointMotor::set_rhs_clamp(btScalar clamp)
|
|
570
|
+
{
|
|
571
|
+
joint_motor_from(*this)->setRhsClamp(clamp);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
MultiBodyJointLimitConstraint::MultiBodyJointLimitConstraint(VALUE multi_body, int link, btScalar lower, btScalar upper)
|
|
575
|
+
: MultiBodyConstraint(std::make_unique<btMultiBodyJointLimitConstraint>(
|
|
576
|
+
multi_body_from_value(multi_body)->get(),
|
|
577
|
+
link,
|
|
578
|
+
lower,
|
|
579
|
+
upper))
|
|
580
|
+
{
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
btScalar MultiBodyJointLimitConstraint::lower_bound() const
|
|
584
|
+
{
|
|
585
|
+
return joint_limit_from(*this)->getLowerBound();
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
btScalar MultiBodyJointLimitConstraint::set_lower_bound(btScalar lower)
|
|
589
|
+
{
|
|
590
|
+
joint_limit_from(*this)->setLowerBound(lower);
|
|
591
|
+
return lower;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
btScalar MultiBodyJointLimitConstraint::upper_bound() const
|
|
595
|
+
{
|
|
596
|
+
return joint_limit_from(*this)->getUpperBound();
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
btScalar MultiBodyJointLimitConstraint::set_upper_bound(btScalar upper)
|
|
600
|
+
{
|
|
601
|
+
joint_limit_from(*this)->setUpperBound(upper);
|
|
602
|
+
return upper;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
MultiBodyPoint2Point::MultiBodyPoint2Point(VALUE multi_body, int link, VALUE rigid_body, VALUE pivot_in_a, VALUE pivot_in_b)
|
|
606
|
+
: MultiBodyConstraint(std::make_unique<btMultiBodyPoint2Point>(
|
|
607
|
+
multi_body_from_value(multi_body)->get(),
|
|
608
|
+
link,
|
|
609
|
+
rigid_body_from_value(rigid_body)->get(),
|
|
610
|
+
coerce_vector(Rice::Object(pivot_in_a)),
|
|
611
|
+
coerce_vector(Rice::Object(pivot_in_b))))
|
|
612
|
+
{
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
MultiBodyPoint2Point::MultiBodyPoint2Point(VALUE multi_body_a, int link_a, VALUE multi_body_b, int link_b, VALUE pivot_in_a, VALUE pivot_in_b)
|
|
616
|
+
: MultiBodyConstraint(std::make_unique<btMultiBodyPoint2Point>(
|
|
617
|
+
multi_body_from_value(multi_body_a)->get(),
|
|
618
|
+
link_a,
|
|
619
|
+
multi_body_from_value(multi_body_b)->get(),
|
|
620
|
+
link_b,
|
|
621
|
+
coerce_vector(Rice::Object(pivot_in_a)),
|
|
622
|
+
coerce_vector(Rice::Object(pivot_in_b))))
|
|
623
|
+
{
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
btVector3 MultiBodyPoint2Point::pivot_in_b() const
|
|
627
|
+
{
|
|
628
|
+
return point2point_from(*this)->getPivotInB();
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
btVector3 MultiBodyPoint2Point::set_pivot_in_b(Rice::Object pivot)
|
|
632
|
+
{
|
|
633
|
+
btVector3 vector = coerce_vector(pivot);
|
|
634
|
+
point2point_from(*this)->setPivotInB(vector);
|
|
635
|
+
return vector;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
MultiBodyDynamicsWorld::MultiBodyDynamicsWorld()
|
|
639
|
+
: configuration_(std::make_unique<btDefaultCollisionConfiguration>()),
|
|
640
|
+
dispatcher_(std::make_unique<btCollisionDispatcher>(configuration_.get())),
|
|
641
|
+
broadphase_(std::make_unique<btDbvtBroadphase>()),
|
|
642
|
+
solver_(std::make_unique<btMultiBodyConstraintSolver>()),
|
|
643
|
+
world_(std::make_unique<btMultiBodyDynamicsWorld>(
|
|
644
|
+
dispatcher_.get(),
|
|
645
|
+
broadphase_.get(),
|
|
646
|
+
solver_.get(),
|
|
647
|
+
configuration_.get()))
|
|
648
|
+
{
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
MultiBodyDynamicsWorld::~MultiBodyDynamicsWorld()
|
|
652
|
+
{
|
|
653
|
+
constraints_.clear();
|
|
654
|
+
colliders_.clear();
|
|
655
|
+
multi_bodies_.clear();
|
|
656
|
+
constraint_values_.clear();
|
|
657
|
+
collider_values_.clear();
|
|
658
|
+
multi_body_values_.clear();
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
btMultiBodyDynamicsWorld* MultiBodyDynamicsWorld::get()
|
|
662
|
+
{
|
|
663
|
+
return world_.get();
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
btVector3 MultiBodyDynamicsWorld::gravity() const
|
|
667
|
+
{
|
|
668
|
+
return world_->getGravity();
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
btVector3 MultiBodyDynamicsWorld::set_gravity(Rice::Object gravity)
|
|
672
|
+
{
|
|
673
|
+
btVector3 vector = coerce_vector(gravity);
|
|
674
|
+
world_->setGravity(vector);
|
|
675
|
+
return vector;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
void MultiBodyDynamicsWorld::add_multi_body_object(VALUE multi_body, int group, int mask)
|
|
679
|
+
{
|
|
680
|
+
MultiBody* body = multi_body_from_value(multi_body);
|
|
681
|
+
btMultiBody* bullet_body = body->get();
|
|
682
|
+
if (multi_bodies_.insert(bullet_body).second) {
|
|
683
|
+
world_->addMultiBody(bullet_body, group, mask);
|
|
684
|
+
multi_body_values_[bullet_body] = multi_body;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
void MultiBodyDynamicsWorld::remove_multi_body_object(VALUE multi_body)
|
|
689
|
+
{
|
|
690
|
+
MultiBody* body = multi_body_from_value(multi_body);
|
|
691
|
+
btMultiBody* bullet_body = body->get();
|
|
692
|
+
auto iterator = multi_bodies_.find(bullet_body);
|
|
693
|
+
if (iterator != multi_bodies_.end()) {
|
|
694
|
+
world_->removeMultiBody(bullet_body);
|
|
695
|
+
multi_bodies_.erase(iterator);
|
|
696
|
+
}
|
|
697
|
+
multi_body_values_.erase(bullet_body);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
void MultiBodyDynamicsWorld::add_constraint_object(VALUE constraint)
|
|
701
|
+
{
|
|
702
|
+
MultiBodyConstraint* typed_constraint = multi_body_constraint_from_value(constraint);
|
|
703
|
+
btMultiBodyConstraint* bullet_constraint = typed_constraint->get();
|
|
704
|
+
if (constraints_.insert(bullet_constraint).second) {
|
|
705
|
+
world_->addMultiBodyConstraint(bullet_constraint);
|
|
706
|
+
constraint_values_[bullet_constraint] = constraint;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
void MultiBodyDynamicsWorld::remove_constraint_object(VALUE constraint)
|
|
711
|
+
{
|
|
712
|
+
MultiBodyConstraint* typed_constraint = multi_body_constraint_from_value(constraint);
|
|
713
|
+
btMultiBodyConstraint* bullet_constraint = typed_constraint->get();
|
|
714
|
+
auto iterator = constraints_.find(bullet_constraint);
|
|
715
|
+
if (iterator != constraints_.end()) {
|
|
716
|
+
world_->removeMultiBodyConstraint(bullet_constraint);
|
|
717
|
+
constraints_.erase(iterator);
|
|
718
|
+
}
|
|
719
|
+
constraint_values_.erase(bullet_constraint);
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
void MultiBodyDynamicsWorld::add_link_collider_object(VALUE collider, int group, int mask)
|
|
723
|
+
{
|
|
724
|
+
MultiBodyLinkCollider* link_collider = multi_body_collider_from_value(collider);
|
|
725
|
+
btMultiBodyLinkCollider* bullet_collider = link_collider->get();
|
|
726
|
+
if (colliders_.insert(bullet_collider).second) {
|
|
727
|
+
world_->addCollisionObject(bullet_collider, group, mask);
|
|
728
|
+
collider_values_[bullet_collider] = collider;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
void MultiBodyDynamicsWorld::remove_link_collider_object(VALUE collider)
|
|
733
|
+
{
|
|
734
|
+
MultiBodyLinkCollider* link_collider = multi_body_collider_from_value(collider);
|
|
735
|
+
btMultiBodyLinkCollider* bullet_collider = link_collider->get();
|
|
736
|
+
auto iterator = colliders_.find(bullet_collider);
|
|
737
|
+
if (iterator != colliders_.end()) {
|
|
738
|
+
world_->removeCollisionObject(bullet_collider);
|
|
739
|
+
colliders_.erase(iterator);
|
|
740
|
+
}
|
|
741
|
+
collider_values_.erase(bullet_collider);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
int MultiBodyDynamicsWorld::step_simulation(btScalar time_step, int max_sub_steps, btScalar fixed_time_step)
|
|
745
|
+
{
|
|
746
|
+
StepSimulationArgs args{world_.get(), time_step, max_sub_steps, fixed_time_step, 0};
|
|
747
|
+
rb_thread_call_without_gvl(step_simulation_without_gvl, &args, nullptr, nullptr);
|
|
748
|
+
return args.result;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
int MultiBodyDynamicsWorld::num_multi_bodies() const
|
|
752
|
+
{
|
|
753
|
+
return world_->getNumMultibodies();
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
int MultiBodyDynamicsWorld::num_multi_body_constraints() const
|
|
757
|
+
{
|
|
758
|
+
return world_->getNumMultiBodyConstraints();
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
int MultiBodyDynamicsWorld::num_collision_objects() const
|
|
762
|
+
{
|
|
763
|
+
return world_->getNumCollisionObjects();
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
void MultiBodyDynamicsWorld::forward_kinematics()
|
|
767
|
+
{
|
|
768
|
+
world_->forwardKinematics();
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
void MultiBodyDynamicsWorld::clear_forces()
|
|
772
|
+
{
|
|
773
|
+
world_->clearForces();
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
void MultiBodyDynamicsWorld::clear_multi_body_forces()
|
|
777
|
+
{
|
|
778
|
+
world_->clearMultiBodyForces();
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
void MultiBodyDynamicsWorld::mark() const
|
|
782
|
+
{
|
|
783
|
+
for (const auto& entry : multi_body_values_) {
|
|
784
|
+
rb_gc_mark(entry.second);
|
|
785
|
+
}
|
|
786
|
+
for (const auto& entry : constraint_values_) {
|
|
787
|
+
rb_gc_mark(entry.second);
|
|
788
|
+
}
|
|
789
|
+
for (const auto& entry : collider_values_) {
|
|
790
|
+
rb_gc_mark(entry.second);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
} // namespace bullet3
|
|
794
|
+
|
|
795
|
+
namespace Rice {
|
|
796
|
+
template <>
|
|
797
|
+
void ruby_mark<bullet3::MultiBodyDynamicsWorld>(bullet3::MultiBodyDynamicsWorld* world)
|
|
798
|
+
{
|
|
799
|
+
if (world != nullptr) {
|
|
800
|
+
world->mark();
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
} // namespace Rice
|
|
804
|
+
|
|
805
|
+
void Init_MultiBody(Rice::Module rb_mBullet)
|
|
806
|
+
{
|
|
807
|
+
Rice::Module rb_mMultiBody = Rice::define_module_under(rb_mBullet, "MultiBody");
|
|
808
|
+
|
|
809
|
+
Rice::define_class_under<bullet3::MultiBody>(rb_mMultiBody, "MultiBody")
|
|
810
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBody, int, btScalar, Rice::Object, bool, bool, bool>(),
|
|
811
|
+
Rice::Arg("link_count"),
|
|
812
|
+
Rice::Arg("base_mass"),
|
|
813
|
+
Rice::Arg("base_inertia"),
|
|
814
|
+
Rice::Arg("fixed_base"),
|
|
815
|
+
Rice::Arg("can_sleep"),
|
|
816
|
+
Rice::Arg("deprecated_multi_dof") = true)
|
|
817
|
+
.define_method("num_links", &bullet3::MultiBody::num_links)
|
|
818
|
+
.define_method("num_dofs", &bullet3::MultiBody::num_dofs)
|
|
819
|
+
.define_method("num_pos_vars", &bullet3::MultiBody::num_pos_vars)
|
|
820
|
+
.define_method("base_mass", &bullet3::MultiBody::base_mass)
|
|
821
|
+
.define_method("base_mass=", &bullet3::MultiBody::set_base_mass)
|
|
822
|
+
.define_method("base_inertia", &bullet3::MultiBody::base_inertia)
|
|
823
|
+
.define_method("base_inertia=", &bullet3::MultiBody::set_base_inertia)
|
|
824
|
+
.define_method("base_position", &bullet3::MultiBody::base_position)
|
|
825
|
+
.define_method("base_position=", &bullet3::MultiBody::set_base_position)
|
|
826
|
+
.define_method("base_velocity", &bullet3::MultiBody::base_velocity)
|
|
827
|
+
.define_method("base_velocity=", &bullet3::MultiBody::set_base_velocity)
|
|
828
|
+
.define_method("base_omega", &bullet3::MultiBody::base_omega)
|
|
829
|
+
.define_method("base_omega=", &bullet3::MultiBody::set_base_omega)
|
|
830
|
+
.define_method("world_to_base_rotation", &bullet3::MultiBody::world_to_base_rotation)
|
|
831
|
+
.define_method("world_to_base_rotation=", &bullet3::MultiBody::set_world_to_base_rotation)
|
|
832
|
+
.define_method("base_world_transform", &bullet3::MultiBody::base_world_transform)
|
|
833
|
+
.define_method("base_world_transform=", &bullet3::MultiBody::set_base_world_transform)
|
|
834
|
+
.define_method("fixed_base?", &bullet3::MultiBody::fixed_base)
|
|
835
|
+
.define_method("can_sleep?", &bullet3::MultiBody::can_sleep)
|
|
836
|
+
.define_method("can_sleep=", &bullet3::MultiBody::set_can_sleep)
|
|
837
|
+
.define_method("awake?", &bullet3::MultiBody::awake)
|
|
838
|
+
.define_method("wake_up", &bullet3::MultiBody::wake_up)
|
|
839
|
+
.define_method("go_to_sleep", &bullet3::MultiBody::go_to_sleep)
|
|
840
|
+
.define_method("linear_damping", &bullet3::MultiBody::linear_damping)
|
|
841
|
+
.define_method("linear_damping=", &bullet3::MultiBody::set_linear_damping)
|
|
842
|
+
.define_method("angular_damping", &bullet3::MultiBody::angular_damping)
|
|
843
|
+
.define_method("angular_damping=", &bullet3::MultiBody::set_angular_damping)
|
|
844
|
+
.define_method("self_collision?", &bullet3::MultiBody::self_collision)
|
|
845
|
+
.define_method("self_collision=", &bullet3::MultiBody::set_self_collision)
|
|
846
|
+
.define_method("joint_position", &bullet3::MultiBody::joint_position)
|
|
847
|
+
.define_method("set_joint_position", &bullet3::MultiBody::set_joint_position)
|
|
848
|
+
.define_method("joint_velocity", &bullet3::MultiBody::joint_velocity)
|
|
849
|
+
.define_method("set_joint_velocity", &bullet3::MultiBody::set_joint_velocity)
|
|
850
|
+
.define_method("setup_fixed", &bullet3::MultiBody::setup_fixed,
|
|
851
|
+
Rice::Arg("link"),
|
|
852
|
+
Rice::Arg("mass"),
|
|
853
|
+
Rice::Arg("inertia"),
|
|
854
|
+
Rice::Arg("parent"),
|
|
855
|
+
Rice::Arg("parent_to_this_rotation"),
|
|
856
|
+
Rice::Arg("parent_pivot"),
|
|
857
|
+
Rice::Arg("child_pivot"),
|
|
858
|
+
Rice::Arg("disable_parent_collision") = true)
|
|
859
|
+
.define_method("setup_revolute", &bullet3::MultiBody::setup_revolute,
|
|
860
|
+
Rice::Arg("link"),
|
|
861
|
+
Rice::Arg("mass"),
|
|
862
|
+
Rice::Arg("inertia"),
|
|
863
|
+
Rice::Arg("parent"),
|
|
864
|
+
Rice::Arg("parent_to_this_rotation"),
|
|
865
|
+
Rice::Arg("joint_axis"),
|
|
866
|
+
Rice::Arg("parent_pivot"),
|
|
867
|
+
Rice::Arg("child_pivot"),
|
|
868
|
+
Rice::Arg("disable_parent_collision") = false)
|
|
869
|
+
.define_method("setup_prismatic", &bullet3::MultiBody::setup_prismatic,
|
|
870
|
+
Rice::Arg("link"),
|
|
871
|
+
Rice::Arg("mass"),
|
|
872
|
+
Rice::Arg("inertia"),
|
|
873
|
+
Rice::Arg("parent"),
|
|
874
|
+
Rice::Arg("parent_to_this_rotation"),
|
|
875
|
+
Rice::Arg("joint_axis"),
|
|
876
|
+
Rice::Arg("parent_pivot"),
|
|
877
|
+
Rice::Arg("child_pivot"),
|
|
878
|
+
Rice::Arg("disable_parent_collision") = false)
|
|
879
|
+
.define_method("finalize_multi_dof", &bullet3::MultiBody::finalize_multi_dof)
|
|
880
|
+
.define_method("clear_forces_and_torques", &bullet3::MultiBody::clear_forces_and_torques)
|
|
881
|
+
.define_method("clear_velocities", &bullet3::MultiBody::clear_velocities)
|
|
882
|
+
.define_method("add_base_force", &bullet3::MultiBody::add_base_force)
|
|
883
|
+
.define_method("add_base_torque", &bullet3::MultiBody::add_base_torque)
|
|
884
|
+
.define_method("add_link_force", &bullet3::MultiBody::add_link_force)
|
|
885
|
+
.define_method("add_link_torque", &bullet3::MultiBody::add_link_torque)
|
|
886
|
+
.define_method("add_joint_torque", &bullet3::MultiBody::add_joint_torque)
|
|
887
|
+
.define_method("parent", &bullet3::MultiBody::parent)
|
|
888
|
+
.define_method("set_base_collider", &bullet3::MultiBody::set_base_collider,
|
|
889
|
+
Rice::Arg("collider").keepAlive())
|
|
890
|
+
.define_method("set_link_collider", &bullet3::MultiBody::set_link_collider,
|
|
891
|
+
Rice::Arg("link"),
|
|
892
|
+
Rice::Arg("collider").keepAlive());
|
|
893
|
+
|
|
894
|
+
Rice::define_class_under<bullet3::MultiBodyLinkCollider>(rb_mMultiBody, "MultiBodyLinkCollider")
|
|
895
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyLinkCollider, bullet3::MultiBody&, int>(),
|
|
896
|
+
Rice::Arg("multi_body").keepAlive(),
|
|
897
|
+
Rice::Arg("link"))
|
|
898
|
+
.define_method("link", &bullet3::MultiBodyLinkCollider::link)
|
|
899
|
+
.define_method("world_transform", &bullet3::MultiBodyLinkCollider::world_transform)
|
|
900
|
+
.define_method("world_transform=", &bullet3::MultiBodyLinkCollider::set_world_transform)
|
|
901
|
+
.define_method("collision_shape=", &bullet3::MultiBodyLinkCollider::set_collision_shape,
|
|
902
|
+
Rice::Arg("collision_shape").setValue().keepAlive())
|
|
903
|
+
.define_method("collision_shape", &bullet3::MultiBodyLinkCollider::collision_shape)
|
|
904
|
+
.define_method("collision_flags", &bullet3::MultiBodyLinkCollider::collision_flags)
|
|
905
|
+
.define_method("collision_flags=", &bullet3::MultiBodyLinkCollider::set_collision_flags)
|
|
906
|
+
.define_method("kinematic?", &bullet3::MultiBodyLinkCollider::kinematic)
|
|
907
|
+
.define_method("static_or_kinematic?", &bullet3::MultiBodyLinkCollider::static_or_kinematic);
|
|
908
|
+
|
|
909
|
+
Rice::define_class_under<bullet3::MultiBodyConstraint>(rb_mMultiBody, "MultiBodyConstraint")
|
|
910
|
+
.define_method("constraint_type", &bullet3::MultiBodyConstraint::constraint_type)
|
|
911
|
+
.define_method("num_rows", &bullet3::MultiBodyConstraint::num_rows)
|
|
912
|
+
.define_method("max_applied_impulse", &bullet3::MultiBodyConstraint::max_applied_impulse)
|
|
913
|
+
.define_method("max_applied_impulse=", &bullet3::MultiBodyConstraint::set_max_applied_impulse)
|
|
914
|
+
.define_method("applied_impulse", &bullet3::MultiBodyConstraint::applied_impulse)
|
|
915
|
+
.define_method("position", &bullet3::MultiBodyConstraint::position);
|
|
916
|
+
|
|
917
|
+
Rice::define_class_under<bullet3::MultiBodyJointMotor, bullet3::MultiBodyConstraint>(rb_mMultiBody, "MultiBodyJointMotor")
|
|
918
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyJointMotor, VALUE, int, btScalar, btScalar>(),
|
|
919
|
+
Rice::Arg("multi_body").setValue().keepAlive(),
|
|
920
|
+
Rice::Arg("link"),
|
|
921
|
+
Rice::Arg("desired_velocity"),
|
|
922
|
+
Rice::Arg("max_motor_impulse"))
|
|
923
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyJointMotor, VALUE, int, int, btScalar, btScalar>(),
|
|
924
|
+
Rice::Arg("multi_body").setValue().keepAlive(),
|
|
925
|
+
Rice::Arg("link"),
|
|
926
|
+
Rice::Arg("link_dof"),
|
|
927
|
+
Rice::Arg("desired_velocity"),
|
|
928
|
+
Rice::Arg("max_motor_impulse"))
|
|
929
|
+
.define_method("set_velocity_target", &bullet3::MultiBodyJointMotor::set_velocity_target,
|
|
930
|
+
Rice::Arg("velocity"),
|
|
931
|
+
Rice::Arg("kd") = btScalar(1.0))
|
|
932
|
+
.define_method("set_position_target", &bullet3::MultiBodyJointMotor::set_position_target,
|
|
933
|
+
Rice::Arg("position"),
|
|
934
|
+
Rice::Arg("kp") = btScalar(1.0))
|
|
935
|
+
.define_method("erp", &bullet3::MultiBodyJointMotor::erp)
|
|
936
|
+
.define_method("erp=", &bullet3::MultiBodyJointMotor::set_erp)
|
|
937
|
+
.define_method("rhs_clamp=", &bullet3::MultiBodyJointMotor::set_rhs_clamp);
|
|
938
|
+
|
|
939
|
+
Rice::define_class_under<bullet3::MultiBodyJointLimitConstraint, bullet3::MultiBodyConstraint>(rb_mMultiBody, "MultiBodyJointLimitConstraint")
|
|
940
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyJointLimitConstraint, VALUE, int, btScalar, btScalar>(),
|
|
941
|
+
Rice::Arg("multi_body").setValue().keepAlive(),
|
|
942
|
+
Rice::Arg("link"),
|
|
943
|
+
Rice::Arg("lower"),
|
|
944
|
+
Rice::Arg("upper"))
|
|
945
|
+
.define_method("lower_bound", &bullet3::MultiBodyJointLimitConstraint::lower_bound)
|
|
946
|
+
.define_method("lower_bound=", &bullet3::MultiBodyJointLimitConstraint::set_lower_bound)
|
|
947
|
+
.define_method("upper_bound", &bullet3::MultiBodyJointLimitConstraint::upper_bound)
|
|
948
|
+
.define_method("upper_bound=", &bullet3::MultiBodyJointLimitConstraint::set_upper_bound);
|
|
949
|
+
|
|
950
|
+
Rice::define_class_under<bullet3::MultiBodyPoint2Point, bullet3::MultiBodyConstraint>(rb_mMultiBody, "MultiBodyPoint2Point")
|
|
951
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyPoint2Point, VALUE, int, VALUE, VALUE, VALUE>(),
|
|
952
|
+
Rice::Arg("multi_body").setValue().keepAlive(),
|
|
953
|
+
Rice::Arg("link"),
|
|
954
|
+
Rice::Arg("rigid_body").setValue().keepAlive(),
|
|
955
|
+
Rice::Arg("pivot_in_a").setValue(),
|
|
956
|
+
Rice::Arg("pivot_in_b").setValue())
|
|
957
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyPoint2Point, VALUE, int, VALUE, int, VALUE, VALUE>(),
|
|
958
|
+
Rice::Arg("multi_body_a").setValue().keepAlive(),
|
|
959
|
+
Rice::Arg("link_a"),
|
|
960
|
+
Rice::Arg("multi_body_b").setValue().keepAlive(),
|
|
961
|
+
Rice::Arg("link_b"),
|
|
962
|
+
Rice::Arg("pivot_in_a").setValue(),
|
|
963
|
+
Rice::Arg("pivot_in_b").setValue())
|
|
964
|
+
.define_method("pivot_in_b", &bullet3::MultiBodyPoint2Point::pivot_in_b)
|
|
965
|
+
.define_method("pivot_in_b=", &bullet3::MultiBodyPoint2Point::set_pivot_in_b);
|
|
966
|
+
|
|
967
|
+
Rice::define_class_under<bullet3::MultiBodyDynamicsWorld>(rb_mMultiBody, "MultiBodyDynamicsWorld")
|
|
968
|
+
.define_constructor(Rice::Constructor<bullet3::MultiBodyDynamicsWorld>())
|
|
969
|
+
.define_singleton_method("create", [](Rice::Object) -> bullet3::MultiBodyDynamicsWorld* {
|
|
970
|
+
return new bullet3::MultiBodyDynamicsWorld();
|
|
971
|
+
}, Rice::Return().takeOwnership())
|
|
972
|
+
.define_method("gravity", &bullet3::MultiBodyDynamicsWorld::gravity)
|
|
973
|
+
.define_method("gravity=", &bullet3::MultiBodyDynamicsWorld::set_gravity)
|
|
974
|
+
.define_method("add_multi_body", &bullet3::MultiBodyDynamicsWorld::add_multi_body_object,
|
|
975
|
+
Rice::Arg("multi_body").setValue().keepAlive(),
|
|
976
|
+
Rice::Arg("group") = int(btBroadphaseProxy::DefaultFilter),
|
|
977
|
+
Rice::Arg("mask") = int(btBroadphaseProxy::AllFilter))
|
|
978
|
+
.define_method("remove_multi_body", &bullet3::MultiBodyDynamicsWorld::remove_multi_body_object,
|
|
979
|
+
Rice::Arg("multi_body").setValue())
|
|
980
|
+
.define_method("add_constraint", &bullet3::MultiBodyDynamicsWorld::add_constraint_object,
|
|
981
|
+
Rice::Arg("constraint").setValue().keepAlive())
|
|
982
|
+
.define_method("remove_constraint", &bullet3::MultiBodyDynamicsWorld::remove_constraint_object,
|
|
983
|
+
Rice::Arg("constraint").setValue())
|
|
984
|
+
.define_method("add_link_collider", &bullet3::MultiBodyDynamicsWorld::add_link_collider_object,
|
|
985
|
+
Rice::Arg("collider").setValue().keepAlive(),
|
|
986
|
+
Rice::Arg("group") = int(btBroadphaseProxy::DefaultFilter),
|
|
987
|
+
Rice::Arg("mask") = int(btBroadphaseProxy::AllFilter))
|
|
988
|
+
.define_method("remove_link_collider", &bullet3::MultiBodyDynamicsWorld::remove_link_collider_object,
|
|
989
|
+
Rice::Arg("collider").setValue())
|
|
990
|
+
.define_method("step_simulation", &bullet3::MultiBodyDynamicsWorld::step_simulation,
|
|
991
|
+
Rice::Arg("time_step"),
|
|
992
|
+
Rice::Arg("max_sub_steps") = 1,
|
|
993
|
+
Rice::Arg("fixed_time_step") = btScalar(1.0 / 60.0))
|
|
994
|
+
.define_method("num_multi_bodies", &bullet3::MultiBodyDynamicsWorld::num_multi_bodies)
|
|
995
|
+
.define_method("num_multi_body_constraints", &bullet3::MultiBodyDynamicsWorld::num_multi_body_constraints)
|
|
996
|
+
.define_method("num_collision_objects", &bullet3::MultiBodyDynamicsWorld::num_collision_objects)
|
|
997
|
+
.define_method("forward_kinematics", &bullet3::MultiBodyDynamicsWorld::forward_kinematics)
|
|
998
|
+
.define_method("clear_forces", &bullet3::MultiBodyDynamicsWorld::clear_forces)
|
|
999
|
+
.define_method("clear_multi_body_forces", &bullet3::MultiBodyDynamicsWorld::clear_multi_body_forces);
|
|
1000
|
+
}
|