Argh! Forgot a log message for this. Stupid update conflicts..<br><br>----------------------<br><br>Spline IK Constraint - Review of Scaling Options<br><br>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)<br>
<br>Changes:<br>- Added a proper volume preservation xz-scaling mode. The previous one has been renamed back to 'None', since that's what it did.<br>- 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.<br>
- Renamed 'Y Scaling' to 'Y Stretch' for more clarity.<br><br><br><div class="gmail_quote">On Mon, Nov 23, 2009 at 1:03 PM, Joshua Leung <span dir="ltr"><<a href="mailto:aligorith@gmail.com">aligorith@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Revision: 24794<br>
          <a href="http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24794" target="_blank">http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24794</a><br>

Author:   aligorith<br>
Date:     2009-11-23 01:03:51 +0100 (Mon, 23 Nov 2009)<br>
<br>
Log Message:<br>
-----------<br>
<br>
<br>
Modified Paths:<br>
--------------<br>
    trunk/blender/release/scripts/ui/properties_object_constraint.py<br>
    trunk/blender/source/blender/blenkernel/intern/armature.c<br>
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c<br>
    trunk/blender/source/blender/makesdna/DNA_constraint_types.h<br>
    trunk/blender/source/blender/makesrna/intern/rna_constraint.c<br>
<br>
Modified: trunk/blender/release/scripts/ui/properties_object_constraint.py<br>
===================================================================<br>
--- trunk/blender/release/scripts/ui/properties_object_constraint.py    2009-11-22 23:57:06 UTC (rev 24793)<br>
+++ trunk/blender/release/scripts/ui/properties_object_constraint.py    2009-11-23 00:03:51 UTC (rev 24794)<br>
@@ -706,11 +706,12 @@<br>
<br>
         col = layout.column()<br>
         col.itemL(text="Chain Scaling:")<br>
-        col.itemR(con, "y_scaling")<br>
+        col.itemR(con, "y_stretch")<br>
         if wide_ui:<br>
             col.itemR(con, "xz_scaling_mode")<br>
         else:<br>
             col.itemR(con, "xz_scaling_mode", text="")<br>
+        col.itemR(con, "use_curve_radius")<br>
<br>
<br>
 class OBJECT_PT_constraints(ConstraintButtonsPanel):<br>
<br>
Modified: trunk/blender/source/blender/blenkernel/intern/armature.c<br>
===================================================================<br>
--- trunk/blender/source/blender/blenkernel/intern/armature.c   2009-11-22 23:57:06 UTC (rev 24793)<br>
+++ trunk/blender/source/blender/blenkernel/intern/armature.c   2009-11-23 00:03:51 UTC (rev 24794)<br>
@@ -1915,20 +1915,12 @@<br>
        }<br>
<br>
        /* step 4: set the scaling factors for the axes */<br>
