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