diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2015-04-07 18:02:59 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2015-05-02 21:36:45 +0200 |
commit | d9c048f2028e3103212a1cfc6a29b2dc6c729387 (patch) | |
tree | acec919d535e645c1080043aeaf023b5fb5977cc | |
parent | 83818b18a1fa1e8a00332489e31d346101b6fe9e (diff) | |
download | pucket-d9c048f2028e3103212a1cfc6a29b2dc6c729387.tar.gz pucket-d9c048f2028e3103212a1cfc6a29b2dc6c729387.tar.bz2 pucket-d9c048f2028e3103212a1cfc6a29b2dc6c729387.zip |
Precalc variation constants once
No difference measureable.
-rw-r--r-- | flam3.c | 17 | ||||
-rw-r--r-- | rect.c | 3 | ||||
-rw-r--r-- | variations.c | 21 | ||||
-rw-r--r-- | variations.h | 2 |
4 files changed, 22 insertions, 21 deletions
@@ -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); @@ -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); |