Merge branch 'master' into varregion

Conflicts:
	OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs
	OpenSim/Region/CoreModules/World/LegacyMap/ShadedMapTileRenderer.cs
	OpenSim/Region/CoreModules/World/LegacyMap/TexturedMapTileRenderer.cs
varregion
Robert Adams 2014-01-26 07:56:47 -08:00
commit 13a9d5409c
5 changed files with 144 additions and 117 deletions

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
public struct DrawStruct public struct DrawStruct
{ {
public DrawRoutine dr; public DrawRoutine dr;
public Rectangle rect; // public Rectangle rect;
public SolidBrush brush; public SolidBrush brush;
public face[] trns; public face[] trns;
} }
@ -120,6 +120,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{ {
mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID); mapbmp = FetchTexture(m_scene.RegionInfo.RegionSettings.TerrainImageID);
} }
return mapbmp; return mapbmp;
} }
@ -128,7 +129,10 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
try try
{ {
using (Bitmap mapbmp = CreateMapTile()) using (Bitmap mapbmp = CreateMapTile())
return OpenJPEG.EncodeFromImage(mapbmp, true); {
if (mapbmp != null)
return OpenJPEG.EncodeFromImage(mapbmp, true);
}
} }
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
{ {
@ -278,10 +282,9 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
tc = Environment.TickCount; tc = Environment.TickCount;
m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile"); m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
EntityBase[] objs = whichScene.GetEntities(); EntityBase[] objs = whichScene.GetEntities();
Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
//SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
List<float> z_sortheights = new List<float>(); List<float> z_sortheights = new List<float>();
List<uint> z_localIDs = new List<uint>(); List<uint> z_localIDs = new List<uint>();
Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
try try
{ {
@ -294,7 +297,6 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{ {
SceneObjectGroup mapdot = (SceneObjectGroup)obj; SceneObjectGroup mapdot = (SceneObjectGroup)obj;
Color mapdotspot = Color.Gray; // Default color when prim color is white Color mapdotspot = Color.Gray; // Default color when prim color is white
// Loop over prim in group // Loop over prim in group
foreach (SceneObjectPart part in mapdot.Parts) foreach (SceneObjectPart part in mapdot.Parts)
{ {
@ -547,27 +549,25 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
z_localIDs.Add(part.LocalId); z_localIDs.Add(part.LocalId);
z_sortheights.Add(pos.Z); z_sortheights.Add(pos.Z);
//for (int wx = mapdrawstartX; wx < mapdrawendX; wx++) for (int wx = mapdrawstartX; wx < mapdrawendX; wx++)
//{ // {
//for (wy = mapdrawstartY; wy < mapdrawendY; wy++) // for (wy = mapdrawstartY; wy < mapdrawendY; wy++)
//{ // {
//m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy); // m_log.InfoFormat("[MAPDEBUG]: {0},{1}({2})", wx, (255 - wy),wy);
//try // try
//{ // {
// Remember, flip the y! // // Remember, flip the y!
// mapbmp.SetPixel(wx, (255 - wy), mapdotspot); // mapbmp.SetPixel(wx, (255 - wy), mapdotspot);
//} // }
//catch (ArgumentException) // catch (ArgumentException)
//{ // {
// breakYN = true; // breakYN = true;
//} // }
// }
//if (breakYN) // if (breakYN)
// break; // break;
//} // }
// }
//if (breakYN)
// break;
//} //}
} // Object is within 256m Z of terrain } // Object is within 256m Z of terrain
} // object is at least a meter wide } // object is at least a meter wide
@ -581,21 +581,23 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
// Sort prim by Z position // Sort prim by Z position
Array.Sort(sortedZHeights, sortedlocalIds); Array.Sort(sortedZHeights, sortedlocalIds);
Graphics g = Graphics.FromImage(mapbmp); using (Graphics g = Graphics.FromImage(mapbmp))
for (int s = 0; s < sortedZHeights.Length; s++)
{ {
if (z_sort.ContainsKey(sortedlocalIds[s])) for (int s = 0; s < sortedZHeights.Length; s++)
{ {
DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]]; if (z_sort.ContainsKey(sortedlocalIds[s]))
for (int r = 0; r < rectDrawStruct.trns.Length; r++)
{ {
g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts); DrawStruct rectDrawStruct = z_sort[sortedlocalIds[s]];
for (int r = 0; r < rectDrawStruct.trns.Length; r++)
{
g.FillPolygon(rectDrawStruct.brush,rectDrawStruct.trns[r].pts);
}
//g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
} }
//g.FillRectangle(rectDrawStruct.brush , rectDrawStruct.rect);
} }
} }
} // lock(objs) } // lock entities objs
} }
finally finally
{ {
@ -603,9 +605,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
ds.brush.Dispose(); ds.brush.Dispose();
} }
g.Dispose();
m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms"); m_log.Debug("[MAPTILE]: Generating Maptile Step 2: Done in " + (Environment.TickCount - tc) + " ms");
return mapbmp; return mapbmp;
} }

