diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-06-12 18:46:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-06-12 18:46:32 +0400 |
commit | 82a108b4134cf43a185c22bfe7bf2035c4f6375a (patch) | |
tree | 6aa97ca308eeeb49ca8ff6d459c01e4b5d271ae7 /source | |
parent | 39a47826e31219996c8a08b6cbe80d87ad3661cd (diff) |
Curve Smoorth for venomgfx adjusting animation paths over terrain.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BDR_editcurve.h | 1 | ||||
-rw-r--r-- | source/blender/src/editcurve.c | 56 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 5 |
3 files changed, 61 insertions, 1 deletions
diff --git a/source/blender/include/BDR_editcurve.h b/source/blender/include/BDR_editcurve.h index 4604359fcc9..363a6567f3e 100644 --- a/source/blender/include/BDR_editcurve.h +++ b/source/blender/include/BDR_editcurve.h @@ -99,6 +99,7 @@ int bezt_compare (const void *e1, const void *e2); void setweightNurb( void ); void setradiusNurb( void ); void smoothradiusNurb( void ); +void smoothNurb( void ); extern void undo_push_curve(char *name); diff --git a/source/blender/src/editcurve.c b/source/blender/src/editcurve.c index bd0abe83ee4..261bb26b0c4 100644 --- a/source/blender/src/editcurve.c +++ b/source/blender/src/editcurve.c @@ -1158,6 +1158,62 @@ void setradiusNurb( void ) allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */ } +void smoothNurb( void ) +{ + + extern ListBase editNurb; + Nurb *nu; + BezTriple *bezt, *beztOrig; + BPoint *bp, *bpOrig; + int a, i, change = 0; + + /* floats for smoothing */ + float val, newval, offset; + + for(nu= editNurb.first; nu; nu= nu->next) { + if(nu->bezt) { + change = 0; + beztOrig = MEM_dupallocN( nu->bezt ); + for(bezt=nu->bezt+1, a=1; a<nu->pntsu-1; a++, bezt++) { + if(bezt->f2 & SELECT) { + for(i=0; i<3; i++) { + val = bezt->vec[1][i]; + newval = ((beztOrig+(a-1))->vec[1][i] * 0.5) + ((beztOrig+(a+1))->vec[1][i] * 0.5); + offset = (val*((1.0/6.0)*5)) + (newval*(1.0/6.0)) - val; + /* offset handles */ + bezt->vec[1][i] += offset; + bezt->vec[0][i] += offset; + bezt->vec[2][i] += offset; + } + change = 1; + } + } + MEM_freeN(beztOrig); + if (change) + calchandlesNurb(nu); + } else if (nu->bp) { + bpOrig = MEM_dupallocN( nu->bp ); + /* Same as above, keep these the same! */ + for(bp=nu->bp+1, a=1; a<nu->pntsu-1; a++, bp++) { + if(bp->f1 & SELECT) { + for(i=0; i<3; i++) { + val = bp->vec[i]; + newval = ((bpOrig+(a-1))->vec[i] * 0.5) + ((bpOrig+(a+1))->vec[i] * 0.5); + offset = (val*((1.0/6.0)*5)) + (newval*(1.0/6.0)) - val; + + bp->vec[i] += offset; + } + } + } + MEM_freeN(bpOrig); + } + } + BIF_undo_push("Smooth Curve"); + DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSALL, 0); + allqueue(REDRAWINFO, 1); /* 1, because header->win==0! */ +} /* TODO, make smoothing distance based */ void smoothradiusNurb( void ) diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 4029e031b63..38664f72b25 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -2735,7 +2735,7 @@ void special_editmenu(void) } else if ELEM(G.obedit->type, OB_CURVE, OB_SURF) { - nr= pupmenu("Specials%t|Subdivide%x1|Switch Direction%x2|Set Goal Weight %x3|Set Radius %x4|Smooth Radius %x5"); + nr= pupmenu("Specials%t|Subdivide%x1|Switch Direction%x2|Set Goal Weight %x3|Set Radius %x4|Smooth Radius %x5|Smooth Radius %x6"); switch(nr) { case 1: @@ -2751,6 +2751,9 @@ void special_editmenu(void) setradiusNurb(); break; case 5: + smoothNurb(); + break; + case 6: smoothradiusNurb(); break; } |