diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/TerrainUtil.cs | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainUtil.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainUtil.cs index c52d2c8..23ab321 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/TerrainUtil.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainUtil.cs | |||
@@ -1,51 +1,51 @@ | |||
1 | using System; | 1 | using System; |
2 | using OpenSim.Region.Environment.Interfaces; | 2 | using OpenSim.Region.Environment.Interfaces; |
3 | 3 | ||
4 | namespace OpenSim.Region.Environment.Modules.Terrain | 4 | namespace OpenSim.Region.Environment.Modules.Terrain |
5 | { | 5 | { |
6 | public static class TerrainUtil | 6 | public static class TerrainUtil |
7 | { | 7 | { |
8 | public static double MetersToSphericalStrength(double size) | 8 | public static double MetersToSphericalStrength(double size) |
9 | { | 9 | { |
10 | return Math.Pow(2, size); | 10 | return Math.Pow(2, size); |
11 | } | 11 | } |
12 | 12 | ||
13 | public static double SphericalFactor(double x, double y, double rx, double ry, double size) | 13 | public static double SphericalFactor(double x, double y, double rx, double ry, double size) |
14 | { | 14 | { |
15 | return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 15 | return size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
16 | } | 16 | } |
17 | 17 | ||
18 | public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 18 | public static double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
19 | { | 19 | { |
20 | int w = map.Width; | 20 | int w = map.Width; |
21 | int h = map.Height; | 21 | int h = map.Height; |
22 | 22 | ||
23 | if (x > w - 2.0) | 23 | if (x > w - 2.0) |
24 | x = w - 2.0; | 24 | x = w - 2.0; |
25 | if (y > h - 2.0) | 25 | if (y > h - 2.0) |
26 | y = h - 2.0; | 26 | y = h - 2.0; |
27 | if (x < 0.0) | 27 | if (x < 0.0) |
28 | x = 0.0; | 28 | x = 0.0; |
29 | if (y < 0.0) | 29 | if (y < 0.0) |
30 | y = 0.0; | 30 | y = 0.0; |
31 | 31 | ||
32 | int stepSize = 1; | 32 | int stepSize = 1; |
33 | double h00 = map[(int)x, (int)y]; | 33 | double h00 = map[(int)x, (int)y]; |
34 | double h10 = map[(int)x + stepSize, (int)y]; | 34 | double h10 = map[(int)x + stepSize, (int)y]; |
35 | double h01 = map[(int)x, (int)y + stepSize]; | 35 | double h01 = map[(int)x, (int)y + stepSize]; |
36 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; | 36 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; |
37 | double h1 = h00; | 37 | double h1 = h00; |
38 | double h2 = h10; | 38 | double h2 = h10; |
39 | double h3 = h01; | 39 | double h3 = h01; |
40 | double h4 = h11; | 40 | double h4 = h11; |
41 | double a00 = h1; | 41 | double a00 = h1; |
42 | double a10 = h2 - h1; | 42 | double a10 = h2 - h1; |
43 | double a01 = h3 - h1; | 43 | double a01 = h3 - h1; |
44 | double a11 = h1 - h2 - h3 + h4; | 44 | double a11 = h1 - h2 - h3 + h4; |
45 | double partialx = x - (int)x; | 45 | double partialx = x - (int)x; |
46 | double partialz = y - (int)y; | 46 | double partialz = y - (int)y; |
47 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 47 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
48 | return hi; | 48 | return hi; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | } | 51 | } |