[Bf-blender-cvs] [53c43259ad0] master: Cleanup: factorize RNA constraint targets definition.

Bastien Montagne noreply at git.blender.org
Thu May 3 15:01:29 CEST 2018


Commit: 53c43259ad0a576912b350269cfbfcc72302a105
Author: Bastien Montagne
Date:   Thu May 3 15:00:12 2018 +0200
Branches: master
https://developer.blender.org/rB53c43259ad0a576912b350269cfbfcc72302a105

Cleanup: factorize RNA constraint targets definition.

No expected changes in behavior from that commit!

===================================================================

M	source/blender/makesrna/intern/rna_constraint.c

===================================================================

diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index bef121cd535..a6daea4c3f3 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -523,25 +523,31 @@ static void rna_def_constraint_headtail_common(StructRNA *srna)
 	RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
 }
 
-static void rna_def_constrainttarget(BlenderRNA *brna)
+static void rna_def_constraint_target_common(StructRNA *srna)
 {
-	StructRNA *srna;
 	PropertyRNA *prop;
 
-	srna = RNA_def_struct(brna, "ConstraintTarget", NULL);
-	RNA_def_struct_ui_text(srna, "Constraint Target", "Target object for multi-target constraints");
-	RNA_def_struct_sdna(srna, "bConstraintTarget");
-
 	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");
+	RNA_def_property_ui_text(prop, "Target", "Target object");
 	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_ui_text(prop, "Sub-Target", "Only Armature bones are supported currently");
 	RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
+}
+
+static void rna_def_constrainttarget(BlenderRNA *brna)
+{
+	StructRNA *srna;
+
+	srna = RNA_def_struct(brna, "ConstraintTarget", NULL);
+	RNA_def_struct_ui_text(srna, "Constraint Target", "Target object for multi-target constraints");
+	RNA_def_struct_sdna(srna, "bConstraintTarget");
+
+	rna_def_constraint_target_common(srna);
 
 	/* space, flag and type still to do  */
 }
@@ -555,16 +561,7 @@ static void rna_def_constraint_childof(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Child Of Constraint", "Create constraint-based parent-child relationship");
 	RNA_def_struct_sdna_from(srna, "bChildOfConstraint", "data");
 
-	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");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "use_location_x", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CHILDOF_LOCX);
@@ -675,16 +672,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Kinematic Constraint", "Inverse Kinematics");
 	RNA_def_struct_sdna_from(srna, "bKinematicConstraint", "data");
 
-	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");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
 	RNA_def_property_range(prop, 0, 10000);
@@ -831,16 +819,7 @@ static void rna_def_constraint_track_to(BlenderRNA *brna)
 
 	RNA_def_struct_sdna_from(srna, "bTrackToConstraint", "data");
 
-	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");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "reserved1");
@@ -872,17 +851,7 @@ static void rna_def_constraint_locate_like(BlenderRNA *brna)
 
 	RNA_def_struct_sdna_from(srna, "bLocateLikeConstraint", "data");
 
-	prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-	RNA_def_property_pointer_sdna(prop, NULL, "tar");
-	RNA_def_property_flag(prop, PROP_EDITABLE);
-	RNA_def_property_ui_text(prop, "Target", "Target Object");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", LOCLIKE_X);
@@ -929,16 +898,7 @@ static void rna_def_constraint_rotate_like(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Copy Rotation Constraint", "Copy the rotation of the target");
 	RNA_def_struct_sdna_from(srna, "bRotateLikeConstraint", "data");
 
-	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");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", ROTLIKE_X);
@@ -985,17 +945,7 @@ static void rna_def_constraint_size_like(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Copy Scale Constraint", "Copy the scale of the target");
 	RNA_def_struct_sdna_from(srna, "bSizeLikeConstraint", "data");
 
-	prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
-	RNA_def_property_pointer_sdna(prop, NULL, "tar");
-	RNA_def_property_flag(prop, PROP_EDITABLE);
-	RNA_def_property_ui_text(prop, "Target", "Target Object");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", SIZELIKE_X);
@@ -1051,7 +1001,6 @@ static void rna_def_constraint_same_volume(BlenderRNA *brna)
 static void rna_def_constraint_transform_like(BlenderRNA *brna)
 {
 	StructRNA *srna;
-	PropertyRNA *prop;
 
 	srna = RNA_def_struct(brna, "CopyTransformsConstraint", "Constraint");
 	RNA_def_struct_ui_text(srna, "Copy Transforms Constraint", "Copy all the transforms of the target");
@@ -1060,16 +1009,7 @@ static void rna_def_constraint_transform_like(BlenderRNA *brna)
 
 	RNA_def_struct_sdna_from(srna, "bTransLikeConstraint", "data");
 
-	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");
-	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");
+	rna_def_constraint_target_common(srna);
 }
 
 static void rna_def_constraint_minmax(BlenderRNA *brna)
@@ -1091,16 +1031,7 @@ static void rna_def_constraint_minmax(BlenderRNA *brna)
 	RNA_def_struct_ui_text(srna, "Floor Constraint", "Use the target object for location limitation");
 	RNA_def_struct_sdna_from(srna, "bMinMaxConstraint", "data");
 
-	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");
-	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");
+	rna_def_constraint_target_common(srna);
 
 	prop = RNA_def_property(srna, "floor_location", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_sdna(prop, NULL, "minmaxflag");
@@ -1146,16 +1077,7 @@ static void rna_def_constraint_action(B

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list