aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs29
1 files changed, 13 insertions, 16 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
index 45bb06b..e753847 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
@@ -28,8 +28,6 @@
28 28
29 29
30using System; 30using System;
31using System.Collections.Generic;
32using System.Text;
33 31
34namespace libTerrain 32namespace libTerrain
35{ 33{
@@ -58,12 +56,12 @@ namespace libTerrain
58 56
59 // Establish the average height under the area 57 // Establish the average height under the area
60 Channel newmap = new Channel(w, h); 58 Channel newmap = new Channel(w, h);
61 newmap.map = (double[,])map.Clone(); 59 newmap.map = (double[,]) map.Clone();
62 60
63 newmap *= temp; 61 newmap *= temp;
64 62
65 double total_terrain = newmap.Sum(); 63 double total_terrain = newmap.Sum();
66 double avg_height = total_terrain / total_mod; 64 double avg_height = total_terrain/total_mod;
67 65
68 // Create a flat terrain using the average height 66 // Create a flat terrain using the average height
69 Channel flat = new Channel(w, h); 67 Channel flat = new Channel(w, h);
@@ -72,7 +70,6 @@ namespace libTerrain
72 // Blend the current terrain with the average height terrain 70 // Blend the current terrain with the average height terrain
73 // using the "raised" empty terrain as a mask 71 // using the "raised" empty terrain as a mask
74 Blend(flat, temp); 72 Blend(flat, temp);
75
76 } 73 }
77 74
78 private void FlattenFast(double rx, double ry, double size, double amount) 75 private void FlattenFast(double rx, double ry, double size, double amount)
@@ -81,10 +78,10 @@ namespace libTerrain
81 double avg = 0; 78 double avg = 0;
82 double div = 0; 79 double div = 0;
83 80
84 int minX = Math.Max(0, (int)(rx - (size + 1))); 81 int minX = Math.Max(0, (int) (rx - (size + 1)));
85 int maxX = Math.Min(w, (int)(rx + (size + 1))); 82 int maxX = Math.Min(w, (int) (rx + (size + 1)));
86 int minY = Math.Max(0, (int)(ry - (size + 1))); 83 int minY = Math.Max(0, (int) (ry - (size + 1)));
87 int maxY = Math.Min(h, (int)(ry + (size + 1))); 84 int maxY = Math.Min(h, (int) (ry + (size + 1)));
88 85
89 for (x = minX; x < maxX; x++) 86 for (x = minX; x < maxX; x++)
90 { 87 {
@@ -92,17 +89,17 @@ namespace libTerrain
92 { 89 {
93 double z = size; 90 double z = size;
94 z *= z; 91 z *= z;
95 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 92 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
96 93
97 if (z < 0) 94 if (z < 0)
98 z = 0; 95 z = 0;
99 96
100 avg += z * amount; 97 avg += z*amount;
101 div += z; 98 div += z;
102 } 99 }
103 } 100 }
104 101
105 double height = avg / div; 102 double height = avg/div;
106 103
107 for (x = minX; x < maxX; x++) 104 for (x = minX; x < maxX; x++)
108 { 105 {
@@ -110,7 +107,7 @@ namespace libTerrain
110 { 107 {
111 double z = size; 108 double z = size;
112 z *= z; 109 z *= z;
113 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 110 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
114 111
115 if (z < 0) 112 if (z < 0)
116 z = 0; 113 z = 0;
@@ -123,19 +120,19 @@ namespace libTerrain
123 public void Flatten(Channel mask, double amount) 120 public void Flatten(Channel mask, double amount)
124 { 121 {
125 // Generate the mask 122 // Generate the mask
126 Channel temp = mask * amount; 123 Channel temp = mask*amount;
127 temp.Clip(0, 1); // Cut off out-of-bounds values 124 temp.Clip(0, 1); // Cut off out-of-bounds values
128 125
129 double total_mod = temp.Sum(); 126 double total_mod = temp.Sum();
130 127
131 // Establish the average height under the area 128 // Establish the average height under the area
132 Channel map = new Channel(w, h); 129 Channel map = new Channel(w, h);
133 map.map = (double[,])this.map.Clone(); 130 map.map = (double[,]) this.map.Clone();
134 131
135 map *= temp; 132 map *= temp;
136 133
137 double total_terrain = map.Sum(); 134 double total_terrain = map.Sum();
138 double avg_height = total_terrain / total_mod; 135 double avg_height = total_terrain/total_mod;
139 136
140 // Create a flat terrain using the average height 137 // Create a flat terrain using the average height
141 Channel flat = new Channel(w, h); 138 Channel flat = new Channel(w, h);