2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation 2013, Joshua Leung, Sergej Reich
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file rna_rigidbody.c
25 * \brief RNA property definitions for Rigid Body datatypes
31 #include "RNA_define.h"
33 #include "rna_internal.h"
35 #include "DNA_group_types.h"
36 #include "DNA_object_types.h"
37 #include "DNA_rigidbody_types.h"
38 #include "DNA_scene_types.h"
40 #include "BLI_utildefines.h"
45 /* roles of objects in RigidBody Sims */
46 EnumPropertyItem rigidbody_ob_type_items[] = {
47 {RBO_TYPE_ACTIVE, "ACTIVE", 0, "Active", "Object is directly controlled by simulation results"},
48 {RBO_TYPE_PASSIVE, "PASSIVE", 0, "Passive", "Object is directly controlled by animation system"},
49 {0, NULL, 0, NULL, NULL}};
51 /* collision shapes of objects in rigid body sim */
52 EnumPropertyItem rigidbody_ob_shape_items[] = {
53 {RB_SHAPE_BOX, "BOX", ICON_MESH_CUBE, "Box", "Box-like shapes (i.e. cubes), including planes (i.e. ground planes)"},
54 {RB_SHAPE_SPHERE, "SPHERE", ICON_MESH_UVSPHERE, "Sphere", ""},
55 {RB_SHAPE_CAPSULE, "CAPSULE", ICON_OUTLINER_OB_META, "Capsule", ""},
56 {RB_SHAPE_CYLINDER, "CYLINDER", ICON_MESH_CYLINDER, "Cylinder", ""},
57 {RB_SHAPE_CONE, "CONE", ICON_MESH_CONE, "Cone", ""},
58 {RB_SHAPE_CONVEXH, "CONVEX_HULL", ICON_MESH_ICOSPHERE, "Convex Hull", "A mesh-like surface encompassing (i.e. shrinkwrap over) all verts. Best results with fewer vertices"},
59 {RB_SHAPE_TRIMESH, "MESH", ICON_MESH_MONKEY, "Mesh", "Mesh consisting of triangles only, allowing for more detailed interactions than convex hulls"},
60 {0, NULL, 0, NULL, NULL}};
62 /* collision shapes of constraints in rigid body sim */
63 EnumPropertyItem rigidbody_con_type_items[] = {
64 {RBC_TYPE_FIXED, "FIXED", ICON_FORCE_FORCE, "Fixed", "Glues rigid bodies together"},
65 {RBC_TYPE_POINT, "POINT", ICON_FORCE_FORCE, "Point", "Constrains rigid bodies to move aound common pivot point"},
66 {RBC_TYPE_HINGE, "HINGE", ICON_FORCE_FORCE, "Hinge", "Restricts rigid body rotation to one axis"},
67 {RBC_TYPE_SLIDER, "SLIDER", ICON_FORCE_FORCE, "Slider", "Restricts rigid boddy translation to one axis"},
68 {RBC_TYPE_PISTON, "PISTON", ICON_FORCE_FORCE, "Piston", "Restricts rigid boddy translation and rotation to one axis"},
69 {RBC_TYPE_6DOF, "GENERIC", ICON_FORCE_FORCE, "Generic", "Restricts translation and rotation to specified axes"},
70 {RBC_TYPE_6DOF_SPRING, "GENERIC_SPRING", ICON_FORCE_FORCE, "Generic Spring", "Restricts translation and rotation to specified axes with springs"},
71 {0, NULL, 0, NULL, NULL}};
80 #include "BKE_depsgraph.h"
81 #include "BKE_rigidbody.h"
83 #define RB_FLAG_SET(dest, value, flag) { \
91 /* ******************************** */
93 static void rna_RigidBodyWorld_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
95 RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
97 BKE_rigidbody_cache_reset(rbw);
100 static char *rna_RigidBodyWorld_path(PointerRNA *ptr)
102 return BLI_sprintfN("rigidbody_world");
105 static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int value)
107 RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
109 rbw->num_solver_iterations = value;
112 if (rbw->physics_world) {
113 RB_dworld_set_solver_iterations(rbw->physics_world, value);
118 static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value)
120 RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
122 RB_FLAG_SET(rbw->flag, value, RBW_FLAG_USE_SPLIT_IMPULSE);
125 if (rbw->physics_world) {
126 RB_dworld_set_split_impulse(rbw->physics_world, value);
131 /* ******************************** */
133 static void rna_RigidBodyOb_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
135 RigidBodyWorld *rbw = scene->rigidbody_world;
137 BKE_rigidbody_cache_reset(rbw);
140 static void rna_RigidBodyOb_shape_reset(Main *bmain, Scene *scene, PointerRNA *ptr)
142 RigidBodyWorld *rbw = scene->rigidbody_world;
143 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
145 BKE_rigidbody_cache_reset(rbw);
146 if (rbo->physics_shape)
147 rbo->flag |= RBO_FLAG_NEEDS_RESHAPE;
150 static char *rna_RigidBodyOb_path(PointerRNA *ptr)
152 /* NOTE: this hardcoded path should work as long as only Objects have this */
153 return BLI_sprintfN("rigid_body");
156 static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value)
158 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
161 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
164 /* do physics sim updates */
165 if (rbo->physics_object) {
166 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
171 static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value)
173 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
175 RB_FLAG_SET(rbo->flag, !value, RBO_FLAG_DISABLED);
178 /* update kinematic state if necessary - only needed for active bodies */
179 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
180 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
181 RB_body_set_kinematic_state(rbo->physics_object, !value);
182 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
187 static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value)
189 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
190 Object *ob = (Object *)ptr->id.data;
194 /* force creation of new collision shape reflecting this */
195 BKE_rigidbody_validate_sim_shape(ob, TRUE);
198 /* now tell RB sim about it */
199 if (rbo->physics_object && rbo->physics_shape) {
200 RB_body_set_collision_shape(rbo->physics_object, rbo->physics_shape);
206 static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value)
208 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
213 /* only active bodies need mass update */
214 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
215 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
220 static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value)
222 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
224 rbo->friction = value;
227 if (rbo->physics_object) {
228 RB_body_set_friction(rbo->physics_object, value);
233 static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value)
235 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
237 rbo->restitution = value;
239 if (rbo->physics_object) {
240 RB_body_set_restitution(rbo->physics_object, value);
245 static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value)
247 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
252 if (rbo->physics_shape) {
253 RB_shape_set_margin(rbo->physics_shape, RBO_GET_MARGIN(rbo));
258 static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value)
260 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
262 RB_FLAG_SET(rbo->flag, value, RBO_FLAG_KINEMATIC);
265 /* update kinematic state if necessary */
266 if (rbo->physics_object) {
267 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
268 RB_body_set_kinematic_state(rbo->physics_object, value);
269 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
274 static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value)
276 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
278 RB_FLAG_SET(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION);
281 /* update activation state if necessary - only active bodies can be deactivated */
282 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
283 RB_body_set_activation_state(rbo->physics_object, value);
288 static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value)
290 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
292 rbo->lin_sleep_thresh = value;
295 /* only active bodies need sleep threshold update */
296 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
297 RB_body_set_linear_sleep_thresh(rbo->physics_object, value);
302 static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value)
304 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
306 rbo->ang_sleep_thresh = value;
309 /* only active bodies need sleep threshold update */
310 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
311 RB_body_set_angular_sleep_thresh(rbo->physics_object, value);
316 static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value)
318 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
320 rbo->lin_damping = value;
323 /* only active bodies need damping update */
324 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
325 RB_body_set_linear_damping(rbo->physics_object, value);
330 static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value)
332 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
334 rbo->ang_damping = value;
337 /* only active bodies need damping update */
338 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
339 RB_body_set_angular_damping(rbo->physics_object, value);
344 static char *rna_RigidBodyCon_path(PointerRNA *ptr)
346 /* NOTE: this hardcoded path should work as long as only Objects have this */
347 return BLI_sprintfN("rigid_body_constraint");
350 static void rna_RigidBodyCon_type_set(PointerRNA *ptr, int value)
352 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
355 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
358 static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, int value)
360 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
362 RB_FLAG_SET(rbc->flag, value, RBC_FLAG_ENABLED);
365 if (rbc->physics_constraint) {
366 RB_constraint_set_enabled(rbc->physics_constraint, value);
371 static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, int value)
373 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
375 RB_FLAG_SET(rbc->flag, value, RBC_FLAG_DISABLE_COLLISIONS);
377 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
380 static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, int value)
382 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
385 rbc->flag |= RBC_FLAG_USE_BREAKING;
387 if (rbc->physics_constraint) {
388 RB_constraint_set_breaking_threshold(rbc->physics_constraint, rbc->breaking_threshold);
393 rbc->flag &= ~RBC_FLAG_USE_BREAKING;
395 if (rbc->physics_constraint) {
396 RB_constraint_set_breaking_threshold(rbc->physics_constraint, FLT_MAX);
402 static void rna_RigidBodyCon_breaking_threshold_set(PointerRNA *ptr, float value)
404 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
406 rbc->breaking_threshold = value;
409 if (rbc->physics_constraint && (rbc->flag & RBC_FLAG_USE_BREAKING)) {
410 RB_constraint_set_breaking_threshold(rbc->physics_constraint, value);
415 static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, int value)
417 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
420 rbc->flag |= RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
422 if (rbc->physics_constraint) {
423 RB_constraint_set_solver_iterations(rbc->physics_constraint, rbc->num_solver_iterations);
428 rbc->flag &= ~RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
430 if (rbc->physics_constraint) {
431 RB_constraint_set_solver_iterations(rbc->physics_constraint, -1);
437 static void rna_RigidBodyCon_num_solver_iterations_set(PointerRNA *ptr, int value)
439 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
441 rbc->num_solver_iterations = value;
444 if (rbc->physics_constraint && (rbc->flag & RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS)) {
445 RB_constraint_set_solver_iterations(rbc->physics_constraint, value);
450 static void rna_RigidBodyCon_spring_stiffness_x_set(PointerRNA *ptr, float value)
452 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
454 rbc->spring_stiffness_x = value;
457 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_X)) {
458 RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_X, value);
463 static void rna_RigidBodyCon_spring_stiffness_y_set(PointerRNA *ptr, float value)
465 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
467 rbc->spring_stiffness_y = value;
470 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Y)) {
471 RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Y, value);
476 static void rna_RigidBodyCon_spring_stiffness_z_set(PointerRNA *ptr, float value)
478 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
480 rbc->spring_stiffness_z = value;
483 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Z)) {
484 RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, value);
489 static void rna_RigidBodyCon_spring_damping_x_set(PointerRNA *ptr, float value)
491 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
493 rbc->spring_damping_x = value;
496 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_X)) {
497 RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_X, value);
502 static void rna_RigidBodyCon_spring_damping_y_set(PointerRNA *ptr, float value)
504 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
506 rbc->spring_damping_y = value;
508 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Y)) {
509 RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Y, value);
514 static void rna_RigidBodyCon_spring_damping_z_set(PointerRNA *ptr, float value)
516 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
518 rbc->spring_damping_z = value;
520 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Z)) {
521 RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, value);
528 static void rna_def_rigidbody_world(BlenderRNA *brna)
533 srna = RNA_def_struct(brna, "RigidBodyWorld", NULL);
534 RNA_def_struct_sdna(srna, "RigidBodyWorld");
535 RNA_def_struct_ui_text(srna, "Rigid Body World", "Self-contained rigid body simulation environment and settings");
536 RNA_def_struct_path_func(srna, "rna_RigidBodyWorld_path");
539 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
540 RNA_def_property_struct_type(prop, "Group");
541 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
542 RNA_def_property_ui_text(prop, "Group", "Group containing objects participating in this simulation");
543 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
545 prop = RNA_def_property(srna, "constraints", PROP_POINTER, PROP_NONE);
546 RNA_def_property_struct_type(prop, "Group");
547 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
548 RNA_def_property_ui_text(prop, "Constraints", "Group containing rigid body constraint objects");
549 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
552 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
553 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBW_FLAG_MUTED);
554 RNA_def_property_ui_text(prop, "Enabled", "Simulation will be evaluated");
555 RNA_def_property_update(prop, NC_SCENE, NULL);
558 prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
559 RNA_def_property_float_sdna(prop, NULL, "time_scale");
560 RNA_def_property_range(prop, 0.0f, 100.0f);
561 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
562 RNA_def_property_float_default(prop, 1.0f);
563 RNA_def_property_ui_text(prop, "Time Scale", "Changes the speed of the simulation");
564 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
567 prop = RNA_def_property(srna, "steps_per_second", PROP_INT, PROP_NONE);
568 RNA_def_property_int_sdna(prop, NULL, "steps_per_second");
569 RNA_def_property_range(prop, 1, SHRT_MAX);
570 RNA_def_property_ui_range(prop, 60, 1000, 1, 0);
571 RNA_def_property_int_default(prop, 60);
572 RNA_def_property_ui_text(prop, "Steps Per Second", "Number of simulation steps taken per second (higher values are more accurate but slower)");
573 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
575 /* constraint solver iterations */
576 prop = RNA_def_property(srna, "num_solver_iterations", PROP_INT, PROP_NONE);
577 RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations");
578 RNA_def_property_range(prop, 1, 1000);
579 RNA_def_property_ui_range(prop, 10, 100, 1, 0);
580 RNA_def_property_int_default(prop, 10);
581 RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyWorld_num_solver_iterations_set", NULL);
582 RNA_def_property_ui_text(prop, "Solver Iterations", "Number of constraint solver iterations made per simulation step (higher values are more accurate but slower)");
583 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
586 prop = RNA_def_property(srna, "use_split_impulse", PROP_BOOLEAN, PROP_NONE);
587 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBW_FLAG_USE_SPLIT_IMPULSE);
588 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyWorld_split_impulse_set");
589 RNA_def_property_ui_text(prop, "Split Impulse", "Reduces extra velocity that can build up when objects collide (lowers simulation stabilty a litte so use only when necessary)");
590 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
593 prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
594 RNA_def_property_flag(prop, PROP_NEVER_NULL);
595 RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
596 RNA_def_property_ui_text(prop, "Point Cache", "");
598 /* effector weights */
599 prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
600 RNA_def_property_struct_type(prop, "EffectorWeights");
601 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
602 RNA_def_property_ui_text(prop, "Effector Weights", "");
605 static void rna_def_rigidbody_object(BlenderRNA *brna)
611 srna = RNA_def_struct(brna, "RigidBodyObject", NULL);
612 RNA_def_struct_sdna(srna, "RigidBodyOb");
613 RNA_def_struct_ui_text(srna, "Rigid Body Object", "Settings for object participating in Rigid Body Simulation");
614 RNA_def_struct_path_func(srna, "rna_RigidBodyOb_path");
617 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
618 RNA_def_property_enum_sdna(prop, NULL, "type");
619 RNA_def_property_enum_items(prop, rigidbody_ob_type_items);
620 RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyOb_type_set", NULL);
621 RNA_def_property_ui_text(prop, "Type", "Role of object in Rigid Body Simulations");
622 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
623 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
626 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
627 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBO_FLAG_DISABLED);
628 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_disabled_set");
629 RNA_def_property_ui_text(prop, "Enabled", "Rigid Body actively participated in the simulation");
630 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
632 prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE);
633 RNA_def_property_enum_sdna(prop, NULL, "shape");
634 RNA_def_property_enum_items(prop, rigidbody_ob_shape_items);
635 RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyOb_shape_set", NULL);
636 RNA_def_property_ui_text(prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations");
637 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
639 prop = RNA_def_property(srna, "kinematic", PROP_BOOLEAN, PROP_NONE);
640 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_KINEMATIC);
641 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_kinematic_state_set");
642 RNA_def_property_ui_text(prop, "Kinematic", "Allows rigid body to be controlled by the animation system");
643 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
645 /* Physics Parameters */
646 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
647 RNA_def_property_float_sdna(prop, NULL, "mass");
648 RNA_def_property_range(prop, 0.001f, FLT_MAX); // range must always be positive (and non-zero)
649 RNA_def_property_float_default(prop, 1.0f);
650 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_mass_set", NULL);
651 RNA_def_property_ui_text(prop, "Mass", "How much the object 'weighs' irrespective of gravity");
652 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
654 /* Dynamics Parameters - Activation */
655 // TODO: define and figure out how to implement these
657 /* Dynamics Parameters - Deactivation */
658 prop = RNA_def_property(srna, "use_deactivation", PROP_BOOLEAN, PROP_NONE);
659 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEACTIVATION);
660 RNA_def_property_boolean_default(prop, TRUE);
661 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_activation_state_set");
662 RNA_def_property_ui_text(prop, "Enable Deactivation", "Enables deactivation of resting rigid bodies (increases performance and stability but can cause glitches)");
663 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
665 prop = RNA_def_property(srna, "start_deactivated", PROP_BOOLEAN, PROP_NONE);
666 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_START_DEACTIVATED);
667 RNA_def_property_ui_text(prop, "Start Deactivated", "Deactivates rigid body at the start of the simulation");
668 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
669 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
671 prop = RNA_def_property(srna, "deactivate_linear_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
672 RNA_def_property_float_sdna(prop, NULL, "lin_sleep_thresh");
673 RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
674 RNA_def_property_float_default(prop, 0.4f);
675 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_linear_sleepThresh_set", NULL);
676 RNA_def_property_ui_text(prop, "Linear Velocity Deactivation Threshold", "Linear Velocity below which simulation stops simulating object");
677 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
679 prop = RNA_def_property(srna, "deactivate_angular_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
680 RNA_def_property_float_sdna(prop, NULL, "ang_sleep_thresh");
681 RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
682 RNA_def_property_float_default(prop, 0.5f);
683 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_angular_sleepThresh_set", NULL);
684 RNA_def_property_ui_text(prop, "Angular Velocity Deactivation Threshold", "Angular Velocity below which simulation stops simulating object");
685 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
687 /* Dynamics Parameters - Damping Parameters */
688 prop = RNA_def_property(srna, "linear_damping", PROP_FLOAT, PROP_FACTOR);
689 RNA_def_property_float_sdna(prop, NULL, "lin_damping");
690 RNA_def_property_range(prop, 0.0f, 1.0f);
691 RNA_def_property_float_default(prop, 0.04f);
692 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_linear_damping_set", NULL);
693 RNA_def_property_ui_text(prop, "Linear Damping", "Amount of linear velocity that is lost over time");
694 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
696 prop = RNA_def_property(srna, "angular_damping", PROP_FLOAT, PROP_FACTOR);
697 RNA_def_property_float_sdna(prop, NULL, "ang_damping");
698 RNA_def_property_range(prop, 0.0f, 1.0f);
699 RNA_def_property_float_default(prop, 0.1f);
700 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_angular_damping_set", NULL);
701 RNA_def_property_ui_text(prop, "Angular Damping", "Amount of angular velocity that is lost over time");
702 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
704 /* Collision Parameters - Surface Parameters */
705 prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_FACTOR);
706 RNA_def_property_float_sdna(prop, NULL, "friction");
707 RNA_def_property_range(prop, 0.0f, FLT_MAX);
708 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
709 RNA_def_property_float_default(prop, 0.5f);
710 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_friction_set", NULL);
711 RNA_def_property_ui_text(prop, "Friction", "Resistance of object to movement");
712 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
714 prop = RNA_def_property(srna, "restitution", PROP_FLOAT, PROP_FACTOR);
715 RNA_def_property_float_sdna(prop, NULL, "restitution");
716 RNA_def_property_range(prop, 0.0f, FLT_MAX);
717 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
718 RNA_def_property_float_default(prop, 0.0f);
719 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_restitution_set", NULL);
720 RNA_def_property_ui_text(prop, "Restitution", "Tendency of object to bounce after colliding with another (0 = stays still, 1 = perfectly elastic)");
721 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
723 /* Collision Parameters - Sensitivity */
724 prop = RNA_def_property(srna, "use_margin", PROP_BOOLEAN, PROP_NONE);
725 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_MARGIN);
726 RNA_def_property_boolean_default(prop, FALSE);
727 RNA_def_property_ui_text(prop, "Collision Margin", "Use custom collision margin (some shapes will have a visible gap around them)");
728 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
730 prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_UNIT_LENGTH);
731 RNA_def_property_float_sdna(prop, NULL, "margin");
732 RNA_def_property_range(prop, 0.0f, 1.0f);
733 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 3);
734 RNA_def_property_float_default(prop, 0.04f);
735 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_collision_margin_set", NULL);
736 RNA_def_property_ui_text(prop, "Collision Margin", "Threshold of distance near surface where collisions are still considered (best results when non-zero)");
737 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
739 prop = RNA_def_property(srna, "collision_groups", PROP_BOOLEAN, PROP_LAYER_MEMBER);
740 RNA_def_property_boolean_sdna(prop, NULL, "col_groups", 1);
741 RNA_def_property_array(prop, 20);
742 RNA_def_property_ui_text(prop, "Collison Groups", "Collision Groups Rigid Body belongs to");
743 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
744 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
747 static void rna_def_rigidbody_constraint(BlenderRNA *brna)
752 srna = RNA_def_struct(brna, "RigidBodyConstraint", NULL);
753 RNA_def_struct_sdna(srna, "RigidBodyCon");
754 RNA_def_struct_ui_text(srna, "Rigid Body Constraint", "Constraint influencing Objects inside Rigid Body Simulation");
755 RNA_def_struct_path_func(srna, "rna_RigidBodyCon_path");
758 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
759 RNA_def_property_enum_sdna(prop, NULL, "type");
760 RNA_def_property_enum_items(prop, rigidbody_con_type_items);
761 RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyCon_type_set", NULL);
762 RNA_def_property_ui_text(prop, "Type", "Type of Rigid Body Constraint");
763 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
764 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
766 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
767 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_ENABLED);
768 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_enabled_set");
769 RNA_def_property_ui_text(prop, "Enabled", "Enable this constraint");
770 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
772 prop = RNA_def_property(srna, "disable_collisions", PROP_BOOLEAN, PROP_NONE);
773 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_DISABLE_COLLISIONS);
774 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_disable_collisions_set");
775 RNA_def_property_ui_text(prop, "Disable Collisions", "Disables collisions between constrained ridid bodies");
776 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
778 prop = RNA_def_property(srna, "object1", PROP_POINTER, PROP_NONE);
779 RNA_def_property_pointer_sdna(prop, NULL, "ob1");
780 RNA_def_property_flag(prop, PROP_EDITABLE);
781 RNA_def_property_ui_text(prop, "Object 1", "First Rigid Body Object to be constrained");
782 RNA_def_property_flag(prop, PROP_EDITABLE);
783 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
785 prop = RNA_def_property(srna, "object2", PROP_POINTER, PROP_NONE);
786 RNA_def_property_pointer_sdna(prop, NULL, "ob2");
787 RNA_def_property_flag(prop, PROP_EDITABLE);
788 RNA_def_property_ui_text(prop, "Object 2", "Second Rigid Body Object to be constrained");
789 RNA_def_property_flag(prop, PROP_EDITABLE);
790 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
792 /* Breaking Threshold */
793 prop = RNA_def_property(srna, "use_breaking", PROP_BOOLEAN, PROP_NONE);
794 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_BREAKING);
795 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_use_breaking_set");
796 RNA_def_property_ui_text(prop, "Breakable", "Constraint can be broaken if it receives an impulse above the threshold");
797 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
799 prop = RNA_def_property(srna, "breaking_threshold", PROP_FLOAT, PROP_NONE);
800 RNA_def_property_float_sdna(prop, NULL, "breaking_threshold");
801 RNA_def_property_range(prop, 0.0f, FLT_MAX);
802 RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 100.0, 2);
803 RNA_def_property_float_default(prop, 10.0f);
804 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_breaking_threshold_set", NULL);
805 RNA_def_property_ui_text(prop, "Breaking Threshold", "Impulse threshold that must be reached for the constraint to break");
806 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
808 /* Solver Iterations */
809 prop = RNA_def_property(srna, "override_solver_iterations", PROP_BOOLEAN, PROP_NONE);
810 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS);
811 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_override_solver_iterations_set");
812 RNA_def_property_ui_text(prop, "Override Solver Iterations", "Overrides the number of solver iterations for this constraint");
813 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
815 prop = RNA_def_property(srna, "num_solver_iterations", PROP_INT, PROP_NONE);
816 RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations");
817 RNA_def_property_range(prop, 1, 1000);
818 RNA_def_property_ui_range(prop, 1, 100, 1, 0);
819 RNA_def_property_int_default(prop, 10);
820 RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyCon_num_solver_iterations_set", NULL);
821 RNA_def_property_ui_text(prop, "Solver Iterations", "Number of constraint solver iterations made per simulation step (higher values are more accurate but slower)");
822 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
825 prop = RNA_def_property(srna, "use_limit_lin_x", PROP_BOOLEAN, PROP_NONE);
826 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_LIN_X);
827 RNA_def_property_ui_text(prop, "X Axis", "Limits translation on x axis");
828 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
830 prop = RNA_def_property(srna, "use_limit_lin_y", PROP_BOOLEAN, PROP_NONE);
831 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_LIN_Y);
832 RNA_def_property_ui_text(prop, "Y Axis", "Limits translation on y axis");
833 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
835 prop = RNA_def_property(srna, "use_limit_lin_z", PROP_BOOLEAN, PROP_NONE);
836 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_LIN_Z);
837 RNA_def_property_ui_text(prop, "Z Axis", "Limits translation on z axis");
838 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
840 prop = RNA_def_property(srna, "use_limit_ang_x", PROP_BOOLEAN, PROP_NONE);
841 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_ANG_X);
842 RNA_def_property_ui_text(prop, "X Angle", "Limits rotation around x axis");
843 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
845 prop = RNA_def_property(srna, "use_limit_ang_y", PROP_BOOLEAN, PROP_NONE);
846 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_ANG_Y);
847 RNA_def_property_ui_text(prop, "Y Angle", "Limits rotation around y axis");
848 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
850 prop = RNA_def_property(srna, "use_limit_ang_z", PROP_BOOLEAN, PROP_NONE);
851 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_ANG_Z);
852 RNA_def_property_ui_text(prop, "Z Angle", "Limits rotation around z axis");
853 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
855 prop = RNA_def_property(srna, "use_spring_x", PROP_BOOLEAN, PROP_NONE);
856 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_X);
857 RNA_def_property_ui_text(prop, "X Spring", "Enables spring on X axis");
858 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
860 prop = RNA_def_property(srna, "use_spring_y", PROP_BOOLEAN, PROP_NONE);
861 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_Y);
862 RNA_def_property_ui_text(prop, "Y Spring", "Enables spring on Y axis");
863 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
865 prop = RNA_def_property(srna, "use_spring_z", PROP_BOOLEAN, PROP_NONE);
866 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_Z);
867 RNA_def_property_ui_text(prop, "Z Spring", "Enables spring on Z axis");
868 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
870 prop = RNA_def_property(srna, "limit_lin_x_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
871 RNA_def_property_float_sdna(prop, NULL, "limit_lin_x_lower");
872 RNA_def_property_float_default(prop, -1.0f);
873 RNA_def_property_ui_text(prop, "Lower X Limit", "Lower limit of x axis translation");
874 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
876 prop = RNA_def_property(srna, "limit_lin_x_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
877 RNA_def_property_float_sdna(prop, NULL, "limit_lin_x_upper");
878 RNA_def_property_float_default(prop, 1.0f);
879 RNA_def_property_ui_text(prop, "Upper X Limit", "Upper limit of x axis translation");
880 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
882 prop = RNA_def_property(srna, "limit_lin_y_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
883 RNA_def_property_float_sdna(prop, NULL, "limit_lin_y_lower");
884 RNA_def_property_float_default(prop, -1.0f);
885 RNA_def_property_ui_text(prop, "Lower Y Limit", "Lower limit of y axis translation");
886 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
888 prop = RNA_def_property(srna, "limit_lin_y_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
889 RNA_def_property_float_sdna(prop, NULL, "limit_lin_y_upper");
890 RNA_def_property_float_default(prop, 1.0f);
891 RNA_def_property_ui_text(prop, "Upper Y Limit", "Upper limit of y axis translation");
892 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
894 prop = RNA_def_property(srna, "limit_lin_z_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
895 RNA_def_property_float_sdna(prop, NULL, "limit_lin_z_lower");
896 RNA_def_property_float_default(prop, -1.0f);
897 RNA_def_property_ui_text(prop, "Lower Z Limit", "Lower limit of z axis translation");
898 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
900 prop = RNA_def_property(srna, "limit_lin_z_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
901 RNA_def_property_float_sdna(prop, NULL, "limit_lin_z_upper");
902 RNA_def_property_float_default(prop, 1.0f);
903 RNA_def_property_ui_text(prop, "Upper Z Limit", "Upper limit of z axis translation");
904 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
906 prop = RNA_def_property(srna, "limit_ang_x_lower", PROP_FLOAT, PROP_ANGLE);
907 RNA_def_property_float_sdna(prop, NULL, "limit_ang_x_lower");
908 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
909 RNA_def_property_float_default(prop, -M_PI_4);
910 RNA_def_property_ui_text(prop, "Lower X Angle Limit", "Lower limit of x axis rotation");
911 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
913 prop = RNA_def_property(srna, "limit_ang_x_upper", PROP_FLOAT, PROP_ANGLE);
914 RNA_def_property_float_sdna(prop, NULL, "limit_ang_x_upper");
915 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
916 RNA_def_property_float_default(prop, M_PI_4);
917 RNA_def_property_ui_text(prop, "Upper X Angle Limit", "Upper limit of x axis rotation");
918 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
920 prop = RNA_def_property(srna, "limit_ang_y_lower", PROP_FLOAT, PROP_ANGLE);
921 RNA_def_property_float_sdna(prop, NULL, "limit_ang_y_lower");
922 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
923 RNA_def_property_float_default(prop, -M_PI_4);
924 RNA_def_property_ui_text(prop, "Lower Y Angle Limit", "Lower limit of y axis rotation");
925 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
927 prop = RNA_def_property(srna, "limit_ang_y_upper", PROP_FLOAT, PROP_ANGLE);
928 RNA_def_property_float_sdna(prop, NULL, "limit_ang_y_upper");
929 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
930 RNA_def_property_float_default(prop, M_PI_4);
931 RNA_def_property_ui_text(prop, "Upper Y Angle Limit", "Upper limit of y axis rotation");
932 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
934 prop = RNA_def_property(srna, "limit_ang_z_lower", PROP_FLOAT, PROP_ANGLE);
935 RNA_def_property_float_sdna(prop, NULL, "limit_ang_z_lower");
936 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
937 RNA_def_property_float_default(prop, -M_PI_4);
938 RNA_def_property_ui_text(prop, "Lower Z Angle Limit", "Lower limit of z axis rotation");
939 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
941 prop = RNA_def_property(srna, "limit_ang_z_upper", PROP_FLOAT, PROP_ANGLE);
942 RNA_def_property_float_sdna(prop, NULL, "limit_ang_z_upper");
943 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
944 RNA_def_property_float_default(prop, M_PI_4);
945 RNA_def_property_ui_text(prop, "Upper Z Angle Limit", "Upper limit of z axis rotation");
946 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
948 prop = RNA_def_property(srna, "spring_stiffness_x", PROP_FLOAT, PROP_UNIT_LENGTH);
949 RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_x");
950 RNA_def_property_range(prop, 0.0f, FLT_MAX);
951 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
952 RNA_def_property_float_default(prop, 10.0f);
953 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_stiffness_x_set", NULL);
954 RNA_def_property_ui_text(prop, "X Axis Stiffness", "Stiffness on the X axis");
955 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
957 prop = RNA_def_property(srna, "spring_stiffness_y", PROP_FLOAT, PROP_UNIT_LENGTH);
958 RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_y");
959 RNA_def_property_range(prop, 0.0f, FLT_MAX);
960 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
961 RNA_def_property_float_default(prop, 10.0f);
962 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_stiffness_y_set", NULL);
963 RNA_def_property_ui_text(prop, "Y Axis Stiffness", "Stiffness on the Y axis");
964 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
966 prop = RNA_def_property(srna, "spring_stiffness_z", PROP_FLOAT, PROP_UNIT_LENGTH);
967 RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_z");
968 RNA_def_property_range(prop, 0.0f, FLT_MAX);
969 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
970 RNA_def_property_float_default(prop, 10.0f);
971 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_stiffness_z_set", NULL);
972 RNA_def_property_ui_text(prop, "Z Axis Stiffness", "Stiffness on the Z axis");
973 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
975 prop = RNA_def_property(srna, "spring_damping_x", PROP_FLOAT, PROP_FACTOR);
976 RNA_def_property_float_sdna(prop, NULL, "spring_damping_x");
977 RNA_def_property_range(prop, 0.0f, 1.0f);
978 RNA_def_property_float_default(prop, 0.5f);
979 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_damping_x_set", NULL);
980 RNA_def_property_ui_text(prop, "Damping X", "Damping on the X axis");
981 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
983 prop = RNA_def_property(srna, "spring_damping_y", PROP_FLOAT, PROP_FACTOR);
984 RNA_def_property_float_sdna(prop, NULL, "spring_damping_y");
985 RNA_def_property_range(prop, 0.0f, 1.0f);
986 RNA_def_property_float_default(prop, 0.5f);
987 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_damping_y_set", NULL);
988 RNA_def_property_ui_text(prop, "Damping Y", "Damping on the Y axis");
989 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
991 prop = RNA_def_property(srna, "spring_damping_z", PROP_FLOAT, PROP_FACTOR);
992 RNA_def_property_float_sdna(prop, NULL, "spring_damping_z");
993 RNA_def_property_range(prop, 0.0f, 1.0f);
994 RNA_def_property_float_default(prop, 0.5f);
995 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_damping_z_set", NULL);
996 RNA_def_property_ui_text(prop, "Damping Z", "Damping on the Z axis");
997 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1000 void RNA_def_rigidbody(BlenderRNA *brna)
1002 rna_def_rigidbody_world(brna);
1003 rna_def_rigidbody_object(brna);
1004 rna_def_rigidbody_constraint(brna);