summaryrefslogtreecommitdiff
path: root/src/simulation/Gravity.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-06-25 11:19:26 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-06-25 11:19:26 (GMT)
commit04b007b36f3341d0906b64f8f59eab36ba58988a (patch)
tree3dc4123ba7790fbd2edaff49de757f20cc36df2f /src/simulation/Gravity.cpp
parentba802b3243c3e1721a84126e2bed6c3b24532b27 (diff)
downloadpowder-04b007b36f3341d0906b64f8f59eab36ba58988a.zip
powder-04b007b36f3341d0906b64f8f59eab36ba58988a.tar.gz
Create FFT plan on demand instead of at startup on the main thread
Diffstat (limited to 'src/simulation/Gravity.cpp')
-rw-r--r--src/simulation/Gravity.cpp18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/simulation/Gravity.cpp b/src/simulation/Gravity.cpp
index 356872a..6ef1382 100644
--- a/src/simulation/Gravity.cpp
+++ b/src/simulation/Gravity.cpp
@@ -5,10 +5,6 @@
#include "Gravity.h"
//#include "powder.h"
-#ifdef GRAVFFT
-#include <fftw3.h>
-#endif
-
void Gravity::bilinear_interpolation(float *src, float *dst, int sw, int sh, int rw, int rh)
{
int y, x, fxceil, fyceil;
@@ -49,9 +45,6 @@ void Gravity::gravity_init()
gravx = (float *)calloc((XRES/CELL)*(YRES/CELL), sizeof(float));
gravp = (float *)calloc((XRES/CELL)*(YRES/CELL), sizeof(float));
gravmask = (unsigned int *)calloc((XRES/CELL)*(YRES/CELL), sizeof(unsigned));
-#ifdef GRAVFFT
- grav_fft_init();
-#endif
}
void Gravity::gravity_cleanup()
@@ -196,10 +189,6 @@ void Gravity::stop_grav_async()
}
#ifdef GRAVFFT
-int grav_fft_status = 0;
-float *th_ptgravx, *th_ptgravy, *th_gravmapbig, *th_gravxbig, *th_gravybig;
-fftwf_complex *th_ptgravxt, *th_ptgravyt, *th_gravmapbigt, *th_gravxbigt, *th_gravybigt;
-fftwf_plan plan_gravmap, plan_gravx_inverse, plan_gravy_inverse;
void Gravity::grav_fft_init()
{
@@ -256,7 +245,7 @@ void Gravity::grav_fft_init()
//clear padded gravmap
memset(th_gravmapbig,0,xblock2*yblock2*sizeof(float));
- grav_fft_status = 1;
+ grav_fft_status = true;
}
void Gravity::grav_fft_cleanup()
@@ -273,7 +262,7 @@ void Gravity::grav_fft_cleanup()
fftwf_destroy_plan(plan_gravmap);
fftwf_destroy_plan(plan_gravx_inverse);
fftwf_destroy_plan(plan_gravy_inverse);
- grav_fft_status = 0;
+ grav_fft_status = false;
}
void Gravity::update_grav()
@@ -495,7 +484,8 @@ void Gravity::gravity_mask()
mask_free(t_mask_el);
}
-Gravity::Gravity()
+Gravity::Gravity():
+ grav_fft_status(false)
{
gravity_init();
}