Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna/intern/rna_constraint.c')
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c110
1 files changed, 102 insertions, 8 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 65114804a3f..fb19e8976c3 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -25,7 +25,6 @@
#include <stdlib.h>
#include "RNA_define.h"
-#include "RNA_types.h"
#include "rna_internal.h"
@@ -50,6 +49,7 @@ EnumPropertyItem constraint_type_items[] ={
{CONSTRAINT_TYPE_LOCLIMIT, "LIMIT_LOCATION", ICON_CONSTRAINT_DATA, "Limit Location", ""},
{CONSTRAINT_TYPE_ROTLIMIT, "LIMIT_ROTATION", ICON_CONSTRAINT_DATA, "Limit Rotation", ""},
{CONSTRAINT_TYPE_SIZELIMIT, "LIMIT_SCALE", ICON_CONSTRAINT_DATA, "Limit Scale", ""},
+ {CONSTRAINT_TYPE_SAMEVOL, "MAINTAIN_VOLUME", ICON_CONSTRAINT_DATA, "Maintain Volume", ""},
{CONSTRAINT_TYPE_TRANSFORM, "TRANSFORM", ICON_CONSTRAINT_DATA, "Transformation", ""},
{0, "", 0, "Tracking", ""},
{CONSTRAINT_TYPE_CLAMPTO, "CLAMP_TO", ICON_CONSTRAINT_DATA, "Clamp To", ""},
@@ -64,6 +64,7 @@ EnumPropertyItem constraint_type_items[] ={
{CONSTRAINT_TYPE_CHILDOF, "CHILD_OF", ICON_CONSTRAINT_DATA, "Child Of", ""},
{CONSTRAINT_TYPE_MINMAX, "FLOOR", ICON_CONSTRAINT_DATA, "Floor", ""},
{CONSTRAINT_TYPE_FOLLOWPATH, "FOLLOW_PATH", ICON_CONSTRAINT_DATA, "Follow Path", ""},
+ {CONSTRAINT_TYPE_PIVOT, "PIVOT", ICON_CONSTRAINT_DATA, "Pivot", ""},
{CONSTRAINT_TYPE_RIGIDBODYJOINT, "RIGID_BODY_JOINT", ICON_CONSTRAINT_DATA, "Rigid Body Joint", ""},
{CONSTRAINT_TYPE_PYTHON, "SCRIPT", ICON_CONSTRAINT_DATA, "Script", ""},
{CONSTRAINT_TYPE_SHRINKWRAP, "SHRINKWRAP", ICON_CONSTRAINT_DATA, "Shrinkwrap", ""},
@@ -103,7 +104,6 @@ EnumPropertyItem constraint_ik_axisref_items[] ={
#include "BKE_context.h"
#include "BKE_depsgraph.h"
-#include "ED_object.h"
static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
{
@@ -124,6 +124,8 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
return &RNA_CopyLocationConstraint;
case CONSTRAINT_TYPE_SIZELIKE:
return &RNA_CopyScaleConstraint;
+ case CONSTRAINT_TYPE_SAMEVOL:
+ return &RNA_MaintainVolumeConstraint;
case CONSTRAINT_TYPE_PYTHON:
return &RNA_PythonConstraint;
case CONSTRAINT_TYPE_ACTION:
@@ -156,6 +158,8 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
return &RNA_SplineIKConstraint;
case CONSTRAINT_TYPE_TRANSLIKE:
return &RNA_CopyTransformsConstraint;
+ case CONSTRAINT_TYPE_PIVOT:
+ return &RNA_PivotConstraint;
default:
return &RNA_UnknownType;
}
@@ -164,10 +168,10 @@ static StructRNA *rna_ConstraintType_refine(struct PointerRNA *ptr)
static void rna_Constraint_name_set(PointerRNA *ptr, const char *value)
{
bConstraint *con= ptr->data;
- char oldname[32];
+ char oldname[sizeof(con->name)];
/* make a copy of the old name first */
- BLI_strncpy(oldname, con->name, sizeof(oldname));
+ BLI_strncpy(oldname, con->name, sizeof(con->name));
/* copy the new name into the name slot */
BLI_strncpy(con->name, value, sizeof(con->name));
@@ -813,6 +817,34 @@ static void rna_def_constraint_size_like(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
}
+static void rna_def_constraint_same_volume(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static EnumPropertyItem volume_items[] = {
+ {SAMEVOL_X, "SAMEVOL_X", 0, "X", ""},
+ {SAMEVOL_Y, "SAMEVOL_Y", 0, "Y", ""},
+ {SAMEVOL_Z, "SAMEVOL_Z", 0, "Z", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+ srna= RNA_def_struct(brna, "MaintainVolumeConstraint", "Constraint");
+ RNA_def_struct_ui_text(srna, "Maintain Volume Constraint", "Maintains a constant volume along a single scaling axis");
+ RNA_def_struct_sdna_from(srna, "bSameVolumeConstraint", "data");
+
+ prop= RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, volume_items);
+ RNA_def_property_ui_text(prop, "Free Axis", "The free scaling axis of the object");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop= RNA_def_property(srna, "volume", PROP_FLOAT, PROP_DISTANCE);
+ RNA_def_property_range(prop, 0.001, 100.f);
+ RNA_def_property_ui_text(prop, "Volume", "Volume of the bone at rest");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
+}
+
static void rna_def_constraint_transform_like(BlenderRNA *brna)
{
StructRNA *srna;
@@ -934,13 +966,13 @@ static void rna_def_constraint_action(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
- prop= RNA_def_property(srna, "start_frame", PROP_INT, PROP_TIME);
+ prop= RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "start");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "Start Frame", "First frame of the Action to use");
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
- prop= RNA_def_property(srna, "end_frame", PROP_INT, PROP_TIME);
+ prop= RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
RNA_def_property_int_sdna(prop, NULL, "end");
RNA_def_property_range(prop, MINAFRAME, MAXFRAME);
RNA_def_property_ui_text(prop, "End Frame", "Last frame of the Action to use");
@@ -1810,6 +1842,62 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
}
+static void rna_def_constraint_pivot(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ static EnumPropertyItem pivot_rotAxis_items[] = {
+ {PIVOTCON_AXIS_NONE, "ALWAYS_ACTIVE", 0, "Always", ""},
+ {PIVOTCON_AXIS_X_NEG, "NX", 0, "-X Rot", ""},
+ {PIVOTCON_AXIS_Y_NEG, "NY", 0, "-Y Rot", ""},
+ {PIVOTCON_AXIS_Z_NEG, "NZ", 0, "-Z Rot", ""},
+ {PIVOTCON_AXIS_X, "X", 0, "X Rot", ""},
+ {PIVOTCON_AXIS_Y, "Y", 0, "Y Rot", ""},
+ {PIVOTCON_AXIS_Z, "Z", 0, "Z Rot", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+ srna= RNA_def_struct(brna, "PivotConstraint", "Constraint");
+ RNA_def_struct_ui_text(srna, "Pivot Constraint", "Rotate around a different point");
+
+ prop= RNA_def_property(srna, "head_tail", PROP_FLOAT, PROP_FACTOR);
+ RNA_def_property_float_sdna(prop, "bConstraint", "headtail");
+ RNA_def_property_ui_text(prop, "Head/Tail", "Target along length of bone: Head=0, Tail=1");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
+ RNA_def_struct_sdna_from(srna, "bPivotConstraint", "data");
+
+ /* target-defined pivot */
+ prop= RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "tar");
+ RNA_def_property_ui_text(prop, "Target", "Target Object, defining the position of the pivot when defined");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update");
+
+ prop= RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "subtarget");
+ RNA_def_property_ui_text(prop, "Sub-Target", "");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_dependency_update");
+
+ /* pivot offset */
+ prop= RNA_def_property(srna, "use_relative_position", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PIVOTCON_FLAG_OFFSET_ABS);
+ RNA_def_property_ui_text(prop, "Use Relative Offset", "Offset will be an absolute point in space instead of relative to the target");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
+ prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_XYZ);
+ RNA_def_property_float_sdna(prop, NULL, "offset");
+ RNA_def_property_ui_text(prop, "Offset", "Offset of pivot from target (when set), or from owner's location (when Fixed Position is off), or the absolute pivot point");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+
+ /* rotation-based activation */
+ prop= RNA_def_property(srna, "enabled_rotation_range", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "rotAxis");
+ RNA_def_property_enum_items(prop, pivot_rotAxis_items);
+ RNA_def_property_ui_text(prop, "Enabled Rotation Range", "Rotation range on which pivoting should occur");
+ RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
+}
+
/* base struct for constraints */
void RNA_def_constraint(BlenderRNA *brna)
{
@@ -1826,7 +1914,7 @@ void RNA_def_constraint(BlenderRNA *brna)
/* strings */
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Constraint_name_set");
- RNA_def_property_ui_text(prop, "Name", "");
+ RNA_def_property_ui_text(prop, "Name", "Constraint name");
RNA_def_struct_name_property(srna, prop);
/* enums */
@@ -1849,11 +1937,15 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in");
/* flags */
+ prop= RNA_def_property(srna, "enabled", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
+ RNA_def_property_ui_text(prop, "Enabled", "Enable/Disable Constraint");
+
prop= RNA_def_property(srna, "expanded", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_EXPAND);
RNA_def_property_ui_text(prop, "Expanded", "Constraint's panel is expanded in UI");
RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
-
+
// XXX this is really an internal flag, but it may be useful for some tools to be able to access this...
prop= RNA_def_property(srna, "disabled", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
@@ -1897,6 +1989,7 @@ void RNA_def_constraint(BlenderRNA *brna)
rna_def_constraint_locked_track(brna);
rna_def_constraint_action(brna);
rna_def_constraint_size_like(brna);
+ rna_def_constraint_same_volume(brna);
rna_def_constraint_locate_like(brna);
rna_def_constraint_rotate_like(brna);
rna_def_constraint_transform_like(brna);
@@ -1913,6 +2006,7 @@ void RNA_def_constraint(BlenderRNA *brna)
rna_def_constraint_shrinkwrap(brna);
rna_def_constraint_damped_track(brna);
rna_def_constraint_spline_ik(brna);
+ rna_def_constraint_pivot(brna);
}
#endif