duck

duck

Aug 4th, 2010
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1.  
  2. DebugX.Log("Interpolating unset height cells");
  3. for (int x = 0; x < heightmapSize; ++x)
  4. {
  5.     for (int y = 0; y < heightmapSize; ++y)
  6.     {
  7.         if (!(setHeights[x, y]))
  8.         {
  9.             float totalWeight = 0;
  10.             float totalHeight = 0;
  11.  
  12.             foreach (float[] knownHeight in knownHeights)
  13.             {
  14.                 float kx = knownHeight[0];
  15.                 float ky = knownHeight[1];
  16.                 float kz = knownHeight[2];
  17.  
  18.                 float xDiff = (x-kx);
  19.                 float zDiff = (z-kz);
  20.  
  21.                 float distSq = xDiff*xDiff + zDiff*zDiff;
  22.  
  23.                 float weight = 1;
  24.                 if (distSq > 0)
  25.                 {
  26.                     weight = 1/distSq;
  27.                 }
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment