aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing
diff options
context:
space:
mode:
authorlbsa712007-10-30 09:05:31 +0000
committerlbsa712007-10-30 09:05:31 +0000
commit67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch)
tree20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing
parent* Deleted .user file (diff)
downloadopensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2
opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz
* Optimized usings
* Shortened type references * Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs29
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs14
2 files changed, 19 insertions, 24 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);
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
index 15631df..9e8f3a4 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.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{
@@ -63,12 +61,12 @@ namespace libTerrain
63 { 61 {
64 double z = size; 62 double z = size;
65 z *= z; 63 z *= z;
66 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 64 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
67 65
68 if (z < 0) 66 if (z < 0)
69 z = 0; 67 z = 0;
70 68
71 Set(x, y, map[x, y] + (z * amount)); 69 Set(x, y, map[x, y] + (z*amount));
72 } 70 }
73 } 71 }
74 } 72 }
@@ -88,12 +86,12 @@ namespace libTerrain
88 for (y = 0; y < h; y++) 86 for (y = 0; y < h; y++)
89 { 87 {
90 double z = size; 88 double z = size;
91 z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); 89 z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
92 90
93 if (z < 0) 91 if (z < 0)
94 z = 0; 92 z = 0;
95 93
96 Set(x, y, map[x, y] + (z * amount)); 94 Set(x, y, map[x, y] + (z*amount));
97 } 95 }
98 } 96 }
99 } 97 }
@@ -126,12 +124,12 @@ namespace libTerrain
126 { 124 {
127 double z = size; 125 double z = size;
128 z *= z; 126 z *= z;
129 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); 127 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
130 128
131 if (z < 0) 129 if (z < 0)
132 z = 0; 130 z = 0;
133 131
134 Set(x, y, map[x, y] - (z * amount)); 132 Set(x, y, map[x, y] - (z*amount));
135 } 133 }
136 } 134 }
137 } 135 }