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