aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs77
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs106
4 files changed, 117 insertions, 88 deletions
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
index 165ea6e..81d1a4a 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 }
@@ -120,6 +120,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
120 { 120 {
121 mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); 121 mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
122 } 122 }
123
123 return mapbmp; 124 return mapbmp;
124 } 125 }
125 126
@@ -128,7 +129,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
128 try 129 try
129 { 130 {
130 using (Bitmap mapbmp = CreateMapTile()) 131 using (Bitmap mapbmp = CreateMapTile())
131 return OpenJPEG.EncodeFromImage(mapbmp, true); 132 {
133 if (mapbmp != null)
134 return OpenJPEG.EncodeFromImage(mapbmp, true);
135 }
132 } 136 }
133 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke 137 catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
134 { 138 {
@@ -278,12 +282,11 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
278 tc = Environment.TickCount; 282 tc = Environment.TickCount;
279 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); 283 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
280 EntityBase[] objs = whichScene.GetEntities(); 284 EntityBase[] objs = whichScene.GetEntities();
281 Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
282 //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
283 List<float> z_sortheights = new List<float>(); 285 List<float> z_sortheights = new List<float>();
284 List<uint> z_localIDs = new List<uint>(); 286 List<uint> z_localIDs = new List<uint>();
287 Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
285 288
286 try 289 try
287 { 290 {
288 lock (objs) 291 lock (objs)
289 { 292 {
@@ -294,7 +297,6 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
294 { 297 {
295 SceneObjectGroup mapdot = (SceneObjectGroup)obj; 298 SceneObjectGroup mapdot = (SceneObjectGroup)obj;
296 Color mapdotspot = Color.Gray; // Default color when prim color is white 299 Color mapdotspot = Color.Gray; // Default color when prim color is white
297
298 // Loop over prim in group 300 // Loop over prim in group
299 foreach (SceneObjectPart part in mapdot.Parts) 301 foreach (SceneObjectPart part in mapdot.Parts)
300 { 302 {
@@ -547,27 +549,25 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
547 z_localIDs.Add(part.LocalId); 549 z_localIDs.Add(part.LocalId);
548 z_sortheights.Add(pos.Z); 550 z_sortheights.Add(pos.Z);
549 551
550 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) 552 for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
551 //{ 553 // {
552 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) 554 // for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
553 //{ 555 // {
554 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); 556 // m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
555 //try 557 // try
556 //{ 558 // {
557 // Remember, flip the y! 559 // // Remember, flip the y!
558 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); 560 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
559 //} 561 // }
560 //catch (ArgumentException) 562 // catch (ArgumentException)
561 //{ 563 // {
562 // breakYN = true; 564 // breakYN = true;
563 //} 565 // }
564 566 // }
565 //if (breakYN) 567 // if (breakYN)
566 // break; 568 // break;
567 //} 569 // }
568 570 // }
569 //if (breakYN)
570 // break;
571 //} 571 //}
572 } // Object is within 256m Z of terrain 572 } // Object is within 256m Z of terrain
573 } // object is at least a meter wide 573 } // object is at least a meter wide
@@ -581,21 +581,23 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
581 // Sort prim by Z position 581 // Sort prim by Z position
582 Array.Sort(sortedZHeights, sortedlocalIds); 582 Array.Sort(sortedZHeights, sortedlocalIds);
583 583
584 Graphics g = Graphics.FromImage(mapbmp); 584 using (Graphics g = Graphics.FromImage(mapbmp))
585
586 for (int s = 0; s < sortedZHeights.Length; s++)
587 { 585 {
588 if (z_sort.ContainsKey(sortedlocalIds[s])) 586 for (int s = 0; s < sortedZHeights.Length; s++)
589 { 587 {
590 DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; 588 if (z_sort.ContainsKey(sortedlocalIds[s]))
591 for (int r = 0; r < rectDrawStruct.trns.Length; r++)
592 { 589 {
593 g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); 590 DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
591 for (int r = 0; r < rectDrawStruct.trns.Length; r++)
592 {
593 g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
594 }
595 //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
594 } 596 }
595 //g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
596 } 597 }
597 } 598 }
598 } // lock(objs) 599 } // lock entities objs
600
599 } 601 }
600 finally 602 finally
601 { 603 {
@@ -603,9 +605,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
603 ds.brush.Dispose(); 605 ds.brush.Dispose();
604 } 606 }
605 607
606 g.Dispose();
607
608 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); 608 m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
609
609 return mapbmp; 610 return mapbmp;
610 } 611 }
611 612
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
index 9b939c9..708286c 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
@@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
207 { 207 {
208 if (!terraincorruptedwarningsaid) 208 if (!terraincorruptedwarningsaid)
209 { 209 {
210 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); 210 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);
211 terraincorruptedwarningsaid = true; 211 terraincorruptedwarningsaid = true;
212 } 212 }
213 color = Color.Black; 213 color = Color.Black;
@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
237 { 237 {
238 if (!terraincorruptedwarningsaid) 238 if (!terraincorruptedwarningsaid)
239 { 239 {
240 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); 240 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);
241 terraincorruptedwarningsaid = true; 241 terraincorruptedwarningsaid = true;
242 } 242 }
243 Color black = Color.Black; 243 Color black = Color.Black;
@@ -246,7 +246,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
246 } 246 }
247 } 247 }
248 } 248 }
249 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); 249
250 m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
250 } 251 }
251 } 252 }
252} 253}
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
index 413ac64..9f23141 100644
--- a/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
+++ b/OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
@@ -232,10 +232,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
232 if (textureID == UUID.Zero) return defaultColor; // not set 232 if (textureID == UUID.Zero) return defaultColor; // not set
233 if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures 233 if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures
234 234
235 Bitmap bmp = fetchTexture(textureID); 235 Color color;
236 Color color = bmp == null ? defaultColor : computeAverageColor(bmp); 236
237 // store it for future reference 237 using (Bitmap bmp = fetchTexture(textureID))
238 m_mapping[textureID] = color; 238 {
239 color = bmp == null ? defaultColor : computeAverageColor(bmp);
240 // store it for future reference
241 m_mapping[textureID] = color;
242 }
239 243
240 return color; 244 return color;
241 } 245 }
@@ -417,7 +421,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
417 } 421 }
418 } 422 }
419 } 423 }
420 m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms"); 424
425 m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
421 } 426 }
422 } 427 }
423} 428}
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
index e925f0d..b472038 100644
--- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
+++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs
@@ -114,6 +114,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
114 "export-map [<path>]", 114 "export-map [<path>]",
115 "Save an image of the world map", HandleExportWorldMapConsoleCommand); 115 "Save an image of the world map", HandleExportWorldMapConsoleCommand);
116 116
117 m_scene.AddCommand(
118 "Regions", this, "generate map",
119 "generate map",
120 "Generates and stores a new maptile.", HandleGenerateMapConsoleCommand);
121
117 AddHandlers(); 122 AddHandlers();
118 } 123 }
119 } 124 }
@@ -1271,6 +1276,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1271 m_scene.RegionInfo.RegionName, exportPath); 1276 m_scene.RegionInfo.RegionName, exportPath);
1272 } 1277 }
1273 1278
1279 public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams)
1280 {
1281 Scene consoleScene = m_scene.ConsoleScene();
1282
1283 if (consoleScene != null && consoleScene != m_scene)
1284 return;
1285
1286 GenerateMaptile();
1287 }
1288
1274 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) 1289 public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
1275 { 1290 {
1276 uint xstart = 0; 1291 uint xstart = 0;
@@ -1502,62 +1517,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
1502 1517
1503 private Byte[] GenerateOverlay() 1518 private Byte[] GenerateOverlay()
1504 { 1519 {
1505 Bitmap overlay = new Bitmap(256, 256); 1520 using (Bitmap overlay = new Bitmap(256, 256))
1506
1507 bool[,] saleBitmap = new bool[64, 64];
1508 for (int x = 0 ; x < 64 ; x++)
1509 { 1521 {
1510 for (int y = 0 ; y < 64 ; y++) 1522 bool[,] saleBitmap = new bool[64, 64];
1511 saleBitmap[x, y] = false; 1523 for (int x = 0 ; x < 64 ; x++)
1512 } 1524 {
1513 1525 for (int y = 0 ; y < 64 ; y++)
1514 bool landForSale = false; 1526 saleBitmap[x, y] = false;
1527 }
1515 1528
1516 List<ILandObject> parcels = m_scene.LandChannel.AllParcels(); 1529 bool landForSale = false;
1517 1530
1518 Color background = Color.FromArgb(0, 0, 0, 0); 1531 List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
1519 SolidBrush transparent = new SolidBrush(background);
1520 Graphics g = Graphics.FromImage(overlay);
1521 g.FillRectangle(transparent, 0, 0, 256, 256);
1522 1532
1523 SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)); 1533 Color background = Color.FromArgb(0, 0, 0, 0);
1524 1534
1525 foreach (ILandObject land in parcels) 1535 using (Graphics g = Graphics.FromImage(overlay))
1526 {
1527 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1528 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1529 { 1536 {
1530 landForSale = true; 1537 using (SolidBrush transparent = new SolidBrush(background))
1538 g.FillRectangle(transparent, 0, 0, 256, 256);
1531 1539
1532 saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
1533 }
1534 }
1535 1540
1536 if (!landForSale) 1541 foreach (ILandObject land in parcels)
1537 { 1542 {
1538 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName); 1543 // m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
1539 return null; 1544 if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
1540 } 1545 {
1546 landForSale = true;
1547
1548 saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
1549 }
1550 }
1551
1552 if (!landForSale)
1553 {
1554 m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
1555 return null;
1556 }
1541 1557
1542 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName); 1558 m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
1543 1559
1544 for (int x = 0 ; x < 64 ; x++) 1560 using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
1545 { 1561 {
1546 for (int y = 0 ; y < 64 ; y++) 1562 for (int x = 0 ; x < 64 ; x++)
1563 {
1564 for (int y = 0 ; y < 64 ; y++)
1565 {
1566 if (saleBitmap[x, y])
1567 g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
1568 }
1569 }
1570 }
1571 }
1572
1573 try
1547 { 1574 {
1548 if (saleBitmap[x, y]) 1575 return OpenJPEG.EncodeFromImage(overlay, true);
1549 g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4); 1576 }
1577 catch (Exception e)
1578 {
1579 m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
1550 } 1580 }
1551 } 1581 }
1552 1582
1553 try
1554 {
1555 return OpenJPEG.EncodeFromImage(overlay, true);
1556 }
1557 catch (Exception e)
1558 {
1559 m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
1560 }
1561 return null; 1583 return null;
1562 } 1584 }
1563 } 1585 }