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 (2008), Joshua Leung, Roland Hess
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_constraint.c
31 #include "BLF_translation.h"
33 #include "DNA_action_types.h"
34 #include "DNA_constraint_types.h"
35 #include "DNA_modifier_types.h"
36 #include "DNA_object_types.h"
37 #include "DNA_scene_types.h"
39 #include "RNA_define.h"
40 #include "RNA_enum_types.h"
42 #include "rna_internal.h"
46 #include "ED_object.h"
48 /* please keep the names in sync with constraint.c */
49 EnumPropertyItem constraint_type_items[] = {
50 {0, "", 0, N_("Motion Tracking"), ""},
51 {CONSTRAINT_TYPE_CAMERASOLVER, "CAMERA_SOLVER", ICON_CONSTRAINT_DATA, "Camera Solver", ""},
52 {CONSTRAINT_TYPE_FOLLOWTRACK, "FOLLOW_TRACK", ICON_CONSTRAINT_DATA, "Follow Track", ""},
53 {CONSTRAINT_TYPE_OBJECTSOLVER, "OBJECT_SOLVER", ICON_CONSTRAINT_DATA, "Object Solver", ""},
54 {0, "", 0, N_("Transform"), ""},
55 {CONSTRAINT_TYPE_LOCLIKE, "COPY_LOCATION", ICON_CONSTRAINT_DATA, "Copy Location",
56 "Copy the location of a target (with an optional offset), so that they move together"},
57 {CONSTRAINT_TYPE_ROTLIKE, "COPY_ROTATION", ICON_CONSTRAINT_DATA, "Copy Rotation",
58 "Copy the rotation of a target (with an optional offset), so that they rotate together"},
59 {CONSTRAINT_TYPE_SIZELIKE, "COPY_SCALE", ICON_CONSTRAINT_DATA, "Copy Scale",
60 "Copy the scale factors of a target (with an optional offset), so that they are scaled by the same amount"},
61 {CONSTRAINT_TYPE_TRANSLIKE, "COPY_TRANSFORMS", ICON_CONSTRAINT_DATA, "Copy Transforms",
62 "Copy all the transformations of a target, so that they move together"},
63 {CONSTRAINT_TYPE_DISTLIMIT, "LIMIT_DISTANCE", ICON_CONSTRAINT_DATA, "Limit Distance",
64 "Restrict movements to within a certain distance of a target (at the time of constraint evaluation only)"},
65 {CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT_DATA, "Limit Location",
66 "Restrict movement along each axis within given ranges"},
67 {CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT_DATA, "Limit Rotation",
68 "Restrict rotation along each axis within given ranges"},
69 {CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", ICON_CONSTRAINT_DATA, "Limit Scale",
70 "Restrict scaling along each axis with given ranges"},
71 {CONSTRAINT_TYPE_SAMEVOL, "MAINTAIN_VOLUME", ICON_CONSTRAINT_DATA, "Maintain Volume",
72 "Compensate for scaling one axis by applying suitable scaling to the other two axes"},
73 {CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", ICON_CONSTRAINT_DATA, "Transformation",
74 "Use one transform property from target to control another (or same) property on owner"},
75 {0, "", 0, N_("Tracking"), ""},
76 {CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", ICON_CONSTRAINT_DATA, "Clamp To",
77 "Restrict movements to lie along a curve by remapping location along curve's longest axis"},
78 {CONSTRAINT_TYPE_DAMPTRACK, "DAMPED_TRACK", ICON_CONSTRAINT_DATA, "Damped Track",
79 "Point towards a target by performing the smallest rotation necessary"},
80 {CONSTRAINT_TYPE_KINEMATIC, "IK", ICON_CONSTRAINT_DATA, "Inverse Kinematics",
81 "Control a chain of bones by specifying the endpoint target (Bones only)"},
82 {CONSTRAINT_TYPE_LOCKTRACK, "LOCKED_TRACK", ICON_CONSTRAINT_DATA, "Locked Track",
83 "Rotate around the specified ('locked') axis to point towards a target"},
84 {CONSTRAINT_TYPE_SPLINEIK, "SPLINE_IK", ICON_CONSTRAINT_DATA, "Spline IK",
85 "Align chain of bones along a curve (Bones only)"},
86 {CONSTRAINT_TYPE_STRETCHTO, "STRETCH_TO", ICON_CONSTRAINT_DATA, "Stretch To",
87 "Stretch along Y-Axis to point towards a target"},
88 {CONSTRAINT_TYPE_TRACKTO, "TRACK_TO", ICON_CONSTRAINT_DATA, "Track To",
89 "Legacy tracking constraint prone to twisting artifacts"},
90 {0, "", 0, N_("Relationship"), ""},
91 {CONSTRAINT_TYPE_ACTION, "ACTION", ICON_CONSTRAINT_DATA, "Action",
92 "Use transform property of target to look up pose for owner from an Action"},
93 {CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT_DATA, "Child Of",
94 "Make target the 'detachable' parent of owner"},
95 {CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT_DATA, "Floor",
96 "Use position (and optionally rotation) of target to define a 'wall' or 'floor' that the owner can not cross"},
97 {CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", ICON_CONSTRAINT_DATA, "Follow Path",
98 "Use to animate an object/bone following a path"},
99 {CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT_DATA, "Pivot",
100 "Change pivot point for transforms (buggy)"},
101 {CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint",
102 "Use to define a Rigid Body Constraint (for Game Engine use only)"},
103 /* {CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script",
104 "Custom constraint(s) written in Python (Not yet implemented)"}, */
105 {CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap",
106 "Restrict movements to surface of target mesh"},
107 {0, NULL, 0, NULL, NULL}
110 static EnumPropertyItem target_space_pchan_items[] = {
111 {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space",
112 "The transformation of the target is evaluated relative to the world "
113 "coordinate system"},
114 {CONSTRAINT_SPACE_POSE, "POSE", 0, "Pose Space",
115 "The transformation of the target is only evaluated in the Pose Space, "
116 "the target armature object transformation is ignored"},
117 {CONSTRAINT_SPACE_PARLOCAL, "LOCAL_WITH_PARENT", 0, "Local With Parent",
118 "The transformation of the target bone is evaluated relative its local "
119 "coordinate system, with the parent transformation added"},
120 {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space",
121 "The transformation of the target is evaluated relative to its local "
122 "coordinate system"},
123 {0, NULL, 0, NULL, NULL}
126 static EnumPropertyItem owner_space_pchan_items[] = {
127 {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space",
128 "The constraint is applied relative to the world coordinate system"},
129 {CONSTRAINT_SPACE_POSE, "POSE", 0, "Pose Space",
130 "The constraint is applied in Pose Space, the object transformation is ignored"},
131 {CONSTRAINT_SPACE_PARLOCAL, "LOCAL_WITH_PARENT", 0, "Local With Parent",
132 "The constraint is applied relative to the local coordinate system of the object, "
133 "with the parent transformation added"},
134 {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space",
135 "The constraint is applied relative to the local coordinate system of the object"},
136 {0, NULL, 0, NULL, NULL}
141 static EnumPropertyItem space_object_items[] = {
142 {CONSTRAINT_SPACE_WORLD, "WORLD", 0, "World Space",
143 "The transformation of the target is evaluated relative to the world coordinate system"},
144 {CONSTRAINT_SPACE_LOCAL, "LOCAL", 0, "Local Space",
145 "The transformation of the target is evaluated relative to its local coordinate system"},
146 {0, NULL, 0, NULL, NULL}
149 #include "BKE_animsys.h"
150 #include "BKE_action.h"
151 #include "BKE_constraint.h"
152 #include "BKE_context.h"
153 #include "BKE_depsgraph.h"
156 static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
158 bConstraint *con = (bConstraint *)ptr->data;
161 case CONSTRAINT_TYPE_CHILDOF:
162 return &RNA_ChildOfConstraint;
163 case CONSTRAINT_TYPE_TRACKTO:
164 return &RNA_TrackToConstraint;
165 case CONSTRAINT_TYPE_KINEMATIC:
166 return &RNA_KinematicConstraint;
167 case CONSTRAINT_TYPE_FOLLOWPATH:
168 return &RNA_FollowPathConstraint;
169 case CONSTRAINT_TYPE_ROTLIKE:
170 return &RNA_CopyRotationConstraint;
171 case CONSTRAINT_TYPE_LOCLIKE:
172 return &RNA_CopyLocationConstraint;
173 case CONSTRAINT_TYPE_SIZELIKE:
174 return &RNA_CopyScaleConstraint;
175 case CONSTRAINT_TYPE_SAMEVOL:
176 return &RNA_MaintainVolumeConstraint;
177 case CONSTRAINT_TYPE_PYTHON:
178 return &RNA_PythonConstraint;
179 case CONSTRAINT_TYPE_ACTION:
180 return &RNA_ActionConstraint;
181 case CONSTRAINT_TYPE_LOCKTRACK:
182 return &RNA_LockedTrackConstraint;
183 case CONSTRAINT_TYPE_STRETCHTO:
184 return &RNA_StretchToConstraint;
185 case CONSTRAINT_TYPE_MINMAX:
186 return &RNA_FloorConstraint;
187 case CONSTRAINT_TYPE_RIGIDBODYJOINT:
188 return &RNA_RigidBodyJointConstraint;
189 case CONSTRAINT_TYPE_CLAMPTO:
190 return &RNA_ClampToConstraint;
191 case CONSTRAINT_TYPE_TRANSFORM:
192 return &RNA_TransformConstraint;
193 case CONSTRAINT_TYPE_ROTLIMIT:
194 return &RNA_LimitRotationConstraint;
195 case CONSTRAINT_TYPE_LOCLIMIT:
196 return &RNA_LimitLocationConstraint;
197 case CONSTRAINT_TYPE_SIZELIMIT:
198 return &RNA_LimitScaleConstraint;
199 case CONSTRAINT_TYPE_DISTLIMIT:
200 return &RNA_LimitDistanceConstraint;
201 case CONSTRAINT_TYPE_SHRINKWRAP:
202 return &RNA_ShrinkwrapConstraint;
203 case CONSTRAINT_TYPE_DAMPTRACK:
204 return &RNA_DampedTrackConstraint;
205 case CONSTRAINT_TYPE_SPLINEIK:
206 return &RNA_SplineIKConstraint;
207 case CONSTRAINT_TYPE_TRANSLIKE:
208 return &RNA_CopyTransformsConstraint;
209 case CONSTRAINT_TYPE_PIVOT:
210 return &RNA_PivotConstraint;
211 case CONSTRAINT_TYPE_FOLLOWTRACK:
212 return &RNA_FollowTrackConstraint;
213 case CONSTRAINT_TYPE_CAMERASOLVER:
214 return &RNA_CameraSolverConstraint;
215 case CONSTRAINT_TYPE_OBJECTSOLVER:
216 return &RNA_ObjectSolverConstraint;
218 return &RNA_UnknownType;
222 static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
224 bConstraint *con = ptr->data;
225 char oldname[sizeof(con->name)];
227 /* make a copy of the old name first */
228 BLI_strncpy(oldname, con->name, sizeof(con->name));
230 /* copy the new name into the name slot */
231 BLI_strncpy_utf8(con->name, value, sizeof(con->name));
233 /* make sure name is unique */
235 Object *ob = ptr->id.data;
236 ListBase *list = get_constraint_lb(ob, con, NULL);
238 /* if we have the list, check for unique name, otherwise give up */
240 BKE_unique_constraint_name(con, list);
243 /* fix all the animation data which may link to this */
244 BKE_all_animdata_fix_paths_rename(NULL, "constraints", oldname, con->name);
247 static char *rna_Constraint_path(PointerRNA *ptr)
249 Object *ob = ptr->id.data;
250 bConstraint *con = ptr->data;
252 ListBase *lb = get_constraint_lb(ob, con, &pchan);
255 printf("%s: internal error, constraint '%s' not found in object '%s'\n",
256 __func__, con->name, ob->id.name);
259 char name_esc_pchan[sizeof(pchan->name) * 2];
260 char name_esc_const[sizeof(con->name) * 2];
261 BLI_strescape(name_esc_pchan, pchan->name, sizeof(name_esc_pchan));
262 BLI_strescape(name_esc_const, con->name, sizeof(name_esc_const));
263 return BLI_sprintfN("pose.bones[\"%s\"].constraints[\"%s\"]", name_esc_pchan, name_esc_const);
266 char name_esc_const[sizeof(con->name) * 2];
267 BLI_strescape(name_esc_const, con->name, sizeof(name_esc_const));
268 return BLI_sprintfN("constraints[\"%s\"]", name_esc_const);
272 static void rna_Constraint_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
274 ED_object_constraint_update(ptr->id.data);
277 static void rna_Constraint_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
279 ED_object_constraint_dependency_update(bmain, ptr->id.data);
282 static void rna_Constraint_influence_update(Main *bmain, Scene *scene, PointerRNA *ptr)
284 Object *ob = ptr->id.data;
287 ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK);
289 rna_Constraint_update(bmain, scene, ptr);
292 static void rna_Constraint_ik_type_set(struct PointerRNA *ptr, int value)
294 bConstraint *con = ptr->data;
295 bKinematicConstraint *ikdata = con->data;
297 if (ikdata->type != value) {
298 /* the type of IK constraint has changed, set suitable default values */
299 /* in case constraints reuse same fields incompatible */
301 case CONSTRAINT_IK_COPYPOSE:
303 case CONSTRAINT_IK_DISTANCE:
306 ikdata->type = value;
310 static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *UNUSED(C), PointerRNA *ptr,
311 PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
313 Object *ob = (Object *)ptr->id.data;
314 bConstraint *con = (bConstraint *)ptr->data;
316 if (BLI_findindex(&ob->constraints, con) == -1)
317 return owner_space_pchan_items;
319 return space_object_items;
322 static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *UNUSED(C), PointerRNA *ptr,
323 PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
325 bConstraint *con = (bConstraint *)ptr->data;
326 bConstraintTypeInfo *cti = BKE_constraint_get_typeinfo(con);
327 ListBase targets = {NULL, NULL};
328 bConstraintTarget *ct;
330 if (cti && cti->get_constraint_targets) {
331 cti->get_constraint_targets(con, &targets);
333 for (ct = targets.first; ct; ct = ct->next)
334 if (ct->tar && ct->tar->type == OB_ARMATURE)
337 if (cti->flush_constraint_targets)
338 cti->flush_constraint_targets(con, &targets, 1);
341 return target_space_pchan_items;
344 return space_object_items;
347 static void rna_ActionConstraint_minmax_range(PointerRNA *ptr, float *min, float *max,
348 float *UNUSED(softmin), float *UNUSED(softmax))
350 bConstraint *con = (bConstraint *)ptr->data;
351 bActionConstraint *acon = (bActionConstraint *)con->data;
353 /* 0, 1, 2 = magic numbers for rotX, rotY, rotZ */
354 if (ELEM3(acon->type, 0, 1, 2)) {
364 static int rna_SplineIKConstraint_joint_bindings_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
366 bConstraint *con = (bConstraint *)ptr->data;
367 bSplineIKConstraint *ikData = (bSplineIKConstraint *)con->data;
370 length[0] = ikData->numpoints;
372 length[0] = 256; /* for raw_access, untested */
377 static void rna_SplineIKConstraint_joint_bindings_get(PointerRNA *ptr, float *values)
379 bConstraint *con = (bConstraint *)ptr->data;
380 bSplineIKConstraint *ikData = (bSplineIKConstraint *)con->data;
382 memcpy(values, ikData->points, ikData->numpoints * sizeof(float));
385 static void rna_SplineIKConstraint_joint_bindings_set(PointerRNA *ptr, const float *values)
387 bConstraint *con = (bConstraint *)ptr->data;
388 bSplineIKConstraint *ikData = (bSplineIKConstraint *)con->data;
390 memcpy(ikData->points, values, ikData->numpoints * sizeof(float));
393 static int rna_Constraint_cameraObject_poll(PointerRNA *ptr, PointerRNA value)
395 Object *ob = (Object *)value.data;
398 if (ob->type == OB_CAMERA && ob != (Object *)ptr->id.data) {
406 static void rna_Constraint_followTrack_camera_set(PointerRNA *ptr, PointerRNA value)
408 bConstraint *con = (bConstraint *)ptr->data;
409 bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
410 Object *ob = (Object *)value.data;
413 if (ob->type == OB_CAMERA && ob != (Object *)ptr->id.data) {
422 static void rna_Constraint_followTrack_depthObject_set(PointerRNA *ptr, PointerRNA value)
424 bConstraint *con = (bConstraint *)ptr->data;
425 bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data;
426 Object *ob = (Object *)value.data;
429 if (ob->type == OB_MESH && ob != (Object *)ptr->id.data) {
434 data->depth_ob = NULL;
438 static int rna_Constraint_followTrack_depthObject_poll(PointerRNA *ptr, PointerRNA value)
440 Object *ob = (Object *)value.data;
443 if (ob->type == OB_MESH && ob != (Object *)ptr->id.data) {
451 static void rna_Constraint_objectSolver_camera_set(PointerRNA *ptr, PointerRNA value)
453 bConstraint *con = (bConstraint *)ptr->data;
454 bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data;
455 Object *ob = (Object *)value.data;
458 if (ob->type == OB_CAMERA && ob != (Object *)ptr->id.data) {
469 static EnumPropertyItem constraint_distance_items[] = {
470 {LIMITDIST_INSIDE, "LIMITDIST_INSIDE", 0, "Inside",
471 "The object is constrained inside a virtual sphere around the target object, "
472 "with a radius defined by the limit distance"},
473 {LIMITDIST_OUTSIDE, "LIMITDIST_OUTSIDE", 0, "Outside",
474 "The object is constrained outside a virtual sphere around the target object, "
475 "with a radius defined by the limit distance"},
476 {LIMITDIST_ONSURFACE, "LIMITDIST_ONSURFACE", 0, "On Surface",
477 "The object is constrained on the surface of a virtual sphere around the target object, "
478 "with a radius defined by the limit distance"},
479 {0, NULL, 0, NULL, NULL}
483 static void rna_def_constrainttarget(BlenderRNA *brna)
488 srna = RNA_def_struct(brna, "ConstraintTarget", NULL);
489 RNA_def_struct_ui_text(srna, "Constraint Target", "Target object for multi-target constraints");
490 RNA_def_struct_sdna(srna, "bConstraintTarget");
492 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
493 RNA_def_property_pointer_sdna(prop, NULL, "tar");
494 RNA_def_property_ui_text(prop, "Target", "Target Object");
495 RNA_def_property_flag(prop, PROP_EDITABLE);
496 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
498 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
499 RNA_def_property_string_sdna(prop, NULL, "subtarget");
500 RNA_def_property_ui_text(prop, "Sub-Target", "");
501 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
503 /* space, flag and type still to do */
506 static void rna_def_constraint_childof(BlenderRNA *brna)
511 srna = RNA_def_struct(brna, "ChildOfConstraint", "Constraint");
512 RNA_def_struct_ui_text(srna, "Child Of Constraint", "Create constraint-based parent-child relationship");
513 RNA_def_struct_sdna_from(srna, "bChildOfConstraint", "data");
515 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
516 RNA_def_property_pointer_sdna(prop, NULL, "tar");
517 RNA_def_property_ui_text(prop, "Target", "Target Object");
518 RNA_def_property_flag(prop, PROP_EDITABLE);
519 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
521 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
522 RNA_def_property_string_sdna(prop, NULL, "subtarget");
523 RNA_def_property_ui_text(prop, "Sub-Target", "");
524 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
526 prop = RNA_def_property(srna, "use_location_x", PROP_BOOLEAN, PROP_NONE);
527 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCX);
528 RNA_def_property_ui_text(prop, "Location X", "Use X Location of Parent");
529 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
531 prop = RNA_def_property(srna, "use_location_y", PROP_BOOLEAN, PROP_NONE);
532 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCY);
533 RNA_def_property_ui_text(prop, "Location Y", "Use Y Location of Parent");
534 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
536 prop = RNA_def_property(srna, "use_location_z", PROP_BOOLEAN, PROP_NONE);
537 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCZ);
538 RNA_def_property_ui_text(prop, "Location Z", "Use Z Location of Parent");
539 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
541 prop = RNA_def_property(srna, "use_rotation_x", PROP_BOOLEAN, PROP_NONE);
542 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_ROTX);
543 RNA_def_property_ui_text(prop, "Rotation X", "Use X Rotation of Parent");
544 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
546 prop = RNA_def_property(srna, "use_rotation_y", PROP_BOOLEAN, PROP_NONE);
547 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_ROTY);
548 RNA_def_property_ui_text(prop, "Rotation Y", "Use Y Rotation of Parent");
549 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
551 prop = RNA_def_property(srna, "use_rotation_z", PROP_BOOLEAN, PROP_NONE);
552 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_ROTZ);
553 RNA_def_property_ui_text(prop, "Rotation Z", "Use Z Rotation of Parent");
554 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
556 prop = RNA_def_property(srna, "use_scale_x", PROP_BOOLEAN, PROP_NONE);
557 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEX);
558 RNA_def_property_ui_text(prop, "Scale X", "Use X Scale of Parent");
559 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
561 prop = RNA_def_property(srna, "use_scale_y", PROP_BOOLEAN, PROP_NONE);
562 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEY);
563 RNA_def_property_ui_text(prop, "Scale Y", "Use Y Scale of Parent");
564 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
566 prop = RNA_def_property(srna, "use_scale_z", PROP_BOOLEAN, PROP_NONE);
567 RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_SIZEZ);
568 RNA_def_property_ui_text(prop, "Scale Z", "Use Z Scale of Parent");
569 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
571 prop = RNA_def_property(srna, "inverse_matrix", PROP_FLOAT, PROP_MATRIX);
572 RNA_def_property_float_sdna(prop, NULL, "invmat");
573 RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
574 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
575 RNA_def_property_ui_text(prop, "Inverse Matrix", "Transformation matrix to apply before");
579 static void rna_def_constraint_python(BlenderRNA *brna)
584 srna = RNA_def_struct(brna, "PythonConstraint", "Constraint");
585 RNA_def_struct_ui_text(srna, "Python Constraint", "Use Python script for constraint evaluation");
586 RNA_def_struct_sdna_from(srna, "bPythonConstraint", "data");
588 prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
589 RNA_def_property_collection_sdna(prop, NULL, "targets", NULL);
590 RNA_def_property_struct_type(prop, "ConstraintTarget");
591 RNA_def_property_ui_text(prop, "Targets", "Target Objects");
593 prop = RNA_def_property(srna, "target_count", PROP_INT, PROP_NONE);
594 RNA_def_property_int_sdna(prop, NULL, "tarnum");
595 RNA_def_property_ui_text(prop, "Number of Targets", "Usually only 1-3 are needed");
596 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
598 prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
599 RNA_def_property_ui_text(prop, "Script", "The text object that contains the Python script");
600 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
601 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
603 prop = RNA_def_property(srna, "use_targets", PROP_BOOLEAN, PROP_NONE);
604 RNA_def_property_boolean_sdna(prop, NULL, "flag", PYCON_USETARGETS);
605 RNA_def_property_ui_text(prop, "Use Targets", "Use the targets indicated in the constraint panel");
606 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
608 prop = RNA_def_property(srna, "has_script_error", PROP_BOOLEAN, PROP_NONE);
609 RNA_def_property_boolean_sdna(prop, NULL, "flag", PYCON_SCRIPTERROR);
610 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
611 RNA_def_property_ui_text(prop, "Script Error", "The linked Python script has thrown an error");
614 static void rna_def_constraint_kinematic(BlenderRNA *brna)
619 static EnumPropertyItem constraint_ik_axisref_items[] = {
620 {0, "BONE", 0, "Bone", ""},
621 {CONSTRAINT_IK_TARGETAXIS, "TARGET", 0, "Target", ""},
622 {0, NULL, 0, NULL, NULL},
625 static EnumPropertyItem constraint_ik_type_items[] = {
626 {CONSTRAINT_IK_COPYPOSE, "COPY_POSE", 0, "Copy Pose", ""},
627 {CONSTRAINT_IK_DISTANCE, "DISTANCE", 0, "Distance", ""},
628 {0, NULL, 0, NULL, NULL},
631 srna = RNA_def_struct(brna, "KinematicConstraint", "Constraint");
632 RNA_def_struct_ui_text(srna, "Kinematic Constraint", "Inverse Kinematics");
633 RNA_def_struct_sdna_from(srna, "bKinematicConstraint", "data");
635 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
636 RNA_def_property_pointer_sdna(prop, NULL, "tar");
637 RNA_def_property_ui_text(prop, "Target", "Target Object");
638 RNA_def_property_flag(prop, PROP_EDITABLE);
639 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
641 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
642 RNA_def_property_string_sdna(prop, NULL, "subtarget");
643 RNA_def_property_ui_text(prop, "Sub-Target", "");
644 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
646 prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
647 RNA_def_property_range(prop, 0, 10000);
648 RNA_def_property_ui_text(prop, "Iterations", "Maximum number of solving iterations");
649 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
651 prop = RNA_def_property(srna, "pole_target", PROP_POINTER, PROP_NONE);
652 RNA_def_property_pointer_sdna(prop, NULL, "poletar");
653 RNA_def_property_ui_text(prop, "Pole Target", "Object for pole rotation");
654 RNA_def_property_flag(prop, PROP_EDITABLE);
655 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
657 prop = RNA_def_property(srna, "pole_subtarget", PROP_STRING, PROP_NONE);
658 RNA_def_property_string_sdna(prop, NULL, "polesubtarget");
659 RNA_def_property_ui_text(prop, "Pole Sub-Target", "");
660 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
662 prop = RNA_def_property(srna, "pole_angle", PROP_FLOAT, PROP_ANGLE);
663 RNA_def_property_float_sdna(prop, NULL, "poleangle");
664 RNA_def_property_range(prop, -M_PI, M_PI);
665 RNA_def_property_ui_text(prop, "Pole Angle", "Pole rotation offset");
666 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
668 prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
669 RNA_def_property_range(prop, 0.01, 1.f);
670 RNA_def_property_ui_text(prop, "Weight", "For Tree-IK: Weight of position control for this target");
672 prop = RNA_def_property(srna, "orient_weight", PROP_FLOAT, PROP_NONE);
673 RNA_def_property_float_sdna(prop, NULL, "orientweight");
674 RNA_def_property_range(prop, 0.01, 1.f);
675 RNA_def_property_ui_text(prop, "Orientation Weight", "For Tree-IK: Weight of orientation control for this target");
676 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
678 prop = RNA_def_property(srna, "chain_count", PROP_INT, PROP_NONE);
679 RNA_def_property_int_sdna(prop, NULL, "rootbone");
680 RNA_def_property_range(prop, 0, 255);
681 RNA_def_property_ui_text(prop, "Chain Length", "How many bones are included in the IK effect - 0 uses all bones");
682 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
684 prop = RNA_def_property(srna, "use_tail", PROP_BOOLEAN, PROP_NONE);
685 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_TIP);
686 RNA_def_property_ui_text(prop, "Use Tail", "Include bone's tail as last element in chain");
687 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
689 prop = RNA_def_property(srna, "reference_axis", PROP_ENUM, PROP_NONE);
690 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
691 RNA_def_property_enum_items(prop, constraint_ik_axisref_items);
692 RNA_def_property_ui_text(prop, "Axis Reference",
693 "Constraint axis Lock options relative to Bone or Target reference");
694 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
696 prop = RNA_def_property(srna, "use_location", PROP_BOOLEAN, PROP_NONE);
697 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_POS);
698 RNA_def_property_ui_text(prop, "Position", "Chain follows position of target");
699 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
701 prop = RNA_def_property(srna, "lock_location_x", PROP_BOOLEAN, PROP_NONE);
702 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_NO_POS_X);
703 RNA_def_property_ui_text(prop, "Lock X Pos", "Constraint position along X axis");
704 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
706 prop = RNA_def_property(srna, "lock_location_y", PROP_BOOLEAN, PROP_NONE);
707 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_NO_POS_Y);
708 RNA_def_property_ui_text(prop, "Lock Y Pos", "Constraint position along Y axis");
709 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
711 prop = RNA_def_property(srna, "lock_location_z", PROP_BOOLEAN, PROP_NONE);
712 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_NO_POS_Z);
713 RNA_def_property_ui_text(prop, "Lock Z Pos", "Constraint position along Z axis");
714 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
716 prop = RNA_def_property(srna, "use_rotation", PROP_BOOLEAN, PROP_NONE);
717 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_ROT);
718 RNA_def_property_ui_text(prop, "Rotation", "Chain follows rotation of target");
719 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
721 prop = RNA_def_property(srna, "lock_rotation_x", PROP_BOOLEAN, PROP_NONE);
722 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_NO_ROT_X);
723 RNA_def_property_ui_text(prop, "Lock X Rot", "Constraint rotation along X axis");
724 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
726 prop = RNA_def_property(srna, "lock_rotation_y", PROP_BOOLEAN, PROP_NONE);
727 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_NO_ROT_Y);
728 RNA_def_property_ui_text(prop, "Lock Y Rot", "Constraint rotation along Y axis");
729 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
731 prop = RNA_def_property(srna, "lock_rotation_z", PROP_BOOLEAN, PROP_NONE);
732 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_NO_ROT_Z);
733 RNA_def_property_ui_text(prop, "Lock Z Rot", "Constraint rotation along Z axis");
734 RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update");
736 prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
737 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_STRETCH);
738 RNA_def_property_ui_text(prop, "Stretch", "Enable IK Stretching");
739 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
741 prop = RNA_def_property(srna, "ik_type", PROP_ENUM, PROP_NONE);
742 RNA_def_property_enum_sdna(prop, NULL, "type");
743 RNA_def_property_enum_funcs(prop, NULL, "rna_Constraint_ik_type_set", NULL);
744 RNA_def_property_enum_items(prop, constraint_ik_type_items);
745 RNA_def_property_ui_text(prop, "IK Type", "");
746 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
748 prop = RNA_def_property(srna, "limit_mode", PROP_ENUM, PROP_NONE);
749 RNA_def_property_enum_sdna(prop, NULL, "mode");
750 RNA_def_property_enum_items(prop, constraint_distance_items);
751 RNA_def_property_ui_text(prop, "Limit Mode", "Distances in relation to sphere of influence to allow");
752 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
754 prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
755 RNA_def_property_float_sdna(prop, NULL, "dist");
756 RNA_def_property_range(prop, 0.0, 100.f);
757 RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere");
758 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
761 static void rna_def_constraint_track_to(BlenderRNA *brna)
766 static EnumPropertyItem track_items[] = {
767 {TRACK_X, "TRACK_X", 0, "X", ""},
768 {TRACK_Y, "TRACK_Y", 0, "Y", ""},
769 {TRACK_Z, "TRACK_Z", 0, "Z", ""},
770 {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""},
771 {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""},
772 {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""},
773 {0, NULL, 0, NULL, NULL}
776 static EnumPropertyItem up_items[] = {
777 {TRACK_X, "UP_X", 0, "X", ""},
778 {TRACK_Y, "UP_Y", 0, "Y", ""},
779 {TRACK_Z, "UP_Z", 0, "Z", ""},
780 {0, NULL, 0, NULL, NULL}
783 srna = RNA_def_struct(brna, "TrackToConstraint", "Constraint");
784 RNA_def_struct_ui_text(srna, "Track To Constraint", "Aim the constrained object toward the target");
786 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
787 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
788 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
789 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
791 RNA_def_struct_sdna_from(srna, "bTrackToConstraint", "data");
793 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
794 RNA_def_property_pointer_sdna(prop, NULL, "tar");
795 RNA_def_property_ui_text(prop, "Target", "Target Object");
796 RNA_def_property_flag(prop, PROP_EDITABLE);
797 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
799 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
800 RNA_def_property_string_sdna(prop, NULL, "subtarget");
801 RNA_def_property_ui_text(prop, "Sub-Target", "");
802 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
804 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
805 RNA_def_property_enum_sdna(prop, NULL, "reserved1");
806 RNA_def_property_enum_items(prop, track_items);
807 RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object");
808 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
810 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
811 RNA_def_property_enum_sdna(prop, NULL, "reserved2");
812 RNA_def_property_enum_items(prop, up_items);
813 RNA_def_property_ui_text(prop, "Up Axis", "Axis that points upward");
814 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
816 prop = RNA_def_property(srna, "use_target_z", PROP_BOOLEAN, PROP_NONE);
817 RNA_def_property_boolean_sdna(prop, NULL, "flags", TARGET_Z_UP);
818 RNA_def_property_ui_text(prop, "Target Z", "Target's Z axis, not World Z axis, will constraint the Up direction");
819 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
822 static void rna_def_constraint_locate_like(BlenderRNA *brna)
827 srna = RNA_def_struct(brna, "CopyLocationConstraint", "Constraint");
828 RNA_def_struct_ui_text(srna, "Copy Location Constraint", "Copy the location of the target");
830 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
831 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
832 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
833 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
835 RNA_def_struct_sdna_from(srna, "bLocateLikeConstraint", "data");
837 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
838 RNA_def_property_pointer_sdna(prop, NULL, "tar");
839 RNA_def_property_flag(prop, PROP_EDITABLE);
840 RNA_def_property_ui_text(prop, "Target", "Target Object");
841 RNA_def_property_flag(prop, PROP_EDITABLE);
842 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
844 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
845 RNA_def_property_string_sdna(prop, NULL, "subtarget");
846 RNA_def_property_ui_text(prop, "Sub-Target", "");
847 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
849 prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
850 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X);
851 RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X location");
852 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
854 prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
855 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y);
856 RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y location");
857 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
859 prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
860 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z);
861 RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z location");
862 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
864 prop = RNA_def_property(srna, "invert_x", PROP_BOOLEAN, PROP_NONE);
865 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X_INVERT);
866 RNA_def_property_ui_text(prop, "Invert X", "Invert the X location");
867 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
869 prop = RNA_def_property(srna, "invert_y", PROP_BOOLEAN, PROP_NONE);
870 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Y_INVERT);
871 RNA_def_property_ui_text(prop, "Invert Y", "Invert the Y location");
872 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
874 prop = RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE);
875 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_Z_INVERT);
876 RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z location");
877 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
879 prop = RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE);
880 RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_OFFSET);
881 RNA_def_property_ui_text(prop, "Offset", "Add original location into copied location");
882 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
885 static void rna_def_constraint_rotate_like(BlenderRNA *brna)
890 srna = RNA_def_struct(brna, "CopyRotationConstraint", "Constraint");
891 RNA_def_struct_ui_text(srna, "Copy Rotation Constraint", "Copy the rotation of the target");
892 RNA_def_struct_sdna_from(srna, "bRotateLikeConstraint", "data");
894 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
895 RNA_def_property_pointer_sdna(prop, NULL, "tar");
896 RNA_def_property_ui_text(prop, "Target", "Target Object");
897 RNA_def_property_flag(prop, PROP_EDITABLE);
898 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
900 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
901 RNA_def_property_string_sdna(prop, NULL, "subtarget");
902 RNA_def_property_ui_text(prop, "Sub-Target", "");
903 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
905 prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
906 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X);
907 RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X rotation");
908 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
910 prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
911 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Y);
912 RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y rotation");
913 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
915 prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
916 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Z);
917 RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z rotation");
918 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
920 prop = RNA_def_property(srna, "invert_x", PROP_BOOLEAN, PROP_NONE);
921 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X_INVERT);
922 RNA_def_property_ui_text(prop, "Invert X", "Invert the X rotation");
923 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
925 prop = RNA_def_property(srna, "invert_y", PROP_BOOLEAN, PROP_NONE);
926 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Y_INVERT);
927 RNA_def_property_ui_text(prop, "Invert Y", "Invert the Y rotation");
928 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
930 prop = RNA_def_property(srna, "invert_z", PROP_BOOLEAN, PROP_NONE);
931 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_Z_INVERT);
932 RNA_def_property_ui_text(prop, "Invert Z", "Invert the Z rotation");
933 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
935 prop = RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE);
936 RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_OFFSET);
937 RNA_def_property_ui_text(prop, "Offset", "Add original rotation into copied rotation");
938 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
941 static void rna_def_constraint_size_like(BlenderRNA *brna)
946 srna = RNA_def_struct(brna, "CopyScaleConstraint", "Constraint");
947 RNA_def_struct_ui_text(srna, "Copy Scale Constraint", "Copy the scale of the target");
948 RNA_def_struct_sdna_from(srna, "bSizeLikeConstraint", "data");
950 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
951 RNA_def_property_pointer_sdna(prop, NULL, "tar");
952 RNA_def_property_flag(prop, PROP_EDITABLE);
953 RNA_def_property_ui_text(prop, "Target", "Target Object");
954 RNA_def_property_flag(prop, PROP_EDITABLE);
955 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
957 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
958 RNA_def_property_string_sdna(prop, NULL, "subtarget");
959 RNA_def_property_ui_text(prop, "Sub-Target", "");
960 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
962 prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
963 RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_X);
964 RNA_def_property_ui_text(prop, "Copy X", "Copy the target's X scale");
965 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
967 prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
968 RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Y);
969 RNA_def_property_ui_text(prop, "Copy Y", "Copy the target's Y scale");
970 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
972 prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
973 RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_Z);
974 RNA_def_property_ui_text(prop, "Copy Z", "Copy the target's Z scale");
975 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
977 prop = RNA_def_property(srna, "use_offset", PROP_BOOLEAN, PROP_NONE);
978 RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_OFFSET);
979 RNA_def_property_ui_text(prop, "Offset", "Add original scale into copied scale");
980 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
983 static void rna_def_constraint_same_volume(BlenderRNA *brna)
988 static EnumPropertyItem volume_items[] = {
989 {SAMEVOL_X, "SAMEVOL_X", 0, "X", ""},
990 {SAMEVOL_Y, "SAMEVOL_Y", 0, "Y", ""},
991 {SAMEVOL_Z, "SAMEVOL_Z", 0, "Z", ""},
992 {0, NULL, 0, NULL, NULL}
995 srna = RNA_def_struct(brna, "MaintainVolumeConstraint", "Constraint");
996 RNA_def_struct_ui_text(srna, "Maintain Volume Constraint",
997 "Maintain a constant volume along a single scaling axis");
998 RNA_def_struct_sdna_from(srna, "bSameVolumeConstraint", "data");
1000 prop = RNA_def_property(srna, "free_axis", PROP_ENUM, PROP_NONE);
1001 RNA_def_property_enum_sdna(prop, NULL, "flag");
1002 RNA_def_property_enum_items(prop, volume_items);
1003 RNA_def_property_ui_text(prop, "Free Axis", "The free scaling axis of the object");
1004 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1006 prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_DISTANCE);
1007 RNA_def_property_range(prop, 0.001, 100.f);
1008 RNA_def_property_ui_text(prop, "Volume", "Volume of the bone at rest");
1009 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1013 static void rna_def_constraint_transform_like(BlenderRNA *brna)
1018 srna = RNA_def_struct(brna, "CopyTransformsConstraint", "Constraint");
1019 RNA_def_struct_ui_text(srna, "Copy Transforms Constraint", "Copy all the transforms of the target");
1021 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
1022 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
1023 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
1024 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1026 RNA_def_struct_sdna_from(srna, "bTransLikeConstraint", "data");
1028 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1029 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1030 RNA_def_property_ui_text(prop, "Target", "Target Object");
1031 RNA_def_property_flag(prop, PROP_EDITABLE);
1032 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1034 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
1035 RNA_def_property_string_sdna(prop, NULL, "subtarget");
1036 RNA_def_property_ui_text(prop, "Sub-Target", "");
1037 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1040 static void rna_def_constraint_minmax(BlenderRNA *brna)
1045 static EnumPropertyItem minmax_items[] = {
1046 {TRACK_X, "FLOOR_X", 0, "X", ""},
1047 {TRACK_Y, "FLOOR_Y", 0, "Y", ""},
1048 {TRACK_Z, "FLOOR_Z", 0, "Z", ""},
1049 {TRACK_nX, "FLOOR_NEGATIVE_X", 0, "-X", ""},
1050 {TRACK_nY, "FLOOR_NEGATIVE_Y", 0, "-Y", ""},
1051 {TRACK_nZ, "FLOOR_NEGATIVE_Z", 0, "-Z", ""},
1052 {0, NULL, 0, NULL, NULL}
1055 srna = RNA_def_struct(brna, "FloorConstraint", "Constraint");
1056 RNA_def_struct_ui_text(srna, "Floor Constraint", "Use the target object for location limitation");
1057 RNA_def_struct_sdna_from(srna, "bMinMaxConstraint", "data");
1059 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1060 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1061 RNA_def_property_ui_text(prop, "Target", "Target Object");
1062 RNA_def_property_flag(prop, PROP_EDITABLE);
1063 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1065 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
1066 RNA_def_property_string_sdna(prop, NULL, "subtarget");
1067 RNA_def_property_ui_text(prop, "Sub-Target", "");
1068 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1070 prop = RNA_def_property(srna, "floor_location", PROP_ENUM, PROP_NONE);
1071 RNA_def_property_enum_sdna(prop, NULL, "minmaxflag");
1072 RNA_def_property_enum_items(prop, minmax_items);
1073 RNA_def_property_ui_text(prop, "Floor Location", "Location of target that object will not pass through");
1074 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1076 prop = RNA_def_property(srna, "use_sticky", PROP_BOOLEAN, PROP_NONE);
1077 RNA_def_property_boolean_sdna(prop, NULL, "flag", MINMAX_STICKY);
1078 RNA_def_property_ui_text(prop, "Sticky", "Immobilize object while constrained");
1079 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1081 prop = RNA_def_property(srna, "use_rotation", PROP_BOOLEAN, PROP_NONE);
1082 RNA_def_property_boolean_sdna(prop, NULL, "flag", MINMAX_USEROT);
1083 RNA_def_property_ui_text(prop, "Use Rotation", "Use the target's rotation to determine floor");
1084 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1086 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_DISTANCE);
1087 RNA_def_property_range(prop, -1000.0, 1000.0f);
1088 RNA_def_property_ui_range(prop, -100.0f, 100.0f, 1, -1);
1089 RNA_def_property_ui_text(prop, "Offset", "Offset of floor from object origin");
1090 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1093 static void rna_def_constraint_action(BlenderRNA *brna)
1098 static EnumPropertyItem transform_channel_items[] = {
1099 {20, "LOCATION_X", 0, "X Location", ""},
1100 {21, "LOCATION_Y", 0, "Y Location", ""},
1101 {22, "LOCATION_Z", 0, "Z Location", ""},
1102 {00, "ROTATION_X", 0, "X Rotation", ""},
1103 {01, "ROTATION_Y", 0, "Y Rotation", ""},
1104 {02, "ROTATION_Z", 0, "Z Rotation", ""},
1105 {10, "SCALE_X", 0, "X Scale", ""},
1106 {11, "SCALE_Y", 0, "Y Scale", ""},
1107 {12, "SCALE_Z", 0, "Z Scale", ""},
1108 {0, NULL, 0, NULL, NULL}
1111 srna = RNA_def_struct(brna, "ActionConstraint", "Constraint");
1112 RNA_def_struct_ui_text(srna, "Action Constraint", "Map an action to the transform axes of a bone");
1113 RNA_def_struct_sdna_from(srna, "bActionConstraint", "data");
1115 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1116 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1117 RNA_def_property_ui_text(prop, "Target", "Target Object");
1118 RNA_def_property_flag(prop, PROP_EDITABLE);
1119 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1121 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
1122 RNA_def_property_string_sdna(prop, NULL, "subtarget");
1123 RNA_def_property_ui_text(prop, "Sub-Target", "");
1124 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1126 prop = RNA_def_property(srna, "transform_channel", PROP_ENUM, PROP_NONE);
1127 RNA_def_property_enum_sdna(prop, NULL, "type");
1128 RNA_def_property_enum_items(prop, transform_channel_items);
1129 RNA_def_property_ui_text(prop, "Transform Channel",
1130 "Transformation channel from the target that is used to key the Action");
1131 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1133 prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
1134 RNA_def_property_pointer_sdna(prop, NULL, "act");
1135 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll");
1136 RNA_def_property_ui_text(prop, "Action", "The constraining action");
1137 RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
1138 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1140 prop = RNA_def_property(srna, "use_bone_object_action", PROP_BOOLEAN, PROP_NONE);
1141 RNA_def_property_boolean_sdna(prop, NULL, "flag", ACTCON_BONE_USE_OBJECT_ACTION);
1142 RNA_def_property_ui_text(prop, "Object Action",
1143 "Bones only: apply the object's transformation channels of the action "
1144 "to the constrained bone, instead of bone's channels");
1145 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1147 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
1148 RNA_def_property_int_sdna(prop, NULL, "start");
1149 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1150 RNA_def_property_ui_text(prop, "Start Frame", "First frame of the Action to use");
1151 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1153 prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
1154 RNA_def_property_int_sdna(prop, NULL, "end");
1155 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1156 RNA_def_property_ui_text(prop, "End Frame", "Last frame of the Action to use");
1157 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1159 prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
1160 RNA_def_property_float_sdna(prop, NULL, "max");
1161 RNA_def_property_range(prop, -1000.f, 1000.f);
1162 RNA_def_property_ui_text(prop, "Maximum", "Maximum value for target channel range");
1163 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1164 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_ActionConstraint_minmax_range");
1166 prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
1167 RNA_def_property_float_sdna(prop, NULL, "min");
1168 RNA_def_property_range(prop, -1000.f, 1000.f);
1169 RNA_def_property_ui_text(prop, "Minimum", "Minimum value for target channel range");
1170 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1171 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_ActionConstraint_minmax_range");
1174 static void rna_def_constraint_locked_track(BlenderRNA *brna)
1179 static EnumPropertyItem locktrack_items[] = {
1180 {TRACK_X, "TRACK_X", 0, "X", ""},
1181 {TRACK_Y, "TRACK_Y", 0, "Y", ""},
1182 {TRACK_Z, "TRACK_Z", 0, "Z", ""},
1183 {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""},
1184 {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""},
1185 {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""},
1186 {0, NULL, 0, NULL, NULL}
1189 static EnumPropertyItem lock_items[] = {
1190 {TRACK_X, "LOCK_X", 0, "X", ""},
1191 {TRACK_Y, "LOCK_Y", 0, "Y", ""},
1192 {TRACK_Z, "LOCK_Z", 0, "Z", ""},
1193 {0, NULL, 0, NULL, NULL}
1196 srna = RNA_def_struct(brna, "LockedTrackConstraint", "Constraint");
1197 RNA_def_struct_ui_text(srna, "Locked Track Constraint",
1198 "Point toward the target along the track axis, while locking the other axis");
1200 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
1201 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
1202 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
1203 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1205 RNA_def_struct_sdna_from(srna, "bLockTrackConstraint", "data");
1207 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1208 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1209 RNA_def_property_ui_text(prop, "Target", "Target Object");
1210 RNA_def_property_flag(prop, PROP_EDITABLE);
1211 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1213 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
1214 RNA_def_property_string_sdna(prop, NULL, "subtarget");
1215 RNA_def_property_ui_text(prop, "Sub-Target", "");
1216 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1218 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
1219 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
1220 RNA_def_property_enum_items(prop, locktrack_items);
1221 RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object");
1222 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1224 prop = RNA_def_property(srna, "lock_axis", PROP_ENUM, PROP_NONE);
1225 RNA_def_property_enum_sdna(prop, NULL, "lockflag");
1226 RNA_def_property_enum_items(prop, lock_items);
1227 RNA_def_property_ui_text(prop, "Locked Axis", "Axis that points upward");
1228 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1231 static void rna_def_constraint_follow_path(BlenderRNA *brna)
1236 static EnumPropertyItem forwardpath_items[] = {
1237 {TRACK_X, "FORWARD_X", 0, "X", ""},
1238 {TRACK_Y, "FORWARD_Y", 0, "Y", ""},
1239 {TRACK_Z, "FORWARD_Z", 0, "Z", ""},
1240 {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""},
1241 {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""},
1242 {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""},
1243 {0, NULL, 0, NULL, NULL}
1246 static EnumPropertyItem pathup_items[] = {
1247 {TRACK_X, "UP_X", 0, "X", ""},
1248 {TRACK_Y, "UP_Y", 0, "Y", ""},
1249 {TRACK_Z, "UP_Z", 0, "Z", ""},
1250 {0, NULL, 0, NULL, NULL}
1253 srna = RNA_def_struct(brna, "FollowPathConstraint", "Constraint");
1254 RNA_def_struct_ui_text(srna, "Follow Path Constraint", "Lock motion to the target path");
1255 RNA_def_struct_sdna_from(srna, "bFollowPathConstraint", "data");
1257 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1258 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1259 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll");
1260 RNA_def_property_ui_text(prop, "Target", "Target Object");
1261 RNA_def_property_flag(prop, PROP_EDITABLE);
1262 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1264 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TIME);
1265 RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
1266 RNA_def_property_ui_text(prop, "Offset", "Offset from the position corresponding to the time frame");
1267 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1269 prop = RNA_def_property(srna, "offset_factor", PROP_FLOAT, PROP_FACTOR);
1270 RNA_def_property_float_sdna(prop, NULL, "offset_fac");
1271 RNA_def_property_range(prop, 0.0f, 1.0f);
1272 RNA_def_property_ui_text(prop, "Offset Factor", "Percentage value defining target position along length of curve");
1273 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1275 prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE);
1276 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
1277 RNA_def_property_enum_items(prop, forwardpath_items);
1278 RNA_def_property_ui_text(prop, "Forward Axis", "Axis that points forward along the path");
1279 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1281 prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
1282 RNA_def_property_enum_sdna(prop, NULL, "upflag");
1283 RNA_def_property_enum_items(prop, pathup_items);
1284 RNA_def_property_ui_text(prop, "Up Axis", "Axis that points upward");
1285 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1287 prop = RNA_def_property(srna, "use_curve_follow", PROP_BOOLEAN, PROP_NONE);
1288 RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_FOLLOW);
1289 RNA_def_property_ui_text(prop, "Follow Curve", "Object will follow the heading and banking of the curve");
1290 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1292 prop = RNA_def_property(srna, "use_fixed_location", PROP_BOOLEAN, PROP_NONE);
1293 RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_STATIC);
1294 RNA_def_property_ui_text(prop, "Fixed Position",
1295 "Object will stay locked to a single point somewhere along the length of the curve "
1296 "regardless of time");
1297 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1299 prop = RNA_def_property(srna, "use_curve_radius", PROP_BOOLEAN, PROP_NONE);
1300 RNA_def_property_boolean_sdna(prop, NULL, "followflag", FOLLOWPATH_RADIUS);
1301 RNA_def_property_ui_text(prop, "Curve Radius", "Object is scaled by the curve radius");
1302 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1305 static void rna_def_constraint_stretch_to(BlenderRNA *brna)
1310 static EnumPropertyItem volume_items[] = {
1311 {VOLUME_XZ, "VOLUME_XZX", 0, "XZ", ""},
1312 {VOLUME_X, "VOLUME_X", 0, "X", ""},
1313 {VOLUME_Z, "VOLUME_Z", 0, "Z", ""},
1314 {NO_VOLUME, "NO_VOLUME", 0, "None", ""},
1315 {0, NULL, 0, NULL, NULL}
1318 static EnumPropertyItem plane_items[] = {
1319 {PLANE_X, "PLANE_X", 0, "X", "Keep X Axis"},
1320 {PLANE_Z, "PLANE_Z", 0, "Z", "Keep Z Axis"},
1321 {0, NULL, 0, NULL, NULL}
1324 srna = RNA_def_struct(brna, "StretchToConstraint", "Constraint");
1325 RNA_def_struct_ui_text(srna, "Stretch To Constraint", "Stretch to meet the target object");
1327 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
1328 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
1329 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
1330 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1332 RNA_def_struct_sdna_from(srna, "bStretchToConstraint", "data");
1334 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1335 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1336 RNA_def_property_ui_text(prop, "Target", "Target Object");
1337 RNA_def_property_flag(prop, PROP_EDITABLE);
1338 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1340 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
1341 RNA_def_property_string_sdna(prop, NULL, "subtarget");
1342 RNA_def_property_ui_text(prop, "Sub-Target", "");
1343 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1345 prop = RNA_def_property(srna, "volume", PROP_ENUM, PROP_NONE);
1346 RNA_def_property_enum_sdna(prop, NULL, "volmode");
1347 RNA_def_property_enum_items(prop, volume_items);
1348 RNA_def_property_ui_text(prop, "Maintain Volume", "Maintain the object's volume as it stretches");
1349 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1351 prop = RNA_def_property(srna, "keep_axis", PROP_ENUM, PROP_NONE);
1352 RNA_def_property_enum_sdna(prop, NULL, "plane");
1353 RNA_def_property_enum_items(prop, plane_items);
1354 RNA_def_property_ui_text(prop, "Keep Axis", "Axis to maintain during stretch");
1355 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1357 prop = RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_DISTANCE);
1358 RNA_def_property_float_sdna(prop, NULL, "orglength");
1359 RNA_def_property_range(prop, 0.0, 100.f);
1360 RNA_def_property_ui_text(prop, "Original Length", "Length at rest position");
1361 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1363 prop = RNA_def_property(srna, "bulge", PROP_FLOAT, PROP_NONE);
1364 RNA_def_property_range(prop, 0.0, 100.f);
1365 RNA_def_property_ui_text(prop, "Volume Variation", "Factor between volume variation and stretching");
1366 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1369 static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna)
1374 static EnumPropertyItem pivot_items[] = {
1375 {CONSTRAINT_RB_BALL, "BALL", 0, "Ball", "Allow rotations around all axes"},
1376 {CONSTRAINT_RB_HINGE, "HINGE", 0, "Hinge", "Work in one plane, allow rotations around one axis only"},
1377 {CONSTRAINT_RB_CONETWIST, "CONE_TWIST", 0, "Cone Twist",
1378 "Allow rotations around all axes with limits for the cone and twist axes"},
1379 {CONSTRAINT_RB_GENERIC6DOF, "GENERIC_6_DOF", 0, "Generic 6 DoF",
1380 "No constraints by default, limits can be set individually"},
1381 {0, NULL, 0, NULL, NULL}
1384 srna = RNA_def_struct(brna, "RigidBodyJointConstraint", "Constraint");
1385 RNA_def_struct_ui_text(srna, "Rigid Body Joint Constraint", "For use with the Game Engine");
1386 RNA_def_struct_sdna_from(srna, "bRigidBodyJointConstraint", "data");
1388 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1389 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1390 RNA_def_property_ui_text(prop, "Target", "Target Object");
1391 RNA_def_property_flag(prop, PROP_EDITABLE);
1392 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1394 prop = RNA_def_property(srna, "child", PROP_POINTER, PROP_NONE);
1395 RNA_def_property_ui_text(prop, "Child Object", "Child object");
1396 RNA_def_property_flag(prop, PROP_EDITABLE);
1397 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1399 prop = RNA_def_property(srna, "pivot_type", PROP_ENUM, PROP_NONE);
1400 RNA_def_property_enum_sdna(prop, NULL, "type");
1401 RNA_def_property_enum_items(prop, pivot_items);
1402 RNA_def_property_ui_text(prop, "Pivot Type", "");
1403 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1405 prop = RNA_def_property(srna, "pivot_x", PROP_FLOAT, PROP_DISTANCE);
1406 RNA_def_property_float_sdna(prop, NULL, "pivX");
1407 RNA_def_property_range(prop, -1000.0, 1000.f);
1408 RNA_def_property_ui_text(prop, "Pivot X", "Offset pivot on X");
1409 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1411 prop = RNA_def_property(srna, "pivot_y", PROP_FLOAT, PROP_DISTANCE);
1412 RNA_def_property_float_sdna(prop, NULL, "pivY");
1413 RNA_def_property_range(prop, -1000.0, 1000.f);
1414 RNA_def_property_ui_text(prop, "Pivot Y", "Offset pivot on Y");
1415 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1417 prop = RNA_def_property(srna, "pivot_z", PROP_FLOAT, PROP_DISTANCE);
1418 RNA_def_property_float_sdna(prop, NULL, "pivZ");
1419 RNA_def_property_range(prop, -1000.0, 1000.f);
1420 RNA_def_property_ui_text(prop, "Pivot Z", "Offset pivot on Z");
1421 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1423 prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_ANGLE);
1424 RNA_def_property_float_sdna(prop, NULL, "axX");
1425 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1426 RNA_def_property_ui_text(prop, "Axis X", "Rotate pivot on X axis");
1427 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1429 prop = RNA_def_property(srna, "axis_y", PROP_FLOAT, PROP_ANGLE);
1430 RNA_def_property_float_sdna(prop, NULL, "axY");
1431 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1432 RNA_def_property_ui_text(prop, "Axis Y", "Rotate pivot on Y axis");
1433 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1435 prop = RNA_def_property(srna, "axis_z", PROP_FLOAT, PROP_ANGLE);
1436 RNA_def_property_float_sdna(prop, NULL, "axZ");
1437 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1438 RNA_def_property_ui_text(prop, "Axis Z", "Rotate pivot on Z axis");
1439 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1441 prop = RNA_def_property(srna, "use_linked_collision", PROP_BOOLEAN, PROP_NONE);
1442 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE_LINKED_COLLISION);
1443 RNA_def_property_ui_text(prop, "Disable Linked Collision", "Disable collision between linked bodies");
1444 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1446 prop = RNA_def_property(srna, "show_pivot", PROP_BOOLEAN, PROP_NONE);
1447 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_DRAW_PIVOT);
1448 RNA_def_property_ui_text(prop, "Draw Pivot", "Display the pivot point and rotation in 3D view");
1449 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1454 prop = RNA_def_property(srna, "limit_min_x", PROP_FLOAT, PROP_NONE);
1455 RNA_def_property_float_sdna(prop, NULL, "minLimit[0]");
1456 RNA_def_property_ui_text(prop, "Minimum Limit X", "");
1458 prop = RNA_def_property(srna, "limit_min_y", PROP_FLOAT, PROP_NONE);
1459 RNA_def_property_float_sdna(prop, NULL, "minLimit[1]");
1460 RNA_def_property_ui_text(prop, "Minimum Limit Y", "");
1462 prop = RNA_def_property(srna, "limit_min_z", PROP_FLOAT, PROP_NONE);
1463 RNA_def_property_float_sdna(prop, NULL, "minLimit[2]");
1464 RNA_def_property_ui_text(prop, "Minimum Limit Z", "");
1466 prop = RNA_def_property(srna, "limit_max_x", PROP_FLOAT, PROP_NONE);
1467 RNA_def_property_float_sdna(prop, NULL, "maxLimit[0]");
1468 RNA_def_property_ui_text(prop, "Maximum Limit X", "");
1470 prop = RNA_def_property(srna, "limit_max_y", PROP_FLOAT, PROP_NONE);
1471 RNA_def_property_float_sdna(prop, NULL, "maxLimit[1]");
1472 RNA_def_property_ui_text(prop, "Maximum Limit Y", "");
1474 prop = RNA_def_property(srna, "limit_max_z", PROP_FLOAT, PROP_NONE);
1475 RNA_def_property_float_sdna(prop, NULL, "maxLimit[2]");
1476 RNA_def_property_ui_text(prop, "Maximum Limit Z", "");
1478 /* Limit Min/Max for angle */
1479 prop = RNA_def_property(srna, "limit_angle_min_x", PROP_FLOAT, PROP_ANGLE);
1480 RNA_def_property_float_sdna(prop, NULL, "minLimit[3]");
1481 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1482 RNA_def_property_ui_text(prop, "Minimum Angular Limit X", "");
1484 prop = RNA_def_property(srna, "limit_angle_min_y", PROP_FLOAT, PROP_ANGLE);
1485 RNA_def_property_float_sdna(prop, NULL, "minLimit[4]");
1486 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1487 RNA_def_property_ui_text(prop, "Minimum Angular Limit Y", "");
1489 prop = RNA_def_property(srna, "limit_angle_min_z", PROP_FLOAT, PROP_ANGLE);
1490 RNA_def_property_float_sdna(prop, NULL, "minLimit[5]");
1491 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1492 RNA_def_property_ui_text(prop, "Minimum Angular Limit Z", "");
1494 prop = RNA_def_property(srna, "limit_angle_max_x", PROP_FLOAT, PROP_ANGLE);
1495 RNA_def_property_float_sdna(prop, NULL, "maxLimit[3]");
1496 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1497 RNA_def_property_ui_text(prop, "Maximum Angular Limit X", "");
1499 prop = RNA_def_property(srna, "limit_angle_max_y", PROP_FLOAT, PROP_ANGLE);
1500 RNA_def_property_float_sdna(prop, NULL, "maxLimit[4]");
1501 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1502 RNA_def_property_ui_text(prop, "Maximum Angular Limit Y", "");
1504 prop = RNA_def_property(srna, "limit_angle_max_z", PROP_FLOAT, PROP_ANGLE);
1505 RNA_def_property_float_sdna(prop, NULL, "maxLimit[5]");
1506 RNA_def_property_range(prop, -M_PI * 2, M_PI * 2);
1507 RNA_def_property_ui_text(prop, "Maximum Angular Limit Z", "");
1509 /* Limit Booleans */
1510 prop = RNA_def_property(srna, "use_limit_x", PROP_BOOLEAN, PROP_NONE);
1511 RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
1512 RNA_def_property_ui_text(prop, "Limit X", "Use minimum/maximum X limit");
1513 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1515 prop = RNA_def_property(srna, "use_limit_y", PROP_BOOLEAN, PROP_NONE);
1516 RNA_def_property_boolean_sdna(prop, NULL, "flag", 2);
1517 RNA_def_property_ui_text(prop, "Limit Y", "Use minimum/maximum y limit");
1518 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1520 prop = RNA_def_property(srna, "use_limit_z", PROP_BOOLEAN, PROP_NONE);
1521 RNA_def_property_boolean_sdna(prop, NULL, "flag", 4);
1522 RNA_def_property_ui_text(prop, "Limit Z", "Use minimum/maximum z limit");
1523 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1525 prop = RNA_def_property(srna, "use_angular_limit_x", PROP_BOOLEAN, PROP_NONE);
1526 RNA_def_property_boolean_sdna(prop, NULL, "flag", 8);
1527 RNA_def_property_ui_text(prop, "Angular X Limit", "Use minimum/maximum X angular limit");
1528 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1530 prop = RNA_def_property(srna, "use_angular_limit_y", PROP_BOOLEAN, PROP_NONE);
1531 RNA_def_property_boolean_sdna(prop, NULL, "flag", 16);
1532 RNA_def_property_ui_text(prop, "Angular Y Limit", "Use minimum/maximum Y angular limit");
1533 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1535 prop = RNA_def_property(srna, "use_angular_limit_z", PROP_BOOLEAN, PROP_NONE);
1536 RNA_def_property_boolean_sdna(prop, NULL, "flag", 32);
1537 RNA_def_property_ui_text(prop, "Angular Z Limit", "Use minimum/maximum Z angular limit");
1538 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1541 static void rna_def_constraint_clamp_to(BlenderRNA *brna)
1546 static EnumPropertyItem clamp_items[] = {
1547 {CLAMPTO_AUTO, "CLAMPTO_AUTO", 0, "Auto", ""},
1548 {CLAMPTO_X, "CLAMPTO_X", 0, "X", ""},
1549 {CLAMPTO_Y, "CLAMPTO_Y", 0, "Y", ""},
1550 {CLAMPTO_Z, "CLAMPTO_Z", 0, "Z", ""},
1551 {0, NULL, 0, NULL, NULL}
1554 srna = RNA_def_struct(brna, "ClampToConstraint", "Constraint");
1555 RNA_def_struct_ui_text(srna, "Clamp To Constraint",
1556 "Constrain an object's location to the nearest point along the target path");
1557 RNA_def_struct_sdna_from(srna, "bClampToConstraint", "data");
1559 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1560 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1561 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll");
1562 RNA_def_property_ui_text(prop, "Target", "Target Object (Curves only)");
1563 RNA_def_property_flag(prop, PROP_EDITABLE);
1564 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1566 prop = RNA_def_property(srna, "main_axis", PROP_ENUM, PROP_NONE);
1567 RNA_def_property_enum_sdna(prop, NULL, "flag");
1568 RNA_def_property_enum_items(prop, clamp_items);
1569 RNA_def_property_ui_text(prop, "Main Axis", "Main axis of movement");
1570 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1572 prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
1573 RNA_def_property_boolean_sdna(prop, NULL, "flag2", CLAMPTO_CYCLIC);
1574 RNA_def_property_ui_text(prop, "Cyclic", "Treat curve as cyclic curve (no clamping to curve bounding box)");
1575 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1578 static void rna_def_constraint_transform(BlenderRNA *brna)
1583 static EnumPropertyItem transform_items[] = {
1584 {TRANS_LOCATION, "LOCATION", 0, "Loc", ""},
1585 {TRANS_ROTATION, "ROTATION", 0, "Rot", ""},
1586 {TRANS_SCALE, "SCALE", 0, "Scale", ""},
1587 {0, NULL, 0, NULL, NULL}
1590 static EnumPropertyItem axis_map_items[] = {
1591 {0, "X", 0, "X", ""},
1592 {1, "Y", 0, "Y", ""},
1593 {2, "Z", 0, "Z", ""},
1594 {0, NULL, 0, NULL, NULL}
1597 srna = RNA_def_struct(brna, "TransformConstraint", "Constraint");
1598 RNA_def_struct_ui_text(srna, "Transformation Constraint", "Map transformations of the target to the object");
1599 RNA_def_struct_sdna_from(srna, "bTransformConstraint", "data");
1601 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
1602 RNA_def_property_pointer_sdna(prop, NULL, "tar");
1603 RNA_def_property_ui_text(prop, "Target", "Target Object");
1604 RNA_def_property_flag(prop, PROP_EDITABLE);
1605 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1607 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
1608 RNA_def_property_string_sdna(prop, NULL, "subtarget");
1609 RNA_def_property_ui_text(prop, "Sub-Target", "");
1610 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
1612 prop = RNA_def_property(srna, "map_from", PROP_ENUM, PROP_NONE);
1613 RNA_def_property_enum_sdna(prop, NULL, "from");
1614 RNA_def_property_enum_items(prop, transform_items);
1615 RNA_def_property_ui_text(prop, "Map From", "The transformation type to use from the target");
1616 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1618 prop = RNA_def_property(srna, "map_to", PROP_ENUM, PROP_NONE);
1619 RNA_def_property_enum_sdna(prop, NULL, "to");
1620 RNA_def_property_enum_items(prop, transform_items);
1621 RNA_def_property_ui_text(prop, "Map To", "The transformation type to affect of the constrained object");
1622 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1624 prop = RNA_def_property(srna, "map_to_x_from", PROP_ENUM, PROP_NONE);
1625 RNA_def_property_enum_sdna(prop, NULL, "map[0]");
1626 RNA_def_property_enum_items(prop, axis_map_items);
1627 RNA_def_property_ui_text(prop, "Map To X From", "The source axis constrained object's X axis uses");
1628 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1630 prop = RNA_def_property(srna, "map_to_y_from", PROP_ENUM, PROP_NONE);
1631 RNA_def_property_enum_sdna(prop, NULL, "map[1]");
1632 RNA_def_property_enum_items(prop, axis_map_items);
1633 RNA_def_property_ui_text(prop, "Map To Y From", "The source axis constrained object's Y axis uses");
1634 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1636 prop = RNA_def_property(srna, "map_to_z_from", PROP_ENUM, PROP_NONE);
1637 RNA_def_property_enum_sdna(prop, NULL, "map[2]");
1638 RNA_def_property_enum_items(prop, axis_map_items);
1639 RNA_def_property_ui_text(prop, "Map To Z From", "The source axis constrained object's Z axis uses");
1640 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1642 prop = RNA_def_property(srna, "use_motion_extrapolate", PROP_BOOLEAN, PROP_NONE);
1643 RNA_def_property_boolean_sdna(prop, NULL, "expo", CLAMPTO_CYCLIC);
1644 RNA_def_property_ui_text(prop, "Extrapolate Motion", "Extrapolate ranges");
1645 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1648 prop = RNA_def_property(srna, "from_min_x", PROP_FLOAT, PROP_DISTANCE);
1649 RNA_def_property_float_sdna(prop, NULL, "from_min[0]");
1650 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1651 RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
1652 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1654 prop = RNA_def_property(srna, "from_min_y", PROP_FLOAT, PROP_DISTANCE);
1655 RNA_def_property_float_sdna(prop, NULL, "from_min[1]");
1656 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1657 RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
1658 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1660 prop = RNA_def_property(srna, "from_min_z", PROP_FLOAT, PROP_DISTANCE);
1661 RNA_def_property_float_sdna(prop, NULL, "from_min[2]");
1662 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1663 RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
1664 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1666 prop = RNA_def_property(srna, "from_max_x", PROP_FLOAT, PROP_DISTANCE);
1667 RNA_def_property_float_sdna(prop, NULL, "from_max[0]");
1668 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1669 RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
1670 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1672 prop = RNA_def_property(srna, "from_max_y", PROP_FLOAT, PROP_DISTANCE);
1673 RNA_def_property_float_sdna(prop, NULL, "from_max[1]");
1674 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1675 RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
1676 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1678 prop = RNA_def_property(srna, "from_max_z", PROP_FLOAT, PROP_DISTANCE);
1679 RNA_def_property_float_sdna(prop, NULL, "from_max[2]");
1680 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1681 RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
1682 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1684 prop = RNA_def_property(srna, "to_min_x", PROP_FLOAT, PROP_DISTANCE);
1685 RNA_def_property_float_sdna(prop, NULL, "to_min[0]");
1686 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1687 RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
1688 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1690 prop = RNA_def_property(srna, "to_min_y", PROP_FLOAT, PROP_DISTANCE);
1691 RNA_def_property_float_sdna(prop, NULL, "to_min[1]");
1692 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1693 RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
1694 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1696 prop = RNA_def_property(srna, "to_min_z", PROP_FLOAT, PROP_DISTANCE);
1697 RNA_def_property_float_sdna(prop, NULL, "to_min[2]");
1698 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1699 RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
1700 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1702 prop = RNA_def_property(srna, "to_max_x", PROP_FLOAT, PROP_DISTANCE);
1703 RNA_def_property_float_sdna(prop, NULL, "to_max[0]");
1704 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1705 RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
1706 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1708 prop = RNA_def_property(srna, "to_max_y", PROP_FLOAT, PROP_DISTANCE);
1709 RNA_def_property_float_sdna(prop, NULL, "to_max[1]");
1710 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1711 RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
1712 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1714 prop = RNA_def_property(srna, "to_max_z", PROP_FLOAT, PROP_DISTANCE);
1715 RNA_def_property_float_sdna(prop, NULL, "to_max[2]");
1716 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1717 RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
1718 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1721 prop = RNA_def_property(srna, "from_min_x_rot", PROP_FLOAT, PROP_ANGLE);
1722 RNA_def_property_float_sdna(prop, NULL, "from_min[0]");
1723 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1724 RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
1725 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1727 prop = RNA_def_property(srna, "from_min_y_rot", PROP_FLOAT, PROP_ANGLE);
1728 RNA_def_property_float_sdna(prop, NULL, "from_min[1]");
1729 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1730 RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
1731 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1733 prop = RNA_def_property(srna, "from_min_z_rot", PROP_FLOAT, PROP_ANGLE);
1734 RNA_def_property_float_sdna(prop, NULL, "from_min[2]");
1735 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1736 RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
1737 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1739 prop = RNA_def_property(srna, "from_max_x_rot", PROP_FLOAT, PROP_ANGLE);
1740 RNA_def_property_float_sdna(prop, NULL, "from_max[0]");
1741 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1742 RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
1743 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1745 prop = RNA_def_property(srna, "from_max_y_rot", PROP_FLOAT, PROP_ANGLE);
1746 RNA_def_property_float_sdna(prop, NULL, "from_max[1]");
1747 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1748 RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
1749 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1751 prop = RNA_def_property(srna, "from_max_z_rot", PROP_FLOAT, PROP_ANGLE);
1752 RNA_def_property_float_sdna(prop, NULL, "from_max[2]");
1753 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1754 RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
1755 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1757 prop = RNA_def_property(srna, "to_min_x_rot", PROP_FLOAT, PROP_ANGLE);
1758 RNA_def_property_float_sdna(prop, NULL, "to_min[0]");
1759 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1760 RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
1761 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1763 prop = RNA_def_property(srna, "to_min_y_rot", PROP_FLOAT, PROP_ANGLE);
1764 RNA_def_property_float_sdna(prop, NULL, "to_min[1]");
1765 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1766 RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
1767 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1769 prop = RNA_def_property(srna, "to_min_z_rot", PROP_FLOAT, PROP_ANGLE);
1770 RNA_def_property_float_sdna(prop, NULL, "to_min[2]");
1771 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1772 RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
1773 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1775 prop = RNA_def_property(srna, "to_max_x_rot", PROP_FLOAT, PROP_ANGLE);
1776 RNA_def_property_float_sdna(prop, NULL, "to_max[0]");
1777 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1778 RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
1779 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1781 prop = RNA_def_property(srna, "to_max_y_rot", PROP_FLOAT, PROP_ANGLE);
1782 RNA_def_property_float_sdna(prop, NULL, "to_max[1]");
1783 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1784 RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
1785 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1787 prop = RNA_def_property(srna, "to_max_z_rot", PROP_FLOAT, PROP_ANGLE);
1788 RNA_def_property_float_sdna(prop, NULL, "to_max[2]");
1789 RNA_def_property_ui_range(prop, DEG2RADF(-180.0f), DEG2RADF(180.0f), 10, 3);
1790 RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
1791 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1794 prop = RNA_def_property(srna, "from_min_x_scale", PROP_FLOAT, PROP_NONE);
1795 RNA_def_property_float_sdna(prop, NULL, "from_min[0]");
1796 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1797 RNA_def_property_ui_text(prop, "From Minimum X", "Bottom range of X axis source motion");
1798 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1800 prop = RNA_def_property(srna, "from_min_y_scale", PROP_FLOAT, PROP_NONE);
1801 RNA_def_property_float_sdna(prop, NULL, "from_min[1]");
1802 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1803 RNA_def_property_ui_text(prop, "From Minimum Y", "Bottom range of Y axis source motion");
1804 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1806 prop = RNA_def_property(srna, "from_min_z_scale", PROP_FLOAT, PROP_NONE);
1807 RNA_def_property_float_sdna(prop, NULL, "from_min[2]");
1808 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1809 RNA_def_property_ui_text(prop, "From Minimum Z", "Bottom range of Z axis source motion");
1810 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1812 prop = RNA_def_property(srna, "from_max_x_scale", PROP_FLOAT, PROP_NONE);
1813 RNA_def_property_float_sdna(prop, NULL, "from_max[0]");
1814 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1815 RNA_def_property_ui_text(prop, "From Maximum X", "Top range of X axis source motion");
1816 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1818 prop = RNA_def_property(srna, "from_max_y_scale", PROP_FLOAT, PROP_NONE);
1819 RNA_def_property_float_sdna(prop, NULL, "from_max[1]");
1820 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1821 RNA_def_property_ui_text(prop, "From Maximum Y", "Top range of Y axis source motion");
1822 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1824 prop = RNA_def_property(srna, "from_max_z_scale", PROP_FLOAT, PROP_NONE);
1825 RNA_def_property_float_sdna(prop, NULL, "from_max[2]");
1826 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1827 RNA_def_property_ui_text(prop, "From Maximum Z", "Top range of Z axis source motion");
1828 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1830 prop = RNA_def_property(srna, "to_min_x_scale", PROP_FLOAT, PROP_NONE);
1831 RNA_def_property_float_sdna(prop, NULL, "to_min[0]");
1832 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1833 RNA_def_property_ui_text(prop, "To Minimum X", "Bottom range of X axis destination motion");
1834 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1836 prop = RNA_def_property(srna, "to_min_y_scale", PROP_FLOAT, PROP_NONE);
1837 RNA_def_property_float_sdna(prop, NULL, "to_min[1]");
1838 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1839 RNA_def_property_ui_text(prop, "To Minimum Y", "Bottom range of Y axis destination motion");
1840 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1842 prop = RNA_def_property(srna, "to_min_z_scale", PROP_FLOAT, PROP_NONE);
1843 RNA_def_property_float_sdna(prop, NULL, "to_min[2]");
1844 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1845 RNA_def_property_ui_text(prop, "To Minimum Z", "Bottom range of Z axis destination motion");
1846 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1848 prop = RNA_def_property(srna, "to_max_x_scale", PROP_FLOAT, PROP_NONE);
1849 RNA_def_property_float_sdna(prop, NULL, "to_max[0]");
1850 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1851 RNA_def_property_ui_text(prop, "To Maximum X", "Top range of X axis destination motion");
1852 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1854 prop = RNA_def_property(srna, "to_max_y_scale", PROP_FLOAT, PROP_NONE);
1855 RNA_def_property_float_sdna(prop, NULL, "to_max[1]");
1856 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1857 RNA_def_property_ui_text(prop, "To Maximum Y", "Top range of Y axis destination motion");
1858 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1860 prop = RNA_def_property(srna, "to_max_z_scale", PROP_FLOAT, PROP_NONE);
1861 RNA_def_property_float_sdna(prop, NULL, "to_max[2]");
1862 RNA_def_property_ui_range(prop, -1000.0f, 1000.0f, 10, 3);
1863 RNA_def_property_ui_text(prop, "To Maximum Z", "Top range of Z axis destination motion");
1864 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1867 static void rna_def_constraint_location_limit(BlenderRNA *brna)
1872 srna = RNA_def_struct(brna, "LimitLocationConstraint", "Constraint");
1873 RNA_def_struct_ui_text(srna, "Limit Location Constraint", "Limit the location of the constrained object");
1874 RNA_def_struct_sdna_from(srna, "bLocLimitConstraint", "data");
1876 prop = RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
1877 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMIN);
1878 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
1879 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1881 prop = RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
1882 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMIN);
1883 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
1884 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1886 prop = RNA_def_property(srna, "use_min_z", PROP_BOOLEAN, PROP_NONE);
1887 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMIN);
1888 RNA_def_property_ui_text(prop, "Minimum Z", "Use the minimum Z value");
1889 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1891 prop = RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
1892 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMAX);
1893 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
1894 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1896 prop = RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
1897 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMAX);
1898 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
1899 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1901 prop = RNA_def_property(srna, "use_max_z", PROP_BOOLEAN, PROP_NONE);
1902 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMAX);
1903 RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value");
1904 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1906 prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_DISTANCE);
1907 RNA_def_property_float_sdna(prop, NULL, "xmin");
1908 RNA_def_property_range(prop, -1000.0, 1000.f);
1909 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
1910 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1912 prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_DISTANCE);
1913 RNA_def_property_float_sdna(prop, NULL, "ymin");
1914 RNA_def_property_range(prop, -1000.0, 1000.f);
1915 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
1916 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1918 prop = RNA_def_property(srna, "min_z", PROP_FLOAT, PROP_DISTANCE);
1919 RNA_def_property_float_sdna(prop, NULL, "zmin");
1920 RNA_def_property_range(prop, -1000.0, 1000.f);
1921 RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow");
1922 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1924 prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_DISTANCE);
1925 RNA_def_property_float_sdna(prop, NULL, "xmax");
1926 RNA_def_property_range(prop, -1000.0, 1000.f);
1927 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
1928 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1930 prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_DISTANCE);
1931 RNA_def_property_float_sdna(prop, NULL, "ymax");
1932 RNA_def_property_range(prop, -1000.0, 1000.f);
1933 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
1934 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1936 prop = RNA_def_property(srna, "max_z", PROP_FLOAT, PROP_DISTANCE);
1937 RNA_def_property_float_sdna(prop, NULL, "zmax");
1938 RNA_def_property_range(prop, -1000.0, 1000.f);
1939 RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
1940 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1942 prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, PROP_NONE);
1943 RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM);
1944 RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well");
1945 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1948 static void rna_def_constraint_rotation_limit(BlenderRNA *brna)
1953 srna = RNA_def_struct(brna, "LimitRotationConstraint", "Constraint");
1954 RNA_def_struct_ui_text(srna, "Limit Rotation Constraint", "Limit the rotation of the constrained object");
1955 RNA_def_struct_sdna_from(srna, "bRotLimitConstraint", "data");
1957 prop = RNA_def_property(srna, "use_limit_x", PROP_BOOLEAN, PROP_NONE);
1958 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XROT);
1959 RNA_def_property_ui_text(prop, "Limit X", "Use the minimum X value");
1960 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1962 prop = RNA_def_property(srna, "use_limit_y", PROP_BOOLEAN, PROP_NONE);
1963 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YROT);
1964 RNA_def_property_ui_text(prop, "Limit Y", "Use the minimum Y value");
1965 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1967 prop = RNA_def_property(srna, "use_limit_z", PROP_BOOLEAN, PROP_NONE);
1968 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZROT);
1969 RNA_def_property_ui_text(prop, "Limit Z", "Use the minimum Z value");
1970 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1972 prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_ANGLE);
1973 RNA_def_property_float_sdna(prop, NULL, "xmin");
1974 RNA_def_property_range(prop, -1000.0, 1000.f);
1975 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
1976 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1978 prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_ANGLE);
1979 RNA_def_property_float_sdna(prop, NULL, "ymin");
1980 RNA_def_property_range(prop, -1000.0, 1000.f);
1981 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
1982 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1984 prop = RNA_def_property(srna, "min_z", PROP_FLOAT, PROP_ANGLE);
1985 RNA_def_property_float_sdna(prop, NULL, "zmin");
1986 RNA_def_property_range(prop, -1000.0, 1000.f);
1987 RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow");
1988 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1990 prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_ANGLE);
1991 RNA_def_property_float_sdna(prop, NULL, "xmax");
1992 RNA_def_property_range(prop, -1000.0, 1000.f);
1993 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
1994 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
1996 prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_ANGLE);
1997 RNA_def_property_float_sdna(prop, NULL, "ymax");
1998 RNA_def_property_range(prop, -1000.0, 1000.f);
1999 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
2000 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2002 prop = RNA_def_property(srna, "max_z", PROP_FLOAT, PROP_ANGLE);
2003 RNA_def_property_float_sdna(prop, NULL, "zmax");
2004 RNA_def_property_range(prop, -1000.0, 1000.f);
2005 RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
2006 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2008 prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, PROP_NONE);
2009 RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM);
2010 RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well");
2011 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2014 static void rna_def_constraint_size_limit(BlenderRNA *brna)
2019 srna = RNA_def_struct(brna, "LimitScaleConstraint", "Constraint");
2020 RNA_def_struct_ui_text(srna, "Limit Size Constraint", "Limit the scaling of the constrained object");
2021 RNA_def_struct_sdna_from(srna, "bSizeLimitConstraint", "data");
2023 prop = RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
2024 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMIN);
2025 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
2026 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2028 prop = RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
2029 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMIN);
2030 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
2031 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2033 prop = RNA_def_property(srna, "use_min_z", PROP_BOOLEAN, PROP_NONE);
2034 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMIN);
2035 RNA_def_property_ui_text(prop, "Minimum Z", "Use the minimum Z value");
2036 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2038 prop = RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
2039 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_XMAX);
2040 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
2041 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2043 prop = RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
2044 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_YMAX);
2045 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
2046 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2048 prop = RNA_def_property(srna, "use_max_z", PROP_BOOLEAN, PROP_NONE);
2049 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMIT_ZMAX);
2050 RNA_def_property_ui_text(prop, "Maximum Z", "Use the maximum Z value");
2051 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2053 prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
2054 RNA_def_property_float_sdna(prop, NULL, "xmin");
2055 RNA_def_property_range(prop, -1000.0, 1000.f);
2056 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
2057 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2059 prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
2060 RNA_def_property_float_sdna(prop, NULL, "ymin");
2061 RNA_def_property_range(prop, -1000.0, 1000.f);
2062 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
2063 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2065 prop = RNA_def_property(srna, "min_z", PROP_FLOAT, PROP_NONE);
2066 RNA_def_property_float_sdna(prop, NULL, "zmin");
2067 RNA_def_property_range(prop, -1000.0, 1000.f);
2068 RNA_def_property_ui_text(prop, "Minimum Z", "Lowest Z value to allow");
2069 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2071 prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
2072 RNA_def_property_float_sdna(prop, NULL, "xmax");
2073 RNA_def_property_range(prop, -1000.0, 1000.f);
2074 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
2075 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2077 prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
2078 RNA_def_property_float_sdna(prop, NULL, "ymax");
2079 RNA_def_property_range(prop, -1000.0, 1000.f);
2080 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
2081 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2083 prop = RNA_def_property(srna, "max_z", PROP_FLOAT, PROP_NONE);
2084 RNA_def_property_float_sdna(prop, NULL, "zmax");
2085 RNA_def_property_range(prop, -1000.0, 1000.f);
2086 RNA_def_property_ui_text(prop, "Maximum Z", "Highest Z value to allow");
2087 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2089 prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, PROP_NONE);
2090 RNA_def_property_boolean_sdna(prop, NULL, "flag2", LIMIT_TRANSFORM);
2091 RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well");
2092 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2095 static void rna_def_constraint_distance_limit(BlenderRNA *brna)
2100 srna = RNA_def_struct(brna, "LimitDistanceConstraint", "Constraint");
2101 RNA_def_struct_ui_text(srna, "Limit Distance Constraint", "Limit the distance from target object");
2103 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
2104 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
2105 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
2106 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2108 RNA_def_struct_sdna_from(srna, "bDistLimitConstraint", "data");
2110 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
2111 RNA_def_property_pointer_sdna(prop, NULL, "tar");
2112 RNA_def_property_ui_text(prop, "Target", "Target Object");
2113 RNA_def_property_flag(prop, PROP_EDITABLE);
2114 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2116 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
2117 RNA_def_property_string_sdna(prop, NULL, "subtarget");
2118 RNA_def_property_ui_text(prop, "Sub-Target", "");
2119 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2121 prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
2122 RNA_def_property_float_sdna(prop, NULL, "dist");
2123 RNA_def_property_range(prop, 0.0, 100.f);
2124 RNA_def_property_ui_text(prop, "Distance", "Radius of limiting sphere");
2125 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2127 prop = RNA_def_property(srna, "limit_mode", PROP_ENUM, PROP_NONE);
2128 RNA_def_property_enum_sdna(prop, NULL, "mode");
2129 RNA_def_property_enum_items(prop, constraint_distance_items);
2130 RNA_def_property_ui_text(prop, "Limit Mode", "Distances in relation to sphere of influence to allow");
2131 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2133 prop = RNA_def_property(srna, "use_transform_limit", PROP_BOOLEAN, PROP_NONE);
2134 RNA_def_property_boolean_sdna(prop, NULL, "flag", LIMITDIST_TRANSFORM);
2135 RNA_def_property_ui_text(prop, "For Transform", "Transforms are affected by this constraint as well");
2136 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2139 static void rna_def_constraint_shrinkwrap(BlenderRNA *brna)
2144 static EnumPropertyItem type_items[] = {
2145 {MOD_SHRINKWRAP_NEAREST_SURFACE, "NEAREST_SURFACE", 0, "Nearest Surface Point",
2146 "Shrink the location to the nearest target surface"},
2147 {MOD_SHRINKWRAP_PROJECT, "PROJECT", 0, "Project",
2148 "Shrink the location to the nearest target surface along a given axis"},
2149 {MOD_SHRINKWRAP_NEAREST_VERTEX, "NEAREST_VERTEX", 0, "Nearest Vertex",
2150 "Shrink the location to the nearest target vertex"},
2151 {0, NULL, 0, NULL, NULL}
2154 srna = RNA_def_struct(brna, "ShrinkwrapConstraint", "Constraint");
2155 RNA_def_struct_ui_text(srna, "Shrinkwrap Constraint", "Create constraint-based shrinkwrap relationship");
2156 RNA_def_struct_sdna_from(srna, "bShrinkwrapConstraint", "data");
2158 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
2159 RNA_def_property_pointer_sdna(prop, NULL, "target"); /* TODO, mesh type */
2160 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
2161 RNA_def_property_ui_text(prop, "Target", "Target Object");
2162 RNA_def_property_flag(prop, PROP_EDITABLE);
2163 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2165 prop = RNA_def_property(srna, "shrinkwrap_type", PROP_ENUM, PROP_NONE);
2166 RNA_def_property_enum_sdna(prop, NULL, "shrinkType");
2167 RNA_def_property_enum_items(prop, type_items);
2168 RNA_def_property_ui_text(prop, "Shrinkwrap Type", "Select type of shrinkwrap algorithm for target position");
2169 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2171 prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
2172 RNA_def_property_float_sdna(prop, NULL, "dist");
2173 RNA_def_property_range(prop, 0.0, 100.f);
2174 RNA_def_property_ui_text(prop, "Distance", "Distance to Target");
2175 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2177 prop = RNA_def_property(srna, "project_axis", PROP_ENUM, PROP_NONE);
2178 RNA_def_property_enum_sdna(prop, NULL, "projAxis");
2179 RNA_def_property_enum_items(prop, object_axis_items);
2180 RNA_def_property_ui_text(prop, "Project Axis", "Axis constrain to");
2181 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2183 prop = RNA_def_property(srna, "project_axis_space", PROP_ENUM, PROP_NONE);
2184 RNA_def_property_enum_sdna(prop, NULL, "projAxisSpace");
2185 RNA_def_property_enum_items(prop, owner_space_pchan_items);
2186 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
2187 RNA_def_property_ui_text(prop, "Axis Space", "Space for the projection axis");
2189 prop = RNA_def_property(srna, "project_limit", PROP_FLOAT, PROP_DISTANCE);
2190 RNA_def_property_float_sdna(prop, NULL, "projLimit");
2191 RNA_def_property_range(prop, 0.0, 100.f);
2192 RNA_def_property_ui_text(prop, "Project Distance", "Limit the distance used for projection (zero disables)");
2193 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2196 static void rna_def_constraint_damped_track(BlenderRNA *brna)
2201 static EnumPropertyItem damptrack_items[] = {
2202 {TRACK_X, "TRACK_X", 0, "X", ""},
2203 {TRACK_Y, "TRACK_Y", 0, "Y", ""},
2204 {TRACK_Z, "TRACK_Z", 0, "Z", ""},
2205 {TRACK_nX, "TRACK_NEGATIVE_X", 0, "-X", ""},
2206 {TRACK_nY, "TRACK_NEGATIVE_Y", 0, "-Y", ""},
2207 {TRACK_nZ, "TRACK_NEGATIVE_Z", 0, "-Z", ""},
2208 {0, NULL, 0, NULL, NULL}
2211 srna = RNA_def_struct(brna, "DampedTrackConstraint", "Constraint");
2212 RNA_def_struct_ui_text(srna, "Damped Track Constraint",
2213 "Point toward target by taking the shortest rotation path");
2215 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
2216 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
2217 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
2218 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2220 RNA_def_struct_sdna_from(srna, "bDampTrackConstraint", "data");
2222 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
2223 RNA_def_property_pointer_sdna(prop, NULL, "tar");
2224 RNA_def_property_ui_text(prop, "Target", "Target Object");
2225 RNA_def_property_flag(prop, PROP_EDITABLE);
2226 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2228 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
2229 RNA_def_property_string_sdna(prop, NULL, "subtarget");
2230 RNA_def_property_ui_text(prop, "Sub-Target", "");
2231 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2233 prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
2234 RNA_def_property_enum_sdna(prop, NULL, "trackflag");
2235 RNA_def_property_enum_items(prop, damptrack_items);
2236 RNA_def_property_ui_text(prop, "Track Axis", "Axis that points to the target object");
2237 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2240 static void rna_def_constraint_spline_ik(BlenderRNA *brna)
2245 static EnumPropertyItem splineik_xz_scale_mode[] = {
2246 {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes (Default)"},
2247 {CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original",
2248 "Use the original scaling of the bones"},
2249 {CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC, "VOLUME_PRESERVE", 0, "Volume Preservation",
2250 "Scale of the X and Z axes is the inverse of the Y-Scale"},
2251 {0, NULL, 0, NULL, NULL}
2254 srna = RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
2255 RNA_def_struct_ui_text(srna, "Spline IK Constraint", "Align 'n' bones along a curve");
2256 RNA_def_struct_sdna_from(srna, "bSplineIKConstraint", "data");
2259 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
2260 RNA_def_property_pointer_sdna(prop, NULL, "tar");
2261 RNA_def_property_ui_text(prop, "Target", "Curve that controls this relationship");
2262 RNA_def_property_flag(prop, PROP_EDITABLE);
2263 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2265 prop = RNA_def_property(srna, "chain_count", PROP_INT, PROP_NONE);
2266 RNA_def_property_int_sdna(prop, NULL, "chainlen");
2267 /* TODO: this should really check the max length of the chain the constraint is attached to */
2268 RNA_def_property_range(prop, 1, 255);
2269 RNA_def_property_ui_text(prop, "Chain Length", "How many bones are included in the chain");
2270 /* XXX: this update goes wrong... needs extra flush? */
2271 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2273 /* direct access to bindings */
2274 /* NOTE: only to be used by experienced users */
2275 prop = RNA_def_property(srna, "joint_bindings", PROP_FLOAT, PROP_FACTOR);
2276 RNA_def_property_array(prop, 32); /* XXX this is the maximum value allowed - why? */
2277 RNA_def_property_flag(prop, PROP_DYNAMIC);
2278 RNA_def_property_dynamic_array_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get_length");
2279 RNA_def_property_float_funcs(prop, "rna_SplineIKConstraint_joint_bindings_get",
2280 "rna_SplineIKConstraint_joint_bindings_set", NULL);
2281 RNA_def_property_ui_text(prop, "Joint Bindings",
2282 "(EXPERIENCED USERS ONLY) The relative positions of the joints along the chain, "
2284 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2287 prop = RNA_def_property(srna, "use_chain_offset", PROP_BOOLEAN, PROP_NONE);
2288 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_NO_ROOT);
2289 RNA_def_property_ui_text(prop, "Chain Offset", "Offset the entire chain relative to the root joint");
2290 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2292 prop = RNA_def_property(srna, "use_even_divisions", PROP_BOOLEAN, PROP_NONE);
2293 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_EVENSPLITS);
2294 RNA_def_property_ui_text(prop, "Even Divisions",
2295 "Ignore the relative lengths of the bones when fitting to the curve");
2296 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2298 prop = RNA_def_property(srna, "use_y_stretch", PROP_BOOLEAN, PROP_NONE);
2299 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_SCALE_LIMITED);
2300 RNA_def_property_ui_text(prop, "Y Stretch", "Stretch the Y axis of the bones to fit the curve");
2301 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2303 prop = RNA_def_property(srna, "use_curve_radius", PROP_BOOLEAN, PROP_NONE);
2304 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_NO_CURVERAD);
2305 RNA_def_property_ui_text(prop, "Use Curve Radius",
2306 "Average radius of the endpoints is used to tweak the X and Z Scaling of the bones, "
2307 "on top of XZ Scale mode");
2308 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2310 prop = RNA_def_property(srna, "xz_scale_mode", PROP_ENUM, PROP_NONE);
2311 RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode");
2312 RNA_def_property_enum_items(prop, splineik_xz_scale_mode);
2313 RNA_def_property_ui_text(prop, "XZ Scale Mode",
2314 "Method used for determining the scaling of the X and Z axes of the bones");
2315 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2318 static void rna_def_constraint_pivot(BlenderRNA *brna)
2323 static EnumPropertyItem pivot_rotAxis_items[] = {
2324 {PIVOTCON_AXIS_NONE, "ALWAYS_ACTIVE", 0, "Always", "Use the pivot point in every rotation"},
2325 {PIVOTCON_AXIS_X_NEG, "NX", 0, "-X Rot",
2326 "Use the pivot point in the negative rotation range around the X-axis"},
2327 {PIVOTCON_AXIS_Y_NEG, "NY", 0, "-Y Rot",
2328 "Use the pivot point in the negative rotation range around the Y-axis"},
2329 {PIVOTCON_AXIS_Z_NEG, "NZ", 0, "-Z Rot",
2330 "Use the pivot point in the negative rotation range around the Z-axis"},
2331 {PIVOTCON_AXIS_X, "X", 0, "X Rot", "Use the pivot point in the positive rotation range around the X-axis"},
2332 {PIVOTCON_AXIS_Y, "Y", 0, "Y Rot", "Use the pivot point in the positive rotation range around the Y-axis"},
2333 {PIVOTCON_AXIS_Z, "Z", 0, "Z Rot", "Use the pivot point in the positive rotation range around the Z-axis"},
2334 {0, NULL, 0, NULL, NULL}
2337 srna = RNA_def_struct(brna, "PivotConstraint", "Constraint");
2338 RNA_def_struct_ui_text(srna, "Pivot Constraint", "Rotate around a different point");
2340 prop = RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
2341 RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
2342 RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
2343 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2345 RNA_def_struct_sdna_from(srna, "bPivotConstraint", "data");
2347 /* target-defined pivot */
2348 prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
2349 RNA_def_property_pointer_sdna(prop, NULL, "tar");
2350 RNA_def_property_ui_text(prop, "Target", "Target Object, defining the position of the pivot when defined");
2351 RNA_def_property_flag(prop, PROP_EDITABLE);
2352 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2354 prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
2355 RNA_def_property_string_sdna(prop, NULL, "subtarget");
2356 RNA_def_property_ui_text(prop, "Sub-Target", "");
2357 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2360 prop = RNA_def_property(srna, "use_relative_location", PROP_BOOLEAN, PROP_NONE);
2361 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PIVOTCON_FLAG_OFFSET_ABS);
2362 RNA_def_property_ui_text(prop, "Use Relative Offset",
2363 "Offset will be an absolute point in space instead of relative to the target");
2364 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2366 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ);
2367 RNA_def_property_float_sdna(prop, NULL, "offset");
2368 RNA_def_property_ui_text(prop, "Offset",
2369 "Offset of pivot from target (when set), or from owner's location "
2370 "(when Fixed Position is off), or the absolute pivot point");
2371 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2373 /* rotation-based activation */
2374 prop = RNA_def_property(srna, "rotation_range", PROP_ENUM, PROP_NONE);
2375 RNA_def_property_enum_sdna(prop, NULL, "rotAxis");
2376 RNA_def_property_enum_items(prop, pivot_rotAxis_items);
2377 RNA_def_property_ui_text(prop, "Enabled Rotation Range", "Rotation range on which pivoting should occur");
2378 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2381 static void rna_def_constraint_follow_track(BlenderRNA *brna)
2386 static const EnumPropertyItem frame_method_items[] = {
2387 {FOLLOWTRACK_FRAME_STRETCH, "STRETCH", 0, "Stretch", ""},
2388 {FOLLOWTRACK_FRAME_FIT, "FIT", 0, "Fit", ""},
2389 {FOLLOWTRACK_FRAME_CROP, "CROP", 0, "Crop", ""},
2390 {0, NULL, 0, NULL, NULL}
2393 srna = RNA_def_struct(brna, "FollowTrackConstraint", "Constraint");
2394 RNA_def_struct_ui_text(srna, "Follow Track Constraint", "Lock motion to the target motion track");
2395 RNA_def_struct_sdna_from(srna, "bFollowTrackConstraint", "data");
2398 prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
2399 RNA_def_property_pointer_sdna(prop, NULL, "clip");
2400 RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from");
2401 RNA_def_property_flag(prop, PROP_EDITABLE);
2402 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2405 prop = RNA_def_property(srna, "track", PROP_STRING, PROP_NONE);
2406 RNA_def_property_string_sdna(prop, NULL, "track");
2407 RNA_def_property_ui_text(prop, "Track", "Movie tracking track to follow");
2408 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2410 /* use default clip */
2411 prop = RNA_def_property(srna, "use_active_clip", PROP_BOOLEAN, PROP_NONE);
2412 RNA_def_property_boolean_sdna(prop, NULL, "flag", FOLLOWTRACK_ACTIVECLIP);
2413 RNA_def_property_ui_text(prop, "Active Clip", "Use active clip defined in scene");
2414 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2416 /* use 3d position */
2417 prop = RNA_def_property(srna, "use_3d_position", PROP_BOOLEAN, PROP_NONE);
2418 RNA_def_property_boolean_sdna(prop, NULL, "flag", FOLLOWTRACK_USE_3D_POSITION);
2419 RNA_def_property_ui_text(prop, "3D Position", "Use 3D position of track to parent to");
2420 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2423 prop = RNA_def_property(srna, "object", PROP_STRING, PROP_NONE);
2424 RNA_def_property_string_sdna(prop, NULL, "object");
2425 RNA_def_property_ui_text(prop, "Object", "Movie tracking object to follow (if empty, camera object is used)");
2426 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2429 prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
2430 RNA_def_property_pointer_sdna(prop, NULL, "camera");
2431 RNA_def_property_ui_text(prop, "Camera",
2432 "Camera to which motion is parented (if empty active scene camera is used)");
2433 RNA_def_property_flag(prop, PROP_EDITABLE);
2434 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2435 RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_camera_set", NULL,
2436 "rna_Constraint_cameraObject_poll");
2439 prop = RNA_def_property(srna, "depth_object", PROP_POINTER, PROP_NONE);
2440 RNA_def_property_pointer_sdna(prop, NULL, "depth_ob");
2441 RNA_def_property_ui_text(prop, "Depth Object",
2442 "Object used to define depth in camera space by projecting onto surface of this object");
2443 RNA_def_property_flag(prop, PROP_EDITABLE);
2444 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2445 RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_followTrack_depthObject_set", NULL,
2446 "rna_Constraint_followTrack_depthObject_poll");
2449 prop = RNA_def_property(srna, "frame_method", PROP_ENUM, PROP_NONE);
2450 RNA_def_property_enum_bitflag_sdna(prop, NULL, "frame_method");
2451 RNA_def_property_enum_items(prop, frame_method_items);
2452 RNA_def_property_ui_text(prop, "Frame Method", "How the footage fits in the camera frame");
2453 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2456 static void rna_def_constraint_camera_solver(BlenderRNA *brna)
2461 srna = RNA_def_struct(brna, "CameraSolverConstraint", "Constraint");
2462 RNA_def_struct_ui_text(srna, "Camera Solver Constraint", "Lock motion to the reconstructed camera movement");
2463 RNA_def_struct_sdna_from(srna, "bCameraSolverConstraint", "data");
2466 prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
2467 RNA_def_property_pointer_sdna(prop, NULL, "clip");
2468 RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from");
2469 RNA_def_property_flag(prop, PROP_EDITABLE);
2470 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2472 /* use default clip */
2473 prop = RNA_def_property(srna, "use_active_clip", PROP_BOOLEAN, PROP_NONE);
2474 RNA_def_property_boolean_sdna(prop, NULL, "flag", CAMERASOLVER_ACTIVECLIP);
2475 RNA_def_property_ui_text(prop, "Active Clip", "Use active clip defined in scene");
2476 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2479 static void rna_def_constraint_object_solver(BlenderRNA *brna)
2484 srna = RNA_def_struct(brna, "ObjectSolverConstraint", "Constraint");
2485 RNA_def_struct_ui_text(srna, "Object Solver Constraint", "Lock motion to the reconstructed object movement");
2486 RNA_def_struct_sdna_from(srna, "bObjectSolverConstraint", "data");
2489 prop = RNA_def_property(srna, "clip", PROP_POINTER, PROP_NONE);
2490 RNA_def_property_pointer_sdna(prop, NULL, "clip");
2491 RNA_def_property_ui_text(prop, "Movie Clip", "Movie Clip to get tracking data from");
2492 RNA_def_property_flag(prop, PROP_EDITABLE);
2493 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2495 /* use default clip */
2496 prop = RNA_def_property(srna, "use_active_clip", PROP_BOOLEAN, PROP_NONE);
2497 RNA_def_property_boolean_sdna(prop, NULL, "flag", CAMERASOLVER_ACTIVECLIP);
2498 RNA_def_property_ui_text(prop, "Active Clip", "Use active clip defined in scene");
2499 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
2502 prop = RNA_def_property(srna, "object", PROP_STRING, PROP_NONE);
2503 RNA_def_property_string_sdna(prop, NULL, "object");
2504 RNA_def_property_ui_text(prop, "Object", "Movie tracking object to follow");
2505 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2508 prop = RNA_def_property(srna, "camera", PROP_POINTER, PROP_NONE);
2509 RNA_def_property_pointer_sdna(prop, NULL, "camera");
2510 RNA_def_property_ui_text(prop, "Camera",
2511 "Camera to which motion is parented (if empty active scene camera is used)");
2512 RNA_def_property_flag(prop, PROP_EDITABLE);
2513 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
2514 RNA_def_property_pointer_funcs(prop, NULL, "rna_Constraint_objectSolver_camera_set", NULL,
2515 "rna_Constraint_cameraObject_poll");
2518 /* base struct for constraints */
2519 void RNA_def_constraint(BlenderRNA *brna)
2525 srna = RNA_def_struct(brna, "Constraint", NULL);
2526 RNA_def_struct_ui_text(srna, "Constraint", "Constraint modifying the transformation of objects and bones");
2527 RNA_def_struct_refine_func(srna, "rna_ConstraintType_refine");
2528 RNA_def_struct_path_func(srna, "rna_Constraint_path");
2529 RNA_def_struct_sdna(srna, "bConstraint");
2532 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2533 RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constraint_name_set");
2534 RNA_def_property_ui_text(prop, "Name", "Constraint name");
2535 RNA_def_struct_name_property(srna, prop);
2536 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT | NA_RENAME, NULL);
2539 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2540 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2541 RNA_def_property_enum_sdna(prop, NULL, "type");
2542 RNA_def_property_enum_items(prop, constraint_type_items);
2543 RNA_def_property_ui_text(prop, "Type", "");
2545 prop = RNA_def_property(srna, "owner_space", PROP_ENUM, PROP_NONE);
2546 RNA_def_property_enum_sdna(prop, NULL, "ownspace");
2547 RNA_def_property_enum_items(prop, owner_space_pchan_items);
2548 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
2549 RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in");
2551 prop = RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
2552 RNA_def_property_enum_sdna(prop, NULL, "tarspace");
2553 RNA_def_property_enum_items(prop, target_space_pchan_items);
2554 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
2555 RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in");
2558 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
2559 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
2560 RNA_def_property_ui_text(prop, "Disable", "Enable/Disable Constraint");
2562 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
2563 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND);
2564 RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI");
2565 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
2567 /* XXX this is really an internal flag, but it may be useful for some tools to be able to access this... */
2568 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2569 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2570 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE);
2571 RNA_def_property_ui_text(prop, "Valid", "Constraint has valid settings and can be evaluated");
2573 /* TODO: setting this to true must ensure that all others in stack are turned off too... */
2574 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
2575 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_ACTIVE);
2576 RNA_def_property_ui_text(prop, "Active", "Constraint is the one being edited ");
2578 prop = RNA_def_property(srna, "is_proxy_local", PROP_BOOLEAN, PROP_NONE);
2579 RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_PROXY_LOCAL);
2580 RNA_def_property_ui_text(prop, "Proxy Local",
2581 "Constraint was added in this proxy instance (i.e. did not belong to source Armature)");
2584 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
2585 RNA_def_property_float_sdna(prop, NULL, "enforce");
2586 RNA_def_property_range(prop, 0.0f, 1.0f);
2587 RNA_def_property_ui_text(prop, "Influence", "Amount of influence constraint will have on the final solution");
2588 RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_influence_update");
2590 /* readonly values */
2591 prop = RNA_def_property(srna, "error_location", PROP_FLOAT, PROP_NONE);
2592 RNA_def_property_float_sdna(prop, NULL, "lin_error");
2593 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2594 RNA_def_property_ui_text(prop, "Lin error",
2595 "Amount of residual error in Blender space unit for constraints that work on position");
2597 prop = RNA_def_property(srna, "error_rotation", PROP_FLOAT, PROP_NONE);
2598 RNA_def_property_float_sdna(prop, NULL, "rot_error");
2599 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2600 RNA_def_property_ui_text(prop, "Rot error",
2601 "Amount of residual error in radians for constraints that work on orientation");
2604 rna_def_constrainttarget(brna);
2606 rna_def_constraint_childof(brna);
2607 rna_def_constraint_python(brna);
2608 rna_def_constraint_stretch_to(brna);
2609 rna_def_constraint_follow_path(brna);
2610 rna_def_constraint_locked_track(brna);
2611 rna_def_constraint_action(brna);
2612 rna_def_constraint_size_like(brna);
2613 rna_def_constraint_same_volume(brna);
2614 rna_def_constraint_locate_like(brna);
2615 rna_def_constraint_rotate_like(brna);
2616 rna_def_constraint_transform_like(brna);
2617 rna_def_constraint_minmax(brna);
2618 rna_def_constraint_track_to(brna);
2619 rna_def_constraint_kinematic(brna);
2620 rna_def_constraint_rigid_body_joint(brna);
2621 rna_def_constraint_clamp_to(brna);
2622 rna_def_constraint_distance_limit(brna);
2623 rna_def_constraint_size_limit(brna);
2624 rna_def_constraint_rotation_limit(brna);
2625 rna_def_constraint_location_limit(brna);
2626 rna_def_constraint_transform(brna);
2627 rna_def_constraint_shrinkwrap(brna);
2628 rna_def_constraint_damped_track(brna);
2629 rna_def_constraint_spline_ik(brna);
2630 rna_def_constraint_pivot(brna);
2631 rna_def_constraint_follow_track(brna);
2632 rna_def_constraint_camera_solver(brna);
2633 rna_def_constraint_object_solver(brna);