aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
diff options
context:
space:
mode:
authorMW2007-07-25 18:19:38 +0000
committerMW2007-07-25 18:19:38 +0000
commit2b42ea0a429c722bd7c5c67d3815c2ddc8399e78 (patch)
tree0a6338ff52efbdaadaa9a307bee618867460cfb6 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
parent* Terrain now uses the older slower method again until the fast version can b... (diff)
downloadopensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.zip
opensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.gz
opensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.bz2
opensim-SC-2b42ea0a429c722bd7c5c67d3815c2ddc8399e78.tar.xz
Start of the OpenSim library , for now only contains a few textures.
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs224
1 files changed, 112 insertions, 112 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
index 07c7d66..695d501 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
@@ -1,112 +1,112 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32 32
33namespace libTerrain 33namespace libTerrain
34{ 34{
35 partial class Channel 35 partial class Channel
36 { 36 {
37 /// <summary> 37 /// <summary>
38 /// A thermal weathering implementation based on Musgrave's original 1989 algorithm. This is Adam's custom implementation which may differ slightly from the original. 38 /// A thermal weathering implementation based on Musgrave's original 1989 algorithm. This is Adam's custom implementation which may differ slightly from the original.
39 /// </summary> 39 /// </summary>
40 /// <param name="talus">The rock angle (represented as a dy/dx ratio) at which point it will be succeptible to breakage</param> 40 /// <param name="talus">The rock angle (represented as a dy/dx ratio) at which point it will be succeptible to breakage</param>
41 /// <param name="rounds">The number of erosion rounds</param> 41 /// <param name="rounds">The number of erosion rounds</param>
42 /// <param name="c">The amount of rock to carry each round</param> 42 /// <param name="c">The amount of rock to carry each round</param>
43 public Channel ThermalWeathering(double talus, int rounds, double c) 43 public Channel ThermalWeathering(double talus, int rounds, double c)
44 { 44 {
45 SetDiff(); 45 SetDiff();
46 46
47 double[,] lastFrame; 47 double[,] lastFrame;
48 double[,] thisFrame; 48 double[,] thisFrame;
49 49
50 lastFrame = (double[,])map.Clone(); 50 lastFrame = (double[,])map.Clone();
51 thisFrame = (double[,])map.Clone(); 51 thisFrame = (double[,])map.Clone();
52 52
53 NeighbourSystem type = NeighbourSystem.Moore; // Using moore neighbourhood (twice as computationally expensive) 53 NeighbourSystem type = NeighbourSystem.Moore; // Using moore neighbourhood (twice as computationally expensive)
54 int NEIGHBOUR_ME = 4; // I am always 4 in both systems. 54 int NEIGHBOUR_ME = 4; // I am always 4 in both systems.
55 55
56 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; 56 int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5;
57 57
58 int frames = rounds; // Number of thermal erosion iterations to run 58 int frames = rounds; // Number of thermal erosion iterations to run
59 int i, j; 59 int i, j;
60 int x, y; 60 int x, y;
61 61
62 for (i = 0; i < frames; i++) 62 for (i = 0; i < frames; i++)
63 { 63 {
64 for (x = 0; x < w; x++) 64 for (x = 0; x < w; x++)
65 { 65 {
66 for (y = 0; y < h; y++) 66 for (y = 0; y < h; y++)
67 { 67 {
68 for (j = 0; j < NEIGHBOUR_MAX; j++) 68 for (j = 0; j < NEIGHBOUR_MAX; j++)
69 { 69 {
70 if (j != NEIGHBOUR_ME) 70 if (j != NEIGHBOUR_ME)
71 { 71 {
72 int[] coords = Neighbours(type, j); 72 int[] coords = Neighbours(type, j);
73 73
74 coords[0] += x; 74 coords[0] += x;
75 coords[1] += y; 75 coords[1] += y;
76 76
77 if (coords[0] > w - 1) 77 if (coords[0] > w - 1)
78 coords[0] = w - 1; 78 coords[0] = w - 1;
79 if (coords[1] > h - 1) 79 if (coords[1] > h - 1)
80 coords[1] = h - 1; 80 coords[1] = h - 1;
81 if (coords[0] < 0) 81 if (coords[0] < 0)
82 coords[0] = 0; 82 coords[0] = 0;
83 if (coords[1] < 0) 83 if (coords[1] < 0)
84 coords[1] = 0; 84 coords[1] = 0;
85 85
86 double heightF = thisFrame[x, y]; 86 double heightF = thisFrame[x, y];
87 double target = thisFrame[coords[0], coords[1]]; 87 double target = thisFrame[coords[0], coords[1]];
88 88
89 if (target > heightF + talus) 89 if (target > heightF + talus)
90 { 90 {
91 double calc = c * ((target - heightF) - talus); 91 double calc = c * ((target - heightF) - talus);
92 heightF += calc; 92 heightF += calc;
93 target -= calc; 93 target -= calc;
94 } 94 }
95 95
96 thisFrame[x, y] = heightF; 96 thisFrame[x, y] = heightF;
97 thisFrame[coords[0], coords[1]] = target; 97 thisFrame[coords[0], coords[1]] = target;
98 98
99 } 99 }
100 } 100 }
101 } 101 }
102 } 102 }
103 lastFrame = (double[,])thisFrame.Clone(); 103 lastFrame = (double[,])thisFrame.Clone();
104 } 104 }
105 105
106 map = thisFrame; 106 map = thisFrame;
107 107
108 Normalise(); // Just to guaruntee a smooth 0..1 value 108 Normalise(); // Just to guaruntee a smooth 0..1 value
109 return this; 109 return this;
110 } 110 }
111 } 111 }
112} 112}