summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flam3.c17
-rw-r--r--rect.c3
-rw-r--r--variations.c21
-rw-r--r--variations.h2
4 files changed, 22 insertions, 21 deletions
diff --git a/flam3.c b/flam3.c
index 7d0a18d..55990d9 100644
--- a/flam3.c
+++ b/flam3.c
@@ -147,13 +147,10 @@ int flam3_create_chaos_distrib(flam3_genome *cp, int xi, unsigned short *xform_d
return(0);
}
-/*
- * run the function system described by CP forward N generations. store
- * the N resulting 4-vectors in SAMPLES. the initial point is passed in
- * SAMPLES[0..3]. ignore the first FUSE iterations.
- */
-
+/* xform_precalc must be called once for each xform before running this
+ * function
+ */
int flam3_iterate(flam3_genome *cp, int n, int fuse, const double4 in, double4 *samples, const unsigned short *xform_distrib, randctx *rc) {
int i;
double4 p, q;
@@ -164,10 +161,6 @@ int flam3_iterate(flam3_genome *cp, int n, int fuse, const double4 in, double4 *
p = in;
- /* Perform precalculations */
- for (i=0;i<cp->num_xforms;i++)
- xform_precalc(cp,i);
-
for (i = -fuse; i < n; i++) {
// fn = xform_distrib[ lastxf*CHOOSE_XFORM_GRAIN + (((unsigned)irand(rc)) % CHOOSE_XFORM_GRAIN)];
@@ -1859,6 +1852,10 @@ int flam3_estimate_bounding_box(flam3_genome *cp, double eps, int nsamples,
xform_distrib = flam3_create_xform_distrib(cp);
if (xform_distrib==NULL)
return(-1);
+ for (unsigned int i = 0; i < cp->num_xforms; i++) {
+ xform_precalc (&cp->xform[i]);
+ }
+
bv=flam3_iterate(cp, nsamples, 20, start, points, xform_distrib, rc);
free(xform_distrib);
diff --git a/rect.c b/rect.c
index 13a76c6..6341c8d 100644
--- a/rect.c
+++ b/rect.c
@@ -76,6 +76,9 @@ static void iter_thread (flam3_genome * const input_genome,
flam3_genome genome;
memset (&genome, 0, sizeof (genome));
flam3_copy (&genome, input_genome);
+ for (unsigned int i = 0; i < genome.num_xforms; i++) {
+ xform_precalc (&genome.xform[i]);
+ }
double4 *iter_storage;
int ret = posix_memalign ((void **) &iter_storage, sizeof (*iter_storage),
diff --git a/variations.c b/variations.c
index 8c28a0c..82a74a7 100644
--- a/variations.c
+++ b/variations.c
@@ -1900,16 +1900,17 @@ static void supershape_precalc(flam3_xform *xf) {
xf->super_shape_pneg1_n1 = -1.0 / xf->super_shape_n1;
}
-void xform_precalc(flam3_genome *cp, int xi) {
-
- perspective_precalc(&(cp->xform[xi]));
- juliaN_precalc(&(cp->xform[xi]));
- juliaScope_precalc(&(cp->xform[xi]));
- radial_blur_precalc(&(cp->xform[xi]));
- waves_precalc(&(cp->xform[xi]));
- disc2_precalc(&(cp->xform[xi]));
- supershape_precalc(&(cp->xform[xi]));
- wedgeJulia_precalc(&(cp->xform[xi]));
+/* Precalculate constants (i.e. not depending on position) for variations
+ */
+void xform_precalc (flam3_xform * const xform) {
+ perspective_precalc(xform);
+ juliaN_precalc(xform);
+ juliaScope_precalc(xform);
+ radial_blur_precalc(xform);
+ waves_precalc(xform);
+ disc2_precalc(xform);
+ supershape_precalc(xform);
+ wedgeJulia_precalc(xform);
}
static double adjust_percentage(double in) {
diff --git a/variations.h b/variations.h
index f6cade7..519a9e8 100644
--- a/variations.h
+++ b/variations.h
@@ -19,7 +19,7 @@
#include "flam3.h"
-void xform_precalc(flam3_genome *cp, int xi);
+void xform_precalc (flam3_xform * const xform);
int prepare_precalc_flags(flam3_genome *);
int apply_xform(flam3_genome *cp, int fn, const double4 p, double4 *, randctx *rc);