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:
authorHenrik Dick <weasel>2020-12-03 12:42:29 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-12-03 13:20:21 +0300
commita6c4e39876d8a0765290312f6d8c0175274114cd (patch)
tree98568a07fb46bb643cee07ea0ac08991f4f4db2e /source/blender/makesrna
parent899dcc5f60667a54d9628fcb5656f7e9db642068 (diff)
Add Custom Object Space to Constraints
Add Custom Space to the list of space conversions for constraints. Constraints can use World Space, Local Space, Pose Space, Local with Parent, and now also Custom Space with a custom object to define the evaluation space. The Custom Space option uses the Local Space of an other object/bone/vertex group. If selected on owner or target it will show a box for object selection. If an armature is selected, then it will also show a box for bone selection. If a mesh object is selected it will show the option for using the local space of a vertex group. Reviewed By: #animation_rigging, sybren, Severin, angavrilov Differential Revision: https://developer.blender.org/D7437
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c29
-rw-r--r--source/blender/makesrna/intern/rna_object_api.c21
2 files changed, 49 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index 1c84be5907b..170de68a038 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -200,6 +200,12 @@ static const EnumPropertyItem target_space_pchan_items[] = {
"World Space",
"The transformation of the target is evaluated relative to the world "
"coordinate system"},
+ {CONSTRAINT_SPACE_CUSTOM,
+ "CUSTOM",
+ 0,
+ "Custom Space",
+ "The transformation of the target is evaluated relative to a custom object/bone/vertex "
+ "group"},
{CONSTRAINT_SPACE_POSE,
"POSE",
0,
@@ -227,6 +233,11 @@ static const EnumPropertyItem owner_space_pchan_items[] = {
0,
"World Space",
"The constraint is applied relative to the world coordinate system"},
+ {CONSTRAINT_SPACE_CUSTOM,
+ "CUSTOM",
+ 0,
+ "Custom Space",
+ "The constraint is applied in local space of a custom object/bone/vertex group"},
{CONSTRAINT_SPACE_POSE,
"POSE",
0,
@@ -275,6 +286,12 @@ static const EnumPropertyItem space_object_items[] = {
0,
"World Space",
"The transformation of the target is evaluated relative to the world coordinate system"},
+ {CONSTRAINT_SPACE_CUSTOM,
+ "CUSTOM",
+ 0,
+ "Custom Space",
+ "The transformation of the target is evaluated relative to a custom object/bone/vertex "
+ "group"},
{CONSTRAINT_SPACE_LOCAL,
"LOCAL",
0,
@@ -3398,6 +3415,18 @@ void RNA_def_constraint(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in");
RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
+ prop = RNA_def_property(srna, "space_object", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "space_object");
+ RNA_def_property_ui_text(prop, "Object", "Object for Custom Space");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+
+ prop = RNA_def_property(srna, "space_subtarget", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "space_subtarget");
+ RNA_def_property_ui_text(prop, "Sub-Target", "Armature bone, mesh or lattice vertex group, ...");
+ RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+
/* flags */
prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_OFF);
diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c
index a04ad28f9c3..9fb883568c9 100644
--- a/source/blender/makesrna/intern/rna_object_api.c
+++ b/source/blender/makesrna/intern/rna_object_api.c
@@ -324,8 +324,27 @@ static void rna_Object_mat_convert_space(Object *ob,
return;
}
}
+ /* These checks are extra security, they should never occur. */
+ if (from == CONSTRAINT_SPACE_CUSTOM) {
+ const char *identifier = NULL;
+ RNA_enum_identifier(space_items, from, &identifier);
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "'from_space' '%s' is invalid when no custom space is given!",
+ identifier);
+ return;
+ }
+ if (to == CONSTRAINT_SPACE_CUSTOM) {
+ const char *identifier = NULL;
+ RNA_enum_identifier(space_items, to, &identifier);
+ BKE_reportf(reports,
+ RPT_ERROR,
+ "'to_space' '%s' is invalid when no custom space is given!",
+ identifier);
+ return;
+ }
- BKE_constraint_mat_convertspace(ob, pchan, (float(*)[4])mat_ret, from, to, false);
+ BKE_constraint_mat_convertspace(ob, pchan, NULL, (float(*)[4])mat_ret, from, to, false);
}
static void rna_Object_calc_matrix_camera(Object *ob,