I am currently playing around with the fftw fourier library with the intention
of coming out with some routines that would implement a deep ocean simulator using a
filtered frequency spectrum and phase shifting in frequency space (based on code
derived from mwave which has been put into the public domain). This is similar
to the wave effect but it gives a much more realistic result.
So far I have:
* back ported the effect over to effects.c - which compiles
* implemented an untested GUI
* added the OceanFFTEff to DNA_effect_types.h and BKE_effect.h
however when I come to compile the modified source tree I get an error in the
build process:
---------------------------------------------------------------------------------------
gcc -o /home/simon/develop/build/linux2/makesdna /home/simon/develop/build/linux2/source/blender/makesdna/intern/makesdna.o -L/home/simon/develop/build/linux2/lib -Llib -lblender_guardedalloc
../build/linux2/makesdna /home/simon/develop/build/linux2/source/blender/makesdna/intern/dna.c
Running makesdna at debug level 0
Program version: $Id: makesdna.c,v 1.8 2004/03/20 22:55:38 zuster Exp $
Align pointer error in struct: OceanFFTEff *h0
Error: alphalength is 84, alphalen mod8 4, mul 1, sizeof(fftw_complex)=8
Align pointer error in struct: OceanFFTEff *ht
Error: alphalength is 92, alphalen mod8 4, mul 1, sizeof(fftw_complex)=8
Align pointer error in struct: OceanFFTEff *result
Error: alphalength is 100, alphalen mod8 4, mul 1, sizeof(fftw_complex)=8
scons: *** [/home/simon/develop/build/linux2/source/blender/makesdna/intern/dna.c] Error 1
scons: building terminated because of errors.
[simon@lunar oceanblender]$
---------------------------------------------------------------------------------------
I have added extra debugging info to make it clearer.
The code for the OceanFFTEff is shown below:
---------------------------------------------------------------------------------------
Code: Select all
typedef struct OceanFFTEff {
struct OceanFFTEff *next, *prev;
short type, flag, buttype, stype; /* from the wave effect */
/* this is to store the current effect context, the other values are
* cycled through when the 'Recalc' button is pushed.
*/
struct OceanFFTEff * current;
int fftsamplesize;
float waveRange;
float heightScale;
float windX;
float windY;
float gravity;
float lambda;
float offset_x;
float offset_y;
float offset_z;
float size_x;
float size_y;
float size_z;
fftwf_complex *h0;
fftwf_complex *ht;
fftwf_complex *result;
fftwf_plan fplan2;
} OceanFFTEff;
I have added the marked lines of code to the makesdna.c source file:
---------------------------------------------------------------------------------------
Code: Select all
/* insertion of all known types */
/* watch it: uint is not allowed! use in structs an unsigned int */
add_type("char", 1); /* 0 */
add_type("uchar", 1); /* 1 */
add_type("short", 2); /* 2 */
add_type("ushort", 2); /* 3 */
add_type("int", 4); /* 4 */
add_type("long", 4); /* 5 */
add_type("ulong", 4); /* 6 */
add_type("float", 4); /* 7 */
add_type("double", 8); /* 8 */
add_type("void", 0); /* 9 */
/* FFTW ADD TYPES added to allow DNA code to record FFT data */
add_type("fftwf_complex", sizeof(fftwf_complex)); /* 10? */
add_type("fftwf_plan", sizeof(fftwf_plan)); /* 11? */
however there is a problem - I do not want blender to store the contents at the arrays of
fftwf_complex *h0;
fftwf_complex *ht;
fftwf_complex *result;
and also the fftw plan 'fplan2' because they are generated dynamically and (in case of the plan)
are machine dependant. My Ocean FFT rengeneration routine creates new arrays and plans if they are NULLed -
which is what I want.
I guess what I would want to know is: has anybody else had any experience with DNA that can help me?
Kind Regards
Simon Harvey
-------------------------
Post ChangeLog:
Modified the title, on Thursday 5th August
"Ocean Simulator: Compile Problems" to"Ocean Simulator: Update"