[Bf-blender-cvs] [4a80c0e2751] blender-v2.92-release: Fix T85225: Variable scope in ridged multi-fractal noise

Robert Guetzkow noreply at git.blender.org
Tue Feb 2 20:41:02 CET 2021


Commit: 4a80c0e27519b63929aa48b6fb1d673666829b21
Author: Robert Guetzkow
Date:   Tue Feb 2 20:35:47 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rB4a80c0e27519b63929aa48b6fb1d673666829b21

Fix T85225: Variable scope in ridged multi-fractal noise

This patch fixes a bug introduced in
rB74188e65028d268af887ab2140e4253087410c1e.
The commit incorrectly moved the declaration and intialization of the
variable `pwr` inside the loop. Since the value was originally modified
in each iteration based on it's previous value and `pwHL` through
`pwr *= pwHL`, this change in scope was wrong. It resetted the value in
each iteration. This patch moves the declaration of `pwr` outside the
loop again.

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D10258

===================================================================

M	source/blender/blenlib/intern/noise.c

===================================================================

diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c
index 4ba533c72aa..b770a267eee 100644
--- a/source/blender/blenlib/intern/noise.c
+++ b/source/blender/blenlib/intern/noise.c
@@ -1636,9 +1636,9 @@ float BLI_noise_mg_ridged_multi_fractal(float x,
 
   float signal = powf(offset - fabsf(noisefunc(x, y, z)), 2);
   float result = signal;
+  float pwHL = powf(lacunarity, -H);
+  float pwr = pwHL; /* starts with i=1 instead of 0 */
   for (int i = 1; i < (int)octaves; i++) {
-    float pwHL = powf(lacunarity, -H);
-    float pwr = pwHL; /* starts with i=1 instead of 0 */
     x *= lacunarity;
     y *= lacunarity;
     z *= lacunarity;



More information about the Bf-blender-cvs mailing list