View File

@ -207,7 +207,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{ {
if (!terraincorruptedwarningsaid) if (!terraincorruptedwarningsaid)
{ {
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); 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);
terraincorruptedwarningsaid = true; terraincorruptedwarningsaid = true;
} }
color = Color.Black; color = Color.Black;
@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
{ {
if (!terraincorruptedwarningsaid) if (!terraincorruptedwarningsaid)
{ {
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); 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);
terraincorruptedwarningsaid = true; terraincorruptedwarningsaid = true;
} }
Color black = Color.Black; Color black = Color.Black;
@ -246,7 +246,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
} }
} }
} }
m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
m_log.Debug("[SHADED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
} }
} }
} }

View File

@ -232,10 +232,14 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
if (textureID == UUID.Zero) return defaultColor; // not set if (textureID == UUID.Zero) return defaultColor; // not set
if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures if (m_mapping.ContainsKey(textureID)) return m_mapping[textureID]; // one of the predefined textures
Bitmap bmp = fetchTexture(textureID); Color color;
Color color = bmp == null ? defaultColor : computeAverageColor(bmp);
// store it for future reference using (Bitmap bmp = fetchTexture(textureID))
m_mapping[textureID] = color; {
color = bmp == null ? defaultColor : computeAverageColor(bmp);
// store it for future reference
m_mapping[textureID] = color;
}
return color; return color;
} }
@ -417,7 +421,8 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap
} }
} }
} }
m_log.Debug("[MAPTILE]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
m_log.Debug("[TEXTURED MAP TILE RENDERER]: Generating Maptile Step 1: Done in " + (Environment.TickCount - tc) + " ms");
} }
} }
} }

View File

