Revision: 57733
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57733
Author:   campbellbarton
Date:     2013-06-25 10:49:20 +0000 (Tue, 25 Jun 2013)
Log Message:
-----------
patch [#35830] Add Catmull-Rom spline as an option for lattice deformer

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/key.c
    trunk/blender/source/blender/makesdna/DNA_key_types.h
    trunk/blender/source/blender/makesrna/intern/rna_key.c

Modified: trunk/blender/source/blender/blenkernel/intern/key.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/key.c        2013-06-25 
10:44:30 UTC (rev 57732)
+++ trunk/blender/source/blender/blenkernel/intern/key.c        2013-06-25 
10:49:20 UTC (rev 57733)
@@ -289,6 +289,16 @@
                data[2] = -0.5f        * t3  + 0.5f * t2   + 0.5f * t    + 
0.16666666f;
                data[3] =  0.16666666f * t3;
        }
+       else if (type == KEY_CATMULL_ROM) {
+               t2 = t * t;
+               t3 = t2 * t;
+               fc = 0.5f;
+
+               data[0] = -fc          * t3  + 2.0f * fc          * t2 - fc * t;
+               data[1] =  (2.0f - fc) * t3  + (fc - 3.0f)        * t2 + 1.0f;
+               data[2] =  (fc - 2.0f) * t3  + (3.0f - 2.0f * fc) * t2 + fc * t;
+               data[3] =  fc          * t3  - fc * t2;
+       }
 }
 
 /* first derivative */
@@ -319,6 +329,15 @@
                data[2] = -1.5f * t2  + t         + 0.5f;
                data[3] =  0.5f * t2;
        }
+       else if (type == KEY_CATMULL_ROM) {
+               t2 = t * t;
+               fc = 0.5f;
+
+               data[0] = -3.0f * fc          * t2  + 4.0f * fc * t             
     - fc;
+               data[1] =  3.0f * (2.0f - fc) * t2  + 2.0f * (fc - 3.0f) * t;
+               data[2] =  3.0f * (fc - 2.0f) * t2  + 2.0f * (3.0f - 2.0f * fc) 
* t  + fc;
+               data[3] =  3.0f * fc          * t2  - 2.0f * fc * t;
+       }
 }
 
 /* second derivative */
@@ -346,6 +365,14 @@
                data[2] = -3.0f * t  + 1.0f;
                data[3] =  1.0f * t;
        }
+       else if (type == KEY_CATMULL_ROM) {
+               fc = 0.5f;
+
+               data[0] = -6.0f * fc          * t  + 4.0f * fc;
+               data[1] =  6.0f * (2.0f - fc) * t  + 2.0f * (fc - 3.0f);
+               data[2] =  6.0f * (fc - 2.0f) * t  + 2.0f * (3.0f - 2.0f * fc);
+               data[3] =  6.0f * fc          * t  - 2.0f * fc;
+       }
 }
 
 static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int 
cycl)

Modified: trunk/blender/source/blender/makesdna/DNA_key_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_key_types.h       2013-06-25 
10:44:30 UTC (rev 57732)
+++ trunk/blender/source/blender/makesdna/DNA_key_types.h       2013-06-25 
10:49:20 UTC (rev 57733)
@@ -125,7 +125,8 @@
 enum {
        KEY_LINEAR      = 0,
        KEY_CARDINAL    = 1,
-       KEY_BSPLINE     = 2
+       KEY_BSPLINE     = 2,
+       KEY_CATMULL_ROM = 3,
 };
 
 /* KeyBlock->flag */

Modified: trunk/blender/source/blender/makesrna/intern/rna_key.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_key.c      2013-06-25 
10:44:30 UTC (rev 57732)
+++ trunk/blender/source/blender/makesrna/intern/rna_key.c      2013-06-25 
10:49:20 UTC (rev 57733)
@@ -458,6 +458,7 @@
 EnumPropertyItem keyblock_type_items[] = {
        {KEY_LINEAR, "KEY_LINEAR", 0, "Linear", ""},
        {KEY_CARDINAL, "KEY_CARDINAL", 0, "Cardinal", ""},
+       {KEY_CATMULL_ROM, "KEY_CATMULL_ROM", 0, "Catmull-Rom", ""},
        {KEY_BSPLINE, "KEY_BSPLINE", 0, "BSpline", ""},
        {0, NULL, 0, NULL, NULL}
 };

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to