* Curve tilt interpolation types
authorMatt Ebb <matt@mke3.net>
Tue, 21 Aug 2007 01:57:15 +0000 (01:57 +0000)
committerMatt Ebb <matt@mke3.net>
Tue, 21 Aug 2007 01:57:15 +0000 (01:57 +0000)
Just a quickie feature I needed here at work- the previous linear
interpolation of tilt in curves can give nasty pinching problems
when trying to do flowing curves like a ribbon. This commit lets
you choose the interpolation type, between Linear, Cardinal, and
BSpline. The code was already set up for it pretty easily, mainly
needed to make the choice visible to the user.

Example:
http://mke3.net/blender/devel/etc/tilt_interp_types.png

Works on selected curve 'lines', menu in 'curve tools' panel in
edit mode.

source/blender/blenkernel/intern/curve.c
source/blender/include/butspace.h
source/blender/makesdna/DNA_curve_types.h
source/blender/src/buttons_editing.c

index 769c31ad8a9b37ff9e08c1a936cd5ad1783f88c0..ece0a7f1d6c5403002d8df43ce592ef40a9f8abc 100644 (file)
@@ -1445,7 +1445,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *
        
        for(a=0; a<resolu; a++, fac+= dfac) {
                
-               set_four_ipo(fac, t, KEY_LINEAR);
+               set_four_ipo(fac, t, nu->tilt_interp);
                
                data_a[a]= t[0]*pprev->alfa + t[1]*prevbezt->alfa + t[2]*bezt->alfa + t[3]*next->alfa;
        }
index 95ca38471a92a3fa01a0a0c25ec16b32ecc57fd5..e1aeb4df1e435a9dc17bc84288ccf2f0d5e5129f 100644 (file)
@@ -453,6 +453,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
 #define B_SETRESOLU            2121
 #define B_SETW4                        2122
 #define B_SUBSURFTYPE          2123
+#define B_TILTINTERP           2124
 
 /* *********************** */
 #define B_FONTBUTS             2300
index 8dc284888d7e6bbc8c465f8567e253cb864fa1a4..bd772bbeecbd381fb4a7119e32bb5eca5ab7fb3e 100644 (file)
@@ -116,9 +116,11 @@ typedef struct Nurb {
        float *knotsu, *knotsv;
        BPoint *bp;
        BezTriple *bezt;
+
+       short tilt_interp;      /* KEY_LINEAR, KEY_CARDINAL, KEY_BSPLINE */
+       short pad;
        
        int charidx;
-       int pad;
 } Nurb;
 
 typedef struct CharInfo {
index 3c995c4d19a9dde266f30f536a5ab2a65904c0b0..6efc9ffba55665fb7c05e56ccae6f867f855cfea 100644 (file)
@@ -2794,6 +2794,10 @@ void do_curvebuts(unsigned short event)
                        allqueue(REDRAWVIEW3D, 0);
                }
                break;
+       case B_TILTINTERP:
+               DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA);
+               allqueue(REDRAWVIEW3D, 0);
+               break;
        case B_SUBSURFTYPE:
                /* fallthrough */
        case B_MAKEDISP:
@@ -2904,6 +2908,14 @@ static void editing_panel_curve_tools(Object *ob, Curve *cu)
                nu= lastnu;
                if(nu==NULL) nu= editNurb.first;
                if(nu) {
+                       if (ob->type==OB_CURVE) {
+                               uiDefBut(block, LABEL, 0, "Tilt",
+                                       467,87,72, 18, 0, 0, 0, 0, 0, "");
+                               /* KEY_LINEAR, KEY_CARDINAL, KEY_BSPLINE */
+                               uiDefButS(block, MENU, B_TILTINTERP, "Tilt Interpolation %t|Linear %x0|Cardinal %x1|BSpline %x2",
+                                       467,67,72, 18, &(nu->tilt_interp), 0, 0, 0, 0, "Tilt interpolation");
+                       }
+                                               
                        uiBlockBeginAlign(block);
                        sp= &(nu->orderu);
                        uiDefButS(block, NUM, B_SETORDER, "Order U:", 565,90,102, 19, sp, 2.0, 6.0, 0, 0, "Nurbs only; the amount of control points involved");