aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs6
-rw-r--r--OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs6
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs92
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs10
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs4
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs8
7 files changed, 66 insertions, 62 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 7381930..8ad8147 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -354,7 +354,7 @@ namespace OpenSim.Region.Environment.Scenes
354 354
355 private void UpdateTerrain() 355 private void UpdateTerrain()
356 { 356 {
357 if (Terrain.Tainted()) 357 if (Terrain.Tainted() && !Terrain.StillEditing())
358 { 358 {
359 CreateTerrainTexture(); 359 CreateTerrainTexture();
360 360
@@ -466,7 +466,7 @@ namespace OpenSim.Region.Environment.Scenes
466 { 466 {
467 if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile)) 467 if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile))
468 { 468 {
469 Console.WriteLine("No default terrain, procedurally generating..."); 469 MainLog.Instance.Verbose("TERRAIN", "No default terrain. Generating a new terrain.");
470 Terrain.HillsGenerator(); 470 Terrain.HillsGenerator();
471 471
472 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 472 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD());
@@ -480,7 +480,7 @@ namespace OpenSim.Region.Environment.Scenes
480 } 480 }
481 catch 481 catch
482 { 482 {
483 Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); 483 MainLog.Instance.Verbose("TERRAIN","No terrain found in database or default. Generating a new terrain.");
484 Terrain.HillsGenerator(); 484 Terrain.HillsGenerator();
485 } 485 }
486 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 486 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD());
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
index a0d2399..d2bb106 100644
--- a/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
+++ b/OpenSim/Region/Storage/OpenSim.DataStore.MonoSqlite/MonoSqliteDataStore.cs
@@ -141,8 +141,8 @@ namespace OpenSim.DataStore.MonoSqlite
141 prim.Shape = buildShape(shapeRow); 141 prim.Shape = buildShape(shapeRow);
142 } 142 }
143 else 143 else
144 { 144 {
145 Console.WriteLine("No shape found for prim in storage, so setting default box shape"); 145 MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape");
146 prim.Shape = BoxShape.Default; 146 prim.Shape = BoxShape.Default;
147 } 147 }
148 group.AddPart(prim); 148 group.AddPart(prim);
@@ -161,7 +161,7 @@ namespace OpenSim.DataStore.MonoSqlite
161 } 161 }
162 else 162 else
163 { 163 {
164 Console.WriteLine("No shape found for prim in storage, so setting default box shape"); 164 MainLog.Instance.Notice("No shape found for prim in storage, so setting default box shape");
165 prim.Shape = BoxShape.Default; 165 prim.Shape = BoxShape.Default;
166 } 166 }
167 createdObjects[new LLUUID(objID)].AddPart(prim); 167 createdObjects[new LLUUID(objID)].AddPart(prim);
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index c3c4935..d010a03 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -81,6 +81,11 @@ namespace OpenSim.Region.Terrain
81 /// </summary> 81 /// </summary>
82 public double minLower = 500.0; 82 public double minLower = 500.0;
83 83
84 /// <summary>
85 /// The last time the terrain was edited
86 /// </summary>
87 public DateTime lastEdit = DateTime.Now;
88
84 89
85 /// <summary> 90 /// <summary>
86 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine. 91 /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine.
@@ -120,6 +125,16 @@ namespace OpenSim.Region.Terrain
120 return (tainted != 0); 125 return (tainted != 0);
121 } 126 }
122 127
128 public bool StillEditing()
129 {
130 TimeSpan gap = DateTime.Now - lastEdit;
131
132 if (gap.TotalSeconds <= 2.0)
133 return true;
134
135 return false;
136 }
137
123 public bool Tainted(int x, int y) 138 public bool Tainted(int x, int y)
124 { 139 {
125 return (heightmap.diff[x / 16, y / 16] != 0); 140 return (heightmap.diff[x / 16, y / 16] != 0);
@@ -197,6 +212,8 @@ namespace OpenSim.Region.Terrain
197 } 212 }
198 } 213 }
199 214
215 lastEdit = DateTime.Now;
216
200 return; 217 return;
201 } 218 }
202 219
@@ -1172,28 +1189,7 @@ namespace OpenSim.Region.Terrain
1172 { 1189 {
1173 try 1190 try
1174 { 1191 {
1175 Bitmap gradientmapLd = new Bitmap(gradientmap); 1192 Bitmap bmp = TerrainToBitmap(gradientmap);
1176
1177 int pallete = gradientmapLd.Height;
1178
1179 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
1180 Color[] colours = new Color[pallete];
1181
1182 for (int i = 0; i < pallete; i++)
1183 {
1184 colours[i] = gradientmapLd.GetPixel(0, i);
1185 }
1186
1187 Channel copy = heightmap.Copy();
1188 for (int y = 0; y < copy.h; y++)
1189 {
1190 for (int x = 0; x < copy.w; x++)
1191 {
1192 // 512 is the largest possible height before colours clamp
1193 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(x, y) / 512.0), 0.0) * (pallete - 1));
1194 bmp.SetPixel(x, y, colours[colorindex]);
1195 }
1196 }
1197 1193
1198 bmp.Save(filename, ImageFormat.Png); 1194 bmp.Save(filename, ImageFormat.Png);
1199 } 1195 }
@@ -1212,30 +1208,8 @@ namespace OpenSim.Region.Terrain
1212 byte[] imageData = null; 1208 byte[] imageData = null;
1213 try 1209 try
1214 { 1210 {
1215 Bitmap gradientmapLd = new Bitmap(gradientmap); 1211 Bitmap bmp = TerrainToBitmap(gradientmap);
1216
1217 int pallete = gradientmapLd.Height;
1218
1219 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
1220 Color[] colours = new Color[pallete];
1221 1212
1222 for (int i = 0; i < pallete; i++)
1223 {
1224 colours[i] = gradientmapLd.GetPixel(0, i);
1225 }
1226
1227 Channel copy = heightmap.Copy();
1228 for (int y = 0; y < copy.h; y++)
1229 {
1230 for (int x = 0; x < copy.w; x++)
1231 {
1232 // 512 is the largest possible height before colours clamp
1233 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(x, copy.h - y) / 512.0), 0.0) * (pallete - 1));
1234 bmp.SetPixel(x, y, colours[colorindex]);
1235 }
1236 }
1237
1238 //bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
1239 imageData = OpenJPEG.EncodeFromImage(bmp, true ); 1213 imageData = OpenJPEG.EncodeFromImage(bmp, true );
1240 1214
1241 } 1215 }
@@ -1246,5 +1220,33 @@ namespace OpenSim.Region.Terrain
1246 1220
1247 return imageData; 1221 return imageData;
1248 } 1222 }
1223
1224 private Bitmap TerrainToBitmap(string gradientmap)
1225 {
1226 Bitmap gradientmapLd = new Bitmap(gradientmap);
1227
1228 int pallete = gradientmapLd.Height;
1229
1230 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
1231 Color[] colours = new Color[pallete];
1232
1233 for (int i = 0; i < pallete; i++)
1234 {
1235 colours[i] = gradientmapLd.GetPixel(0, i);
1236 }
1237
1238 Channel copy = heightmap.Copy();
1239 for (int y = 0; y < copy.h; y++)
1240 {
1241 for (int x = 0; x < copy.w; x++)
1242 {
1243 // 512 is the largest possible height before colours clamp
1244 int colorindex = (int)(Math.Max(Math.Min(1.0, copy.Get(x, y) / 512.0), 0.0) * (pallete - 1));
1245 bmp.SetPixel(x, y, colours[colorindex]);
1246 }
1247 }
1248 return bmp;
1249 }
1250
1249 } 1251 }
1250} 1252}
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
index 8e894ab..45bb06b 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
@@ -115,7 +115,7 @@ namespace libTerrain
115 if (z < 0) 115 if (z < 0)
116 z = 0; 116 z = 0;
117 117
118 Set(x, y, Tools.linearInterpolate(map[x, y], height, z)); 118 Set(x, y, Tools.LinearInterpolate(map[x, y], height, z));
119 } 119 }
120 } 120 }
121 } 121 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
index 3e88aa9..3a9b7f7 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
@@ -100,7 +100,7 @@ namespace libTerrain
100 { 100 {
101 for (int y = 0; y < h; y++) 101 for (int y = 0; y < h; y++)
102 { 102 {
103 double miny = Tools.linearInterpolate(a[1], b[1], (double)x / (double)w); 103 double miny = Tools.LinearInterpolate(a[1], b[1], (double)x / (double)w);
104 104
105 if (v >= 0.5) 105 if (v >= 0.5)
106 { 106 {
@@ -108,14 +108,14 @@ namespace libTerrain
108 { 108 {
109 if (y > miny) 109 if (y > miny)
110 { 110 {
111 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z); 111 map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z);
112 } 112 }
113 } 113 }
114 else 114 else
115 { 115 {
116 if (y < miny) 116 if (y < miny)
117 { 117 {
118 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z); 118 map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z);
119 } 119 }
120 } 120 }
121 } 121 }
@@ -125,14 +125,14 @@ namespace libTerrain
125 { 125 {
126 if (x > miny) 126 if (x > miny)
127 { 127 {
128 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z); 128 map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z);
129 } 129 }
130 } 130 }
131 else 131 else
132 { 132 {
133 if (x < miny) 133 if (x < miny)
134 { 134 {
135 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z); 135 map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z);
136 } 136 }
137 } 137 }
138 } 138 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
index 0930a36..0155791 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
@@ -341,7 +341,7 @@ namespace libTerrain
341 { 341 {
342 for (y = 0; y < h; y++) 342 for (y = 0; y < h; y++)
343 { 343 {
344 Set(x, y, Tools.linearInterpolate(map[x, y], other.map[x, y], amount)); 344 Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount));
345 } 345 }
346 } 346 }
347 return this; 347 return this;
@@ -354,7 +354,7 @@ namespace libTerrain
354 { 354 {
355 for (y = 0; y < h; y++) 355 for (y = 0; y < h; y++)
356 { 356 {
357 Set(x, y, Tools.linearInterpolate(map[x, y], other.map[x, y], amount.map[x, y])); 357 Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount.map[x, y]));
358 } 358 }
359 } 359 }
360 return this; 360 return this;
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs
index 60dbf62..13338a2 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Tools/Tools.cs
@@ -37,17 +37,19 @@ namespace libTerrain
37{ 37{
38 class Tools 38 class Tools
39 { 39 {
40 public static double linearInterpolate(double a, double b, double amount) 40 public static double LinearInterpolate(double a, double b, double amount)
41 { 41 {
42 return a + ((b - a) * amount); 42 return a + ((b - a) * amount);
43 } 43 }
44 public static double exponentialInterpolate(double a, double b, double amount) 44
45 public static double ExponentialInterpolate(double a, double b, double amount)
45 { 46 {
46 a = Math.Pow(a, amount); 47 a = Math.Pow(a, amount);
47 b = Math.Pow(b - a, 1.0 - amount); 48 b = Math.Pow(b - a, 1.0 - amount);
48 return a+b; 49 return a+b;
49 } 50 }
50 public static int powerOf2Log2(int n) { 51
52 public static int PowerOf2Log2(int n) {
51 for (int i = 0; i < 31; i++) { 53 for (int i = 0; i < 31; i++) {
52 if ((n & 1) == 1) { 54 if ((n & 1) == 1) {
53 return i; 55 return i;