Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/ocean.c')
-rw-r--r--source/blender/blenkernel/intern/ocean.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 8957628c76a..198ff5a0540 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -147,19 +147,19 @@ static void init_complex(fftw_complex cmpl, float real, float image)
cmpl[1] = image;
}
-static void add_comlex_c(fftw_complex res, fftw_complex cmpl1, fftw_complex cmpl2)
+static void add_comlex_c(fftw_complex res, const fftw_complex cmpl1, const fftw_complex cmpl2)
{
res[0] = cmpl1[0] + cmpl2[0];
res[1] = cmpl1[1] + cmpl2[1];
}
-static void mul_complex_f(fftw_complex res, fftw_complex cmpl, float f)
+static void mul_complex_f(fftw_complex res, const fftw_complex cmpl, float f)
{
res[0] = cmpl[0] * (double)f;
res[1] = cmpl[1] * (double)f;
}
-static void mul_complex_c(fftw_complex res, fftw_complex cmpl1, fftw_complex cmpl2)
+static void mul_complex_c(fftw_complex res, const fftw_complex cmpl1, const fftw_complex cmpl2)
{
fftwf_complex temp;
temp[0] = cmpl1[0] * cmpl2[0] - cmpl1[1] * cmpl2[1];
@@ -178,7 +178,7 @@ static float image_c(fftw_complex cmpl)
return cmpl[1];
}
-static void conj_complex(fftw_complex res, fftw_complex cmpl1)
+static void conj_complex(fftw_complex res, const fftw_complex cmpl1)
{
res[0] = cmpl1[0];
res[1] = -cmpl1[1];
@@ -753,18 +753,26 @@ struct Ocean *BKE_ocean_add(void)
return oc;
}
-bool BKE_ocean_ensure(struct OceanModifierData *omd)
+bool BKE_ocean_ensure(struct OceanModifierData *omd, const int resolution)
{
if (omd->ocean) {
- return false;
+ /* Check that the ocean has the same resolution than we want now. */
+ if (omd->ocean->_M == resolution * resolution) {
+ return false;
+ }
+ else {
+ BKE_ocean_free(omd->ocean);
+ }
}
omd->ocean = BKE_ocean_add();
- BKE_ocean_init_from_modifier(omd->ocean, omd);
+ BKE_ocean_init_from_modifier(omd->ocean, omd, resolution);
return true;
}
-void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd)
+void BKE_ocean_init_from_modifier(struct Ocean *ocean,
+ struct OceanModifierData const *omd,
+ const int resolution)
{
short do_heightfield, do_chop, do_normals, do_jacobian;
@@ -774,9 +782,10 @@ void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData
do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
BKE_ocean_free_data(ocean);
+
BKE_ocean_init(ocean,
- omd->resolution * omd->resolution,
- omd->resolution * omd->resolution,
+ resolution * resolution,
+ resolution * resolution,
omd->spatial_size,
omd->spatial_size,
omd->wind_velocity,
@@ -831,7 +840,7 @@ void BKE_ocean_init(struct Ocean *o,
o->_A = A;
o->_w = w;
o->_damp_reflections = 1.0f - damp;
- o->_wind_alignment = alignment;
+ o->_wind_alignment = alignment * 10.0f;
o->_depth = depth;
o->_Lx = Lx;
o->_Lz = Lz;
@@ -845,7 +854,7 @@ void BKE_ocean_init(struct Ocean *o,
/* Common JONSWAP parameters. */
o->_fetch_jonswap = fetch_jonswap;
- o->_sharpen_peak_jonswap = sharpen_peak_jonswap;
+ o->_sharpen_peak_jonswap = sharpen_peak_jonswap * 10.0f;
o->_do_disp_y = do_height_field;
o->_do_normals = do_normals;
@@ -1607,7 +1616,8 @@ void BKE_ocean_bake(struct Ocean *UNUSED(o),
}
void BKE_ocean_init_from_modifier(struct Ocean *UNUSED(ocean),
- struct OceanModifierData const *UNUSED(omd))
+ struct OceanModifierData const *UNUSED(omd),
+ int UNUSED(resolution))
{
}