-       // TODO: include a no-scale option?<br>
        {<br>
                /* only multiply the y-axis by the scaling factor to get nice volume-preservation */<br>
                mul_v3_fl(poseMat[1], scaleFac);<br>
<br>
                /* set the scaling factors of the x and z axes from... */<br>
                switch (ikData->xzScaleMode) {<br>
-                       case CONSTRAINT_SPLINEIK_XZS_RADIUS:<br>
-                       {<br>
-                               /* radius of curve */<br>
-                               mul_v3_fl(poseMat[0], radius);<br>
-                               mul_v3_fl(poseMat[2], radius);<br>
-                       }<br>
-                               break;<br>
                        case CONSTRAINT_SPLINEIK_XZS_ORIGINAL:<br>
                        {<br>
                                /* original scales get used */<br>
@@ -1942,7 +1934,38 @@<br>
                                mul_v3_fl(poseMat[2], scale);<br>
                        }<br>
                                break;<br>
+                       case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC:<br>
+                       {<br>
+                               /* 'volume preservation' */<br>
+                               float scale;<br>
+<br>
+                               /* calculate volume preservation factor which is<br>
+                                * basically the inverse of the y-scaling factor<br>
+                                */<br>
+                               if (fabs(scaleFac) != 0.0f) {<br>
+                                       scale= 1.0 / fabs(scaleFac);<br>
+<br>
+                                       /* we need to clamp this within sensible values */<br>
+                                       // NOTE: these should be fine for now, but should get sanitised in future<br>
+                                       scale= MIN2( MAX2(scale, 0.0001) , 100000);<br>
+                               }<br>
+                               else<br>
+                                       scale= 1.0f;<br>
+<br>
+                               /* apply the scaling */<br>
+                               mul_v3_fl(poseMat[0], scale);<br>
+                               mul_v3_fl(poseMat[2], scale);<br>
+                       }<br>
+                               break;<br>
                }<br>
+<br>
+               /* finally, multiply the x and z scaling by the radius of the curve too,<br>
+                * to allow automatic scales to get tweaked still<br>
+                */<br>
+               if ((ikData->flag & CONSTRAINT_SPLINEIK_NO_CURVERAD) == 0) {<br>
+                       mul_v3_fl(poseMat[0], radius);<br>
+                       mul_v3_fl(poseMat[2], radius);<br>
+               }<br>
        }<br>
<br>
        /* step 5: set the location of the bone in the matrix<br>
<br>
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c<br>
===================================================================<br>
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c     2009-11-22 23:57:06 UTC (rev 24793)<br>
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c     2009-11-23 00:03:51 UTC (rev 24794)<br>
@@ -1235,7 +1235,6 @@<br>
 static int viewcenter_cursor_exec(bContext *C, wmOperator *op)<br>
 {<br>
        View3D *v3d = CTX_wm_view3d(C);<br>
-       ARegion *ar= CTX_wm_region(C);<br>
        RegionView3D *rv3d= CTX_wm_region_view3d(C);<br>
        Scene *scene= CTX_data_scene(C);<br>
<br>
@@ -1257,7 +1256,7 @@<br>
                }<br>
<br>
                if (rv3d->viewlock & RV3D_BOXVIEW)<br>
-                       view3d_boxview_copy(CTX_wm_area(C), ar);<br>
+                       view3d_boxview_copy(CTX_wm_area(C), CTX_wm_region(C));<br>
        }<br>
<br>
        return OPERATOR_FINISHED;<br>
@@ -1275,7 +1274,7 @@<br>
        ot->poll= ED_operator_view3d_active;<br>
<br>
        /* flags */<br>
-       ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;<br>
+       ot->flag= 0;<br>
 }<br>
<br>
 /* ********************* Set render border operator ****************** */<br>
<br>
Modified: trunk/blender/source/blender/makesdna/DNA_constraint_types.h<br>
===================================================================<br>
--- trunk/blender/source/blender/makesdna/DNA_constraint_types.h        2009-11-22 23:57:06 UTC (rev 24793)<br>
+++ trunk/blender/source/blender/makesdna/DNA_constraint_types.h        2009-11-23 00:03:51 UTC (rev 24794)<br>
@@ -585,16 +585,18 @@<br>
        CONSTRAINT_SPLINEIK_SCALE_LIMITED       = (1<<2),<br>
        /* evenly distribute the bones along the path regardless of length */<br>
        CONSTRAINT_SPLINEIK_EVENSPLITS          = (1<<3),<br>
+       /* don't adjust the x and z scaling of the bones by the curve radius */<br>
+       CONSTRAINT_SPLINEIK_NO_CURVERAD = (1<<4),<br>
 } eSplineIK_Flags;<br>
