Revision: 17258 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17258 Author: aligorith Date: 2008-11-01 11:18:21 +0100 (Sat, 01 Nov 2008)
Log Message: ----------- AnimSys2: Bugfixes for code from past few days * Fixed the causes of several crashes that occurred, also added checks for a few more potential ones (or errors) * New keyframes on new IPO-curves were being added with constant interpolation only * Removed debug code Modified Paths: -------------- branches/animsys2/source/blender/src/drawipo.c branches/animsys2/source/blender/src/keyframing.c Modified: branches/animsys2/source/blender/src/drawipo.c =================================================================== --- branches/animsys2/source/blender/src/drawipo.c 2008-11-01 00:23:08 UTC (rev 17257) +++ branches/animsys2/source/blender/src/drawipo.c 2008-11-01 10:18:21 UTC (rev 17258) @@ -1230,7 +1230,7 @@ * - first handle only if previous beztriple was bezier-mode * - second handle only if current beztriple is bezier-mode */ - if ((!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt->ipo==IPO_BEZ)) { + if ( (!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) ) { if ((bezt->f1 & SELECT) == sel)/* && G.v2d->cur.xmin < bezt->vec[0][0] < G.v2d->cur.xmax)*/ bglVertex3fv(bezt->vec[0]); } @@ -1326,7 +1326,8 @@ fp= bezt->vec[0]; /* only draw first handle if previous segment was had handles */ - if ((!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt->ipo==IPO_BEZ)) { + if ( (!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) ) + { cpack(col[bezt->h1]); glBegin(GL_LINE_STRIP); glVertex2fv(fp); glVertex2fv(fp+3); @@ -1335,7 +1336,8 @@ } /* only draw second handle if this segment is bezier */ - if (bezt->ipo == IPO_BEZ) { + if (bezt->ipo == IPO_BEZ) + { cpack(col[bezt->h2]); glBegin(GL_LINE_STRIP); glVertex2fv(fp+3); glVertex2fv(fp+6); @@ -1345,7 +1347,7 @@ else { /* only draw first handle if previous segment was had handles, and selection is ok */ if ( ((bezt->f1 & SELECT)==sel) && - ((!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt->ipo==IPO_BEZ)) ) + ( (!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt && (prevbezt->ipo==IPO_BEZ)) ) ) { fp= bezt->vec[0]; cpack(col[bezt->h1]); Modified: branches/animsys2/source/blender/src/keyframing.c =================================================================== --- branches/animsys2/source/blender/src/keyframing.c 2008-11-01 00:23:08 UTC (rev 17257) +++ branches/animsys2/source/blender/src/keyframing.c 2008-11-01 10:18:21 UTC (rev 17258) @@ -325,8 +325,12 @@ /* add temp beztriple to keyframes */ a= insert_bezt_icu(icu, &beztr); - if (!fast) calchandles_ipocurve(icu); + /* what if 'a' is a negative index? + * for now, just exit to prevent any segfaults + */ + if (a < 0) return; + /* set handletype and interpolation */ if (icu->totvert > 2) { BezTriple *bezt= (icu->bezt + a); @@ -347,13 +351,20 @@ } else bezt->ipo= icu->ipo; + } + else { + BezTriple *bezt= (icu->bezt + a); - /* don't recalculate handles if fast is set - * - this is a hack to make importers faster - */ - // TODO: importers should add to a bpoint array allocated once instead - if (!fast) calchandles_ipocurve(icu); + /* set interpolation directly from ipo-curve */ + bezt->ipo= icu->ipo; } + + /* don't recalculate handles if fast is set + * - this is a hack to make importers faster + * - in past handles were calculated twice... only once now at end should be sufficient! + */ + // TODO: importers should add to a bpoint array allocated once instead + if (!fast) calchandles_ipocurve(icu); } /* ------------------- Get Data ------------------------ */ @@ -924,12 +935,11 @@ /* --------- KeyingSet Adrcode Getters ------------ */ /* initialise a channel-getter storage */ -static bKS_AdrcodeGetter *ks_adrcodegetter_init (bKeyingSet *ks, bCommonKeySrc *cks) +static void ks_adrcodegetter_init (bKS_AdrcodeGetter *kag, bKeyingSet *ks, bCommonKeySrc *cks) { - bKS_AdrcodeGetter *kag; - /* error checking */ - kag= MEM_callocN(sizeof(bKS_AdrcodeGetter), "KAG"); + if (kag == NULL) + return; if (ELEM(NULL, ks, cks)) { /* set invalid settings that won't cause harm */ @@ -949,8 +959,6 @@ kag->index= -1; kag->tot= ks->chan_num; } - - return kag; } /* 'default' channel-getter that will be used when iterating through keyingset's channels @@ -1014,7 +1022,6 @@ bCommonKeySrc *cks= (kag) ? kag->cks : NULL; short index, adrcode; - /* error checking */ if (ELEM3(NULL, kag, ks, cks)) return 0; if (ks->chan_num <= 0) return 0; @@ -1965,13 +1972,12 @@ } } else { - bKS_AdrcodeGetter *kag; + bKS_AdrcodeGetter kag; short (*get_next_adrcode)(bKS_AdrcodeGetter *); int adrcode; /* initialise keyingset channel iterator */ - kag= ks_adrcodegetter_init(ks, cks); - printf("kag = %p \n", kag); + ks_adrcodegetter_init(&kag, ks, cks); /* get iterator - only one can be in use at a time... the flags should be mutually exclusive in this regard */ if (ks->flag & COMMONKEY_PCHANROT) @@ -1982,7 +1988,7 @@ get_next_adrcode= ks_getnextadrcode_default; /* loop over channels available in keyingset */ - for (adrcode= get_next_adrcode(kag); adrcode > 0; adrcode= get_next_adrcode(kag)) { + for (adrcode= get_next_adrcode(&kag); adrcode > 0; adrcode= get_next_adrcode(&kag)) { short flag; /* insert mode or delete mode */ @@ -2006,9 +2012,6 @@ success += insertkey(cks->id, ks->blocktype, cks->actname, cks->constname, adrcode, flag); } } - - /* free keyingset channel iterator */ - MEM_freeN(kag); } /* special handling for some key-sources */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs