aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-08-18 03:25:23 +0000
committerTeravus Ovares2008-08-18 03:25:23 +0000
commitf842ad4192e993586e5af014122781663acf8960 (patch)
treefe2366433d7882d257ebf147fb19ae41284a77cb /OpenSim
parent* Text/comment cleanup in MapImageModule (diff)
downloadopensim-SC_OLD-f842ad4192e993586e5af014122781663acf8960.zip
opensim-SC_OLD-f842ad4192e993586e5af014122781663acf8960.tar.gz
opensim-SC_OLD-f842ad4192e993586e5af014122781663acf8960.tar.bz2
opensim-SC_OLD-f842ad4192e993586e5af014122781663acf8960.tar.xz
* 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.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/World/WorldMap/MapImageModule.cs85
1 files 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 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Drawing; 31using System.Drawing;
32using System.Drawing.Drawing2D;
33using System.Drawing.Imaging;
31using System.Reflection; 34using System.Reflection;
32using Axiom.Math; 35using Axiom.Math;
33using Nini.Config; 36using Nini.Config;
@@ -39,6 +42,12 @@ using libsecondlife;
39 42
40namespace OpenSim.Region.Environment.Modules.World.WorldMap 43namespace OpenSim.Region.Environment.Modules.World.WorldMap
41{ 44{
45 public struct RectangleDrawStruct
46 {
47 public Rectangle rect;
48 public SolidBrush brush;
49 }
50
42 public class MapImageModule : IMapImageGenerator, IRegionModule 51 public class MapImageModule : IMapImageGenerator, IRegionModule
43 { 52 {
44 private static readonly ILog m_log = 53 private static readonly ILog m_log =
@@ -352,6 +361,10 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
352 tc = System.Environment.TickCount; 361 tc = System.Environment.TickCount;
353 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); 362 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
354 List<EntityBase> objs = whichScene.GetEntities(); 363 List<EntityBase> objs = whichScene.GetEntities();
364 Dictionary<uint, RectangleDrawStruct> z_sort = new Dictionary<uint, RectangleDrawStruct>();
365 //SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
366 List<float> z_sortheights = new List<float>();
367 List<uint> z_localIDs = new List<uint>();
355 368
356 lock (objs) 369 lock (objs)
357 { 370 {
@@ -476,33 +489,65 @@ namespace OpenSim.Region.Environment.Modules.World.WorldMap
476 489
477 bool breakYN = false; // If we run into an error drawing, break out of the 490 bool breakYN = false; // If we run into an error drawing, break out of the
478 // loop so we don't lag to death on error handling 491 // loop so we don't lag to death on error handling
479 for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) 492 RectangleDrawStruct ds = new RectangleDrawStruct();
480 { 493 ds.brush = new SolidBrush(mapdotspot);
481 for (wy = mapdrawstartY; wy < mapdrawendY; wy++) 494 ds.rect = new Rectangle(mapdrawstartX, (255 - mapdrawstartY), mapdrawendX - mapdrawstartX, mapdrawendY - mapdrawstartY);
482 { 495 z_sort.Add(part.LocalId, ds);
496 z_localIDs.Add(part.LocalId);
497 z_sortheights.Add(pos.Z);
498
499
500
501 //for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
502 //{
503 //for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
504 //{
483 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); 505 //m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
484 try 506 //try
485 { 507 //{
486 // Remember, flip the y! 508 // Remember, flip the y!
487 mapbmp.SetPixel(wx, (255 - wy), mapdotspot); 509 // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
488 } 510 //}
489 catch (ArgumentException) 511 //catch (ArgumentException)
490 { 512 //{
491 breakYN = true; 513 // breakYN = true;
492 } 514 //}
493 515
494 if (breakYN) 516 //if (breakYN)
495 break; 517 // break;
496 } 518 //}
497 519
498 if (breakYN) 520 //if (breakYN)
499 break; 521 // break;
500 } 522 //}
501 } // Object is within 256m Z of terrain 523 } // Object is within 256m Z of terrain
502 } // object is at least a meter wide 524 } // object is at least a meter wide
503 } // loop over group children 525 } // loop over group children
504 } // entitybase is sceneobject group 526 } // entitybase is sceneobject group
505 } // foreach loop over entities 527 } // foreach loop over entities
528
529 float[] sortedZHeights = z_sortheights.ToArray();
530 uint[] sortedlocalIds = z_localIDs.ToArray();
531
532 // Sort prim by Z position
533 Array.Sort(sortedZHeights, sortedlocalIds);
534
535
536
537 Graphics g = Graphics.FromImage(mapbmp);
538
539 for (int s = 0; s < sortedZHeights.Length; s++)
540 {
541
542 if (z_sort.ContainsKey(sortedlocalIds[s]))
543 {
544 RectangleDrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
545 g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
546 }
547 }
548
549
550 g.Dispose();
506 } // lock entities objs 551 } // lock entities objs
507 552
508 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (System.Environment.TickCount - tc) + " ms"); 553 m_log.Info("[MAPTILE]: Generating Maptile Step 2: Done in " + (System.Environment.TickCount - tc) + " ms");