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