[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32781] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/system/PseudoNoise.cpp: Fix for occasional disappearance of strokes when using SpatialNoiseShader.
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Sun Oct 31 00:15:13 CEST 2010
Revision: 32781
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32781
Author: kjym3
Date: 2010-10-31 00:15:12 +0200 (Sun, 31 Oct 2010)
Log Message:
-----------
Fix for occasional disappearance of strokes when using SpatialNoiseShader.
The PseudoNoise class for generating a series of noise values had a bug
involving a signed integer overflow when renders were at high image resolution.
This caused the noise generator to yield very large noise values, putting
strokes out of the renders' image boundary.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PseudoNoise.cpp
Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PseudoNoise.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PseudoNoise.cpp 2010-10-30 21:55:17 UTC (rev 32780)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/system/PseudoNoise.cpp 2010-10-30 22:15:12 UTC (rev 32781)
@@ -43,9 +43,10 @@
real
PseudoNoise::linearNoise (real x)
{
- int i = x*NB_VALUE_NOISE;
- real x1=_values[i%NB_VALUE_NOISE], x2=_values[(i+1)%NB_VALUE_NOISE];
- real t=x*real(NB_VALUE_NOISE)-real(i);
+ real tmp;
+ int i = modf(x, &tmp) * NB_VALUE_NOISE;
+ real x1=_values[i], x2=_values[(i+1)%NB_VALUE_NOISE];
+ real t = modf(x * NB_VALUE_NOISE, &tmp);
return x1*(1-t)+x2*t;
}
@@ -60,18 +61,18 @@
real
PseudoNoise::smoothNoise (real x)
{
- int i = x*NB_VALUE_NOISE;
- real t=x*real(NB_VALUE_NOISE)-real(i);
- if (i - 1 < 0)
+ real tmp;
+ int i = modf(x, &tmp) * NB_VALUE_NOISE;
+ int h = i - 1;
+ if (h < 0)
{
- int plus=-i/NB_VALUE_NOISE;
- i=i+NB_VALUE_NOISE*(plus+2);
- t=(x+plus+2)*real(NB_VALUE_NOISE)-real(i);
+ h = NB_VALUE_NOISE + h;
}
- real x1=_values[i%NB_VALUE_NOISE], x2=_values[(i+1)%NB_VALUE_NOISE];
- real x0=_values[(i-1)%NB_VALUE_NOISE], x3=_values[(i+2)%NB_VALUE_NOISE];
+ real x1=_values[i], x2=_values[(i+1)%NB_VALUE_NOISE];
+ real x0=_values[h], x3=_values[(i+2)%NB_VALUE_NOISE];
+ real t = modf(x * NB_VALUE_NOISE, &tmp);
real y0=LanczosWindowed(-1-t);
real y1=LanczosWindowed(-t);
real y2=LanczosWindowed(1-t);
More information about the Bf-blender-cvs
mailing list