[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24794] trunk/blender:

Joshua Leung aligorith at gmail.com
Mon Nov 23 01:05:14 CET 2009


Argh! Forgot a log message for this. Stupid update conflicts..

----------------------

Spline IK Constraint - Review of Scaling Options

WARNING: this commit will again potentially break a few files, so care is
advised (though unless you're the Durian team, you shouldn't really be doing
production work in 2.5 yet)

Changes:
- Added a proper volume preservation xz-scaling mode. The previous one has
been renamed back to 'None', since that's what it did.
- Made the 'Curve Radius' XZ Scale Mode an option on top of the other
scaling modes, since it is useful to be able to tweak this instead of
relying entirely on automatic or manual.
- Renamed 'Y Scaling' to 'Y Stretch' for more clarity.


On Mon, Nov 23, 2009 at 1:03 PM, Joshua Leung <aligorith at gmail.com> wrote:

> Revision: 24794
>
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24794
> Author:   aligorith
> Date:     2009-11-23 01:03:51 +0100 (Mon, 23 Nov 2009)
>
> Log Message:
> -----------
>
>
> Modified Paths:
> --------------
>    trunk/blender/release/scripts/ui/properties_object_constraint.py
>    trunk/blender/source/blender/blenkernel/intern/armature.c
>    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
>    trunk/blender/source/blender/makesdna/DNA_constraint_types.h
>    trunk/blender/source/blender/makesrna/intern/rna_constraint.c
>
> Modified: trunk/blender/release/scripts/ui/properties_object_constraint.py
> ===================================================================
> --- trunk/blender/release/scripts/ui/properties_object_constraint.py
>  2009-11-22 23:57:06 UTC (rev 24793)
> +++ trunk/blender/release/scripts/ui/properties_object_constraint.py
>  2009-11-23 00:03:51 UTC (rev 24794)
> @@ -706,11 +706,12 @@
>
>         col = layout.column()
>         col.itemL(text="Chain Scaling:")
> -        col.itemR(con, "y_scaling")
> +        col.itemR(con, "y_stretch")
>         if wide_ui:
>             col.itemR(con, "xz_scaling_mode")
>         else:
>             col.itemR(con, "xz_scaling_mode", text="")
> +        col.itemR(con, "use_curve_radius")
>
>
>  class OBJECT_PT_constraints(ConstraintButtonsPanel):
>
> Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
> ===================================================================
> --- trunk/blender/source/blender/blenkernel/intern/armature.c   2009-11-22
> 23:57:06 UTC (rev 24793)
> +++ trunk/blender/source/blender/blenkernel/intern/armature.c   2009-11-23
> 00:03:51 UTC (rev 24794)
> @@ -1915,20 +1915,12 @@
>        }
>
>        /* 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 */
>                mul_v3_fl(poseMat[1], scaleFac);
>
>                /* set the scaling factors of the x and z axes from... */
>                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:
>                        {
>                                /* original scales get used */
> @@ -1942,7 +1934,38 @@
>                                mul_v3_fl(poseMat[2], scale);
>                        }
>                                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);
> +               }
>        }
>
>        /* step 5: set the location of the bone in the matrix
>
> Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
> ===================================================================
> --- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
> 2009-11-22 23:57:06 UTC (rev 24793)
> +++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
> 2009-11-23 00:03:51 UTC (rev 24794)
> @@ -1235,7 +1235,6 @@
>  static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
>  {
>        View3D *v3d = CTX_wm_view3d(C);
> -       ARegion *ar= CTX_wm_region(C);
>        RegionView3D *rv3d= CTX_wm_region_view3d(C);
>        Scene *scene= CTX_data_scene(C);
>
> @@ -1257,7 +1256,7 @@
>                }
>
>                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;
> @@ -1275,7 +1274,7 @@
>        ot->poll= ED_operator_view3d_active;
>
>        /* flags */
> -       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
> +       ot->flag= 0;
>  }
>
>  /* ********************* Set render border operator ****************** */
>
> Modified: trunk/blender/source/blender/makesdna/DNA_constraint_types.h
> ===================================================================
> --- trunk/blender/source/blender/makesdna/DNA_constraint_types.h
>  2009-11-22 23:57:06 UTC (rev 24793)
> +++ trunk/blender/source/blender/makesdna/DNA_constraint_types.h
>  2009-11-23 00:03:51 UTC (rev 24794)
> @@ -585,16 +585,18 @@
>        CONSTRAINT_SPLINEIK_SCALE_LIMITED       = (1<<2),
>        /* evenly distribute the bones along the path regardless of length
> */
>        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;
>
>  /* bSplineIKConstraint->xzScaleMode */
>  typedef enum eSplineIK_XZScaleModes {
>        /* no x/z scaling */
>        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 */
>        CONSTRAINT_SPLINEIK_XZS_ORIGINAL,
> +       /* x/z scales are the inverse of the y-scale */
> +       CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC,
>  } eSplineIK_XZScaleModes;
>
>  /* MinMax (floor) flags */
>
> Modified: trunk/blender/source/blender/makesrna/intern/rna_constraint.c
> ===================================================================
> --- trunk/blender/source/blender/makesrna/intern/rna_constraint.c
> 2009-11-22 23:57:06 UTC (rev 24793)
> +++ trunk/blender/source/blender/makesrna/intern/rna_constraint.c
> 2009-11-23 00:03:51 UTC (rev 24794)
> @@ -1679,9 +1679,9 @@
>        PropertyRNA *prop;
>
>        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_RADIUS, "CURVE_RADIUS", 0, "Curve
> Radius", "Use the radius of the curve."},
> +               {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't
> scale the X and Z axes (Default)"},
>                {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}};
>
>        srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint");
> @@ -1718,15 +1718,20 @@
>        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");
>
> -       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_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");
> +
>        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_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");
>  }
>
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-blender-cvs/attachments/20091123/71732bf2/attachment.html>


More information about the Bf-blender-cvs mailing list