Blender V4.3
rna_rigidbody.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include <cstdlib>
11#include <cstring>
12
13#include "RNA_define.hh"
14#include "RNA_enum_types.hh"
15
16#include "rna_internal.hh"
17
19#include "DNA_object_types.h"
20#include "DNA_rigidbody_types.h"
21#include "DNA_scene_types.h"
22
23#include "BLI_math_rotation.h"
24#include "BLI_utildefines.h"
25
27
28#include "WM_types.hh"
29
30/* roles of objects in RigidBody Sims */
33 "ACTIVE",
34 0,
35 "Active",
36 "Object is directly controlled by simulation results"},
38 "PASSIVE",
39 0,
40 "Passive",
41 "Object is directly controlled by animation system"},
42 {0, nullptr, 0, nullptr, nullptr},
43};
44
45/* collision shapes of objects in rigid body sim */
48 "BOX",
49 ICON_MESH_CUBE,
50 "Box",
51 "Box-like shapes (i.e. cubes), including planes (i.e. ground planes)"},
52 {RB_SHAPE_SPHERE, "SPHERE", ICON_MESH_UVSPHERE, "Sphere", ""},
53 {RB_SHAPE_CAPSULE, "CAPSULE", ICON_MESH_CAPSULE, "Capsule", ""},
54 {RB_SHAPE_CYLINDER, "CYLINDER", ICON_MESH_CYLINDER, "Cylinder", ""},
55 {RB_SHAPE_CONE, "CONE", ICON_MESH_CONE, "Cone", ""},
57 "CONVEX_HULL",
58 ICON_MESH_ICOSPHERE,
59 "Convex Hull",
60 "A mesh-like surface encompassing (i.e. shrinkwrap over) all vertices (best results with "
61 "fewer vertices)"},
63 "MESH",
64 ICON_MESH_MONKEY,
65 "Mesh",
66 "Mesh consisting of triangles only, allowing for more detailed interactions than convex "
67 "hulls"},
69 "COMPOUND",
70 ICON_MESH_DATA,
71 "Compound Parent",
72 "Combines all of its direct rigid body children into one rigid object"},
73 {0, nullptr, 0, nullptr, nullptr},
74};
75
76/* collision shapes of constraints in rigid body sim */
78 {RBC_TYPE_FIXED, "FIXED", ICON_NONE, "Fixed", "Glue rigid bodies together"},
80 "POINT",
81 ICON_NONE,
82 "Point",
83 "Constrain rigid bodies to move around common pivot point"},
84 {RBC_TYPE_HINGE, "HINGE", ICON_NONE, "Hinge", "Restrict rigid body rotation to one axis"},
86 "SLIDER",
87 ICON_NONE,
88 "Slider",
89 "Restrict rigid body translation to one axis"},
91 "PISTON",
92 ICON_NONE,
93 "Piston",
94 "Restrict rigid body translation and rotation to one axis"},
96 "GENERIC",
97 ICON_NONE,
98 "Generic",
99 "Restrict translation and rotation to specified axes"},
101 "GENERIC_SPRING",
102 ICON_NONE,
103 "Generic Spring",
104 "Restrict translation and rotation to specified axes with springs"},
105 {RBC_TYPE_MOTOR, "MOTOR", ICON_NONE, "Motor", "Drive rigid body around or along an axis"},
106 {0, nullptr, 0, nullptr, nullptr},
107};
108
109/* bullet spring type */
112 "SPRING1",
113 ICON_NONE,
114 "Blender 2.7",
115 "Spring implementation used in Blender 2.7. Damping is capped at 1.0"},
117 "SPRING2",
118 ICON_NONE,
119 "Blender 2.8",
120 "New implementation available since 2.8"},
121 {0, nullptr, 0, nullptr, nullptr},
122};
123
124#ifndef RNA_RUNTIME
125/* mesh source for collision shape creation */
127 {RBO_MESH_BASE, "BASE", 0, "Base", "Base mesh"},
128 {RBO_MESH_DEFORM, "DEFORM", 0, "Deform", "Deformations (shape keys, deform modifiers)"},
129 {RBO_MESH_FINAL, "FINAL", 0, "Final", "All modifiers"},
130 {0, nullptr, 0, nullptr, nullptr},
131};
132#endif
133
134#ifdef RNA_RUNTIME
135
136# ifdef WITH_BULLET
137# include "RBI_api.h"
138# endif
139
140# include "BKE_rigidbody.h"
141
142# include "WM_api.hh"
143
144/* ******************************** */
145
146static void rna_RigidBodyWorld_reset(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
147{
149
151}
152
153static std::optional<std::string> rna_RigidBodyWorld_path(const PointerRNA * /*ptr*/)
154{
155 return "rigidbody_world";
156}
157
158static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int value)
159{
161
162 rbw->num_solver_iterations = value;
163
164# ifdef WITH_BULLET
165 if (rbw->shared->physics_world) {
166 RB_dworld_set_solver_iterations(static_cast<rbDynamicsWorld *>(rbw->shared->physics_world),
167 value);
168 }
169# endif
170}
171
172static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, bool value)
173{
175
177
178# ifdef WITH_BULLET
179 if (rbw->shared->physics_world) {
180 RB_dworld_set_split_impulse(static_cast<rbDynamicsWorld *>(rbw->shared->physics_world), value);
181 }
182# endif
183}
184
185static void rna_RigidBodyWorld_objects_collection_update(Main *bmain,
186 Scene *scene,
188{
191 rna_RigidBodyWorld_reset(bmain, scene, ptr);
192}
193
194static void rna_RigidBodyWorld_constraints_collection_update(Main *bmain,
195 Scene *scene,
197{
200 rna_RigidBodyWorld_reset(bmain, scene, ptr);
201}
202
203/* ******************************** */
204
205static void rna_RigidBodyOb_reset(Main * /*bmain*/, Scene *scene, PointerRNA * /*ptr*/)
206{
207 if (scene != nullptr) {
208 RigidBodyWorld *rbw = scene->rigidbody_world;
210 }
211}
212
213static void rna_RigidBodyOb_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
214{
215 Object *ob = (Object *)ptr->owner_id;
216
217 rna_RigidBodyOb_reset(bmain, scene, ptr);
219
221}
222
223static void rna_RigidBodyOb_shape_reset(Main * /*bmain*/, Scene *scene, PointerRNA *ptr)
224{
225 if (scene != nullptr) {
226 RigidBodyWorld *rbw = scene->rigidbody_world;
228 }
229
230 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
231 if (rbo->shared->physics_shape) {
232 rbo->flag |= RBO_FLAG_NEEDS_RESHAPE;
233 }
234}
235
236static void rna_RigidBodyOb_mesh_source_update(Main *bmain, Scene *scene, PointerRNA *ptr)
237{
238 Object *ob = (Object *)ptr->owner_id;
239
240 rna_RigidBodyOb_reset(bmain, scene, ptr);
242
244}
245
246static std::optional<std::string> rna_RigidBodyOb_path(const PointerRNA * /*ptr*/)
247{
248 /* NOTE: this hardcoded path should work as long as only Objects have this */
249 return "rigid_body";
250}
251
252static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value)
253{
254 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
255
256 rbo->type = value;
257 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
258}
259
260static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value)
261{
262 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
263
264 rbo->shape = value;
265 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
266}
267
268static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, bool value)
269{
270 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
271
272 SET_FLAG_FROM_TEST(rbo->flag, !value, RBO_FLAG_DISABLED);
273
274# ifdef WITH_BULLET
275 /* update kinematic state if necessary - only needed for active bodies */
276 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
277 RB_body_set_mass(static_cast<rbRigidBody *>(rbo->shared->physics_object), RBO_GET_MASS(rbo));
278 RB_body_set_kinematic_state(static_cast<rbRigidBody *>(rbo->shared->physics_object), !value);
279 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
280 }
281# endif
282}
283
284static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value)
285{
286 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
287
288 rbo->mass = value;
289
290# ifdef WITH_BULLET
291 /* only active bodies need mass update */
292 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
293 RB_body_set_mass(static_cast<rbRigidBody *>(rbo->shared->physics_object), RBO_GET_MASS(rbo));
294 }
295# endif
296}
297
298static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value)
299{
300 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
301
302 rbo->friction = value;
303
304# ifdef WITH_BULLET
305 if (rbo->shared->physics_object) {
306 RB_body_set_friction(static_cast<rbRigidBody *>(rbo->shared->physics_object), value);
307 }
308# endif
309}
310
311static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value)
312{
313 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
314
315 rbo->restitution = value;
316# ifdef WITH_BULLET
317 if (rbo->shared->physics_object) {
318 RB_body_set_restitution(static_cast<rbRigidBody *>(rbo->shared->physics_object), value);
319 }
320# endif
321}
322
323static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value)
324{
325 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
326
327 rbo->margin = value;
328
329# ifdef WITH_BULLET
330 if (rbo->shared->physics_shape) {
331 RB_shape_set_margin(static_cast<rbCollisionShape *>(rbo->shared->physics_shape),
332 RBO_GET_MARGIN(rbo));
333 }
334# endif
335}
336
337static void rna_RigidBodyOb_collision_collections_set(PointerRNA *ptr, const bool *values)
338{
339 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
340 int i;
341
342 for (i = 0; i < 20; i++) {
343 if (values[i]) {
344 rbo->col_groups |= (1 << i);
345 }
346 else {
347 rbo->col_groups &= ~(1 << i);
348 }
349 }
350 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
351}
352
353static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, bool value)
354{
355 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
356
357 SET_FLAG_FROM_TEST(rbo->flag, value, RBO_FLAG_KINEMATIC);
358
359# ifdef WITH_BULLET
360 /* update kinematic state if necessary */
361 if (rbo->shared->physics_object) {
362 RB_body_set_mass(static_cast<rbRigidBody *>(rbo->shared->physics_object), RBO_GET_MASS(rbo));
363 RB_body_set_kinematic_state(static_cast<rbRigidBody *>(rbo->shared->physics_object), value);
364 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
365 }
366# endif
367}
368
369static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, bool value)
370{
371 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
372
374
375# ifdef WITH_BULLET
376 /* update activation state if necessary - only active bodies can be deactivated */
377 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
378 RB_body_set_activation_state(static_cast<rbRigidBody *>(rbo->shared->physics_object), value);
379 }
380# endif
381}
382
383static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value)
384{
385 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
386
387 rbo->lin_sleep_thresh = value;
388
389# ifdef WITH_BULLET
390 /* only active bodies need sleep threshold update */
391 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
392 RB_body_set_linear_sleep_thresh(static_cast<rbRigidBody *>(rbo->shared->physics_object),
393 value);
394 }
395# endif
396}
397
398static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value)
399{
400 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
401
402 rbo->ang_sleep_thresh = value;
403
404# ifdef WITH_BULLET
405 /* only active bodies need sleep threshold update */
406 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
407 RB_body_set_angular_sleep_thresh(static_cast<rbRigidBody *>(rbo->shared->physics_object),
408 value);
409 }
410# endif
411}
412
413static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value)
414{
415 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
416
417 rbo->lin_damping = value;
418
419# ifdef WITH_BULLET
420 /* only active bodies need damping update */
421 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
422 RB_body_set_linear_damping(static_cast<rbRigidBody *>(rbo->shared->physics_object), value);
423 }
424# endif
425}
426
427static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value)
428{
429 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
430
431 rbo->ang_damping = value;
432
433# ifdef WITH_BULLET
434 /* only active bodies need damping update */
435 if ((rbo->shared->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
436 RB_body_set_angular_damping(static_cast<rbRigidBody *>(rbo->shared->physics_object), value);
437 }
438# endif
439}
440
441static std::optional<std::string> rna_RigidBodyCon_path(const PointerRNA * /*ptr*/)
442{
443 /* NOTE: this hardcoded path should work as long as only Objects have this */
444 return "rigid_body_constraint";
445}
446
447static void rna_RigidBodyCon_type_set(PointerRNA *ptr, int value)
448{
450
451 rbc->type = value;
452 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
453}
454
455static void rna_RigidBodyCon_spring_type_set(PointerRNA *ptr, int value)
456{
458
459 rbc->spring_type = value;
460 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
461}
462
463static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, bool value)
464{
466
467 SET_FLAG_FROM_TEST(rbc->flag, value, RBC_FLAG_ENABLED);
468
469# ifdef WITH_BULLET
470 if (rbc->physics_constraint) {
471 RB_constraint_set_enabled(static_cast<rbConstraint *>(rbc->physics_constraint), value);
472 }
473# endif
474}
475
476static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, bool value)
477{
479
481
482 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
483}
484
485static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, bool value)
486{
488
489 if (value) {
490 rbc->flag |= RBC_FLAG_USE_BREAKING;
491# ifdef WITH_BULLET
492 if (rbc->physics_constraint) {
493 RB_constraint_set_breaking_threshold(static_cast<rbConstraint *>(rbc->physics_constraint),
494 rbc->breaking_threshold);
495 }
496# endif
497 }
498 else {
499 rbc->flag &= ~RBC_FLAG_USE_BREAKING;
500# ifdef WITH_BULLET
501 if (rbc->physics_constraint) {
502 RB_constraint_set_breaking_threshold(static_cast<rbConstraint *>(rbc->physics_constraint),
503 FLT_MAX);
504 }
505# endif
506 }
507}
508
509static void rna_RigidBodyCon_breaking_threshold_set(PointerRNA *ptr, float value)
510{
512
513 rbc->breaking_threshold = value;
514
515# ifdef WITH_BULLET
516 if (rbc->physics_constraint && (rbc->flag & RBC_FLAG_USE_BREAKING)) {
517 RB_constraint_set_breaking_threshold(static_cast<rbConstraint *>(rbc->physics_constraint),
518 value);
519 }
520# endif
521}
522
523static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, bool value)
524{
526
527 if (value) {
529# ifdef WITH_BULLET
530 if (rbc->physics_constraint) {
531 RB_constraint_set_solver_iterations(static_cast<rbConstraint *>(rbc->physics_constraint),
532 rbc->num_solver_iterations);
533 }
534# endif
535 }
536 else {
537 rbc->flag &= ~RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
538# ifdef WITH_BULLET
539 if (rbc->physics_constraint) {
540 RB_constraint_set_solver_iterations(static_cast<rbConstraint *>(rbc->physics_constraint),
541 -1);
542 }
543# endif
544 }
545}
546
547static void rna_RigidBodyCon_num_solver_iterations_set(PointerRNA *ptr, int value)
548{
550
551 rbc->num_solver_iterations = value;
552
553# ifdef WITH_BULLET
554 if (rbc->physics_constraint && (rbc->flag & RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS)) {
555 RB_constraint_set_solver_iterations(static_cast<rbConstraint *>(rbc->physics_constraint),
556 value);
557 }
558# endif
559}
560
561# ifdef WITH_BULLET
562static void rna_RigidBodyCon_do_set_spring_stiffness(RigidBodyCon *rbc,
563 float value,
564 int flag,
565 int axis)
566{
567 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & flag)) {
568 switch (rbc->spring_type) {
569 case RBC_SPRING_TYPE1:
571 static_cast<rbConstraint *>(rbc->physics_constraint), axis, value);
572 break;
573 case RBC_SPRING_TYPE2:
575 static_cast<rbConstraint *>(rbc->physics_constraint), axis, value);
576 break;
577 }
578 }
579}
580# endif
581
582static void rna_RigidBodyCon_spring_stiffness_x_set(PointerRNA *ptr, float value)
583{
585
586 rbc->spring_stiffness_x = value;
587
588# ifdef WITH_BULLET
589 rna_RigidBodyCon_do_set_spring_stiffness(rbc, value, RBC_FLAG_USE_SPRING_X, RB_LIMIT_LIN_X);
590# endif
591}
592
593static void rna_RigidBodyCon_spring_stiffness_y_set(PointerRNA *ptr, float value)
594{
596
597 rbc->spring_stiffness_y = value;
598
599# ifdef WITH_BULLET
600 rna_RigidBodyCon_do_set_spring_stiffness(rbc, value, RBC_FLAG_USE_SPRING_Y, RB_LIMIT_LIN_Y);
601# endif
602}
603
604static void rna_RigidBodyCon_spring_stiffness_z_set(PointerRNA *ptr, float value)
605{
607
608 rbc->spring_stiffness_z = value;
609
610# ifdef WITH_BULLET
611 rna_RigidBodyCon_do_set_spring_stiffness(rbc, value, RBC_FLAG_USE_SPRING_Z, RB_LIMIT_LIN_Z);
612# endif
613}
614
615static void rna_RigidBodyCon_spring_stiffness_ang_x_set(PointerRNA *ptr, float value)
616{
618
619 rbc->spring_stiffness_ang_x = value;
620
621# ifdef WITH_BULLET
622 rna_RigidBodyCon_do_set_spring_stiffness(rbc, value, RBC_FLAG_USE_SPRING_ANG_X, RB_LIMIT_ANG_X);
623# endif
624}
625
626static void rna_RigidBodyCon_spring_stiffness_ang_y_set(PointerRNA *ptr, float value)
627{
629
630 rbc->spring_stiffness_ang_y = value;
631
632# ifdef WITH_BULLET
633 rna_RigidBodyCon_do_set_spring_stiffness(rbc, value, RBC_FLAG_USE_SPRING_ANG_Y, RB_LIMIT_ANG_Y);
634# endif
635}
636
637static void rna_RigidBodyCon_spring_stiffness_ang_z_set(PointerRNA *ptr, float value)
638{
640
641 rbc->spring_stiffness_ang_z = value;
642
643# ifdef WITH_BULLET
644 rna_RigidBodyCon_do_set_spring_stiffness(rbc, value, RBC_FLAG_USE_SPRING_ANG_Z, RB_LIMIT_ANG_Z);
645# endif
646}
647
648# ifdef WITH_BULLET
649static void rna_RigidBodyCon_do_set_spring_damping(RigidBodyCon *rbc,
650 float value,
651 int flag,
652 int axis)
653{
654 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & flag)) {
655 switch (rbc->spring_type) {
656 case RBC_SPRING_TYPE1:
658 static_cast<rbConstraint *>(rbc->physics_constraint), axis, value);
659 break;
660 case RBC_SPRING_TYPE2:
662 static_cast<rbConstraint *>(rbc->physics_constraint), axis, value);
663 break;
664 }
665 }
666}
667# endif
668
669static void rna_RigidBodyCon_spring_damping_x_set(PointerRNA *ptr, float value)
670{
672
673 rbc->spring_damping_x = value;
674
675# ifdef WITH_BULLET
676 rna_RigidBodyCon_do_set_spring_damping(rbc, value, RBC_FLAG_USE_SPRING_X, RB_LIMIT_LIN_X);
677# endif
678}
679
680static void rna_RigidBodyCon_spring_damping_y_set(PointerRNA *ptr, float value)
681{
683
684 rbc->spring_damping_y = value;
685# ifdef WITH_BULLET
686 rna_RigidBodyCon_do_set_spring_damping(rbc, value, RBC_FLAG_USE_SPRING_Y, RB_LIMIT_LIN_Y);
687# endif
688}
689
690static void rna_RigidBodyCon_spring_damping_z_set(PointerRNA *ptr, float value)
691{
693
694 rbc->spring_damping_z = value;
695# ifdef WITH_BULLET
696 rna_RigidBodyCon_do_set_spring_damping(rbc, value, RBC_FLAG_USE_SPRING_Z, RB_LIMIT_LIN_Z);
697# endif
698}
699
700static void rna_RigidBodyCon_spring_damping_ang_x_set(PointerRNA *ptr, float value)
701{
703
704 rbc->spring_damping_ang_x = value;
705
706# ifdef WITH_BULLET
707 rna_RigidBodyCon_do_set_spring_damping(rbc, value, RBC_FLAG_USE_SPRING_ANG_X, RB_LIMIT_ANG_X);
708# endif
709}
710
711static void rna_RigidBodyCon_spring_damping_ang_y_set(PointerRNA *ptr, float value)
712{
714
715 rbc->spring_damping_ang_y = value;
716# ifdef WITH_BULLET
717 rna_RigidBodyCon_do_set_spring_damping(rbc, value, RBC_FLAG_USE_SPRING_ANG_Y, RB_LIMIT_ANG_Y);
718# endif
719}
720
721static void rna_RigidBodyCon_spring_damping_ang_z_set(PointerRNA *ptr, float value)
722{
724
725 rbc->spring_damping_ang_z = value;
726# ifdef WITH_BULLET
727 rna_RigidBodyCon_do_set_spring_damping(rbc, value, RBC_FLAG_USE_SPRING_ANG_Z, RB_LIMIT_ANG_Z);
728# endif
729}
730
731static void rna_RigidBodyCon_motor_lin_max_impulse_set(PointerRNA *ptr, float value)
732{
734
735 rbc->motor_lin_max_impulse = value;
736
737# ifdef WITH_BULLET
738 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
740 static_cast<rbConstraint *>(rbc->physics_constraint), value, rbc->motor_ang_max_impulse);
741 }
742# endif
743}
744
745static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, bool value)
746{
748
750
751# ifdef WITH_BULLET
752 if (rbc->physics_constraint) {
753 RB_constraint_set_enable_motor(static_cast<rbConstraint *>(rbc->physics_constraint),
754 rbc->flag & RBC_FLAG_USE_MOTOR_LIN,
755 rbc->flag & RBC_FLAG_USE_MOTOR_ANG);
756 }
757# endif
758}
759
760static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, bool value)
761{
763
765
766# ifdef WITH_BULLET
767 if (rbc->physics_constraint) {
768 RB_constraint_set_enable_motor(static_cast<rbConstraint *>(rbc->physics_constraint),
769 rbc->flag & RBC_FLAG_USE_MOTOR_LIN,
770 rbc->flag & RBC_FLAG_USE_MOTOR_ANG);
771 }
772# endif
773}
774
775static void rna_RigidBodyCon_motor_lin_target_velocity_set(PointerRNA *ptr, float value)
776{
778
779 rbc->motor_lin_target_velocity = value;
780
781# ifdef WITH_BULLET
782 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
783 RB_constraint_set_target_velocity_motor(static_cast<rbConstraint *>(rbc->physics_constraint),
784 value,
785 rbc->motor_ang_target_velocity);
786 }
787# endif
788}
789
790static void rna_RigidBodyCon_motor_ang_max_impulse_set(PointerRNA *ptr, float value)
791{
793
794 rbc->motor_ang_max_impulse = value;
795
796# ifdef WITH_BULLET
797 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
799 static_cast<rbConstraint *>(rbc->physics_constraint), rbc->motor_lin_max_impulse, value);
800 }
801# endif
802}
803
804static void rna_RigidBodyCon_motor_ang_target_velocity_set(PointerRNA *ptr, float value)
805{
807
808 rbc->motor_ang_target_velocity = value;
809
810# ifdef WITH_BULLET
811 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
812 RB_constraint_set_target_velocity_motor(static_cast<rbConstraint *>(rbc->physics_constraint),
813 rbc->motor_lin_target_velocity,
814 value);
815 }
816# endif
817}
818
819/* Sweep test */
820static void rna_RigidBodyWorld_convex_sweep_test(RigidBodyWorld *rbw,
821 ReportList *reports,
822 Object *object,
823 const float ray_start[3],
824 const float ray_end[3],
825 float r_location[3],
826 float r_hitpoint[3],
827 float r_normal[3],
828 int *r_hit)
829{
830# ifdef WITH_BULLET
831 RigidBodyOb *rob = object->rigidbody_object;
832
833 if (rbw->shared->physics_world != nullptr && rob->shared->physics_object != nullptr) {
835 static_cast<rbRigidBody *>(rob->shared->physics_object),
836 ray_start,
837 ray_end,
838 r_location,
839 r_hitpoint,
840 r_normal,
841 r_hit);
842 if (*r_hit == -2) {
843 BKE_report(reports,
844 RPT_ERROR,
845 "A non convex collision shape was passed to the function, use only convex "
846 "collision shapes");
847 }
848 }
849 else {
850 *r_hit = -1;
851 BKE_report(reports,
852 RPT_ERROR,
853 "Rigidbody world was not properly initialized, need to step the simulation first");
854 }
855# else
856 UNUSED_VARS(rbw, reports, object, ray_start, ray_end, r_location, r_hitpoint, r_normal, r_hit);
857# endif
858}
859
860static PointerRNA rna_RigidBodyWorld_PointCache_get(PointerRNA *ptr)
861{
862 RigidBodyWorld *rbw = static_cast<RigidBodyWorld *>(ptr->data);
863 return rna_pointer_inherit_refine(ptr, &RNA_PointCache, rbw->shared->pointcache);
864}
865
866#else
867
869{
870 StructRNA *srna;
871 PropertyRNA *prop;
872
873 FunctionRNA *func;
874 PropertyRNA *parm;
875
876 srna = RNA_def_struct(brna, "RigidBodyWorld", nullptr);
877 RNA_def_struct_sdna(srna, "RigidBodyWorld");
879 srna, "Rigid Body World", "Self-contained rigid body simulation environment and settings");
880 RNA_def_struct_path_func(srna, "rna_RigidBodyWorld_path");
881
882 /* groups */
883 prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
884 RNA_def_property_struct_type(prop, "Collection");
885 RNA_def_property_pointer_sdna(prop, nullptr, "group");
889 prop, "Collection", "Collection containing objects participating in this simulation");
890 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_objects_collection_update");
891
892 prop = RNA_def_property(srna, "constraints", PROP_POINTER, PROP_NONE);
893 RNA_def_property_struct_type(prop, "Collection");
897 prop, "Constraints", "Collection containing rigid body constraint objects");
898 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_constraints_collection_update");
899
900 /* booleans */
901 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
903 RNA_def_property_ui_text(prop, "Enabled", "Simulation will be evaluated");
904 RNA_def_property_update(prop, NC_SCENE, nullptr);
905
906 /* time scale */
907 prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
908 RNA_def_property_float_sdna(prop, nullptr, "time_scale");
909 RNA_def_property_range(prop, 0.0f, 100.0f);
910 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
912 RNA_def_property_ui_text(prop, "Time Scale", "Change the speed of the simulation");
913 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
914
915 /* timestep */
916 prop = RNA_def_property(srna, "substeps_per_frame", PROP_INT, PROP_NONE);
917 RNA_def_property_int_sdna(prop, nullptr, "substeps_per_frame");
918 RNA_def_property_range(prop, 1, SHRT_MAX);
919 RNA_def_property_ui_range(prop, 1, 1000, 1, -1);
922 prop,
923 "Substeps Per Frame",
924 "Number of simulation steps taken per frame (higher values are more accurate "
925 "but slower)");
926 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
927
928 /* constraint solver iterations */
929 prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE);
930 RNA_def_property_int_sdna(prop, nullptr, "num_solver_iterations");
931 RNA_def_property_range(prop, 1, 1000);
932 RNA_def_property_ui_range(prop, 10, 100, 1, -1);
935 prop, nullptr, "rna_RigidBodyWorld_num_solver_iterations_set", nullptr);
937 prop,
938 "Solver Iterations",
939 "Number of constraint solver iterations made per simulation step (higher values are more "
940 "accurate but slower)");
941 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
942
943 /* split impulse */
944 prop = RNA_def_property(srna, "use_split_impulse", PROP_BOOLEAN, PROP_NONE);
946 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyWorld_split_impulse_set");
948 prop,
949 "Split Impulse",
950 "Reduce extra velocity that can build up when objects collide (lowers simulation "
951 "stability a little so use only when necessary)");
952 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
953
954 /* cache */
955 prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
958 prop, "rna_RigidBodyWorld_PointCache_get", nullptr, nullptr, nullptr);
959 RNA_def_property_struct_type(prop, "PointCache");
960 RNA_def_property_ui_text(prop, "Point Cache", "");
961
962 /* effector weights */
963 prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
964 RNA_def_property_struct_type(prop, "EffectorWeights");
967 RNA_def_property_ui_text(prop, "Effector Weights", "");
968
969 /* Sweep test */
970 func = RNA_def_function(srna, "convex_sweep_test", "rna_RigidBodyWorld_convex_sweep_test");
972 func, "Sweep test convex rigidbody against the current rigidbody world");
974 parm = RNA_def_pointer(
975 func, "object", "Object", "", "Rigidbody object with a convex collision shape");
978 /* ray start and end */
979 parm = RNA_def_float_vector(func, "start", 3, nullptr, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
981 parm = RNA_def_float_vector(func, "end", 3, nullptr, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
983 parm = RNA_def_float_vector(func,
984 "object_location",
985 3,
986 nullptr,
987 -FLT_MAX,
988 FLT_MAX,
989 "Location",
990 "The hit location of this sweep test",
991 -1e4,
992 1e4);
994 RNA_def_function_output(func, parm);
995 parm = RNA_def_float_vector(func,
996 "hitpoint",
997 3,
998 nullptr,
999 -FLT_MAX,
1000 FLT_MAX,
1001 "Hitpoint",
1002 "The hit location of this sweep test",
1003 -1e4,
1004 1e4);
1006 RNA_def_function_output(func, parm);
1007 parm = RNA_def_float_vector(func,
1008 "normal",
1009 3,
1010 nullptr,
1011 -FLT_MAX,
1012 FLT_MAX,
1013 "Normal",
1014 "The face normal at the sweep test hit location",
1015 -1e4,
1016 1e4);
1018 RNA_def_function_output(func, parm);
1019 parm = RNA_def_int(func,
1020 "has_hit",
1021 0,
1022 0,
1023 0,
1024 "",
1025 "If the function has found collision point, value is 1, otherwise 0",
1026 0,
1027 0);
1028 RNA_def_function_output(func, parm);
1029}
1030
1032{
1033 StructRNA *srna;
1034 PropertyRNA *prop;
1035
1036 srna = RNA_def_struct(brna, "RigidBodyObject", nullptr);
1037 RNA_def_struct_sdna(srna, "RigidBodyOb");
1039 srna, "Rigid Body Object", "Settings for object participating in Rigid Body Simulation");
1040 RNA_def_struct_path_func(srna, "rna_RigidBodyOb_path");
1041
1042 /* Enums */
1043 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1044 RNA_def_property_enum_sdna(prop, nullptr, "type");
1046 RNA_def_property_enum_funcs(prop, nullptr, "rna_RigidBodyOb_type_set", nullptr);
1047 RNA_def_property_ui_text(prop, "Type", "Role of object in Rigid Body Simulations");
1049 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1050
1051 prop = RNA_def_property(srna, "mesh_source", PROP_ENUM, PROP_NONE);
1052 RNA_def_property_enum_sdna(prop, nullptr, "mesh_source");
1055 prop, "Mesh Source", "Source of the mesh used to create collision shape");
1057 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_mesh_source_update");
1058
1059 /* booleans */
1060 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
1062 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyOb_disabled_set");
1063 RNA_def_property_ui_text(prop, "Enabled", "Rigid Body actively participates to the simulation");
1064 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1065
1066 prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE);
1067 RNA_def_property_enum_sdna(prop, nullptr, "shape");
1069 RNA_def_property_enum_funcs(prop, nullptr, "rna_RigidBodyOb_shape_set", nullptr);
1071 prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations");
1073 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_update");
1074
1075 prop = RNA_def_property(srna, "kinematic", PROP_BOOLEAN, PROP_NONE);
1076 RNA_def_property_boolean_sdna(prop, nullptr, "flag", RBO_FLAG_KINEMATIC);
1077 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyOb_kinematic_state_set");
1079 prop, "Kinematic", "Allow rigid body to be controlled by the animation system");
1080 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1081
1082 prop = RNA_def_property(srna, "use_deform", PROP_BOOLEAN, PROP_NONE);
1083 RNA_def_property_boolean_sdna(prop, nullptr, "flag", RBO_FLAG_USE_DEFORM);
1084 RNA_def_property_ui_text(prop, "Deforming", "Rigid body deforms during simulation");
1085 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1086
1087 /* Physics Parameters */
1088 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
1089 RNA_def_property_float_sdna(prop, nullptr, "mass");
1090 RNA_def_property_range(prop, 0.001f, FLT_MAX); /* range must always be positive (and non-zero) */
1092 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_mass_set", nullptr);
1093 RNA_def_property_ui_text(prop, "Mass", "How much the object 'weighs' irrespective of gravity");
1094 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1095
1096 /* Dynamics Parameters - Activation */
1097 /* TODO: define and figure out how to implement these. */
1098
1099 /* Dynamics Parameters - Deactivation */
1100 prop = RNA_def_property(srna, "use_deactivation", PROP_BOOLEAN, PROP_NONE);
1103 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyOb_activation_state_set");
1105 prop,
1106 "Enable Deactivation",
1107 "Enable deactivation of resting rigid bodies (increases performance and stability "
1108 "but can cause glitches)");
1109 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1110
1111 prop = RNA_def_property(srna, "use_start_deactivated", PROP_BOOLEAN, PROP_NONE);
1114 prop, "Start Deactivated", "Deactivate rigid body at the start of the simulation");
1116 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1117
1118 prop = RNA_def_property(srna, "deactivate_linear_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
1119 RNA_def_property_float_sdna(prop, nullptr, "lin_sleep_thresh");
1121 prop, FLT_MIN, FLT_MAX); /* range must always be positive (and non-zero) */
1123 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_linear_sleepThresh_set", nullptr);
1125 "Linear Velocity Deactivation Threshold",
1126 "Linear Velocity below which simulation stops simulating object");
1127 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1128
1129 prop = RNA_def_property(srna, "deactivate_angular_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
1130 RNA_def_property_float_sdna(prop, nullptr, "ang_sleep_thresh");
1132 prop, FLT_MIN, FLT_MAX); /* range must always be positive (and non-zero) */
1134 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_angular_sleepThresh_set", nullptr);
1136 "Angular Velocity Deactivation Threshold",
1137 "Angular Velocity below which simulation stops simulating object");
1138 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1139
1140 /* Dynamics Parameters - Damping Parameters */
1141 prop = RNA_def_property(srna, "linear_damping", PROP_FLOAT, PROP_FACTOR);
1142 RNA_def_property_float_sdna(prop, nullptr, "lin_damping");
1143 RNA_def_property_range(prop, 0.0f, 1.0f);
1144 RNA_def_property_float_default(prop, 0.04f);
1145 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_linear_damping_set", nullptr);
1147 prop, "Linear Damping", "Amount of linear velocity that is lost over time");
1148 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1149
1150 prop = RNA_def_property(srna, "angular_damping", PROP_FLOAT, PROP_FACTOR);
1151 RNA_def_property_float_sdna(prop, nullptr, "ang_damping");
1152 RNA_def_property_range(prop, 0.0f, 1.0f);
1154 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_angular_damping_set", nullptr);
1156 prop, "Angular Damping", "Amount of angular velocity that is lost over time");
1157 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1158
1159 /* Collision Parameters - Surface Parameters */
1160 prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_FACTOR);
1161 RNA_def_property_float_sdna(prop, nullptr, "friction");
1162 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1163 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
1165 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_friction_set", nullptr);
1166 RNA_def_property_ui_text(prop, "Friction", "Resistance of object to movement");
1167 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1168
1169 prop = RNA_def_property(srna, "restitution", PROP_FLOAT, PROP_FACTOR);
1170 RNA_def_property_float_sdna(prop, nullptr, "restitution");
1171 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1172 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
1174 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_restitution_set", nullptr);
1176 "Bounciness",
1177 "Tendency of object to bounce after colliding with another "
1178 "(0 = stays still, 1 = perfectly elastic)");
1179 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1180
1181 /* Collision Parameters - Sensitivity */
1182 prop = RNA_def_property(srna, "use_margin", PROP_BOOLEAN, PROP_NONE);
1183 RNA_def_property_boolean_sdna(prop, nullptr, "flag", RBO_FLAG_USE_MARGIN);
1186 prop,
1187 "Collision Margin",
1188 "Use custom collision margin (some shapes will have a visible gap around them)");
1189 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
1190
1191 prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_UNIT_LENGTH);
1192 RNA_def_property_float_sdna(prop, nullptr, "margin");
1193 RNA_def_property_range(prop, 0.0f, 1.0f);
1194 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 3);
1195 RNA_def_property_float_default(prop, 0.04f);
1196 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyOb_collision_margin_set", nullptr);
1198 prop,
1199 "Collision Margin",
1200 "Threshold of distance near surface where collisions are still considered "
1201 "(best results when non-zero)");
1202 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
1203
1204 prop = RNA_def_property(srna, "collision_collections", PROP_BOOLEAN, PROP_LAYER_MEMBER);
1205 RNA_def_property_boolean_sdna(prop, nullptr, "col_groups", 1);
1206 RNA_def_property_array(prop, 20);
1207 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyOb_collision_collections_set");
1209 prop, "Collision Collections", "Collision collections rigid body belongs to");
1210 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1212}
1213
1215{
1216 StructRNA *srna;
1217 PropertyRNA *prop;
1218
1219 srna = RNA_def_struct(brna, "RigidBodyConstraint", nullptr);
1220 RNA_def_struct_sdna(srna, "RigidBodyCon");
1222 "Rigid Body Constraint",
1223 "Constraint influencing Objects inside Rigid Body Simulation");
1224 RNA_def_struct_path_func(srna, "rna_RigidBodyCon_path");
1225
1226 /* Enums */
1227 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1228 RNA_def_property_enum_sdna(prop, nullptr, "type");
1230 RNA_def_property_enum_funcs(prop, nullptr, "rna_RigidBodyCon_type_set", nullptr);
1231 RNA_def_property_ui_text(prop, "Type", "Type of Rigid Body Constraint");
1233 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1234
1235 prop = RNA_def_property(srna, "spring_type", PROP_ENUM, PROP_NONE);
1236 RNA_def_property_enum_sdna(prop, nullptr, "spring_type");
1238 RNA_def_property_enum_funcs(prop, nullptr, "rna_RigidBodyCon_spring_type_set", nullptr);
1239 RNA_def_property_ui_text(prop, "Spring Type", "Which implementation of spring to use");
1241 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1242
1243 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
1244 RNA_def_property_boolean_sdna(prop, nullptr, "flag", RBC_FLAG_ENABLED);
1245 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyCon_enabled_set");
1246 RNA_def_property_ui_text(prop, "Enabled", "Enable this constraint");
1247 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1248
1249 prop = RNA_def_property(srna, "disable_collisions", PROP_BOOLEAN, PROP_NONE);
1251 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyCon_disable_collisions_set");
1253 prop, "Disable Collisions", "Disable collisions between constrained rigid bodies");
1254 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1255
1256 prop = RNA_def_property(srna, "object1", PROP_POINTER, PROP_NONE);
1257 RNA_def_property_pointer_sdna(prop, nullptr, "ob1");
1260 RNA_def_property_ui_text(prop, "Object 1", "First Rigid Body Object to be constrained");
1261 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1262
1263 prop = RNA_def_property(srna, "object2", PROP_POINTER, PROP_NONE);
1264 RNA_def_property_pointer_sdna(prop, nullptr, "ob2");
1267 RNA_def_property_ui_text(prop, "Object 2", "Second Rigid Body Object to be constrained");
1268 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1269
1270 /* Breaking Threshold */
1271 prop = RNA_def_property(srna, "use_breaking", PROP_BOOLEAN, PROP_NONE);
1273 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyCon_use_breaking_set");
1275 prop, "Breakable", "Constraint can be broken if it receives an impulse above the threshold");
1276 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1277
1278 prop = RNA_def_property(srna, "breaking_threshold", PROP_FLOAT, PROP_NONE);
1279 RNA_def_property_float_sdna(prop, nullptr, "breaking_threshold");
1280 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1281 RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 100.0, 2);
1282 RNA_def_property_float_default(prop, 10.0f);
1283 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_breaking_threshold_set", nullptr);
1285 "Breaking Threshold",
1286 "Impulse threshold that must be reached for the constraint to break");
1287 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1288
1289 /* Solver Iterations */
1290 prop = RNA_def_property(srna, "use_override_solver_iterations", PROP_BOOLEAN, PROP_NONE);
1292 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyCon_override_solver_iterations_set");
1294 "Override Solver Iterations",
1295 "Override the number of solver iterations for this constraint");
1296 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1297
1298 prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE);
1299 RNA_def_property_int_sdna(prop, nullptr, "num_solver_iterations");
1300 RNA_def_property_range(prop, 1, 1000);
1301 RNA_def_property_ui_range(prop, 1, 100, 1, -1);
1303 RNA_def_property_int_funcs(prop, nullptr, "rna_RigidBodyCon_num_solver_iterations_set", nullptr);
1305 prop,
1306 "Solver Iterations",
1307 "Number of constraint solver iterations made per simulation step (higher values are more "
1308 "accurate but slower)");
1309 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1310
1311 /* Limits */
1312 prop = RNA_def_property(srna, "use_limit_lin_x", PROP_BOOLEAN, PROP_NONE);
1314 RNA_def_property_ui_text(prop, "X Axis", "Limit translation on X axis");
1315 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1316
1317 prop = RNA_def_property(srna, "use_limit_lin_y", PROP_BOOLEAN, PROP_NONE);
1319 RNA_def_property_ui_text(prop, "Y Axis", "Limit translation on Y axis");
1320 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1321
1322 prop = RNA_def_property(srna, "use_limit_lin_z", PROP_BOOLEAN, PROP_NONE);
1324 RNA_def_property_ui_text(prop, "Z Axis", "Limit translation on Z axis");
1325 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1326
1327 prop = RNA_def_property(srna, "use_limit_ang_x", PROP_BOOLEAN, PROP_NONE);
1329 RNA_def_property_ui_text(prop, "X Angle", "Limit rotation around X axis");
1330 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1331
1332 prop = RNA_def_property(srna, "use_limit_ang_y", PROP_BOOLEAN, PROP_NONE);
1334 RNA_def_property_ui_text(prop, "Y Angle", "Limit rotation around Y axis");
1335 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1336
1337 prop = RNA_def_property(srna, "use_limit_ang_z", PROP_BOOLEAN, PROP_NONE);
1339 RNA_def_property_ui_text(prop, "Z Angle", "Limit rotation around Z axis");
1340 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1341
1342 prop = RNA_def_property(srna, "use_spring_x", PROP_BOOLEAN, PROP_NONE);
1344 RNA_def_property_ui_text(prop, "X Spring", "Enable spring on X axis");
1345 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1346
1347 prop = RNA_def_property(srna, "use_spring_y", PROP_BOOLEAN, PROP_NONE);
1349 RNA_def_property_ui_text(prop, "Y Spring", "Enable spring on Y axis");
1350 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1351
1352 prop = RNA_def_property(srna, "use_spring_z", PROP_BOOLEAN, PROP_NONE);
1354 RNA_def_property_ui_text(prop, "Z Spring", "Enable spring on Z axis");
1355 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1356
1357 prop = RNA_def_property(srna, "use_spring_ang_x", PROP_BOOLEAN, PROP_NONE);
1359 RNA_def_property_ui_text(prop, "X Angle Spring", "Enable spring on X rotational axis");
1360 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1361
1362 prop = RNA_def_property(srna, "use_spring_ang_y", PROP_BOOLEAN, PROP_NONE);
1364 RNA_def_property_ui_text(prop, "Y Angle Spring", "Enable spring on Y rotational axis");
1365 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1366
1367 prop = RNA_def_property(srna, "use_spring_ang_z", PROP_BOOLEAN, PROP_NONE);
1369 RNA_def_property_ui_text(prop, "Z Angle Spring", "Enable spring on Z rotational axis");
1370 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1371
1372 prop = RNA_def_property(srna, "use_motor_lin", PROP_BOOLEAN, PROP_NONE);
1374 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyCon_use_motor_lin_set");
1375 RNA_def_property_ui_text(prop, "Linear Motor", "Enable linear motor");
1376 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1377
1378 prop = RNA_def_property(srna, "use_motor_ang", PROP_BOOLEAN, PROP_NONE);
1380 RNA_def_property_boolean_funcs(prop, nullptr, "rna_RigidBodyCon_use_motor_ang_set");
1381 RNA_def_property_ui_text(prop, "Angular Motor", "Enable angular motor");
1382 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1383
1384 prop = RNA_def_property(srna, "limit_lin_x_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
1385 RNA_def_property_float_sdna(prop, nullptr, "limit_lin_x_lower");
1386 RNA_def_property_float_default(prop, -1.0f);
1387 RNA_def_property_ui_text(prop, "Lower X Limit", "Lower limit of X axis translation");
1388 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1389
1390 prop = RNA_def_property(srna, "limit_lin_x_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
1391 RNA_def_property_float_sdna(prop, nullptr, "limit_lin_x_upper");
1393 RNA_def_property_ui_text(prop, "Upper X Limit", "Upper limit of X axis translation");
1394 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1395
1396 prop = RNA_def_property(srna, "limit_lin_y_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
1397 RNA_def_property_float_sdna(prop, nullptr, "limit_lin_y_lower");
1398 RNA_def_property_float_default(prop, -1.0f);
1399 RNA_def_property_ui_text(prop, "Lower Y Limit", "Lower limit of Y axis translation");
1400 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1401
1402 prop = RNA_def_property(srna, "limit_lin_y_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
1403 RNA_def_property_float_sdna(prop, nullptr, "limit_lin_y_upper");
1405 RNA_def_property_ui_text(prop, "Upper Y Limit", "Upper limit of Y axis translation");
1406 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1407
1408 prop = RNA_def_property(srna, "limit_lin_z_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
1409 RNA_def_property_float_sdna(prop, nullptr, "limit_lin_z_lower");
1410 RNA_def_property_float_default(prop, -1.0f);
1411 RNA_def_property_ui_text(prop, "Lower Z Limit", "Lower limit of Z axis translation");
1412 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1413
1414 prop = RNA_def_property(srna, "limit_lin_z_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
1415 RNA_def_property_float_sdna(prop, nullptr, "limit_lin_z_upper");
1417 RNA_def_property_ui_text(prop, "Upper Z Limit", "Upper limit of Z axis translation");
1418 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1419
1420 prop = RNA_def_property(srna, "limit_ang_x_lower", PROP_FLOAT, PROP_ANGLE);
1421 RNA_def_property_float_sdna(prop, nullptr, "limit_ang_x_lower");
1422 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1424 RNA_def_property_ui_text(prop, "Lower X Angle Limit", "Lower limit of X axis rotation");
1425 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1426
1427 prop = RNA_def_property(srna, "limit_ang_x_upper", PROP_FLOAT, PROP_ANGLE);
1428 RNA_def_property_float_sdna(prop, nullptr, "limit_ang_x_upper");
1429 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1431 RNA_def_property_ui_text(prop, "Upper X Angle Limit", "Upper limit of X axis rotation");
1432 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1433
1434 prop = RNA_def_property(srna, "limit_ang_y_lower", PROP_FLOAT, PROP_ANGLE);
1435 RNA_def_property_float_sdna(prop, nullptr, "limit_ang_y_lower");
1436 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1438 RNA_def_property_ui_text(prop, "Lower Y Angle Limit", "Lower limit of Y axis rotation");
1439 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1440
1441 prop = RNA_def_property(srna, "limit_ang_y_upper", PROP_FLOAT, PROP_ANGLE);
1442 RNA_def_property_float_sdna(prop, nullptr, "limit_ang_y_upper");
1443 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1445 RNA_def_property_ui_text(prop, "Upper Y Angle Limit", "Upper limit of Y axis rotation");
1446 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1447
1448 prop = RNA_def_property(srna, "limit_ang_z_lower", PROP_FLOAT, PROP_ANGLE);
1449 RNA_def_property_float_sdna(prop, nullptr, "limit_ang_z_lower");
1450 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1452 RNA_def_property_ui_text(prop, "Lower Z Angle Limit", "Lower limit of Z axis rotation");
1453 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1454
1455 prop = RNA_def_property(srna, "limit_ang_z_upper", PROP_FLOAT, PROP_ANGLE);
1456 RNA_def_property_float_sdna(prop, nullptr, "limit_ang_z_upper");
1457 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1459 RNA_def_property_ui_text(prop, "Upper Z Angle Limit", "Upper limit of Z axis rotation");
1460 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1461
1462 prop = RNA_def_property(srna, "spring_stiffness_x", PROP_FLOAT, PROP_NONE);
1463 RNA_def_property_float_sdna(prop, nullptr, "spring_stiffness_x");
1464 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1465 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1466 RNA_def_property_float_default(prop, 10.0f);
1467 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_spring_stiffness_x_set", nullptr);
1468 RNA_def_property_ui_text(prop, "X Axis Stiffness", "Stiffness on the X axis");
1469 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1470
1471 prop = RNA_def_property(srna, "spring_stiffness_y", PROP_FLOAT, PROP_NONE);
1472 RNA_def_property_float_sdna(prop, nullptr, "spring_stiffness_y");
1473 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1474 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1475 RNA_def_property_float_default(prop, 10.0f);
1476 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_spring_stiffness_y_set", nullptr);
1477 RNA_def_property_ui_text(prop, "Y Axis Stiffness", "Stiffness on the Y axis");
1478 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1479
1480 prop = RNA_def_property(srna, "spring_stiffness_z", PROP_FLOAT, PROP_NONE);
1481 RNA_def_property_float_sdna(prop, nullptr, "spring_stiffness_z");
1482 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1483 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1484 RNA_def_property_float_default(prop, 10.0f);
1485 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_spring_stiffness_z_set", nullptr);
1486 RNA_def_property_ui_text(prop, "Z Axis Stiffness", "Stiffness on the Z axis");
1487 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1488
1489 prop = RNA_def_property(srna, "spring_stiffness_ang_x", PROP_FLOAT, PROP_NONE);
1490 RNA_def_property_float_sdna(prop, nullptr, "spring_stiffness_ang_x");
1491 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1492 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1493 RNA_def_property_float_default(prop, 10.0f);
1495 prop, nullptr, "rna_RigidBodyCon_spring_stiffness_ang_x_set", nullptr);
1496 RNA_def_property_ui_text(prop, "X Angle Stiffness", "Stiffness on the X rotational axis");
1497 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1498
1499 prop = RNA_def_property(srna, "spring_stiffness_ang_y", PROP_FLOAT, PROP_NONE);
1500 RNA_def_property_float_sdna(prop, nullptr, "spring_stiffness_ang_y");
1501 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1502 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1503 RNA_def_property_float_default(prop, 10.0f);
1505 prop, nullptr, "rna_RigidBodyCon_spring_stiffness_ang_y_set", nullptr);
1506 RNA_def_property_ui_text(prop, "Y Angle Stiffness", "Stiffness on the Y rotational axis");
1507 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1508
1509 prop = RNA_def_property(srna, "spring_stiffness_ang_z", PROP_FLOAT, PROP_NONE);
1510 RNA_def_property_float_sdna(prop, nullptr, "spring_stiffness_ang_z");
1511 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1512 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1513 RNA_def_property_float_default(prop, 10.0f);
1515 prop, nullptr, "rna_RigidBodyCon_spring_stiffness_ang_z_set", nullptr);
1516 RNA_def_property_ui_text(prop, "Z Angle Stiffness", "Stiffness on the Z rotational axis");
1517 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1518
1519 prop = RNA_def_property(srna, "spring_damping_x", PROP_FLOAT, PROP_NONE);
1520 RNA_def_property_float_sdna(prop, nullptr, "spring_damping_x");
1521 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1523 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_spring_damping_x_set", nullptr);
1524 RNA_def_property_ui_text(prop, "Damping X", "Damping on the X axis");
1525 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1526
1527 prop = RNA_def_property(srna, "spring_damping_y", PROP_FLOAT, PROP_NONE);
1528 RNA_def_property_float_sdna(prop, nullptr, "spring_damping_y");
1529 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1531 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_spring_damping_y_set", nullptr);
1532 RNA_def_property_ui_text(prop, "Damping Y", "Damping on the Y axis");
1533 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1534
1535 prop = RNA_def_property(srna, "spring_damping_z", PROP_FLOAT, PROP_NONE);
1536 RNA_def_property_float_sdna(prop, nullptr, "spring_damping_z");
1537 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1539 RNA_def_property_float_funcs(prop, nullptr, "rna_RigidBodyCon_spring_damping_z_set", nullptr);
1540 RNA_def_property_ui_text(prop, "Damping Z", "Damping on the Z axis");
1541 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1542
1543 prop = RNA_def_property(srna, "spring_damping_ang_x", PROP_FLOAT, PROP_NONE);
1544 RNA_def_property_float_sdna(prop, nullptr, "spring_damping_ang_x");
1545 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1548 prop, nullptr, "rna_RigidBodyCon_spring_damping_ang_x_set", nullptr);
1549 RNA_def_property_ui_text(prop, "Damping X Angle", "Damping on the X rotational axis");
1550 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1551
1552 prop = RNA_def_property(srna, "spring_damping_ang_y", PROP_FLOAT, PROP_NONE);
1553 RNA_def_property_float_sdna(prop, nullptr, "spring_damping_ang_y");
1554 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1557 prop, nullptr, "rna_RigidBodyCon_spring_damping_ang_y_set", nullptr);
1558 RNA_def_property_ui_text(prop, "Damping Y Angle", "Damping on the Y rotational axis");
1559 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1560
1561 prop = RNA_def_property(srna, "spring_damping_ang_z", PROP_FLOAT, PROP_NONE);
1562 RNA_def_property_float_sdna(prop, nullptr, "spring_damping_ang_z");
1563 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1566 prop, nullptr, "rna_RigidBodyCon_spring_damping_ang_z_set", nullptr);
1567 RNA_def_property_ui_text(prop, "Damping Z Angle", "Damping on the Z rotational axis");
1568 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1569
1570 prop = RNA_def_property(srna, "motor_lin_target_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
1571 RNA_def_property_float_sdna(prop, nullptr, "motor_lin_target_velocity");
1573 RNA_def_property_ui_range(prop, -100.0f, 100.0f, 1, 3);
1576 prop, nullptr, "rna_RigidBodyCon_motor_lin_target_velocity_set", nullptr);
1577 RNA_def_property_ui_text(prop, "Target Velocity", "Target linear motor velocity");
1578 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1579
1580 prop = RNA_def_property(srna, "motor_lin_max_impulse", PROP_FLOAT, PROP_NONE);
1581 RNA_def_property_float_sdna(prop, nullptr, "motor_lin_max_impulse");
1582 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1583 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1586 prop, nullptr, "rna_RigidBodyCon_motor_lin_max_impulse_set", nullptr);
1587 RNA_def_property_ui_text(prop, "Max Impulse", "Maximum linear motor impulse");
1588 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1589
1590 prop = RNA_def_property(srna, "motor_ang_target_velocity", PROP_FLOAT, PROP_NONE);
1591 RNA_def_property_float_sdna(prop, nullptr, "motor_ang_target_velocity");
1593 RNA_def_property_ui_range(prop, -100.0f, 100.0f, 1, 3);
1596 prop, nullptr, "rna_RigidBodyCon_motor_ang_target_velocity_set", nullptr);
1597 RNA_def_property_ui_text(prop, "Target Velocity", "Target angular motor velocity");
1598 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1599
1600 prop = RNA_def_property(srna, "motor_ang_max_impulse", PROP_FLOAT, PROP_NONE);
1601 RNA_def_property_float_sdna(prop, nullptr, "motor_ang_max_impulse");
1602 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1603 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1606 prop, nullptr, "rna_RigidBodyCon_motor_ang_max_impulse_set", nullptr);
1607 RNA_def_property_ui_text(prop, "Max Impulse", "Maximum angular motor impulse");
1608 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1609}
1610
1617
1618#endif
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
API for Blender-side Rigid Body stuff.
#define RBO_GET_MASS(rbo)
#define RBO_GET_MARGIN(rbo)
void BKE_rigidbody_cache_reset(struct RigidBodyWorld *rbw)
void BKE_rigidbody_constraints_collection_validate(struct Scene *scene, struct RigidBodyWorld *rbw)
void BKE_rigidbody_objects_collection_validate(struct Main *bmain, struct Scene *scene, struct RigidBodyWorld *rbw)
#define M_PI
#define M_PI_4
#define UNUSED_VARS(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
void DEG_relations_tag_update(Main *bmain)
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
Types and defines for representing Rigid Body entities.
@ RBO_TYPE_ACTIVE
@ RBO_TYPE_PASSIVE
@ RBW_FLAG_MUTED
@ RBW_FLAG_USE_SPLIT_IMPULSE
@ RBO_MESH_DEFORM
@ RBO_MESH_FINAL
@ RBO_MESH_BASE
@ RBC_TYPE_POINT
@ RBC_TYPE_HINGE
@ RBC_TYPE_FIXED
@ RBC_TYPE_SLIDER
@ RBC_TYPE_MOTOR
@ RBC_TYPE_6DOF_SPRING
@ RBC_TYPE_PISTON
@ RBC_TYPE_6DOF
@ RBO_FLAG_USE_MARGIN
@ RBO_FLAG_START_DEACTIVATED
@ RBO_FLAG_KINEMATIC
@ RBO_FLAG_USE_DEFORM
@ RBO_FLAG_NEEDS_VALIDATE
@ RBO_FLAG_USE_DEACTIVATION
@ RBO_FLAG_NEEDS_RESHAPE
@ RBO_FLAG_DISABLED
@ RBC_FLAG_NEEDS_VALIDATE
@ RBC_FLAG_USE_MOTOR_ANG
@ RBC_FLAG_USE_SPRING_Y
@ RBC_FLAG_USE_SPRING_ANG_Y
@ RBC_FLAG_USE_SPRING_ANG_X
@ RBC_FLAG_USE_LIMIT_ANG_X
@ RBC_FLAG_USE_LIMIT_LIN_Y
@ RBC_FLAG_USE_LIMIT_ANG_Y
@ RBC_FLAG_USE_MOTOR_LIN
@ RBC_FLAG_DISABLE_COLLISIONS
@ RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS
@ RBC_FLAG_USE_BREAKING
@ RBC_FLAG_ENABLED
@ RBC_FLAG_USE_SPRING_Z
@ RBC_FLAG_USE_LIMIT_LIN_X
@ RBC_FLAG_USE_SPRING_ANG_Z
@ RBC_FLAG_USE_SPRING_X
@ RBC_FLAG_USE_LIMIT_LIN_Z
@ RBC_FLAG_USE_LIMIT_ANG_Z
@ RB_SHAPE_CAPSULE
@ RB_SHAPE_CONVEXH
@ RB_SHAPE_COMPOUND
@ RB_SHAPE_BOX
@ RB_SHAPE_TRIMESH
@ RB_SHAPE_SPHERE
@ RB_SHAPE_CYLINDER
@ RB_SHAPE_CONE
@ RBC_SPRING_TYPE1
@ RBC_SPRING_TYPE2
Rigid Body API for interfacing with external Physics Engines.
#define RB_LIMIT_LIN_Y
Definition RBI_api.h:311
#define RB_LIMIT_LIN_X
Definition RBI_api.h:310
#define RB_LIMIT_LIN_Z
Definition RBI_api.h:312
#define RB_LIMIT_ANG_X
Definition RBI_api.h:313
#define RB_LIMIT_ANG_Z
Definition RBI_api.h:315
#define RB_LIMIT_ANG_Y
Definition RBI_api.h:314
struct rbConstraint rbConstraint
Definition RBI_api.h:44
ParameterFlag
Definition RNA_types.hh:396
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_UNIT_VELOCITY
Definition RNA_types.hh:84
@ PROP_UNIT_LENGTH
Definition RNA_types.hh:77
@ PROP_UNIT_MASS
Definition RNA_types.hh:80
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:355
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_LIB_EXCEPTION
Definition RNA_types.hh:213
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_ID_SELF_CHECK
Definition RNA_types.hh:259
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:253
@ PROP_LAYER_MEMBER
Definition RNA_types.hh:181
@ PROP_ANGLE
Definition RNA_types.hh:155
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FACTOR
Definition RNA_types.hh:154
#define ND_DRAW
Definition WM_types.hh:428
#define NC_SCENE
Definition WM_types.hh:345
#define ND_POINTCACHE
Definition WM_types.hh:433
#define NC_OBJECT
Definition WM_types.hh:346
void RB_constraint_set_max_impulse_motor(rbConstraint *con, float max_impulse_lin, float max_impulse_ang)
void RB_dworld_set_solver_iterations(rbDynamicsWorld *world, int num_solver_iterations)
void RB_dworld_set_split_impulse(rbDynamicsWorld *world, int split_impulse)
void RB_constraint_set_stiffness_6dof_spring(rbConstraint *con, int axis, float stiffness)
void RB_body_set_restitution(rbRigidBody *object, float value)
void RB_body_set_friction(rbRigidBody *object, float value)
void RB_body_set_mass(rbRigidBody *object, float value)
void RB_body_set_activation_state(rbRigidBody *object, int use_deactivation)
void RB_constraint_set_damping_6dof_spring(rbConstraint *con, int axis, float damping)
void RB_constraint_set_enabled(rbConstraint *con, int enabled)
void RB_body_set_angular_sleep_thresh(rbRigidBody *object, float value)
void RB_constraint_set_stiffness_6dof_spring2(rbConstraint *con, int axis, float stiffness)
void RB_body_set_angular_damping(rbRigidBody *object, float value)
void RB_constraint_set_breaking_threshold(rbConstraint *con, float threshold)
void RB_world_convex_sweep_test(rbDynamicsWorld *world, rbRigidBody *object, const float loc_start[3], const float loc_end[3], float v_location[3], float v_hitpoint[3], float v_normal[3], int *r_hit)
void RB_constraint_set_enable_motor(rbConstraint *con, int enable_lin, int enable_ang)
void RB_body_set_linear_damping(rbRigidBody *object, float value)
void RB_constraint_set_solver_iterations(rbConstraint *con, int num_solver_iterations)
void RB_constraint_set_damping_6dof_spring2(rbConstraint *con, int axis, float damping)
void RB_shape_set_margin(rbCollisionShape *shape, float value)
void RB_body_set_linear_sleep_thresh(rbRigidBody *object, float value)
void RB_body_set_kinematic_state(rbRigidBody *object, int kinematic)
void RB_constraint_set_target_velocity_motor(rbConstraint *con, float velocity_lin, float velocity_ang)
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_boolean_default(PropertyRNA *prop, bool value)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_int_default(PropertyRNA *prop, int value)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_rigidbody(BlenderRNA *brna)
const EnumPropertyItem rna_enum_rigidbody_object_type_items[]
const EnumPropertyItem rna_enum_rigidbody_object_shape_items[]
static void rna_def_rigidbody_object(BlenderRNA *brna)
const EnumPropertyItem rna_enum_rigidbody_constraint_type_items[]
static void rna_def_rigidbody_world(BlenderRNA *brna)
static void rna_def_rigidbody_constraint(BlenderRNA *brna)
static const EnumPropertyItem rigidbody_mesh_source_items[]
static const EnumPropertyItem rna_enum_rigidbody_constraint_spring_type_items[]
#define FLT_MAX
Definition stdcycles.h:14
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
struct RigidBodyOb_Shared * shared
struct PointCache * pointcache
struct RigidBodyWorld_Shared * shared
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138