mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 18:55:58 +08:00
Merge branch 'master' into careminster-presence-refactor
This commit is contained in:
@@ -70,10 +70,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
#region IMapImageGenerator Members
|
||||
|
||||
public byte[] WriteJpeg2000Image(string gradientmap)
|
||||
public Bitmap CreateMapTile(string gradientmap)
|
||||
{
|
||||
byte[] imageData = null;
|
||||
|
||||
bool drawPrimVolume = true;
|
||||
bool textureTerrain = false;
|
||||
|
||||
@@ -98,32 +96,36 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
}
|
||||
terrainRenderer.Initialise(m_scene, m_config);
|
||||
|
||||
using (Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize))
|
||||
Bitmap mapbmp = new Bitmap((int)Constants.RegionSize, (int)Constants.RegionSize, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
|
||||
//long t = System.Environment.TickCount;
|
||||
//for (int i = 0; i < 10; ++i) {
|
||||
terrainRenderer.TerrainToBitmap(mapbmp);
|
||||
//}
|
||||
//t = System.Environment.TickCount - t;
|
||||
//m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
|
||||
|
||||
|
||||
if (drawPrimVolume)
|
||||
{
|
||||
//long t = System.Environment.TickCount;
|
||||
//for (int i = 0; i < 10; ++i) {
|
||||
terrainRenderer.TerrainToBitmap(mapbmp);
|
||||
//}
|
||||
//t = System.Environment.TickCount - t;
|
||||
//m_log.InfoFormat("[MAPTILE] generation of 10 maptiles needed {0} ms", t);
|
||||
|
||||
|
||||
if (drawPrimVolume)
|
||||
{
|
||||
DrawObjectVolume(m_scene, mapbmp);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
imageData = OpenJPEG.EncodeFromImage(mapbmp, true);
|
||||
}
|
||||
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||
{
|
||||
m_log.Error("Failed generating terrain map: " + e);
|
||||
}
|
||||
DrawObjectVolume(m_scene, mapbmp);
|
||||
}
|
||||
|
||||
return imageData;
|
||||
return mapbmp;
|
||||
}
|
||||
|
||||
public byte[] WriteJpeg2000Image(string gradientmap)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (Bitmap mapbmp = CreateMapTile(gradientmap))
|
||||
return OpenJPEG.EncodeFromImage(mapbmp, true);
|
||||
}
|
||||
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
|
||||
{
|
||||
m_log.Error("Failed generating terrain map: " + e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -37,6 +37,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
{
|
||||
public class ShadedMapTileRenderer : IMapTileTerrainRenderer
|
||||
{
|
||||
private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
|
||||
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
@@ -221,8 +223,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
try
|
||||
{
|
||||
Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
|
||||
mapbmp.SetPixel(x, yr, water);
|
||||
mapbmp.SetPixel(x, yr, WATER_COLOR);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
|
||||
@@ -136,6 +136,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
private static readonly UUID defaultTerrainTexture4 = new UUID("53a2f406-4895-1d13-d541-d2e3b86bc19c");
|
||||
private static readonly Color defaultColor4 = Color.FromArgb(200, 200, 200);
|
||||
|
||||
private static readonly Color WATER_COLOR = Color.FromArgb(29, 71, 95);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -406,8 +408,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
heightvalue = 100f - (heightvalue * 100f) / 19f; // 0 - 19 => 100 - 0
|
||||
|
||||
Color water = Color.FromArgb((int)heightvalue, (int)heightvalue, 255);
|
||||
mapbmp.SetPixel(x, yr, water);
|
||||
mapbmp.SetPixel(x, yr, WATER_COLOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1002,41 +1002,15 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||
|
||||
public void RegenerateMaptile(byte[] data)
|
||||
{
|
||||
// Overwrites the local Asset cache with new maptile data
|
||||
// Assets are single write, this causes the asset server to ignore this update,
|
||||
// but the local asset cache does not
|
||||
|
||||
// this is on purpose! The net result of this is the region always has the most up to date
|
||||
// map tile while protecting the (grid) asset database from bloat caused by a new asset each
|
||||
// time a mapimage is generated!
|
||||
|
||||
UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
|
||||
|
||||
int lastMapRefresh = 0;
|
||||
int twoDays = 172800;
|
||||
// int RefreshSeconds = twoDays;
|
||||
|
||||
try
|
||||
{
|
||||
lastMapRefresh = Convert.ToInt32(m_scene.RegionInfo.lastMapRefresh);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
}
|
||||
catch (OverflowException)
|
||||
{
|
||||
}
|
||||
|
||||
m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE");
|
||||
|
||||
m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random();
|
||||
|
||||
AssetBase asset = new AssetBase(
|
||||
m_scene.RegionInfo.RegionSettings.TerrainImageID,
|
||||
"terrainImage_" + m_scene.RegionInfo.RegionID.ToString() + "_" + lastMapRefresh.ToString(),
|
||||
"terrainImage_" + m_scene.RegionInfo.RegionID.ToString(),
|
||||
(sbyte)AssetType.Texture,
|
||||
m_scene.RegionInfo.RegionID.ToString());
|
||||
asset.Data = data;
|
||||
|
||||
Reference in New Issue
Block a user