diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | 77 |
1 files changed, 39 insertions, 38 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 | ||