From 8039ad32df87fe2e5904a993b9ea7bbc477c2c19 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 4 Jan 2007 22:35:19 +0000 Subject: [PATCH] A few code cleanups for the IPO cleaning stuff in an attempt to get rid of a bug which hides all but the active ipo-curve after cleaning. The bug still remains, but I hope to have a solution soon. --- source/blender/include/BSE_editipo.h | 2 +- source/blender/src/editipo.c | 42 +++++++++++++++------------- source/blender/src/header_ipo.c | 5 +--- source/blender/src/space.c | 2 +- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/source/blender/include/BSE_editipo.h b/source/blender/include/BSE_editipo.h index 2a10ca4a373..7173a6def0b 100644 --- a/source/blender/include/BSE_editipo.h +++ b/source/blender/include/BSE_editipo.h @@ -92,7 +92,7 @@ void insert_vert_ipo(struct IpoCurve *icu, float x, float y); void add_vert_ipo(void); void add_duplicate_editipo(void); void remove_doubles_ipo(void); -void clean_ipo(struct Ipo *ipo, short mode); +void clean_ipo(void); void clean_ipo_curve(struct IpoCurve *icu); void smooth_ipo(void); void join_ipo_menu(void); diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index 485dc055d33..5e475a1bf83 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -3078,11 +3078,11 @@ void remove_doubles_ipo(void) } -void clean_ipo(Ipo *ipo, short mode) +void clean_ipo(void) { - /* fixme: this should probably work on editipo's as well... - aligorith*/ - IpoCurve *icu; - int ok; + EditIpo *ei; + short ok; + int b; if (G.scene->toolsettings->clean_thresh==0) G.scene->toolsettings->clean_thresh= 0.1f; @@ -3091,24 +3091,26 @@ void clean_ipo(Ipo *ipo, short mode) "Clean Threshold"); if (!ok) return; - for (icu= ipo->curve.first; icu; icu= icu->next) { - switch (mode) { - case 1: /* only selected curves get affected */ - if ((icu->flag & IPO_SELECT)||(icu->flag & IPO_ACTIVE)) { - clean_ipo_curve(icu); - } - break; - default: /* any curve gets affected */ - clean_ipo_curve(icu); - break; + get_status_editipo(); + + ei= G.sipo->editipo; + for(b=0; btotipo; b++, ei++) { + if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) { + + ok= 0; + if(G.sipo->showkey) ok= 1; + else if(totipo_vert && (ei->flag & IPO_EDIT)) ok= 2; + else if(totipo_vert==0 && (ei->flag & IPO_SELECT)) ok= 3; + + if(ok) { + /* only clean if ok */ + clean_ipo_curve(ei->icu); + } } } + editipo_changed(G.sipo, 1); BIF_undo_push("Clean IPO"); - allqueue(REMAKEIPO, 0); - allqueue(REDRAWIPO, 0); - allqueue(REDRAWACTION, 0); - allqueue(REDRAWNLA, 0); } void clean_ipo_curve(IpoCurve *icu) @@ -3131,7 +3133,7 @@ void clean_ipo_curve(IpoCurve *icu) thresh= 0.1f; /* pointers to points */ - newb = newbs = MEM_mallocN(sizeof(BezTriple)*totCount, "NewBeztriples"); + newb = newbs = MEM_callocN(sizeof(BezTriple)*totCount, "NewBeztriples"); bezt= icu->bezt; *newb= *bezt; bezt++; @@ -3200,7 +3202,7 @@ void clean_ipo_curve(IpoCurve *icu) } /* make better sized list */ - newbz= MEM_mallocN(sizeof(BezTriple)*newCount, "BezTriples"); + newbz= MEM_callocN(sizeof(BezTriple)*newCount, "BezTriples"); for (i=0; ispacedata.first; - clean_ipo(sipo->ipo, 1); - } + clean_ipo(); break; case 9: /* smooth ipo */ smooth_ipo(); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index fa1f18d58b2..75e84df35c3 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -2606,7 +2606,7 @@ static void winqreadipospace(ScrArea *sa, void *spacedata, BWinEvent *evt) if (G.qual==LR_SHIFTKEY) smooth_ipo(); else - clean_ipo(sipo->ipo, 1); + clean_ipo(); break; case RKEY: if (G.qual==0)