diff options
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs deleted file mode 100644 index 3e1c34c..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | |||
30 | namespace libTerrain | ||
31 | { | ||
32 | partial class Channel | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Produces a set of coordinates defined by an edge point. Eg - 0 = 0,0. 256 = 0,256. 512 = 256,256 | ||
36 | /// Assumes a 256^2 heightmap. This needs fixing for input values of w,h | ||
37 | /// </summary> | ||
38 | /// <param name="val"></param> | ||
39 | /// <param name="w"></param> | ||
40 | /// <param name="h"></param> | ||
41 | /// <returns></returns> | ||
42 | private int[] RadialEdge256(int val) | ||
43 | { | ||
44 | // Four cases: | ||
45 | // 1. 000..255 return 0,val | ||
46 | // 2. 256..511 return val - 256,255 | ||
47 | // 3. 512..767 return 255, val - 511 | ||
48 | // 4. 768..1023 return val - 768,0 | ||
49 | |||
50 | int[] ret = new int[2]; | ||
51 | |||
52 | if (val < 256) | ||
53 | { | ||
54 | ret[0] = 0; | ||
55 | ret[1] = val; | ||
56 | return ret; | ||
57 | } | ||
58 | if (val < 512) | ||
59 | { | ||
60 | ret[0] = (val%256); | ||
61 | ret[1] = 255; | ||
62 | return ret; | ||
63 | } | ||
64 | if (val < 768) | ||
65 | { | ||
66 | ret[0] = 255; | ||
67 | ret[1] = 255 - (val%256); | ||
68 | return ret; | ||
69 | } | ||
70 | if (val < 1024) | ||
71 | { | ||
72 | ret[0] = 255 - (val%256); | ||
73 | ret[1] = 255; | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | throw new Exception("Out of bounds parameter (val)"); | ||
78 | } | ||
79 | |||
80 | public void Fracture(int number, double scalemin, double scalemax) | ||
81 | { | ||
82 | SetDiff(); | ||
83 | |||
84 | Random rand = new Random(seed); | ||
85 | |||
86 | for (int i = 0; i < number; i++) | ||
87 | { | ||
88 | int[] a, b; | ||
89 | |||
90 | a = RadialEdge256(rand.Next(1023)); // TODO: Broken | ||
91 | b = RadialEdge256(rand.Next(1023)); // TODO: Broken | ||
92 | double z = rand.NextDouble(); | ||
93 | double u = rand.NextDouble(); | ||
94 | double v = rand.NextDouble(); | ||
95 | |||
96 | for (int x = 0; x < w; x++) | ||
97 | { | ||
98 | for (int y = 0; y < h; y++) | ||
99 | { | ||
100 | double miny = Tools.LinearInterpolate(a[1], b[1], (double) x/(double) w); | ||
101 | |||
102 | if (v >= 0.5) | ||
103 | { | ||
104 | if (u >= 0.5) | ||
105 | { | ||
106 | if (y > miny) | ||
107 | { | ||
108 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
109 | } | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | if (y < miny) | ||
114 | { | ||
115 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | if (u >= 0.5) | ||
122 | { | ||
123 | if (x > miny) | ||
124 | { | ||
125 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
126 | } | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | if (x < miny) | ||
131 | { | ||
132 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | Normalise(); | ||
140 | } | ||
141 | } | ||
142 | } | ||