diff --git a/release/scripts/ui/properties_object_constraint.py b/release/scripts/ui/properties_object_constraint.py index 3dd7a931316..e6c68c081f3 100644 --- a/release/scripts/ui/properties_object_constraint.py +++ b/release/scripts/ui/properties_object_constraint.py @@ -607,7 +607,7 @@ class ConstraintButtonsPanel(bpy.types.Panel): col = layout.column() col.itemL(text="Chain Scaling:") col.itemR(con, "keep_max_length") - col.itemR(con, "radius_to_thickness") + col.itemR(con, "xz_scaling_mode") class OBJECT_PT_constraints(ConstraintButtonsPanel): diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 3a8a3d4efc9..f178553d796 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1891,14 +1891,33 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } /* step 4: set the scaling factors for the axes */ + // TODO: include a no-scale option? { /* only multiply the y-axis by the scaling factor to get nice volume-preservation */ VecMulf(poseMat[1], scaleFac); - - /* set the scaling factors of the x and z axes from the average radius of the curve? */ - if (ikData->flag & CONSTRAINT_SPLINEIK_RAD2FAT) { - VecMulf(poseMat[0], radius); - VecMulf(poseMat[2], radius); + + /* set the scaling factors of the x and z axes from... */ + switch (ikData->xzScaleMode) { + case CONSTRAINT_SPLINEIK_XZS_RADIUS: + { + /* radius of curve */ + VecMulf(poseMat[0], radius); + VecMulf(poseMat[2], radius); + } + break; + case CONSTRAINT_SPLINEIK_XZS_ORIGINAL: + { + /* original scales get used */ + float scale; + + /* x-axis scale */ + scale= VecLength(pchan->pose_mat[0]); + VecMulf(poseMat[0], scale); + /* z-axis scale */ + scale= VecLength(pchan->pose_mat[2]); + VecMulf(poseMat[2], scale); + } + break; } } diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 5580070b922..1410e5d29c2 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -145,6 +145,7 @@ Curve *add_curve(char *name, int type) cu->fsize= 1.0; cu->ulheight = 0.05; cu->texflag= CU_AUTOSPACE; + cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... cu->bb= unit_boundbox(); diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 4643b875872..22a6329a097 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -362,6 +362,9 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) void object_hook_select(Object *ob, HookModifierData *hmd) { + if (hmd->indexar == NULL) + return; + if(ob->type==OB_MESH) select_editmesh_hook(ob, hmd); else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd); else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd); diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index f5a08764c42..2b24b673185 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -169,7 +169,7 @@ typedef struct bSplineIKConstraint { /* settings */ short flag; /* general settings for constraint */ - short upflag; /* axis of bone that points up */ + short xzScaleMode; /* method used for determining the x & z scaling of the bones */ } bSplineIKConstraint; @@ -551,10 +551,16 @@ typedef enum B_CONSTRAINTCHANNEL_FLAG { #define CONSTRAINT_SPLINEIK_NO_ROOT (1<<1) /* bones in the chain should not scale to fit the curve */ #define CONSTRAINT_SPLINEIK_SCALE_LIMITED (1<<2) - /* bones in the chain should take their x/z scales from the curve radius */ -#define CONSTRAINT_SPLINEIK_RAD2FAT (1<<3) /* evenly distribute the bones along the path regardless of length */ -#define CONSTRAINT_SPLINEIK_EVENSPLITS (1<<4) +#define CONSTRAINT_SPLINEIK_EVENSPLITS (1<<3) + +/* bSplineIKConstraint->xzScaleMode */ + /* no x/z scaling */ +#define CONSTRAINT_SPLINEIK_XZS_NONE 0 + /* bones in the chain should take their x/z scales from the curve radius */ +#define CONSTRAINT_SPLINEIK_XZS_RADIUS 1 + /* bones in the chain should take their x/z scales from the original scaling */ +#define CONSTRAINT_SPLINEIK_XZS_ORIGINAL 2 /* MinMax (floor) flags */ #define MINMAX_STICKY 0x01 diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 02cf44dcc7a..7f7976c365f 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1679,6 +1679,12 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + static EnumPropertyItem splineik_xz_scale_mode[] = { + {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the x and z axes, giving a volume preservation effect. (Default)"}, + {CONSTRAINT_SPLINEIK_XZS_RADIUS, "CURVE_RADIUS", 0, "Curve Radius", "Use the radius of the curve."}, + {CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "ORIGINAL", 0, "Original", "Use the original scaling of the bones."}, + {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint"); RNA_def_struct_ui_text(srna, "Spline IK Constraint", "Align 'n' bones along a curve."); @@ -1715,9 +1721,10 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Keep Max Length", "Maintain the maximum length of the chain when spline is stretched."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - prop= RNA_def_property(srna, "radius_to_thickness", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_RAD2FAT); - RNA_def_property_ui_text(prop, "Radius to Thickness", "Radius of the spline affects the x/z scaling of the bones."); + prop= RNA_def_property(srna, "xz_scaling_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode"); + RNA_def_property_enum_items(prop, splineik_xz_scale_mode); + RNA_def_property_ui_text(prop, "XZ Scale Mode", "Method used for determining the scaling of the X and Z axes of the bone."); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); }