@ -114,6 +114,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
"export-map [<path>]", "export-map [<path>]",
"Save an image of the world map", HandleExportWorldMapConsoleCommand); "Save an image of the world map", HandleExportWorldMapConsoleCommand);
m_scene.AddCommand(
"Regions", this, "generate map",
"generate map",
"Generates and stores a new maptile.", HandleGenerateMapConsoleCommand);
AddHandlers(); AddHandlers();
} }
} }
@ -1271,6 +1276,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
m_scene.RegionInfo.RegionName, exportPath); m_scene.RegionInfo.RegionName, exportPath);
} }
public void HandleGenerateMapConsoleCommand(string module, string[] cmdparams)
{
Scene consoleScene = m_scene.ConsoleScene();
if (consoleScene != null && consoleScene != m_scene)
return;
GenerateMaptile();
}
public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
{ {
uint xstart = 0; uint xstart = 0;
@ -1502,62 +1517,69 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private Byte[] GenerateOverlay() private Byte[] GenerateOverlay()
{ {
Bitmap overlay = new Bitmap(256, 256); using (Bitmap overlay = new Bitmap(256, 256))
bool[,] saleBitmap = new bool[64, 64];
for (int x = 0 ; x < 64 ; x++)
{ {
for (int y = 0 ; y < 64 ; y++) bool[,] saleBitmap = new bool[64, 64];
saleBitmap[x, y] = false; for (int x = 0 ; x < 64 ; x++)
}
bool landForSale = false;
List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
Color background = Color.FromArgb(0, 0, 0, 0);
SolidBrush transparent = new SolidBrush(background);
Graphics g = Graphics.FromImage(overlay);
g.FillRectangle(transparent, 0, 0, 256, 256);
SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9));
foreach (ILandObject land in parcels)
{
// m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
{ {
landForSale = true; for (int y = 0 ; y < 64 ; y++)
saleBitmap[x, y] = false;
}
saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap()); bool landForSale = false;
List<ILandObject> parcels = m_scene.LandChannel.AllParcels();
Color background = Color.FromArgb(0, 0, 0, 0);
using (Graphics g = Graphics.FromImage(overlay))
{
using (SolidBrush transparent = new SolidBrush(background))
g.FillRectangle(transparent, 0, 0, 256, 256);
foreach (ILandObject land in parcels)
{
// m_log.DebugFormat("[WORLD MAP]: Parcel {0} flags {1}", land.LandData.Name, land.LandData.Flags);
if ((land.LandData.Flags & (uint)ParcelFlags.ForSale) != 0)
{
landForSale = true;
saleBitmap = land.MergeLandBitmaps(saleBitmap, land.GetLandBitmap());
}
}
if (!landForSale)
{
m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
return null;
}
m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
using (SolidBrush yellow = new SolidBrush(Color.FromArgb(255, 249, 223, 9)))
{
for (int x = 0 ; x < 64 ; x++)
{
for (int y = 0 ; y < 64 ; y++)
{
if (saleBitmap[x, y])
g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
}
}
}
}
try
{
return OpenJPEG.EncodeFromImage(overlay, true);
}
catch (Exception e)
{
m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
} }
} }
if (!landForSale)
{
m_log.DebugFormat("[WORLD MAP]: Region {0} has no parcels for sale, not generating overlay", m_scene.RegionInfo.RegionName);
return null;
}
m_log.DebugFormat("[WORLD MAP]: Region {0} has parcels for sale, generating overlay", m_scene.RegionInfo.RegionName);
for (int x = 0 ; x < 64 ; x++)
{
for (int y = 0 ; y < 64 ; y++)
{
if (saleBitmap[x, y])
g.FillRectangle(yellow, x * 4, 252 - (y * 4), 4, 4);
}
}
try
{
return OpenJPEG.EncodeFromImage(overlay, true);
}
catch (Exception e)
{
m_log.DebugFormat("[WORLD MAP]: Error creating parcel overlay: " + e.ToString());
}
return null; return null;
} }
} }

View File

@ -304,7 +304,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
private string GetImageQueuesReport(string[] showParams) private string GetImageQueuesReport(string[] showParams)
{ {
if (showParams.Length < 5 || showParams.Length > 6) if (showParams.Length < 5 || showParams.Length > 6)
return "Usage: image queues show <first-name> <last-name> [full]"; return "Usage: show image queues <first-name> <last-name> [full]";
string firstName = showParams[3]; string firstName = showParams[3];
string lastName = showParams[4]; string lastName = showParams[4];
@ -395,7 +395,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
report.AppendFormat( report.AppendFormat(
"{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n",
"Since", "Since",
"Pkts", "Pkts",
"Pkts", "Pkts",
@ -407,12 +407,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
"Q Pkts", "Q Pkts",
"Q Pkts", "Q Pkts",
"Q Pkts", "Q Pkts",
"Q Pkts",
"Q Pkts"); "Q Pkts");
report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", "");
report.AppendFormat( report.AppendFormat(
"{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7} {12,7}\n", "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n",
"Last In", "Last In",
"In", "In",
"Out", "Out",
@ -424,8 +423,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
"Cloud", "Cloud",
"Task", "Task",
"Texture", "Texture",
"Asset", "Asset");
"State");
lock (m_scenes) lock (m_scenes)
{ {
@ -434,24 +432,24 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
scene.ForEachClient( scene.ForEachClient(
delegate(IClientAPI client) delegate(IClientAPI client)
{ {
bool isChild = client.SceneAgent.IsChildAgent;
if (isChild && !showChildren)
return;
string name = client.Name;
if (pname != "" && name != pname)
return;
string regionName = scene.RegionInfo.RegionName;
report.Append(GetColumnEntry(name, maxNameLength, columnPadding));
report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
if (client is IStatsCollector) if (client is IStatsCollector)
{ {
IStatsCollector stats = (IStatsCollector)client;
bool isChild = client.SceneAgent.IsChildAgent;
if (isChild && !showChildren)
return;
string name = client.Name;
if (pname != "" && name != pname)
return;
string regionName = scene.RegionInfo.RegionName;
report.Append(GetColumnEntry(name, maxNameLength, columnPadding));
report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
IStatsCollector stats = (IStatsCollector)client;
report.AppendLine(stats.Report()); report.AppendLine(stats.Report());
} }
}); });