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:
authorPhil Stopford <philstopford>2020-02-25 17:03:47 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-02-25 17:13:25 +0300
commitb0786d069cee989a924338fd450f7b4d5e7f47ce (patch)
treefdfa2200a21630679cfe3399dae5d013cf00019c
parent9cdf01085ffb974bde24c2409d004263c71da755 (diff)
Ocean modifier: fix changes to resolution complete changing the shape
This takes the idea from the aaOcean library to link the RNG seed to the surface point, so that changing resolution only adds/remove surface detail. Differential Revision: https://developer.blender.org/D6871
-rw-r--r--source/blender/blenkernel/intern/ocean.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 9faa61f986d..c27fb59835f 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -49,6 +49,8 @@
#include "RE_render_ext.h"
+#include "BLI_hash.h"
+
#ifdef WITH_OCEANSIM
/* Ocean code */
@@ -985,11 +987,15 @@ void BKE_ocean_init(struct Ocean *o,
}
}
- /*srand(seed);*/
rng = BLI_rng_new(seed);
for (i = 0; i < o->_M; i++) {
for (j = 0; j < o->_N; j++) {
+ /* This ensures we get a value tied to the surface location, avoiding dramatic surface
+ * change with changing resolution. */
+ int new_seed = seed + BLI_hash_int_2d(o->_kx[i] * 360.0f, o->_kz[j] * 360.0f);
+
+ BLI_rng_seed(rng, new_seed);
float r1 = gaussRand(rng);
float r2 = gaussRand(rng);