forked from bartvdbraak/blender
This commit is contained in:
parent
215acdd803
commit
6555eca6fe
@ -706,11 +706,12 @@ class ConstraintButtonsPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.itemL(text="Chain Scaling:")
|
col.itemL(text="Chain Scaling:")
|
||||||
col.itemR(con, "y_scaling")
|
col.itemR(con, "y_stretch")
|
||||||
if wide_ui:
|
if wide_ui:
|
||||||
col.itemR(con, "xz_scaling_mode")
|
col.itemR(con, "xz_scaling_mode")
|
||||||
else:
|
else:
|
||||||
col.itemR(con, "xz_scaling_mode", text="")
|
col.itemR(con, "xz_scaling_mode", text="")
|
||||||
|
col.itemR(con, "use_curve_radius")
|
||||||
|
|
||||||
|
|
||||||
class OBJECT_PT_constraints(ConstraintButtonsPanel):
|
class OBJECT_PT_constraints(ConstraintButtonsPanel):
|
||||||
|
@ -1915,20 +1915,12 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* step 4: set the scaling factors for the axes */
|
/* 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 */
|
/* only multiply the y-axis by the scaling factor to get nice volume-preservation */
|
||||||
mul_v3_fl(poseMat[1], scaleFac);
|
mul_v3_fl(poseMat[1], scaleFac);
|
||||||
|
|
||||||
/* set the scaling factors of the x and z axes from... */
|
/* set the scaling factors of the x and z axes from... */
|
||||||
switch (ikData->xzScaleMode) {
|
switch (ikData->xzScaleMode) {
|
||||||
case CONSTRAINT_SPLINEIK_XZS_RADIUS:
|
|
||||||
{
|
|
||||||
/* radius of curve */
|
|
||||||
mul_v3_fl(poseMat[0], radius);
|
|
||||||
mul_v3_fl(poseMat[2], radius);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:
|
case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:
|
||||||
{
|
{
|
||||||
/* original scales get used */
|
/* original scales get used */
|
||||||
@ -1942,6 +1934,37 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
|
|||||||
mul_v3_fl(poseMat[2], scale);
|
mul_v3_fl(poseMat[2], scale);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC:
|
||||||
|
{
|
||||||
|
/* 'volume preservation' */
|
||||||
|
float scale;
|
||||||
|
|
||||||
|
/* calculate volume preservation factor which is
|
||||||
|
* basically the inverse of the y-scaling factor
|
||||||
|
*/
|
||||||
|
if (fabs(scaleFac) != 0.0f) {
|
||||||
|
scale= 1.0 / fabs(scaleFac);
|
||||||
|
|
||||||
|
/* we need to clamp this within sensible values */
|
||||||
|
// NOTE: these should be fine for now, but should get sanitised in future
|
||||||
|
scale= MIN2( MAX2(scale, 0.0001) , 100000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
scale= 1.0f;
|
||||||
|
|
||||||
|
/* apply the scaling */
|
||||||
|
mul_v3_fl(poseMat[0], scale);
|
||||||
|
mul_v3_fl(poseMat[2], scale);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* finally, multiply the x and z scaling by the radius of the curve too,
|
||||||
|
* to allow automatic scales to get tweaked still
|
||||||
|
*/
|
||||||
|
if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_CURVERAD) == 0) {
|
||||||
|
mul_v3_fl(poseMat[0], radius);
|
||||||
|
mul_v3_fl(poseMat[2], radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1235,7 +1235,6 @@ void VIEW3D_OT_view_center(wmOperatorType *ot)
|
|||||||
static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
|
static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
|
||||||
{
|
{
|
||||||
View3D *v3d = CTX_wm_view3d(C);
|
View3D *v3d = CTX_wm_view3d(C);
|
||||||
ARegion *ar= CTX_wm_region(C);
|
|
||||||
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
RegionView3D *rv3d= CTX_wm_region_view3d(C);
|
||||||
Scene *scene= CTX_data_scene(C);
|
Scene *scene= CTX_data_scene(C);
|
||||||
|
|
||||||
@ -1257,7 +1256,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rv3d->viewlock & RV3D_BOXVIEW)
|
if (rv3d->viewlock & RV3D_BOXVIEW)
|
||||||
view3d_boxview_copy(CTX_wm_area(C), ar);
|
view3d_boxview_copy(CTX_wm_area(C), CTX_wm_region(C));
|
||||||
}
|
}
|
||||||
|
|
||||||
return OPERATOR_FINISHED;
|
return OPERATOR_FINISHED;
|
||||||
@ -1275,7 +1274,7 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
|
|||||||
ot->poll= ED_operator_view3d_active;
|
ot->poll= ED_operator_view3d_active;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
ot->flag= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ********************* Set render border operator ****************** */
|
/* ********************* Set render border operator ****************** */
|
||||||
|
@ -585,16 +585,18 @@ typedef enum eSplineIK_Flags {
|
|||||||
CONSTRAINT_SPLINEIK_SCALE_LIMITED = (1<<2),
|
CONSTRAINT_SPLINEIK_SCALE_LIMITED = (1<<2),
|
||||||
/* evenly distribute the bones along the path regardless of length */
|
/* evenly distribute the bones along the path regardless of length */
|
||||||
CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3),
|
CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3),
|
||||||
|
/* don't adjust the x and z scaling of the bones by the curve radius */
|
||||||
|
CONSTRAINT_SPLINEIK_NO_CURVERAD = (1<<4),
|
||||||
} eSplineIK_Flags;
|
} eSplineIK_Flags;
|
||||||
|
|
||||||
/* bSplineIKConstraint->xzScaleMode */
|
/* bSplineIKConstraint->xzScaleMode */
|
||||||
typedef enum eSplineIK_XZScaleModes {
|
typedef enum eSplineIK_XZScaleModes {
|
||||||
/* no x/z scaling */
|
/* no x/z scaling */
|
||||||
CONSTRAINT_SPLINEIK_XZS_NONE = 0,
|
CONSTRAINT_SPLINEIK_XZS_NONE = 0,
|
||||||
/* bones in the chain should take their x/z scales from the curve radius */
|
|
||||||
CONSTRAINT_SPLINEIK_XZS_RADIUS,
|
|
||||||
/* bones in the chain should take their x/z scales from the original scaling */
|
/* bones in the chain should take their x/z scales from the original scaling */
|
||||||
CONSTRAINT_SPLINEIK_XZS_ORIGINAL,
|
CONSTRAINT_SPLINEIK_XZS_ORIGINAL,
|
||||||
|
/* x/z scales are the inverse of the y-scale */
|
||||||
|
CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC,
|
||||||
} eSplineIK_XZScaleModes;
|
} eSplineIK_XZScaleModes;
|
||||||
|
|
||||||
/* MinMax (floor) flags */
|
/* MinMax (floor) flags */
|
||||||
|
@ -1679,9 +1679,9 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
|
|||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
static EnumPropertyItem splineik_xz_scale_mode[] = {
|
static EnumPropertyItem splineik_xz_scale_mode[] = {
|
||||||
{CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "Volume Preserve", "Don't scale the x and z axes, giving a volume preservation effect. (Default)"},
|
{CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes (Default)"},
|
||||||
{CONSTRAINT_SPLINEIK_XZS_RADIUS, "CURVE_RADIUS", 0, "Curve Radius", "Use the radius of the curve."},
|
|
||||||
{CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original", "Use the original scaling of the bones."},
|
{CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original", "Use the original scaling of the bones."},
|
||||||
|
{CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC, "VOLUME_PRESERVE", 0, "Volume Preservation", "Scale of the X and Z axes is the inverse of the Y-Scale."},
|
||||||
{0, NULL, 0, NULL, NULL}};
|
{0, NULL, 0, NULL, NULL}};
|
||||||
|
|
||||||
srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
|
srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
|
||||||
@ -1718,15 +1718,20 @@ static void rna_def_constraint_spline_ik(BlenderRNA *brna)
|
|||||||
RNA_def_property_ui_text(prop, "Even Divisions", "Ignore the relative lengths of the bones when fitting to the curve.");
|
RNA_def_property_ui_text(prop, "Even Divisions", "Ignore the relative lengths of the bones when fitting to the curve.");
|
||||||
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "y_scaling", PROP_BOOLEAN, PROP_NONE);
|
prop= RNA_def_property(srna, "y_streching", PROP_BOOLEAN, PROP_NONE);
|
||||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_SCALE_LIMITED);
|
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_SCALE_LIMITED);
|
||||||
RNA_def_property_ui_text(prop, "Y Scaling", "Stretch the Y axis of the bones to fit the curve.");
|
RNA_def_property_ui_text(prop, "Y Stretch", "Stretch the Y axis of the bones to fit the curve.");
|
||||||
|
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
|
|
||||||
|
prop= RNA_def_property(srna, "use_curve_radius", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_NO_CURVERAD);
|
||||||
|
RNA_def_property_ui_text(prop, "Use Curve Radius", "Average radius of the endpoints is used to tweak the X and Z Scaling of the bones, on top of XZ Scale mode.");
|
||||||
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "xz_scaling_mode", PROP_ENUM, PROP_NONE);
|
prop= RNA_def_property(srna, "xz_scaling_mode", PROP_ENUM, PROP_NONE);
|
||||||
RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode");
|
RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode");
|
||||||
RNA_def_property_enum_items(prop, splineik_xz_scale_mode);
|
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_ui_text(prop, "XZ Scale Mode", "Method used for determining the scaling of the X and Z axes of the bones.");
|
||||||
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user