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"
32 #include "RNA_enum_types.h"
34 #include "rna_internal.h"
36 #include "DNA_group_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_rigidbody_types.h"
39 #include "DNA_scene_types.h"
41 #include "BLI_utildefines.h"
46 /* roles of objects in RigidBody Sims */
47 EnumPropertyItem rigidbody_object_type_items[] = {
48 {RBO_TYPE_ACTIVE, "ACTIVE", 0, "Active", "Object is directly controlled by simulation results"},
49 {RBO_TYPE_PASSIVE, "PASSIVE", 0, "Passive", "Object is directly controlled by animation system"},
50 {0, NULL, 0, NULL, NULL}};
52 /* collision shapes of objects in rigid body sim */
53 EnumPropertyItem rigidbody_object_shape_items[] = {
54 {RB_SHAPE_BOX, "BOX", ICON_MESH_CUBE, "Box", "Box-like shapes (i.e. cubes), including planes (i.e. ground planes)"},
55 {RB_SHAPE_SPHERE, "SPHERE", ICON_MESH_UVSPHERE, "Sphere", ""},
56 {RB_SHAPE_CAPSULE, "CAPSULE", ICON_OUTLINER_OB_META, "Capsule", ""},
57 {RB_SHAPE_CYLINDER, "CYLINDER", ICON_MESH_CYLINDER, "Cylinder", ""},
58 {RB_SHAPE_CONE, "CONE", ICON_MESH_CONE, "Cone", ""},
59 {RB_SHAPE_CONVEXH, "CONVEX_HULL", ICON_MESH_ICOSPHERE, "Convex Hull",
60 "A mesh-like surface encompassing (i.e. shrinkwrap over) all vertices (best results with "
62 {RB_SHAPE_TRIMESH, "MESH", ICON_MESH_MONKEY, "Mesh",
63 "Mesh consisting of triangles only, allowing for more detailed interactions than convex hulls"},
64 {0, NULL, 0, NULL, NULL}};
66 /* collision shapes of constraints in rigid body sim */
67 EnumPropertyItem rigidbody_constraint_type_items[] = {
68 {RBC_TYPE_FIXED, "FIXED", ICON_NONE, "Fixed", "Glue rigid bodies together"},
69 {RBC_TYPE_POINT, "POINT", ICON_NONE, "Point", "Constrain rigid bodies to move around common pivot point"},
70 {RBC_TYPE_HINGE, "HINGE", ICON_NONE, "Hinge", "Restrict rigid body rotation to one axis"},
71 {RBC_TYPE_SLIDER, "SLIDER", ICON_NONE, "Slider", "Restrict rigid body translation to one axis"},
72 {RBC_TYPE_PISTON, "PISTON", ICON_NONE, "Piston", "Restrict rigid body translation and rotation to one axis"},
73 {RBC_TYPE_6DOF, "GENERIC", ICON_NONE, "Generic", "Restrict translation and rotation to specified axes"},
74 {RBC_TYPE_6DOF_SPRING, "GENERIC_SPRING", ICON_NONE, "Generic Spring",
75 "Restrict translation and rotation to specified axes with springs"},
76 {RBC_TYPE_MOTOR, "MOTOR", ICON_NONE, "Motor", "Drive rigid body around or along an axis"},
77 {0, NULL, 0, NULL, NULL}};
80 /* mesh source for collision shape creation */
81 static EnumPropertyItem rigidbody_mesh_source_items[] = {
82 {RBO_MESH_BASE, "BASE", 0, "Base", "Base mesh"},
83 {RBO_MESH_DEFORM, "DEFORM", 0, "Deform", "Deformations (shape keys, deform modifiers)"},
84 {RBO_MESH_FINAL, "FINAL", 0, "Final", "All modifiers"},
85 {0, NULL, 0, NULL, NULL}};
94 #include "BKE_depsgraph.h"
95 #include "BKE_rigidbody.h"
99 #define RB_FLAG_SET(dest, value, flag) { \
107 /* ******************************** */
109 static void rna_RigidBodyWorld_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
111 RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
113 BKE_rigidbody_cache_reset(rbw);
116 static char *rna_RigidBodyWorld_path(PointerRNA *UNUSED(ptr))
118 return BLI_sprintfN("rigidbody_world");
121 static void rna_RigidBodyWorld_num_solver_iterations_set(PointerRNA *ptr, int value)
123 RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
125 rbw->num_solver_iterations = value;
128 if (rbw->physics_world) {
129 RB_dworld_set_solver_iterations(rbw->physics_world, value);
134 static void rna_RigidBodyWorld_split_impulse_set(PointerRNA *ptr, int value)
136 RigidBodyWorld *rbw = (RigidBodyWorld *)ptr->data;
138 RB_FLAG_SET(rbw->flag, value, RBW_FLAG_USE_SPLIT_IMPULSE);
141 if (rbw->physics_world) {
142 RB_dworld_set_split_impulse(rbw->physics_world, value);
147 /* ******************************** */
149 static void rna_RigidBodyOb_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
151 RigidBodyWorld *rbw = scene->rigidbody_world;
153 BKE_rigidbody_cache_reset(rbw);
156 static void rna_RigidBodyOb_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
158 Object *ob = ptr->id.data;
160 rna_RigidBodyOb_reset(bmain, scene, ptr);
162 WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
165 static void rna_RigidBodyOb_shape_reset(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
167 RigidBodyWorld *rbw = scene->rigidbody_world;
168 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
170 BKE_rigidbody_cache_reset(rbw);
171 if (rbo->physics_shape)
172 rbo->flag |= RBO_FLAG_NEEDS_RESHAPE;
175 static char *rna_RigidBodyOb_path(PointerRNA *UNUSED(ptr))
177 /* NOTE: this hardcoded path should work as long as only Objects have this */
178 return BLI_sprintfN("rigid_body");
181 static void rna_RigidBodyOb_type_set(PointerRNA *ptr, int value)
183 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
186 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
189 static void rna_RigidBodyOb_shape_set(PointerRNA *ptr, int value)
191 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
194 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
197 static void rna_RigidBodyOb_disabled_set(PointerRNA *ptr, int value)
199 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
201 RB_FLAG_SET(rbo->flag, !value, RBO_FLAG_DISABLED);
204 /* update kinematic state if necessary - only needed for active bodies */
205 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
206 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
207 RB_body_set_kinematic_state(rbo->physics_object, !value);
208 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
213 static void rna_RigidBodyOb_mass_set(PointerRNA *ptr, float value)
215 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
220 /* only active bodies need mass update */
221 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
222 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
227 static void rna_RigidBodyOb_friction_set(PointerRNA *ptr, float value)
229 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
231 rbo->friction = value;
234 if (rbo->physics_object) {
235 RB_body_set_friction(rbo->physics_object, value);
240 static void rna_RigidBodyOb_restitution_set(PointerRNA *ptr, float value)
242 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
244 rbo->restitution = value;
246 if (rbo->physics_object) {
247 RB_body_set_restitution(rbo->physics_object, value);
252 static void rna_RigidBodyOb_collision_margin_set(PointerRNA *ptr, float value)
254 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
259 if (rbo->physics_shape) {
260 RB_shape_set_margin(rbo->physics_shape, RBO_GET_MARGIN(rbo));
265 static void rna_RigidBodyOb_collision_groups_set(PointerRNA *ptr, const int *values)
267 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
270 for (i = 0; i < 20; i++) {
272 rbo->col_groups |= (1 << i);
274 rbo->col_groups &= ~(1 << i);
276 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
279 static void rna_RigidBodyOb_kinematic_state_set(PointerRNA *ptr, int value)
281 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
283 RB_FLAG_SET(rbo->flag, value, RBO_FLAG_KINEMATIC);
286 /* update kinematic state if necessary */
287 if (rbo->physics_object) {
288 RB_body_set_mass(rbo->physics_object, RBO_GET_MASS(rbo));
289 RB_body_set_kinematic_state(rbo->physics_object, value);
290 rbo->flag |= RBO_FLAG_NEEDS_VALIDATE;
295 static void rna_RigidBodyOb_activation_state_set(PointerRNA *ptr, int value)
297 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
299 RB_FLAG_SET(rbo->flag, value, RBO_FLAG_USE_DEACTIVATION);
302 /* update activation state if necessary - only active bodies can be deactivated */
303 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
304 RB_body_set_activation_state(rbo->physics_object, value);
309 static void rna_RigidBodyOb_linear_sleepThresh_set(PointerRNA *ptr, float value)
311 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
313 rbo->lin_sleep_thresh = value;
316 /* only active bodies need sleep threshold update */
317 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
318 RB_body_set_linear_sleep_thresh(rbo->physics_object, value);
323 static void rna_RigidBodyOb_angular_sleepThresh_set(PointerRNA *ptr, float value)
325 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
327 rbo->ang_sleep_thresh = value;
330 /* only active bodies need sleep threshold update */
331 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
332 RB_body_set_angular_sleep_thresh(rbo->physics_object, value);
337 static void rna_RigidBodyOb_linear_damping_set(PointerRNA *ptr, float value)
339 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
341 rbo->lin_damping = value;
344 /* only active bodies need damping update */
345 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
346 RB_body_set_linear_damping(rbo->physics_object, value);
351 static void rna_RigidBodyOb_angular_damping_set(PointerRNA *ptr, float value)
353 RigidBodyOb *rbo = (RigidBodyOb *)ptr->data;
355 rbo->ang_damping = value;
358 /* only active bodies need damping update */
359 if ((rbo->physics_object) && (rbo->type == RBO_TYPE_ACTIVE)) {
360 RB_body_set_angular_damping(rbo->physics_object, value);
365 static char *rna_RigidBodyCon_path(PointerRNA *UNUSED(ptr))
367 /* NOTE: this hardcoded path should work as long as only Objects have this */
368 return BLI_sprintfN("rigid_body_constraint");
371 static void rna_RigidBodyCon_type_set(PointerRNA *ptr, int value)
373 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
376 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
379 static void rna_RigidBodyCon_enabled_set(PointerRNA *ptr, int value)
381 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
383 RB_FLAG_SET(rbc->flag, value, RBC_FLAG_ENABLED);
386 if (rbc->physics_constraint) {
387 RB_constraint_set_enabled(rbc->physics_constraint, value);
392 static void rna_RigidBodyCon_disable_collisions_set(PointerRNA *ptr, int value)
394 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
396 RB_FLAG_SET(rbc->flag, value, RBC_FLAG_DISABLE_COLLISIONS);
398 rbc->flag |= RBC_FLAG_NEEDS_VALIDATE;
401 static void rna_RigidBodyCon_use_breaking_set(PointerRNA *ptr, int value)
403 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
406 rbc->flag |= RBC_FLAG_USE_BREAKING;
408 if (rbc->physics_constraint) {
409 RB_constraint_set_breaking_threshold(rbc->physics_constraint, rbc->breaking_threshold);
414 rbc->flag &= ~RBC_FLAG_USE_BREAKING;
416 if (rbc->physics_constraint) {
417 RB_constraint_set_breaking_threshold(rbc->physics_constraint, FLT_MAX);
423 static void rna_RigidBodyCon_breaking_threshold_set(PointerRNA *ptr, float value)
425 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
427 rbc->breaking_threshold = value;
430 if (rbc->physics_constraint && (rbc->flag & RBC_FLAG_USE_BREAKING)) {
431 RB_constraint_set_breaking_threshold(rbc->physics_constraint, value);
436 static void rna_RigidBodyCon_override_solver_iterations_set(PointerRNA *ptr, int value)
438 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
441 rbc->flag |= RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
443 if (rbc->physics_constraint) {
444 RB_constraint_set_solver_iterations(rbc->physics_constraint, rbc->num_solver_iterations);
449 rbc->flag &= ~RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS;
451 if (rbc->physics_constraint) {
452 RB_constraint_set_solver_iterations(rbc->physics_constraint, -1);
458 static void rna_RigidBodyCon_num_solver_iterations_set(PointerRNA *ptr, int value)
460 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
462 rbc->num_solver_iterations = value;
465 if (rbc->physics_constraint && (rbc->flag & RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS)) {
466 RB_constraint_set_solver_iterations(rbc->physics_constraint, value);
471 static void rna_RigidBodyCon_spring_stiffness_x_set(PointerRNA *ptr, float value)
473 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
475 rbc->spring_stiffness_x = value;
478 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_X)) {
479 RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_X, value);
484 static void rna_RigidBodyCon_spring_stiffness_y_set(PointerRNA *ptr, float value)
486 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
488 rbc->spring_stiffness_y = value;
491 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Y)) {
492 RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Y, value);
497 static void rna_RigidBodyCon_spring_stiffness_z_set(PointerRNA *ptr, float value)
499 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
501 rbc->spring_stiffness_z = value;
504 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Z)) {
505 RB_constraint_set_stiffness_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, value);
510 static void rna_RigidBodyCon_spring_damping_x_set(PointerRNA *ptr, float value)
512 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
514 rbc->spring_damping_x = value;
517 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_X)) {
518 RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_X, value);
523 static void rna_RigidBodyCon_spring_damping_y_set(PointerRNA *ptr, float value)
525 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
527 rbc->spring_damping_y = value;
529 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Y)) {
530 RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Y, value);
535 static void rna_RigidBodyCon_spring_damping_z_set(PointerRNA *ptr, float value)
537 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
539 rbc->spring_damping_z = value;
541 if (rbc->physics_constraint && rbc->type == RBC_TYPE_6DOF_SPRING && (rbc->flag & RBC_FLAG_USE_SPRING_Z)) {
542 RB_constraint_set_damping_6dof_spring(rbc->physics_constraint, RB_LIMIT_LIN_Z, value);
547 static void rna_RigidBodyCon_motor_lin_max_impulse_set(PointerRNA *ptr, float value)
549 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
551 rbc->motor_lin_max_impulse = value;
554 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
555 RB_constraint_set_max_impulse_motor(rbc->physics_constraint, value, rbc->motor_ang_max_impulse);
560 static void rna_RigidBodyCon_use_motor_lin_set(PointerRNA *ptr, int value)
562 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
564 RB_FLAG_SET(rbc->flag, value, RBC_FLAG_USE_MOTOR_LIN);
567 if (rbc->physics_constraint) {
568 RB_constraint_set_enable_motor(rbc->physics_constraint, rbc->flag & RBC_FLAG_USE_MOTOR_LIN, rbc->flag & RBC_FLAG_USE_MOTOR_ANG);
573 static void rna_RigidBodyCon_use_motor_ang_set(PointerRNA *ptr, int value)
575 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
577 RB_FLAG_SET(rbc->flag, value, RBC_FLAG_USE_MOTOR_ANG);
580 if (rbc->physics_constraint) {
581 RB_constraint_set_enable_motor(rbc->physics_constraint, rbc->flag & RBC_FLAG_USE_MOTOR_LIN, rbc->flag & RBC_FLAG_USE_MOTOR_ANG);
586 static void rna_RigidBodyCon_motor_lin_target_velocity_set(PointerRNA *ptr, float value)
588 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
590 rbc->motor_lin_target_velocity = value;
593 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
594 RB_constraint_set_target_velocity_motor(rbc->physics_constraint, value, rbc->motor_ang_target_velocity);
599 static void rna_RigidBodyCon_motor_ang_max_impulse_set(PointerRNA *ptr, float value)
601 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
603 rbc->motor_ang_max_impulse = value;
606 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
607 RB_constraint_set_max_impulse_motor(rbc->physics_constraint, rbc->motor_lin_max_impulse, value);
612 static void rna_RigidBodyCon_motor_ang_target_velocity_set(PointerRNA *ptr, float value)
614 RigidBodyCon *rbc = (RigidBodyCon *)ptr->data;
616 rbc->motor_ang_target_velocity = value;
619 if (rbc->physics_constraint && rbc->type == RBC_TYPE_MOTOR) {
620 RB_constraint_set_target_velocity_motor(rbc->physics_constraint, rbc->motor_lin_target_velocity, value);
626 static void rna_RigidBodyWorld_convex_sweep_test(
627 RigidBodyWorld *rbw, ReportList *reports,
628 Object *object, float ray_start[3], float ray_end[3],
629 float r_location[3], float r_hitpoint[3], float r_normal[3], int *r_hit)
632 RigidBodyOb *rob = object->rigidbody_object;
634 if (rbw->physics_world != NULL && rob->physics_object != NULL) {
635 RB_world_convex_sweep_test(rbw->physics_world, rob->physics_object, ray_start, ray_end,
636 r_location, r_hitpoint, r_normal, r_hit);
638 BKE_report(reports, RPT_ERROR,
639 "A non convex collision shape was passed to the function, use only convex collision shapes");
644 BKE_report(reports, RPT_ERROR, "Rigidbody world was not properly initialized, need to step the simulation first");
647 UNUSED_VARS(rbw, reports, object, ray_start, ray_end, r_location, r_hitpoint, r_normal, r_hit);
653 static void rna_def_rigidbody_world(BlenderRNA *brna)
659 srna = RNA_def_struct(brna, "RigidBodyWorld", NULL);
660 RNA_def_struct_sdna(srna, "RigidBodyWorld");
661 RNA_def_struct_ui_text(srna, "Rigid Body World", "Self-contained rigid body simulation environment and settings");
662 RNA_def_struct_path_func(srna, "rna_RigidBodyWorld_path");
665 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
666 RNA_def_property_struct_type(prop, "Group");
667 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
668 RNA_def_property_ui_text(prop, "Group", "Group containing objects participating in this simulation");
669 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
671 prop = RNA_def_property(srna, "constraints", PROP_POINTER, PROP_NONE);
672 RNA_def_property_struct_type(prop, "Group");
673 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
674 RNA_def_property_ui_text(prop, "Constraints", "Group containing rigid body constraint objects");
675 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
678 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
679 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBW_FLAG_MUTED);
680 RNA_def_property_ui_text(prop, "Enabled", "Simulation will be evaluated");
681 RNA_def_property_update(prop, NC_SCENE, NULL);
684 prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
685 RNA_def_property_float_sdna(prop, NULL, "time_scale");
686 RNA_def_property_range(prop, 0.0f, 100.0f);
687 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3);
688 RNA_def_property_float_default(prop, 1.0f);
689 RNA_def_property_ui_text(prop, "Time Scale", "Change the speed of the simulation");
690 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
693 prop = RNA_def_property(srna, "steps_per_second", PROP_INT, PROP_NONE);
694 RNA_def_property_int_sdna(prop, NULL, "steps_per_second");
695 RNA_def_property_range(prop, 1, SHRT_MAX);
696 RNA_def_property_ui_range(prop, 60, 1000, 1, -1);
697 RNA_def_property_int_default(prop, 60);
698 RNA_def_property_ui_text(prop, "Steps Per Second",
699 "Number of simulation steps taken per second (higher values are more accurate "
701 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
703 /* constraint solver iterations */
704 prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE);
705 RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations");
706 RNA_def_property_range(prop, 1, 1000);
707 RNA_def_property_ui_range(prop, 10, 100, 1, -1);
708 RNA_def_property_int_default(prop, 10);
709 RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyWorld_num_solver_iterations_set", NULL);
710 RNA_def_property_ui_text(prop, "Solver Iterations",
711 "Number of constraint solver iterations made per simulation step (higher values are more "
712 "accurate but slower)");
713 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
716 prop = RNA_def_property(srna, "use_split_impulse", PROP_BOOLEAN, PROP_NONE);
717 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBW_FLAG_USE_SPLIT_IMPULSE);
718 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyWorld_split_impulse_set");
719 RNA_def_property_ui_text(prop, "Split Impulse",
720 "Reduce extra velocity that can build up when objects collide (lowers simulation "
721 "stability a little so use only when necessary)");
722 RNA_def_property_update(prop, NC_SCENE, "rna_RigidBodyWorld_reset");
725 prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
726 RNA_def_property_flag(prop, PROP_NEVER_NULL);
727 RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
728 RNA_def_property_ui_text(prop, "Point Cache", "");
730 /* effector weights */
731 prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
732 RNA_def_property_struct_type(prop, "EffectorWeights");
733 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
734 RNA_def_property_ui_text(prop, "Effector Weights", "");
737 func = RNA_def_function(srna, "convex_sweep_test", "rna_RigidBodyWorld_convex_sweep_test");
738 RNA_def_function_ui_description(func, "Sweep test convex rigidbody against the current rigidbody world");
739 RNA_def_function_flag(func, FUNC_USE_REPORTS);
741 prop = RNA_def_pointer(func, "object", "Object", "", "Rigidbody object with a convex collision shape");
742 RNA_def_property_flag(prop, PROP_REQUIRED | PROP_NEVER_NULL);
743 RNA_def_property_clear_flag(prop, PROP_THICK_WRAP);
745 /* ray start and end */
746 prop = RNA_def_float_vector(func, "start", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
747 RNA_def_property_flag(prop, PROP_REQUIRED);
748 prop = RNA_def_float_vector(func, "end", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4);
749 RNA_def_property_flag(prop, PROP_REQUIRED);
751 prop = RNA_def_float_vector(func, "object_location", 3, NULL, -FLT_MAX, FLT_MAX, "Location",
752 "The hit location of this sweep test", -1e4, 1e4);
753 RNA_def_property_flag(prop, PROP_THICK_WRAP);
754 RNA_def_function_output(func, prop);
756 prop = RNA_def_float_vector(func, "hitpoint", 3, NULL, -FLT_MAX, FLT_MAX, "Hitpoint",
757 "The hit location of this sweep test", -1e4, 1e4);
758 RNA_def_property_flag(prop, PROP_THICK_WRAP);
759 RNA_def_function_output(func, prop);
761 prop = RNA_def_float_vector(func, "normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal",
762 "The face normal at the sweep test hit location", -1e4, 1e4);
763 RNA_def_property_flag(prop, PROP_THICK_WRAP);
764 RNA_def_function_output(func, prop);
766 prop = RNA_def_int(func, "has_hit", 0, 0, 0, "", "If the function has found collision point, value is 1, otherwise 0", 0, 0);
767 RNA_def_function_output(func, prop);
770 static void rna_def_rigidbody_object(BlenderRNA *brna)
776 srna = RNA_def_struct(brna, "RigidBodyObject", NULL);
777 RNA_def_struct_sdna(srna, "RigidBodyOb");
778 RNA_def_struct_ui_text(srna, "Rigid Body Object", "Settings for object participating in Rigid Body Simulation");
779 RNA_def_struct_path_func(srna, "rna_RigidBodyOb_path");
782 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
783 RNA_def_property_enum_sdna(prop, NULL, "type");
784 RNA_def_property_enum_items(prop, rigidbody_object_type_items);
785 RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyOb_type_set", NULL);
786 RNA_def_property_ui_text(prop, "Type", "Role of object in Rigid Body Simulations");
787 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
788 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
790 prop = RNA_def_property(srna, "mesh_source", PROP_ENUM, PROP_NONE);
791 RNA_def_property_enum_sdna(prop, NULL, "mesh_source");
792 RNA_def_property_enum_items(prop, rigidbody_mesh_source_items);
793 RNA_def_property_ui_text(prop, "Mesh Source", "Source of the mesh used to create collision shape");
794 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
795 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
798 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
799 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", RBO_FLAG_DISABLED);
800 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_disabled_set");
801 RNA_def_property_ui_text(prop, "Enabled", "Rigid Body actively participates to the simulation");
802 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
804 prop = RNA_def_property(srna, "collision_shape", PROP_ENUM, PROP_NONE);
805 RNA_def_property_enum_sdna(prop, NULL, "shape");
806 RNA_def_property_enum_items(prop, rigidbody_object_shape_items);
807 RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyOb_shape_set", NULL);
808 RNA_def_property_ui_text(prop, "Collision Shape", "Collision Shape of object in Rigid Body Simulations");
809 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
810 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_update");
812 prop = RNA_def_property(srna, "kinematic", PROP_BOOLEAN, PROP_NONE);
813 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_KINEMATIC);
814 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_kinematic_state_set");
815 RNA_def_property_ui_text(prop, "Kinematic", "Allow rigid body to be controlled by the animation system");
816 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
818 prop = RNA_def_property(srna, "use_deform", PROP_BOOLEAN, PROP_NONE);
819 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEFORM);
820 RNA_def_property_ui_text(prop, "Deforming", "Rigid body deforms during simulation");
821 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
823 /* Physics Parameters */
824 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
825 RNA_def_property_float_sdna(prop, NULL, "mass");
826 RNA_def_property_range(prop, 0.001f, FLT_MAX); // range must always be positive (and non-zero)
827 RNA_def_property_float_default(prop, 1.0f);
828 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_mass_set", NULL);
829 RNA_def_property_ui_text(prop, "Mass", "How much the object 'weighs' irrespective of gravity");
830 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
832 /* Dynamics Parameters - Activation */
833 // TODO: define and figure out how to implement these
835 /* Dynamics Parameters - Deactivation */
836 prop = RNA_def_property(srna, "use_deactivation", PROP_BOOLEAN, PROP_NONE);
837 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_DEACTIVATION);
838 RNA_def_property_boolean_default(prop, true);
839 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_activation_state_set");
840 RNA_def_property_ui_text(prop, "Enable Deactivation",
841 "Enable deactivation of resting rigid bodies (increases performance and stability "
842 "but can cause glitches)");
843 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
845 prop = RNA_def_property(srna, "use_start_deactivated", PROP_BOOLEAN, PROP_NONE);
846 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_START_DEACTIVATED);
847 RNA_def_property_ui_text(prop, "Start Deactivated", "Deactivate rigid body at the start of the simulation");
848 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
849 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
851 prop = RNA_def_property(srna, "deactivate_linear_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
852 RNA_def_property_float_sdna(prop, NULL, "lin_sleep_thresh");
853 RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
854 RNA_def_property_float_default(prop, 0.4f);
855 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_linear_sleepThresh_set", NULL);
856 RNA_def_property_ui_text(prop, "Linear Velocity Deactivation Threshold",
857 "Linear Velocity below which simulation stops simulating object");
858 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
860 prop = RNA_def_property(srna, "deactivate_angular_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
861 RNA_def_property_float_sdna(prop, NULL, "ang_sleep_thresh");
862 RNA_def_property_range(prop, FLT_MIN, FLT_MAX); // range must always be positive (and non-zero)
863 RNA_def_property_float_default(prop, 0.5f);
864 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_angular_sleepThresh_set", NULL);
865 RNA_def_property_ui_text(prop, "Angular Velocity Deactivation Threshold",
866 "Angular Velocity below which simulation stops simulating object");
867 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
869 /* Dynamics Parameters - Damping Parameters */
870 prop = RNA_def_property(srna, "linear_damping", PROP_FLOAT, PROP_FACTOR);
871 RNA_def_property_float_sdna(prop, NULL, "lin_damping");
872 RNA_def_property_range(prop, 0.0f, 1.0f);
873 RNA_def_property_float_default(prop, 0.04f);
874 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_linear_damping_set", NULL);
875 RNA_def_property_ui_text(prop, "Linear Damping", "Amount of linear velocity that is lost over time");
876 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
878 prop = RNA_def_property(srna, "angular_damping", PROP_FLOAT, PROP_FACTOR);
879 RNA_def_property_float_sdna(prop, NULL, "ang_damping");
880 RNA_def_property_range(prop, 0.0f, 1.0f);
881 RNA_def_property_float_default(prop, 0.1f);
882 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_angular_damping_set", NULL);
883 RNA_def_property_ui_text(prop, "Angular Damping", "Amount of angular velocity that is lost over time");
884 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
886 /* Collision Parameters - Surface Parameters */
887 prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_FACTOR);
888 RNA_def_property_float_sdna(prop, NULL, "friction");
889 RNA_def_property_range(prop, 0.0f, FLT_MAX);
890 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
891 RNA_def_property_float_default(prop, 0.5f);
892 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_friction_set", NULL);
893 RNA_def_property_ui_text(prop, "Friction", "Resistance of object to movement");
894 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
896 prop = RNA_def_property(srna, "restitution", PROP_FLOAT, PROP_FACTOR);
897 RNA_def_property_float_sdna(prop, NULL, "restitution");
898 RNA_def_property_range(prop, 0.0f, FLT_MAX);
899 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3);
900 RNA_def_property_float_default(prop, 0.0f);
901 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_restitution_set", NULL);
902 RNA_def_property_ui_text(prop, "Restitution",
903 "Tendency of object to bounce after colliding with another "
904 "(0 = stays still, 1 = perfectly elastic)");
905 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
907 /* Collision Parameters - Sensitivity */
908 prop = RNA_def_property(srna, "use_margin", PROP_BOOLEAN, PROP_NONE);
909 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBO_FLAG_USE_MARGIN);
910 RNA_def_property_boolean_default(prop, false);
911 RNA_def_property_ui_text(prop, "Collision Margin",
912 "Use custom collision margin (some shapes will have a visible gap around them)");
913 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
915 prop = RNA_def_property(srna, "collision_margin", PROP_FLOAT, PROP_UNIT_LENGTH);
916 RNA_def_property_float_sdna(prop, NULL, "margin");
917 RNA_def_property_range(prop, 0.0f, 1.0f);
918 RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 3);
919 RNA_def_property_float_default(prop, 0.04f);
920 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyOb_collision_margin_set", NULL);
921 RNA_def_property_ui_text(prop, "Collision Margin",
922 "Threshold of distance near surface where collisions are still considered "
923 "(best results when non-zero)");
924 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_shape_reset");
926 prop = RNA_def_property(srna, "collision_groups", PROP_BOOLEAN, PROP_LAYER_MEMBER);
927 RNA_def_property_boolean_sdna(prop, NULL, "col_groups", 1);
928 RNA_def_property_array(prop, 20);
929 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyOb_collision_groups_set");
930 RNA_def_property_ui_text(prop, "Collision Groups", "Collision Groups Rigid Body belongs to");
931 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
932 RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
935 static void rna_def_rigidbody_constraint(BlenderRNA *brna)
940 srna = RNA_def_struct(brna, "RigidBodyConstraint", NULL);
941 RNA_def_struct_sdna(srna, "RigidBodyCon");
942 RNA_def_struct_ui_text(srna, "Rigid Body Constraint",
943 "Constraint influencing Objects inside Rigid Body Simulation");
944 RNA_def_struct_path_func(srna, "rna_RigidBodyCon_path");
947 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
948 RNA_def_property_enum_sdna(prop, NULL, "type");
949 RNA_def_property_enum_items(prop, rigidbody_constraint_type_items);
950 RNA_def_property_enum_funcs(prop, NULL, "rna_RigidBodyCon_type_set", NULL);
951 RNA_def_property_ui_text(prop, "Type", "Type of Rigid Body Constraint");
952 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
953 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
955 prop = RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
956 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_ENABLED);
957 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_enabled_set");
958 RNA_def_property_ui_text(prop, "Enabled", "Enable this constraint");
959 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
961 prop = RNA_def_property(srna, "disable_collisions", PROP_BOOLEAN, PROP_NONE);
962 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_DISABLE_COLLISIONS);
963 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_disable_collisions_set");
964 RNA_def_property_ui_text(prop, "Disable Collisions", "Disable collisions between constrained rigid bodies");
965 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
967 prop = RNA_def_property(srna, "object1", PROP_POINTER, PROP_NONE);
968 RNA_def_property_pointer_sdna(prop, NULL, "ob1");
969 RNA_def_property_flag(prop, PROP_EDITABLE);
970 RNA_def_property_ui_text(prop, "Object 1", "First Rigid Body Object to be constrained");
971 RNA_def_property_flag(prop, PROP_EDITABLE);
972 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
974 prop = RNA_def_property(srna, "object2", PROP_POINTER, PROP_NONE);
975 RNA_def_property_pointer_sdna(prop, NULL, "ob2");
976 RNA_def_property_flag(prop, PROP_EDITABLE);
977 RNA_def_property_ui_text(prop, "Object 2", "Second Rigid Body Object to be constrained");
978 RNA_def_property_flag(prop, PROP_EDITABLE);
979 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
981 /* Breaking Threshold */
982 prop = RNA_def_property(srna, "use_breaking", PROP_BOOLEAN, PROP_NONE);
983 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_BREAKING);
984 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_use_breaking_set");
985 RNA_def_property_ui_text(prop, "Breakable",
986 "Constraint can be broken if it receives an impulse above the threshold");
987 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
989 prop = RNA_def_property(srna, "breaking_threshold", PROP_FLOAT, PROP_NONE);
990 RNA_def_property_float_sdna(prop, NULL, "breaking_threshold");
991 RNA_def_property_range(prop, 0.0f, FLT_MAX);
992 RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 100.0, 2);
993 RNA_def_property_float_default(prop, 10.0f);
994 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_breaking_threshold_set", NULL);
995 RNA_def_property_ui_text(prop, "Breaking Threshold",
996 "Impulse threshold that must be reached for the constraint to break");
997 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
999 /* Solver Iterations */
1000 prop = RNA_def_property(srna, "use_override_solver_iterations", PROP_BOOLEAN, PROP_NONE);
1001 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_OVERRIDE_SOLVER_ITERATIONS);
1002 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_override_solver_iterations_set");
1003 RNA_def_property_ui_text(prop, "Override Solver Iterations",
1004 "Override the number of solver iterations for this constraint");
1005 RNA_def_property_update(prop, NC_OBJECT | ND_POINTCACHE, "rna_RigidBodyOb_reset");
1007 prop = RNA_def_property(srna, "solver_iterations", PROP_INT, PROP_NONE);
1008 RNA_def_property_int_sdna(prop, NULL, "num_solver_iterations");
1009 RNA_def_property_range(prop, 1, 1000);
1010 RNA_def_property_ui_range(prop, 1, 100, 1, -1);
1011 RNA_def_property_int_default(prop, 10);
1012 RNA_def_property_int_funcs(prop, NULL, "rna_RigidBodyCon_num_solver_iterations_set", NULL);
1013 RNA_def_property_ui_text(prop, "Solver Iterations",
1014 "Number of constraint solver iterations made per simulation step (higher values are more "
1015 "accurate but slower)");
1016 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1019 prop = RNA_def_property(srna, "use_limit_lin_x", PROP_BOOLEAN, PROP_NONE);
1020 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_LIN_X);
1021 RNA_def_property_ui_text(prop, "X Axis", "Limit translation on X axis");
1022 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1024 prop = RNA_def_property(srna, "use_limit_lin_y", PROP_BOOLEAN, PROP_NONE);
1025 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_LIN_Y);
1026 RNA_def_property_ui_text(prop, "Y Axis", "Limit translation on Y axis");
1027 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1029 prop = RNA_def_property(srna, "use_limit_lin_z", PROP_BOOLEAN, PROP_NONE);
1030 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_LIN_Z);
1031 RNA_def_property_ui_text(prop, "Z Axis", "Limit translation on Z axis");
1032 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1034 prop = RNA_def_property(srna, "use_limit_ang_x", PROP_BOOLEAN, PROP_NONE);
1035 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_ANG_X);
1036 RNA_def_property_ui_text(prop, "X Angle", "Limit rotation around X axis");
1037 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1039 prop = RNA_def_property(srna, "use_limit_ang_y", PROP_BOOLEAN, PROP_NONE);
1040 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_ANG_Y);
1041 RNA_def_property_ui_text(prop, "Y Angle", "Limit rotation around Y axis");
1042 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1044 prop = RNA_def_property(srna, "use_limit_ang_z", PROP_BOOLEAN, PROP_NONE);
1045 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_LIMIT_ANG_Z);
1046 RNA_def_property_ui_text(prop, "Z Angle", "Limit rotation around Z axis");
1047 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1049 prop = RNA_def_property(srna, "use_spring_x", PROP_BOOLEAN, PROP_NONE);
1050 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_X);
1051 RNA_def_property_ui_text(prop, "X Spring", "Enable spring on X axis");
1052 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1054 prop = RNA_def_property(srna, "use_spring_y", PROP_BOOLEAN, PROP_NONE);
1055 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_Y);
1056 RNA_def_property_ui_text(prop, "Y Spring", "Enable spring on Y axis");
1057 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1059 prop = RNA_def_property(srna, "use_spring_z", PROP_BOOLEAN, PROP_NONE);
1060 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_SPRING_Z);
1061 RNA_def_property_ui_text(prop, "Z Spring", "Enable spring on Z axis");
1062 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1064 prop = RNA_def_property(srna, "use_motor_lin", PROP_BOOLEAN, PROP_NONE);
1065 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_MOTOR_LIN);
1066 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_use_motor_lin_set");
1067 RNA_def_property_ui_text(prop, "Linear Motor", "Enable linear motor");
1068 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1070 prop = RNA_def_property(srna, "use_motor_ang", PROP_BOOLEAN, PROP_NONE);
1071 RNA_def_property_boolean_sdna(prop, NULL, "flag", RBC_FLAG_USE_MOTOR_ANG);
1072 RNA_def_property_boolean_funcs(prop, NULL, "rna_RigidBodyCon_use_motor_ang_set");
1073 RNA_def_property_ui_text(prop, "Angular Motor", "Enable angular motor");
1074 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1076 prop = RNA_def_property(srna, "limit_lin_x_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
1077 RNA_def_property_float_sdna(prop, NULL, "limit_lin_x_lower");
1078 RNA_def_property_float_default(prop, -1.0f);
1079 RNA_def_property_ui_text(prop, "Lower X Limit", "Lower limit of X axis translation");
1080 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1082 prop = RNA_def_property(srna, "limit_lin_x_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
1083 RNA_def_property_float_sdna(prop, NULL, "limit_lin_x_upper");
1084 RNA_def_property_float_default(prop, 1.0f);
1085 RNA_def_property_ui_text(prop, "Upper X Limit", "Upper limit of X axis translation");
1086 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1088 prop = RNA_def_property(srna, "limit_lin_y_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
1089 RNA_def_property_float_sdna(prop, NULL, "limit_lin_y_lower");
1090 RNA_def_property_float_default(prop, -1.0f);
1091 RNA_def_property_ui_text(prop, "Lower Y Limit", "Lower limit of Y axis translation");
1092 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1094 prop = RNA_def_property(srna, "limit_lin_y_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
1095 RNA_def_property_float_sdna(prop, NULL, "limit_lin_y_upper");
1096 RNA_def_property_float_default(prop, 1.0f);
1097 RNA_def_property_ui_text(prop, "Upper Y Limit", "Upper limit of Y axis translation");
1098 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1100 prop = RNA_def_property(srna, "limit_lin_z_lower", PROP_FLOAT, PROP_UNIT_LENGTH);
1101 RNA_def_property_float_sdna(prop, NULL, "limit_lin_z_lower");
1102 RNA_def_property_float_default(prop, -1.0f);
1103 RNA_def_property_ui_text(prop, "Lower Z Limit", "Lower limit of Z axis translation");
1104 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1106 prop = RNA_def_property(srna, "limit_lin_z_upper", PROP_FLOAT, PROP_UNIT_LENGTH);
1107 RNA_def_property_float_sdna(prop, NULL, "limit_lin_z_upper");
1108 RNA_def_property_float_default(prop, 1.0f);
1109 RNA_def_property_ui_text(prop, "Upper Z Limit", "Upper limit of Z axis translation");
1110 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1112 prop = RNA_def_property(srna, "limit_ang_x_lower", PROP_FLOAT, PROP_ANGLE);
1113 RNA_def_property_float_sdna(prop, NULL, "limit_ang_x_lower");
1114 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1115 RNA_def_property_float_default(prop, -M_PI_4);
1116 RNA_def_property_ui_text(prop, "Lower X Angle Limit", "Lower limit of X axis rotation");
1117 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1119 prop = RNA_def_property(srna, "limit_ang_x_upper", PROP_FLOAT, PROP_ANGLE);
1120 RNA_def_property_float_sdna(prop, NULL, "limit_ang_x_upper");
1121 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1122 RNA_def_property_float_default(prop, M_PI_4);
1123 RNA_def_property_ui_text(prop, "Upper X Angle Limit", "Upper limit of X axis rotation");
1124 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1126 prop = RNA_def_property(srna, "limit_ang_y_lower", PROP_FLOAT, PROP_ANGLE);
1127 RNA_def_property_float_sdna(prop, NULL, "limit_ang_y_lower");
1128 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1129 RNA_def_property_float_default(prop, -M_PI_4);
1130 RNA_def_property_ui_text(prop, "Lower Y Angle Limit", "Lower limit of Y axis rotation");
1131 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1133 prop = RNA_def_property(srna, "limit_ang_y_upper", PROP_FLOAT, PROP_ANGLE);
1134 RNA_def_property_float_sdna(prop, NULL, "limit_ang_y_upper");
1135 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1136 RNA_def_property_float_default(prop, M_PI_4);
1137 RNA_def_property_ui_text(prop, "Upper Y Angle Limit", "Upper limit of Y axis rotation");
1138 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1140 prop = RNA_def_property(srna, "limit_ang_z_lower", PROP_FLOAT, PROP_ANGLE);
1141 RNA_def_property_float_sdna(prop, NULL, "limit_ang_z_lower");
1142 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1143 RNA_def_property_float_default(prop, -M_PI_4);
1144 RNA_def_property_ui_text(prop, "Lower Z Angle Limit", "Lower limit of Z axis rotation");
1145 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1147 prop = RNA_def_property(srna, "limit_ang_z_upper", PROP_FLOAT, PROP_ANGLE);
1148 RNA_def_property_float_sdna(prop, NULL, "limit_ang_z_upper");
1149 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1150 RNA_def_property_float_default(prop, M_PI_4);
1151 RNA_def_property_ui_text(prop, "Upper Z Angle Limit", "Upper limit of Z axis rotation");
1152 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_RigidBodyOb_reset");
1154 prop = RNA_def_property(srna, "spring_stiffness_x", PROP_FLOAT, PROP_NONE);
1155 RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_x");
1156 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1157 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1158 RNA_def_property_float_default(prop, 10.0f);
1159 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_stiffness_x_set", NULL);
1160 RNA_def_property_ui_text(prop, "X Axis Stiffness", "Stiffness on the X axis");
1161 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1163 prop = RNA_def_property(srna, "spring_stiffness_y", PROP_FLOAT, PROP_NONE);
1164 RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_y");
1165 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1166 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1167 RNA_def_property_float_default(prop, 10.0f);
1168 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_stiffness_y_set", NULL);
1169 RNA_def_property_ui_text(prop, "Y Axis Stiffness", "Stiffness on the Y axis");
1170 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1172 prop = RNA_def_property(srna, "spring_stiffness_z", PROP_FLOAT, PROP_NONE);
1173 RNA_def_property_float_sdna(prop, NULL, "spring_stiffness_z");
1174 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1175 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1176 RNA_def_property_float_default(prop, 10.0f);
1177 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_stiffness_z_set", NULL);
1178 RNA_def_property_ui_text(prop, "Z Axis Stiffness", "Stiffness on the Z axis");
1179 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1181 prop = RNA_def_property(srna, "spring_damping_x", PROP_FLOAT, PROP_FACTOR);
1182 RNA_def_property_float_sdna(prop, NULL, "spring_damping_x");
1183 RNA_def_property_range(prop, 0.0f, 1.0f);
1184 RNA_def_property_float_default(prop, 0.5f);
1185 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_damping_x_set", NULL);
1186 RNA_def_property_ui_text(prop, "Damping X", "Damping on the X axis");
1187 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1189 prop = RNA_def_property(srna, "spring_damping_y", PROP_FLOAT, PROP_FACTOR);
1190 RNA_def_property_float_sdna(prop, NULL, "spring_damping_y");
1191 RNA_def_property_range(prop, 0.0f, 1.0f);
1192 RNA_def_property_float_default(prop, 0.5f);
1193 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_damping_y_set", NULL);
1194 RNA_def_property_ui_text(prop, "Damping Y", "Damping on the Y axis");
1195 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1197 prop = RNA_def_property(srna, "spring_damping_z", PROP_FLOAT, PROP_FACTOR);
1198 RNA_def_property_float_sdna(prop, NULL, "spring_damping_z");
1199 RNA_def_property_range(prop, 0.0f, 1.0f);
1200 RNA_def_property_float_default(prop, 0.5f);
1201 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_spring_damping_z_set", NULL);
1202 RNA_def_property_ui_text(prop, "Damping Z", "Damping on the Z axis");
1203 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1205 prop = RNA_def_property(srna, "motor_lin_target_velocity", PROP_FLOAT, PROP_UNIT_VELOCITY);
1206 RNA_def_property_float_sdna(prop, NULL, "motor_lin_target_velocity");
1207 RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
1208 RNA_def_property_ui_range(prop, -100.0f, 100.0f, 1, 3);
1209 RNA_def_property_float_default(prop, 1.0f);
1210 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_motor_lin_target_velocity_set", NULL);
1211 RNA_def_property_ui_text(prop, "Target Velocity", "Target linear motor velocity");
1212 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1214 prop = RNA_def_property(srna, "motor_lin_max_impulse", PROP_FLOAT, PROP_NONE);
1215 RNA_def_property_float_sdna(prop, NULL, "motor_lin_max_impulse");
1216 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1217 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1218 RNA_def_property_float_default(prop, 1.0f);
1219 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_motor_lin_max_impulse_set", NULL);
1220 RNA_def_property_ui_text(prop, "Max Impulse", "Maximum linear motor impulse");
1221 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1223 prop = RNA_def_property(srna, "motor_ang_target_velocity", PROP_FLOAT, PROP_NONE);
1224 RNA_def_property_float_sdna(prop, NULL, "motor_ang_target_velocity");
1225 RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
1226 RNA_def_property_ui_range(prop, -100.0f, 100.0f, 1, 3);
1227 RNA_def_property_float_default(prop, 1.0f);
1228 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_motor_ang_target_velocity_set", NULL);
1229 RNA_def_property_ui_text(prop, "Target Velocity", "Target angular motor velocity");
1230 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1232 prop = RNA_def_property(srna, "motor_ang_max_impulse", PROP_FLOAT, PROP_NONE);
1233 RNA_def_property_float_sdna(prop, NULL, "motor_ang_max_impulse");
1234 RNA_def_property_range(prop, 0.0f, FLT_MAX);
1235 RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 3);
1236 RNA_def_property_float_default(prop, 1.0f);
1237 RNA_def_property_float_funcs(prop, NULL, "rna_RigidBodyCon_motor_ang_max_impulse_set", NULL);
1238 RNA_def_property_ui_text(prop, "Max Impulse", "Maximum angular motor impulse");
1239 RNA_def_property_update(prop, NC_OBJECT, "rna_RigidBodyOb_reset");
1242 void RNA_def_rigidbody(BlenderRNA *brna)
1244 rna_def_rigidbody_world(brna);
1245 rna_def_rigidbody_object(brna);
1246 rna_def_rigidbody_constraint(brna);