From f842ad4192e993586e5af014122781663acf8960 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Mon, 18 Aug 2008 03:25:23 +0000 Subject: * Maptile prim volume drawing change from manually drawing the rectangles using Bitmap.setpixel to a drawing2d graphics context. * Z-sort the prim volumes before drawing. --- .../Modules/World/WorldMap/MapImageModule.cs | 85 +++++++++++++++++----- 1 file changed, 65 insertions(+), 20 deletions(-) diff --git a/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs b/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs index ac6d9b5..52ee84d 100644 --- a/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs +++ b/OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs @@ -26,8 +26,11 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Imaging; using System.Reflection; using Axiom.Math; using Nini.Config; @@ -39,6 +42,12 @@ using libsecondlife; namespace OpenSim.Region.Environment.Modules.World.WorldMap { + public struct RectangleDrawStruct + { + public Rectangle rect; + public SolidBrush brush; + } + public class MapImageModule : IMapImageGenerator, IRegionModule { private static readonly ILog m_log = @@ -352,6 +361,10 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap tc = System.Environment.TickCount; m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); List objs = whichScene.GetEntities(); + Dictionary z_sort = new Dictionary(); + //SortedList z_sort = new SortedList(); + List z_sortheights = new List(); + List z_localIDs = new List(); lock (objs) { @@ -476,33 +489,65 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap bool breakYN = false; // If we run into an error drawing, break out of the // loop so we don't lag to death on error handling - for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) - { - for (wy = mapdrawstartY; wy < mapdrawendY; wy++) - { + RectangleDrawStruct ds = new RectangleDrawStruct(); + ds.brush = new SolidBrush(mapdotspot); + ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY); + z_sort.Add(part.LocalId, ds); + z_localIDs.Add(part.LocalId); + z_sortheights.Add(pos.Z); + + + + //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) + //{ + //for (wy = mapdrawstartY; wy < mapdrawendY; wy++) + //{ //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); - try - { + //try + //{ // Remember, flip the y! - mapbmp.SetPixel(wx, (255 - wy), mapdotspot); - } - catch (ArgumentException) - { - breakYN = true; - } - - if (breakYN) - break; - } - - if (breakYN) - break; - } + // mapbmp.SetPixel(wx, (255 - wy), mapdotspot); + //} + //catch (ArgumentException) + //{ + // breakYN = true; + //} + + //if (breakYN) + // break; + //} + + //if (breakYN) + // break; + //} } // Object is within 256m Z of terrain } // object is at least a meter wide } // loop over group children } // entitybase is sceneobject group } // foreach loop over entities + + float[] sortedZHeights = z_sortheights.ToArray(); + uint[] sortedlocalIds = z_localIDs.ToArray(); + + // Sort prim by Z position + Array.Sort(sortedZHeights, sortedlocalIds); + + + + Graphics g = Graphics.FromImage(mapbmp); + + for (int s = 0; s < sortedZHeights.Length; s++) + { + + if (z_sort.ContainsKey(sortedlocalIds[s])) + { + RectangleDrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; + g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect); + } + } + + + g.Dispose(); } // lock entities objs m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (System.Environment.TickCount - tc) + " ms"); -- cgit v1.1