Bugfixes + Spline IK Tweaks:

* #19819: 'Select' operator for Hooks was crashing when Hooks didn't have any vertices assigned yet

* Default twist resolution mode for curves is now 'Minimise'. This seems to work better for Curve Deforms and other purposes. Can be changed if other ways are better after some more testing.

* Spline IK now has more options for controlling how the x and z axis scaling is determined. There is now a choice between using the radius of the curve, the x+z scaling from the bones, or no scaling (default). This does break old files a bit, but this is to have a more stable base for later.
This commit is contained in:
Joshua Leung 2009-11-05 10:09:45 +00:00
parent 751f07d6d4
commit 06d5d53a24
6 changed files with 49 additions and 13 deletions

@ -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):

@ -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;
}
}

@ -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();

@ -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);

@ -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

@ -1680,6 +1680,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.");
RNA_def_struct_sdna_from(srna, "bSplineIKConstraint", "data");
@ -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");
}