diff options
author | Phil Stopford <philstopford> | 2020-02-25 17:03:47 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2020-02-25 17:13:25 +0300 |
commit | b0786d069cee989a924338fd450f7b4d5e7f47ce (patch) | |
tree | fdfa2200a21630679cfe3399dae5d013cf00019c /source/blender/blenkernel/intern/ocean.c | |
parent | 9cdf01085ffb974bde24c2409d004263c71da755 (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
Diffstat (limited to 'source/blender/blenkernel/intern/ocean.c')
-rw-r--r-- | source/blender/blenkernel/intern/ocean.c | 8 |
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); |