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