Description: Fix rendering bugs in flam3.c Fix smooth interpolation issue (mfeemster) https://github.com/scottdraves/flam3/issues/13 Fix fusing flame iteration (roever) https://github.com/scottdraves/flam3/issues/15 Fix buffer overflows, (ministr too small) Author: Peter Blackman Last-Update: 2020-01-20 Index: b/flam3.c =================================================================== --- a/flam3.c +++ b/flam3.c @@ -255,19 +255,25 @@ fn = xform_distrib[ ((unsigned)irand(rc)) & CHOOSE_XFORM_GRAIN_M1 ]; if (apply_xform(cp, fn, p, q, rc)>0) { - consec ++; +// roever's patch + consec =0; badvals ++; - if (consec<5) { - p[0] = q[0]; - p[1] = q[1]; - p[2] = q[2]; - p[3] = q[3]; - i -= 4; - continue; - } else - consec = 0; - } else - consec = 0; + p[0] = q[0]; + p[1] = q[1]; + p[2] = q[2]; + p[3] = q[3]; + i -= 4; + continue; + } + else if (consec < fuse) { + consec++; + p[0] = q[0]; + p[1] = q[1]; + p[2] = q[2]; + p[3] = q[3]; + i -= 4; + continue; + } /* Store the last used transform */ lastxf = fn+1; @@ -753,23 +759,26 @@ flam3_align(&cpi[0], &cps[i1], 2); smoothflag = 0; - } else { + } + else { + /* mfeemster's patch */ if (0 == i1) { fprintf(stderr, "error: cannot use smooth interpolation on first segment.\n"); fprintf(stderr, "reverting to linear interpolation.\n"); flam3_align(&cpi[0], &cps[i1], 2); smoothflag = 0; } - + else if (ncps-1 == i2) { fprintf(stderr, "error: cannot use smooth interpolation on last segment.\n"); fprintf(stderr, "reverting to linear interpolation.\n"); flam3_align(&cpi[0], &cps[i1], 2); smoothflag = 0; } - + else { flam3_align(&cpi[0], &cps[i1-1], 4); smoothflag = 1; + } } /* Clear the destination cp */ @@ -2659,7 +2668,7 @@ void flam3_cross(flam3_genome *cp0, flam3_genome *cp1, flam3_genome *out, int cross_mode, randctx *rc, char *action) { int i,j, rb; - char ministr[10]; + char ministr[12]; if (cross_mode == CROSS_NOT_SPECIFIED) {