aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World
diff options
context:
space:
mode:
authorMelanie2014-01-28 21:02:20 +0000
committerMelanie2014-01-28 21:02:20 +0000
commitc6e9db58669d773c85041db99b19b942f70324f7 (patch)
tree99f69fb669332cff69a45ce6f7473aed6d965a0d /OpenSim/Region/CoreModules/World
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'justincc-master' (diff)
downloadopensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.zip
opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.gz
opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.bz2
opensim-SC_OLD-c6e9db58669d773c85041db99b19b942f70324f7.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/RegionSettings.cs OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs OpenSim/Region/Framework/Interfaces/IInterregionComms.cs OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs538
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs27
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs126
8 files changed, 376 insertions, 359 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
index a990898..7a844f4 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs
@@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
178 178
179 // Archive the regions 179 // Archive the regions
180 180
181 Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>(); 181 Dictionary<UUID, sbyte> assetUuids = new Dictionary<UUID, sbyte>();
182 182
183 scenesGroup.ForEachScene(delegate(Scene scene) 183 scenesGroup.ForEachScene(delegate(Scene scene)
184 { 184 {
@@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
216 } 216 }
217 } 217 }
218 218
219 private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) 219 private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, sbyte> assetUuids)
220 { 220 {
221 m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); 221 m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName);
222 222
@@ -276,16 +276,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
276 RegionSettings regionSettings = scene.RegionInfo.RegionSettings; 276 RegionSettings regionSettings = scene.RegionInfo.RegionSettings;
277 277
278 if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1) 278 if (regionSettings.TerrainTexture1 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_1)
279 assetUuids[regionSettings.TerrainTexture1] = AssetType.Texture; 279 assetUuids[regionSettings.TerrainTexture1] = (sbyte)AssetType.Texture;
280 280
281 if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2) 281 if (regionSettings.TerrainTexture2 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_2)
282 assetUuids[regionSettings.TerrainTexture2] = AssetType.Texture; 282 assetUuids[regionSettings.TerrainTexture2] = (sbyte)AssetType.Texture;
283 283
284 if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3) 284 if (regionSettings.TerrainTexture3 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_3)
285 assetUuids[regionSettings.TerrainTexture3] = AssetType.Texture; 285 assetUuids[regionSettings.TerrainTexture3] = (sbyte)AssetType.Texture;
286 286
287 if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4) 287 if (regionSettings.TerrainTexture4 != RegionSettings.DEFAULT_TERRAIN_TEXTURE_4)
288 assetUuids[regionSettings.TerrainTexture4] = AssetType.Texture; 288 assetUuids[regionSettings.TerrainTexture4] = (sbyte)AssetType.Texture;
289 289
290 Save(scene, sceneObjects, regionDir); 290 Save(scene, sceneObjects, regionDir);
291 } 291 }
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index ada7ecc..6c2a631 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -81,7 +81,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
81 /// <value> 81 /// <value>
82 /// uuids to request 82 /// uuids to request
83 /// </value> 83 /// </value>
84 protected IDictionary<UUID, AssetType> m_uuids; 84 protected IDictionary<UUID, sbyte> m_uuids;
85 85
86 /// <value> 86 /// <value>
87 /// Callback used when all the assets requested have been received. 87 /// Callback used when all the assets requested have been received.
@@ -115,7 +115,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
115 protected Dictionary<string, object> m_options; 115 protected Dictionary<string, object> m_options;
116 116
117 protected internal AssetsRequest( 117 protected internal AssetsRequest(
118 AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids, 118 AssetsArchiver assetsArchiver, IDictionary<UUID, sbyte> uuids,
119 IAssetService assetService, IUserAccountService userService, 119 IAssetService assetService, IUserAccountService userService,
120 UUID scope, Dictionary<string, object> options, 120 UUID scope, Dictionary<string, object> options,
121 AssetsRequestCallback assetsRequestCallback) 121 AssetsRequestCallback assetsRequestCallback)
@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
154 154
155 m_requestCallbackTimer.Enabled = true; 155 m_requestCallbackTimer.Enabled = true;
156 156
157 foreach (KeyValuePair<UUID, AssetType> kvp in m_uuids) 157 foreach (KeyValuePair<UUID, sbyte> kvp in m_uuids)
158 { 158 {
159// m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key); 159// m_log.DebugFormat("[ARCHIVER]: Requesting asset {0}", kvp.Key);
160 160
@@ -235,9 +235,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
235 // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer 235 // Check for broken asset types and fix them with the AssetType gleaned by UuidGatherer
236 if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown) 236 if (fetchedAsset != null && fetchedAsset.Type == (sbyte)AssetType.Unknown)
237 { 237 {
238 AssetType type = (AssetType)assetType; 238 m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, SLUtil.AssetTypeFromCode((sbyte)assetType));
239 m_log.InfoFormat("[ARCHIVER]: Rewriting broken asset type for {0} to {1}", fetchedAsset.ID, type); 239 fetchedAsset.Type = (sbyte)assetType;
240 fetchedAsset.Type = (sbyte)type;
241 } 240 }
242 241
243 AssetRequestCallback(fetchedAssetID, this, fetchedAsset); 242 AssetRequestCallback(fetchedAssetID, this, fetchedAsset);
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
index 173b603..1659493 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs
@@ -60,7 +60,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
60 60
61 public void Initialise() 61 public void Initialise()
62 { 62 {
63 m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName); 63// m_log.DebugFormat("[ESTATE MODULE]: Setting up estate commands for region {0}", m_module.Scene.RegionInfo.RegionName);
64 64
65 m_module.Scene.AddCommand("Regions", m_module, "set terrain texture", 65 m_module.Scene.AddCommand("Regions", m_module, "set terrain texture",
66 "set terrain texture <number> <uuid> [<x>] [<y>]", 66 "set terrain texture <number> <uuid> [<x>] [<y>]",
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
index 4750b46..7aa1ced 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
@@ -712,7 +712,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
712 } 712 }
713 } 713 }
714 714
715 public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) 715 public void HandleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1)
716 { 716 {
717 SceneObjectPart part; 717 SceneObjectPart part;
718 718
@@ -752,7 +752,9 @@ namespace OpenSim.Region.CoreModules.World.Estate
752 default: 752 default:
753 break; 753 break;
754 } 754 }
755 SendTelehubInfo(client); 755
756 if (client != null)
757 SendTelehubInfo(client);
756 } 758 }
757 759
758 private void SendSimulatorBlueBoxMessage( 760 private void SendSimulatorBlueBoxMessage(
@@ -1224,7 +1226,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
1224 client.OnEstateRestartSimRequest += handleEstateRestartSimRequest; 1226 client.OnEstateRestartSimRequest += handleEstateRestartSimRequest;
1225 client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest; 1227 client.OnEstateChangeCovenantRequest += handleChangeEstateCovenantRequest;
1226 client.OnEstateChangeInfo += handleEstateChangeInfo; 1228 client.OnEstateChangeInfo += handleEstateChangeInfo;
1227 client.OnEstateManageTelehub += handleOnEstateManageTelehub; 1229 client.OnEstateManageTelehub += HandleOnEstateManageTelehub;
1228 client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest; 1230 client.OnUpdateEstateAccessDeltaRequest += handleEstateAccessDeltaRequest;
1229 client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage; 1231 client.OnSimulatorBlueBoxMessageRequest += SendSimulatorBlueBoxMessage;
1230 client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage; 1232 client.OnEstateBlueBoxMessageRequest += SendEstateBlueBoxMessage;
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
index 40638f8..bc52a43 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
55 public struct DrawStruct 55 public struct DrawStruct
56 { 56 {
57 public DrawRoutine dr; 57 public DrawRoutine dr;
58 public Rectangle rect; 58// public Rectangle rect;
59 public SolidBrush brush; 59 public SolidBrush brush;
60 public face[] trns; 60 public face[] trns;
61 } 61 }
@@ -119,6 +119,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
119 { 119 {
120 mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); 120 mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
121 } 121 }
122
122 return mapbmp; 123 return mapbmp;
123 } 124 }
124 125
@@ -127,7 +128,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
127 try 128 try
128 { 129 {
129 using (Bitmap mapbmp = CreateMapTile()) 130 using (Bitmap mapbmp = CreateMapTile())
130 return OpenJPEG.EncodeFromImage(mapbmp, true); 131 {
132 if (mapbmp != null)
133 return OpenJPEG.EncodeFromImage(mapbmp, true);
134 }
131 } 135 }
132 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke 136 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
133 { 137 {
@@ -277,321 +281,331 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
277 tc = Environment.TickCount; 281 tc = Environment.TickCount;
278 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); 282 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
279 EntityBase[] objs = whichScene.GetEntities(); 283 EntityBase[] objs = whichScene.GetEntities();
280 Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
281 //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
282 List<float> z_sortheights = new List<float>(); 284 List<float> z_sortheights = new List<float>();
283 List<uint> z_localIDs = new List<uint>(); 285 List<uint> z_localIDs = new List<uint>();
286 Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
284 287
285 lock (objs) 288 try
286 { 289 {
287 foreach (EntityBase obj in objs) 290 //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
291
292 lock (objs)
288 { 293 {
289 // Only draw the contents of SceneObjectGroup 294 foreach (EntityBase obj in objs)
290 if (obj is SceneObjectGroup)
291 { 295 {
292 SceneObjectGroup mapdot = (SceneObjectGroup)obj; 296 // Only draw the contents of SceneObjectGroup
293 Color mapdotspot = Color.Gray; // Default color when prim color is white 297 if (obj is SceneObjectGroup)
294
295 // Loop over prim in group
296 foreach (SceneObjectPart part in mapdot.Parts)
297 { 298 {
298 if (part == null) 299 SceneObjectGroup mapdot = (SceneObjectGroup)obj;
299 continue; 300 Color mapdotspot = Color.Gray; // Default color when prim color is white
300 301
301 // Draw if the object is at least 1 meter wide in any direction 302 // Loop over prim in group
302 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f) 303 foreach (SceneObjectPart part in mapdot.Parts)
303 { 304 {
304 // Try to get the RGBA of the default texture entry.. 305 if (part == null)
305 // 306 continue;
306 try 307
308 // Draw if the object is at least 1 meter wide in any direction
309 if (part.Scale.X > 1f || part.Scale.Y > 1f || part.Scale.Z > 1f)
307 { 310 {
308 // get the null checks out of the way 311 // Try to get the RGBA of the default texture entry..
309 // skip the ones that break 312 //
310 if (part == null) 313 try
311 continue; 314 {
315 // get the null checks out of the way
316 // skip the ones that break
317 if (part == null)
318 continue;
312 319
313 if (part.Shape == null) 320 if (part.Shape == null)
314 continue; 321 continue;
315 322
316 if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass) 323 if (part.Shape.PCode == (byte)PCode.Tree || part.Shape.PCode == (byte)PCode.NewTree || part.Shape.PCode == (byte)PCode.Grass)
317 continue; // eliminates trees from this since we don't really have a good tree representation 324 continue; // eliminates trees from this since we don't really have a good tree representation
318 // if you want tree blocks on the map comment the above line and uncomment the below line 325 // if you want tree blocks on the map comment the above line and uncomment the below line
319 //mapdotspot = Color.PaleGreen; 326 //mapdotspot = Color.PaleGreen;
320 327
321 Primitive.TextureEntry textureEntry = part.Shape.Textures; 328 Primitive.TextureEntry textureEntry = part.Shape.Textures;
322 329
323 if (textureEntry == null || textureEntry.DefaultTexture == null) 330 if (textureEntry == null || textureEntry.DefaultTexture == null)
324 continue; 331 continue;
325 332
326 Color4 texcolor = textureEntry.DefaultTexture.RGBA; 333 Color4 texcolor = textureEntry.DefaultTexture.RGBA;
327 334
328 // Not sure why some of these are null, oh well. 335 // Not sure why some of these are null, oh well.
329 336
330 int colorr = 255 - (int)(texcolor.R * 255f); 337 int colorr = 255 - (int)(texcolor.R * 255f);
331 int colorg = 255 - (int)(texcolor.G * 255f); 338 int colorg = 255 - (int)(texcolor.G * 255f);
332 int colorb = 255 - (int)(texcolor.B * 255f); 339 int colorb = 255 - (int)(texcolor.B * 255f);
333 340
334 if (!(colorr == 255 && colorg == 255 && colorb == 255)) 341 if (!(colorr == 255 && colorg == 255 && colorb == 255))
335 {
336 //Try to set the map spot color
337 try
338 {
339 // If the color gets goofy somehow, skip it *shakes fist at Color4
340 mapdotspot = Color.FromArgb(colorr, colorg, colorb);
341 }
342 catch (ArgumentException)
343 { 342 {
343 //Try to set the map spot color
344 try
345 {
346 // If the color gets goofy somehow, skip it *shakes fist at Color4
347 mapdotspot = Color.FromArgb(colorr, colorg, colorb);
348 }
349 catch (ArgumentException)
350 {
351 }
344 } 352 }
345 } 353 }
346 } 354 catch (IndexOutOfRangeException)
347 catch (IndexOutOfRangeException) 355 {
348 { 356 // Windows Array
349 // Windows Array 357 }
350 } 358 catch (ArgumentOutOfRangeException)
351 catch (ArgumentOutOfRangeException) 359 {
352 { 360 // Mono Array
353 // Mono Array 361 }
354 }
355
356 Vector3 pos = part.GetWorldPosition();
357
358 // skip prim outside of retion
359 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
360 continue;
361
362 // skip prim in non-finite position
363 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
364 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
365 continue;
366
367 // Figure out if object is under 256m above the height of the terrain
368 bool isBelow256AboveTerrain = false;
369 362
370 try 363 Vector3 pos = part.GetWorldPosition();
371 {
372 isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
373 }
374 catch (Exception)
375 {
376 }
377 364
378 if (isBelow256AboveTerrain) 365 // skip prim outside of retion
379 { 366 if (pos.X < 0f || pos.X > 256f || pos.Y < 0f || pos.Y > 256f)
380 // Translate scale by rotation so scale is represented properly when object is rotated
381 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
382 Vector3 scale = new Vector3();
383 Vector3 tScale = new Vector3();
384 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
385
386 Quaternion llrot = part.GetWorldRotation();
387 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
388 scale = lscale * rot;
389
390 // negative scales don't work in this situation
391 scale.X = Math.Abs(scale.X);
392 scale.Y = Math.Abs(scale.Y);
393 scale.Z = Math.Abs(scale.Z);
394
395 // This scaling isn't very accurate and doesn't take into account the face rotation :P
396 int mapdrawstartX = (int)(pos.X - scale.X);
397 int mapdrawstartY = (int)(pos.Y - scale.Y);
398 int mapdrawendX = (int)(pos.X + scale.X);
399 int mapdrawendY = (int)(pos.Y + scale.Y);
400
401 // If object is beyond the edge of the map, don't draw it to avoid errors
402 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
403 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
404 || mapdrawendY > ((int)Constants.RegionSize - 1))
405 continue; 367 continue;
406 368
407#region obb face reconstruction part duex 369 // skip prim in non-finite position
408 Vector3[] vertexes = new Vector3[8]; 370 if (Single.IsNaN(pos.X) || Single.IsNaN(pos.Y) ||
409 371 Single.IsInfinity(pos.X) || Single.IsInfinity(pos.Y))
410 // float[] distance = new float[6]; 372 continue;
411 Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
412 Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
413 Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
414 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
415
416 tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
417 scale = ((tScale * rot));
418 vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
419 // vertexes[0].x = pos.X + vertexes[0].x;
420 //vertexes[0].y = pos.Y + vertexes[0].y;
421 //vertexes[0].z = pos.Z + vertexes[0].z;
422
423 FaceA[0] = vertexes[0];
424 FaceB[3] = vertexes[0];
425 FaceA[4] = vertexes[0];
426
427 tScale = lscale;
428 scale = ((tScale * rot));
429 vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
430
431 // vertexes[1].x = pos.X + vertexes[1].x;
432 // vertexes[1].y = pos.Y + vertexes[1].y;
433 //vertexes[1].z = pos.Z + vertexes[1].z;
434
435 FaceB[0] = vertexes[1];
436 FaceA[1] = vertexes[1];
437 FaceC[4] = vertexes[1];
438
439 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
440 scale = ((tScale * rot));
441
442 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
443
444 //vertexes[2].x = pos.X + vertexes[2].x;
445 //vertexes[2].y = pos.Y + vertexes[2].y;
446 //vertexes[2].z = pos.Z + vertexes[2].z;
447
448 FaceC[0] = vertexes[2];
449 FaceD[3] = vertexes[2];
450 FaceC[5] = vertexes[2];
451
452 tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
453 scale = ((tScale * rot));
454 vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
455
456 //vertexes[3].x = pos.X + vertexes[3].x;
457 // vertexes[3].y = pos.Y + vertexes[3].y;
458 // vertexes[3].z = pos.Z + vertexes[3].z;
459
460 FaceD[0] = vertexes[3];
461 FaceC[1] = vertexes[3];
462 FaceA[5] = vertexes[3];
463
464 tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
465 scale = ((tScale * rot));
466 vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
467
468 // vertexes[4].x = pos.X + vertexes[4].x;
469 // vertexes[4].y = pos.Y + vertexes[4].y;
470 // vertexes[4].z = pos.Z + vertexes[4].z;
471
472 FaceB[1] = vertexes[4];
473 FaceA[2] = vertexes[4];
474 FaceD[4] = vertexes[4];
475
476 tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
477 scale = ((tScale * rot));
478 vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
479
480 // vertexes[5].x = pos.X + vertexes[5].x;
481 // vertexes[5].y = pos.Y + vertexes[5].y;
482 // vertexes[5].z = pos.Z + vertexes[5].z;
483
484 FaceD[1] = vertexes[5];
485 FaceC[2] = vertexes[5];
486 FaceB[5] = vertexes[5];
487 373
488 tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z); 374 // Figure out if object is under 256m above the height of the terrain
489 scale = ((tScale * rot)); 375 bool isBelow256AboveTerrain = false;
490 vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
491 376
492 // vertexes[6].x = pos.X + vertexes[6].x; 377 try
493 // vertexes[6].y = pos.Y + vertexes[6].y; 378 {
494 // vertexes[6].z = pos.Z + vertexes[6].z; 379 isBelow256AboveTerrain = (pos.Z < ((float)hm[(int)pos.X, (int)pos.Y] + 256f));
380 }
381 catch (Exception)
382 {
383 }
495 384
496 FaceB[2] = vertexes[6]; 385 if (isBelow256AboveTerrain)
497 FaceA[3] = vertexes[6]; 386 {
498 FaceB[4] = vertexes[6]; 387 // Translate scale by rotation so scale is represented properly when object is rotated
388 Vector3 lscale = new Vector3(part.Shape.Scale.X, part.Shape.Scale.Y, part.Shape.Scale.Z);
389 Vector3 scale = new Vector3();
390 Vector3 tScale = new Vector3();
391 Vector3 axPos = new Vector3(pos.X,pos.Y,pos.Z);
392
393 Quaternion llrot = part.GetWorldRotation();
394 Quaternion rot = new Quaternion(llrot.W, llrot.X, llrot.Y, llrot.Z);
395 scale = lscale * rot;
396
397 // negative scales don't work in this situation
398 scale.X = Math.Abs(scale.X);
399 scale.Y = Math.Abs(scale.Y);
400 scale.Z = Math.Abs(scale.Z);
401
402 // This scaling isn't very accurate and doesn't take into account the face rotation :P
403 int mapdrawstartX = (int)(pos.X - scale.X);
404 int mapdrawstartY = (int)(pos.Y - scale.Y);
405 int mapdrawendX = (int)(pos.X + scale.X);
406 int mapdrawendY = (int)(pos.Y + scale.Y);
407
408 // If object is beyond the edge of the map, don't draw it to avoid errors
409 if (mapdrawstartX < 0 || mapdrawstartX > ((int)Constants.RegionSize - 1) || mapdrawendX < 0 || mapdrawendX > ((int)Constants.RegionSize - 1)
410 || mapdrawstartY < 0 || mapdrawstartY > ((int)Constants.RegionSize - 1) || mapdrawendY < 0
411 || mapdrawendY > ((int)Constants.RegionSize - 1))
412 continue;
413
414 #region obb face reconstruction part duex
415 Vector3[] vertexes = new Vector3[8];
416
417 // float[] distance = new float[6];
418 Vector3[] FaceA = new Vector3[6]; // vertex A for Facei
419 Vector3[] FaceB = new Vector3[6]; // vertex B for Facei
420 Vector3[] FaceC = new Vector3[6]; // vertex C for Facei
421 Vector3[] FaceD = new Vector3[6]; // vertex D for Facei
422
423 tScale = new Vector3(lscale.X, -lscale.Y, lscale.Z);
424 scale = ((tScale * rot));
425 vertexes[0] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
426 // vertexes[0].x = pos.X + vertexes[0].x;
427 //vertexes[0].y = pos.Y + vertexes[0].y;
428 //vertexes[0].z = pos.Z + vertexes[0].z;
429
430 FaceA[0] = vertexes[0];
431 FaceB[3] = vertexes[0];
432 FaceA[4] = vertexes[0];
433
434 tScale = lscale;
435 scale = ((tScale * rot));
436 vertexes[1] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
437
438 // vertexes[1].x = pos.X + vertexes[1].x;
439 // vertexes[1].y = pos.Y + vertexes[1].y;
440 //vertexes[1].z = pos.Z + vertexes[1].z;
441
442 FaceB[0] = vertexes[1];
443 FaceA[1] = vertexes[1];
444 FaceC[4] = vertexes[1];
445
446 tScale = new Vector3(lscale.X, -lscale.Y, -lscale.Z);
447 scale = ((tScale * rot));
448
449 vertexes[2] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
450
451 //vertexes[2].x = pos.X + vertexes[2].x;
452 //vertexes[2].y = pos.Y + vertexes[2].y;
453 //vertexes[2].z = pos.Z + vertexes[2].z;
454
455 FaceC[0] = vertexes[2];
456 FaceD[3] = vertexes[2];
457 FaceC[5] = vertexes[2];
458
459 tScale = new Vector3(lscale.X, lscale.Y, -lscale.Z);
460 scale = ((tScale * rot));
461 vertexes[3] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
462
463 //vertexes[3].x = pos.X + vertexes[3].x;
464 // vertexes[3].y = pos.Y + vertexes[3].y;
465 // vertexes[3].z = pos.Z + vertexes[3].z;
466
467 FaceD[0] = vertexes[3];
468 FaceC[1] = vertexes[3];
469 FaceA[5] = vertexes[3];
470
471 tScale = new Vector3(-lscale.X, lscale.Y, lscale.Z);
472 scale = ((tScale * rot));
473 vertexes[4] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
474
475 // vertexes[4].x = pos.X + vertexes[4].x;
476 // vertexes[4].y = pos.Y + vertexes[4].y;
477 // vertexes[4].z = pos.Z + vertexes[4].z;
478
479 FaceB[1] = vertexes[4];
480 FaceA[2] = vertexes[4];
481 FaceD[4] = vertexes[4];
482
483 tScale = new Vector3(-lscale.X, lscale.Y, -lscale.Z);
484 scale = ((tScale * rot));
485 vertexes[5] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
486
487 // vertexes[5].x = pos.X + vertexes[5].x;
488 // vertexes[5].y = pos.Y + vertexes[5].y;
489 // vertexes[5].z = pos.Z + vertexes[5].z;
490
491 FaceD[1] = vertexes[5];
492 FaceC[2] = vertexes[5];
493 FaceB[5] = vertexes[5];
494
495 tScale = new Vector3(-lscale.X, -lscale.Y, lscale.Z);
496 scale = ((tScale * rot));
497 vertexes[6] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
498
499 // vertexes[6].x = pos.X + vertexes[6].x;
500 // vertexes[6].y = pos.Y + vertexes[6].y;
501 // vertexes[6].z = pos.Z + vertexes[6].z;
502
503 FaceB[2] = vertexes[6];
504 FaceA[3] = vertexes[6];
505 FaceB[4] = vertexes[6];
499 506
500 tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z); 507 tScale = new Vector3(-lscale.X, -lscale.Y, -lscale.Z);
501 scale = ((tScale * rot)); 508 scale = ((tScale * rot));
502 vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z))); 509 vertexes[7] = (new Vector3((pos.X + scale.X), (pos.Y + scale.Y), (pos.Z + scale.Z)));
503 510
504 // vertexes[7].x = pos.X + vertexes[7].x; 511 // vertexes[7].x = pos.X + vertexes[7].x;
505 // vertexes[7].y = pos.Y + vertexes[7].y; 512 // vertexes[7].y = pos.Y + vertexes[7].y;
506 // vertexes[7].z = pos.Z + vertexes[7].z; 513 // vertexes[7].z = pos.Z + vertexes[7].z;
507 514
508 FaceD[2] = vertexes[7]; 515 FaceD[2] = vertexes[7];
509 FaceC[3] = vertexes[7]; 516 FaceC[3] = vertexes[7];
510 FaceD[5] = vertexes[7]; 517 FaceD[5] = vertexes[7];
511#endregion 518 #endregion
512 519
513 //int wy = 0; 520 //int wy = 0;
514 521
515 //bool breakYN = false; // If we run into an error drawing, break out of the 522 //bool breakYN = false; // If we run into an error drawing, break out of the
516 // loop so we don't lag to death on error handling 523 // loop so we don't lag to death on error handling
517 DrawStruct ds = new DrawStruct(); 524 DrawStruct ds = new DrawStruct();
518 ds.brush = new SolidBrush(mapdotspot); 525 ds.brush = new SolidBrush(mapdotspot);
519 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); 526 //ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
520 527
521 ds.trns = new face[FaceA.Length]; 528 ds.trns = new face[FaceA.Length];
522 529
523 for (int i = 0; i < FaceA.Length; i++) 530 for (int i = 0; i < FaceA.Length; i++)
524 { 531 {
525 Point[] working = new Point[5]; 532 Point[] working = new Point[5];
526 working[0] = project(FaceA[i], axPos); 533 working[0] = project(FaceA[i], axPos);
527 working[1] = project(FaceB[i], axPos); 534 working[1] = project(FaceB[i], axPos);
528 working[2] = project(FaceD[i], axPos); 535 working[2] = project(FaceD[i], axPos);
529 working[3] = project(FaceC[i], axPos); 536 working[3] = project(FaceC[i], axPos);
530 working[4] = project(FaceA[i], axPos); 537 working[4] = project(FaceA[i], axPos);
531 538
532 face workingface = new face(); 539 face workingface = new face();
533 workingface.pts = working; 540 workingface.pts = working;
534 541
535 ds.trns[i] = workingface; 542 ds.trns[i] = workingface;
536 } 543 }
537 544
538 z_sort.Add(part.LocalId, ds); 545 z_sort.Add(part.LocalId, ds);
539 z_localIDs.Add(part.LocalId); 546 z_localIDs.Add(part.LocalId);
540 z_sortheights.Add(pos.Z); 547 z_sortheights.Add(pos.Z);
541 548
542 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) 549 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
543 //{
544 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
545 //{ 550 //{
546 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); 551 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
547 //try
548 //{
549 // Remember, flip the y!
550 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
551 //}
552 //catch (ArgumentException)
553 //{ 552 //{
554 // breakYN = true; 553 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
554 //try
555 //{
556 // Remember, flip the y!
557 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
558 //}
559 //catch (ArgumentException)
560 //{
561 // breakYN = true;
562 //}
563
564 //if (breakYN)
565 // break;
555 //} 566 //}
556 567
557 //if (breakYN) 568 //if (breakYN)
558 // break; 569 // break;
559 //} 570 //}
571 } // Object is within 256m Z of terrain
572 } // object is at least a meter wide
573 } // loop over group children
574 } // entitybase is sceneobject group
575 } // foreach loop over entities
560 576
561 //if (breakYN) 577 float[] sortedZHeights = z_sortheights.ToArray();
562 // break; 578 uint[] sortedlocalIds = z_localIDs.ToArray();
563 //}
564 } // Object is within 256m Z of terrain
565 } // object is at least a meter wide
566 } // loop over group children
567 } // entitybase is sceneobject group
568 } // foreach loop over entities
569
570 float[] sortedZHeights = z_sortheights.ToArray();
571 uint[] sortedlocalIds = z_localIDs.ToArray();
572
573 // Sort prim by Z position
574 Array.Sort(sortedZHeights, sortedlocalIds);
575 579
576 Graphics g = Graphics.FromImage(mapbmp); 580 // Sort prim by Z position
581 Array.Sort(sortedZHeights, sortedlocalIds);
577 582
578 for (int s = 0; s < sortedZHeights.Length; s++) 583 using (Graphics g = Graphics.FromImage(mapbmp))
579 {
580 if (z_sort.ContainsKey(sortedlocalIds[s]))
581 { 584 {
582 DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; 585 for (int s = 0; s < sortedZHeights.Length; s++)
583 for (int r = 0; r < rectDrawStruct.trns.Length; r++)
584 { 586 {
585 g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); 587 if (z_sort.ContainsKey(sortedlocalIds[s]))
588 {
589 DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
590 for (int r = 0; r < rectDrawStruct.trns.Length; r++)
591 {
592 g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
593 }
594 //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
595 }
586 } 596 }
587 //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
588 } 597 }
589 } 598 } // lock entities objs
590 599
591 g.Dispose(); 600 }
592 } // lock entities objs 601 finally
602 {
603 foreach (DrawStruct ds in z_sort.Values)
604 ds.brush.Dispose();
605 }
593 606
594 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); 607 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
608
595 return mapbmp; 609 return mapbmp;
596 } 610 }
597 611
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
index 992bff3..cb06fd4 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
54 public void TerrainToBitmap(Bitmap mapbmp) 54 public void TerrainToBitmap(Bitmap mapbmp)
55 { 55 {
56 int tc = Environment.TickCount; 56 int tc = Environment.TickCount;
57 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); 57 m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain");
58 58
59 double[,] hm = m_scene.Heightmap.GetDoubles(); 59 double[,] hm = m_scene.Heightmap.GetDoubles();
60 bool ShadowDebugContinue = true; 60 bool ShadowDebugContinue = true;
@@ -199,7 +199,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
199 { 199 {
200 if (!terraincorruptedwarningsaid) 200 if (!terraincorruptedwarningsaid)
201 { 201 {
202 m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); 202 m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
203 terraincorruptedwarningsaid = true; 203 terraincorruptedwarningsaid = true;
204 } 204 }
205 color = Color.Black; 205 color = Color.Black;
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
229 { 229 {
230 if (!terraincorruptedwarningsaid) 230 if (!terraincorruptedwarningsaid)
231 { 231 {
232 m_log.WarnFormat("[MAPIMAGE]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName); 232 m_log.WarnFormat("[SHADED MAP TILE RENDERER]: Your terrain is corrupted in region {0}, it might take a few minutes to generate the map image depending on the corruption level", m_scene.RegionInfo.RegionName);
233 terraincorruptedwarningsaid = true; 233 terraincorruptedwarningsaid = true;
234 } 234 }
235 Color black = Color.Black; 235 Color black = Color.Black;
@@ -238,7 +238,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
238 } 238 }
239 } 239 }
240 } 240 }
241 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); 241
242 m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
242 } 243 }
243 } 244 }
244} 245} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index d13c2ef..e895178 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
173 private Bitmap fetchTexture(UUID id) 173 private Bitmap fetchTexture(UUID id)
174 { 174 {
175 AssetBase asset = m_scene.AssetService.Get(id.ToString()); 175 AssetBase asset = m_scene.AssetService.Get(id.ToString());
176 m_log.DebugFormat("[TexturedMapTileRenderer]: Fetched texture {0}, found: {1}", id, asset != null); 176 m_log.DebugFormat("[TEXTURED MAP TILE RENDERER]: Fetched texture {0}, found: {1}", id, asset != null);
177 if (asset == null) return null; 177 if (asset == null) return null;
178 178
179 ManagedImage managedImage; 179 ManagedImage managedImage;
@@ -188,17 +188,17 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
188 } 188 }
189 catch (DllNotFoundException) 189 catch (DllNotFoundException)
190 { 190 {
191 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id); 191 m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg is not installed correctly on this system. Asset Data is empty for {0}", id);
192 192
193 } 193 }
194 catch (IndexOutOfRangeException) 194 catch (IndexOutOfRangeException)
195 { 195 {
196 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); 196 m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
197 197
198 } 198 }
199 catch (Exception) 199 catch (Exception)
200 { 200 {
201 m_log.ErrorFormat("[TexturedMapTileRenderer]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id); 201 m_log.ErrorFormat("[TEXTURED MAP TILE RENDERER]: OpenJpeg was unable to encode this. Asset Data is empty for {0}", id);
202 202
203 } 203 }
204 return null; 204 return null;
@@ -233,10 +233,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
233 if (textureID == UUID.Zero) return defaultColor; // not set 233 if (textureID == UUID.Zero) return defaultColor; // not set
234 if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures 234 if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures
235 235
236 Bitmap bmp = fetchTexture(textureID); 236 Color color;
237 Color color = bmp == null ? defaultColor : computeAverageColor(bmp); 237
238 // store it for future reference 238 using (Bitmap bmp = fetchTexture(textureID))
239 m_mapping[textureID] = color; 239 {
240 color = bmp == null ? defaultColor : computeAverageColor(bmp);
241 // store it for future reference
242 m_mapping[textureID] = color;
243 }
240 244
241 return color; 245 return color;
242 } 246 }
@@ -278,7 +282,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
278 public void TerrainToBitmap(Bitmap mapbmp) 282 public void TerrainToBitmap(Bitmap mapbmp)
279 { 283 {
280 int tc = Environment.TickCount; 284 int tc = Environment.TickCount;
281 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Terrain"); 285 m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Terrain");
282 286
283 // These textures should be in the AssetCache anyway, as every client conneting to this 287 // These textures should be in the AssetCache anyway, as every client conneting to this
284 // region needs them. Except on start, when the map is recreated (before anyone connected), 288 // region needs them. Except on start, when the map is recreated (before anyone connected),
@@ -412,7 +416,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
412 } 416 }
413 } 417 }
414 } 418 }
415 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); 419
420 m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
416 } 421 }
417 } 422 }
418} 423} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index 98fa763..5412359 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
115 "export-map [<path>]", 115 "export-map [<path>]",
116 "Save an image of the world map", HandleExportWorldMapConsoleCommand); 116 "Save an image of the world map", HandleExportWorldMapConsoleCommand);
117 117
118 m_scene.AddCommand(
119 "Regions", this, "generate map",
120 "generate map",
121 "Generates and stores a new maptile.", HandleGenerateMapConsoleCommand);
122
118 AddHandlers(); 123 AddHandlers();
119 } 124 }
120 } 125 }
@@ -1324,6 +1329,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1324 m_scene.RegionInfo.RegionName, exportPath); 1329 m_scene.RegionInfo.RegionName, exportPath);
1325 } 1330 }
1326 1331
1332 public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams)
1333 {
1334 Scene consoleScene = m_scene.ConsoleScene();
1335
1336 if (consoleScene != null && consoleScene != m_scene)
1337 return;
1338
1339 GenerateMaptile();
1340 }
1341
1327 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) 1342 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
1328 { 1343 {
1329 uint xstart = 0; 1344 uint xstart = 0;
@@ -1561,88 +1576,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1561 1576
1562 private Byte[] GenerateOverlay() 1577 private Byte[] GenerateOverlay()
1563 { 1578 {
1564 Bitmap overlay = new Bitmap(256, 256); 1579 using (Bitmap overlay = new Bitmap(256, 256))
1565
1566 bool[,] saleBitmap = new bool[64, 64];
1567 for (int x = 0 ; x < 64 ; x++)
1568 { 1580 {
1569 for (int y = 0 ; y < 64 ; y++) 1581 bool[,] saleBitmap = new bool[64, 64];
1570 saleBitmap[x, y] = false; 1582 for (int x = 0 ; x < 64 ; x++)
1571 } 1583 {
1572 1584 for (int y = 0 ; y < 64 ; y++)
1573 bool landForSale = false; 1585 saleBitmap[x, y] = false;
1586 }
1574 1587
1575 List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); 1588 bool landForSale = false;
1576 1589
1577 Color background = Color.FromArgb(0, 0, 0, 0); 1590 List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
1578 SolidBrush transparent = new SolidBrush(background);
1579 Graphics g = Graphics.FromImage(overlay);
1580 g.FillRectangle(transparent, 0, 0, 255, 255);
1581 1591
1582 SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); 1592 Color background = Color.FromArgb(0, 0, 0, 0);
1583 Pen grey = new Pen(Color.FromArgb(255, 92, 92, 92));
1584 1593
1585 foreach (ILandObject land in parcels) 1594 using (Graphics g = Graphics.FromImage(overlay))
1586 {
1587 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1588 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1589 { 1595 {
1590 landForSale = true; 1596 using (SolidBrush transparent = new SolidBrush(background))
1591 1597 g.FillRectangle(transparent, 0, 0, 256, 256);
1592 bool[,] landBitmap = land.GetLandBitmap(); 1598
1599
1600 foreach (ILandObject land in parcels)
1601 {
1602 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1603 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1604 {
1605 landForSale = true;
1606
1607 saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
1608 }
1609 }
1610
1611 if (!landForSale)
1612 {
1613 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
1614 return null;
1615 }
1616
1617 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
1593 1618
1594 for (int x = 0 ; x < 64 ; x++) 1619 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
1595 { 1620 {
1596 for (int y = 0 ; y < 64 ; y++) 1621 for (int x = 0 ; x < 64 ; x++)
1597 { 1622 {
1598 if (landBitmap[x, y]) 1623 for (int y = 0 ; y < 64 ; y++)
1599 { 1624 {
1600 g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); 1625 if (saleBitmap[x, y])
1601 1626 g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
1602 if (x > 0)
1603 {
1604 if ((saleBitmap[x - 1, y] || landBitmap[x - 1, y]) == false)
1605 g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4, 255 - (y * 4));
1606 }
1607 if (y > 0)
1608 {
1609 if ((saleBitmap[x, y-1] || landBitmap[x, y-1]) == false)
1610 g.DrawLine(grey, x * 4, 255 - (y * 4), x * 4 + 3, 255 - (y * 4));
1611 }
1612 if (x < 63)
1613 {
1614 if ((saleBitmap[x + 1, y] || landBitmap[x + 1, y]) == false)
1615 g.DrawLine(grey, x * 4 + 3, 252 - (y * 4), x * 4 + 3, 255 - (y * 4));
1616 }
1617 if (y < 63)
1618 {
1619 if ((saleBitmap[x, y + 1] || landBitmap[x, y + 1]) == false)
1620 g.DrawLine(grey, x * 4, 252 - (y * 4), x * 4 + 3, 252 - (y * 4));
1621 }
1622 } 1627 }
1623 } 1628 }
1624 } 1629 }
1625
1626 saleBitmap = land.MergeLandBitmaps(saleBitmap, landBitmap);
1627 } 1630 }
1628 }
1629 1631
1630 if (!landForSale) 1632 try
1631 { 1633 {
1632 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); 1634 return OpenJPEG.EncodeFromImage(overlay, true);
1633 return null; 1635 }
1636 catch (Exception e)
1637 {
1638 m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
1639 }
1634 } 1640 }
1635 1641
1636 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
1637
1638 try
1639 {
1640 return OpenJPEG.EncodeFromImage(overlay, true);
1641 }
1642 catch (Exception e)
1643 {
1644 m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
1645 }
1646 return null; 1642 return null;
1647 } 1643 }
1648 } 1644 }