<br>
 /* bSplineIKConstraint->xzScaleMode */<br>
 typedef enum eSplineIK_XZScaleModes {<br>
        /* no x/z scaling */<br>
        CONSTRAINT_SPLINEIK_XZS_NONE                    = 0,<br>
-       /* bones in the chain should take their x/z scales from the curve radius */<br>
-       CONSTRAINT_SPLINEIK_XZS_RADIUS,<br>
        /* bones in the chain should take their x/z scales from the original scaling */<br>
        CONSTRAINT_SPLINEIK_XZS_ORIGINAL,<br>
+       /* x/z scales are the inverse of the y-scale */<br>
+       CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC,<br>
 } eSplineIK_XZScaleModes;<br>
<br>
 /* MinMax (floor) flags */<br>
<br>
Modified: trunk/blender/source/blender/makesrna/intern/rna_constraint.c<br>
===================================================================<br>
--- trunk/blender/source/blender/makesrna/intern/rna_constraint.c       2009-11-22 23:57:06 UTC (rev 24793)<br>
+++ trunk/blender/source/blender/makesrna/intern/rna_constraint.c       2009-11-23 00:03:51 UTC (rev 24794)<br>
@@ -1679,9 +1679,9 @@<br>
        PropertyRNA *prop;<br>
<br>
        static EnumPropertyItem splineik_xz_scale_mode[] = {<br>
-               {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "Volume Preserve", "Don't scale the x and z axes, giving a volume preservation effect. (Default)"},<br>
-               {CONSTRAINT_SPLINEIK_XZS_RADIUS, "CURVE_RADIUS", 0, "Curve Radius", "Use the radius of the curve."},<br>
+               {CONSTRAINT_SPLINEIK_XZS_NONE, "NONE", 0, "None", "Don't scale the X and Z axes (Default)"},<br>
                {CONSTRAINT_SPLINEIK_XZS_ORIGINAL, "BONE_ORIGINAL", 0, "Bone Original", "Use the original scaling of the bones."},<br>
+               {CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC, "VOLUME_PRESERVE", 0, "Volume Preservation", "Scale of the X and Z axes is the inverse of the Y-Scale."},<br>
                {0, NULL, 0, NULL, NULL}};<br>
<br>
        srna= RNA_def_struct(brna, "SplineIKConstraint", "Constraint");<br>
@@ -1718,15 +1718,20 @@<br>
        RNA_def_property_ui_text(prop, "Even Divisions", "Ignore the relative lengths of the bones when fitting to the curve.");<br>
        RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");<br>
<br>
-       prop= RNA_def_property(srna, "y_scaling", PROP_BOOLEAN, PROP_NONE);<br>
+       prop= RNA_def_property(srna, "y_streching", PROP_BOOLEAN, PROP_NONE);<br>
        RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_SCALE_LIMITED);<br>
-       RNA_def_property_ui_text(prop, "Y Scaling", "Stretch the Y axis of the bones to fit the curve.");<br>
+       RNA_def_property_ui_text(prop, "Y Stretch", "Stretch the Y axis of the bones to fit the curve.");<br>
        RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");<br>
<br>
+       prop= RNA_def_property(srna, "use_curve_radius", PROP_BOOLEAN, PROP_NONE);<br>
+       RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_SPLINEIK_NO_CURVERAD);<br>
+       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.");<br>
+       RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");<br>
+<br>
        prop= RNA_def_property(srna, "xz_scaling_mode", PROP_ENUM, PROP_NONE);<br>
        RNA_def_property_enum_sdna(prop, NULL, "xzScaleMode");<br>
        RNA_def_property_enum_items(prop, splineik_xz_scale_mode);<br>
-       RNA_def_property_ui_text(prop, "XZ Scale Mode", "Method used for determining the scaling of the X and Z axes of the bone.");<br>
+       RNA_def_property_ui_text(prop, "XZ Scale Mode", "Method used for determining the scaling of the X and Z axes of the bones.");<br>
        RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update");<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
Bf-blender-cvs mailing list<br>
<a href="mailto:Bf-blender-cvs@blender.org">Bf-blender-cvs@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-blender-cvs" target="_blank">http://lists.blender.org/mailman/listinfo/bf-blender-cvs</a><br>
</blockquote></div><br>