From 53c43259ad0a576912b350269cfbfcc72302a105 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 3 May 2018 15:00:12 +0200 Subject: Cleanup: factorize RNA constraint targets definition. No expected changes in behavior from that commit! --- source/blender/makesrna/intern/rna_constraint.c | 183 ++++-------------------- 1 file changed, 30 insertions(+), 153 deletions(-) (limited to 'source/blender/makesrna') 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(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Action Constraint", "Map an action to the transform axes of a bone"); RNA_def_struct_sdna_from(srna, "bActionConstraint", "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, "transform_channel", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "type"); @@ -1235,16 +1157,7 @@ static void rna_def_constraint_locked_track(BlenderRNA *brna) RNA_def_struct_sdna_from(srna, "bLockTrackConstraint", "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, "trackflag"); @@ -1288,7 +1201,7 @@ static void rna_def_constraint_follow_path(BlenderRNA *brna) prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "tar"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_object_poll"); - RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_ui_text(prop, "Target", "Target Curve object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); @@ -1359,16 +1272,7 @@ static void rna_def_constraint_stretch_to(BlenderRNA *brna) RNA_def_struct_sdna_from(srna, "bStretchToConstraint", "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, "volume", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "volmode"); @@ -1645,16 +1549,7 @@ static void rna_def_constraint_transform(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Transformation Constraint", "Map transformations of the target to the object"); RNA_def_struct_sdna_from(srna, "bTransformConstraint", "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, "map_from", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "from"); @@ -2151,16 +2046,7 @@ static void rna_def_constraint_distance_limit(BlenderRNA *brna) RNA_def_struct_sdna_from(srna, "bDistLimitConstraint", "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, "distance", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "dist"); @@ -2202,7 +2088,7 @@ static void rna_def_constraint_shrinkwrap(BlenderRNA *brna) prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "target"); /* TODO, mesh type */ RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll"); - RNA_def_property_ui_text(prop, "Target", "Target Object"); + RNA_def_property_ui_text(prop, "Target", "Target Mesh object"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); @@ -2262,16 +2148,7 @@ rna_def_constraint_headtail_common(srna); RNA_def_struct_sdna_from(srna, "bDampTrackConstraint", "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, "trackflag"); -- cgit v1.2.3