Merge branch 'master' of /home/opensim/var/repo/opensim
commit
860cf767a1
|
@ -66,6 +66,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
ThreadPriority.Normal,
|
ThreadPriority.Normal,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
|
null,
|
||||||
int.MaxValue);
|
int.MaxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||||
ThreadPriority.Normal,
|
ThreadPriority.Normal,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
|
null,
|
||||||
1000 * 60 * 10);
|
1000 * 60 * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace OpenSim.Framework
|
||||||
const double WATCHDOG_INTERVAL_MS = 2500.0d;
|
const double WATCHDOG_INTERVAL_MS = 2500.0d;
|
||||||
|
|
||||||
/// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary>
|
/// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary>
|
||||||
const int WATCHDOG_TIMEOUT_MS = 5000;
|
public const int WATCHDOG_TIMEOUT_MS = 5000;
|
||||||
|
|
||||||
[System.Diagnostics.DebuggerDisplay("{Thread.Name}")]
|
[System.Diagnostics.DebuggerDisplay("{Thread.Name}")]
|
||||||
public class ThreadWatchdogInfo
|
public class ThreadWatchdogInfo
|
||||||
|
@ -58,7 +58,7 @@ namespace OpenSim.Framework
|
||||||
public int FirstTick { get; private set; }
|
public int FirstTick { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// First time this heartbeat update was invoked
|
/// Last time this heartbeat update was invoked
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int LastTick { get; set; }
|
public int LastTick { get; set; }
|
||||||
|
|
||||||
|
@ -77,6 +77,11 @@ namespace OpenSim.Framework
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AlarmIfTimeout { get; set; }
|
public bool AlarmIfTimeout { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method execute if alarm goes off. If null then no alarm method is fired.
|
||||||
|
/// </summary>
|
||||||
|
public Func<string> AlarmMethod { get; set; }
|
||||||
|
|
||||||
public ThreadWatchdogInfo(Thread thread, int timeout)
|
public ThreadWatchdogInfo(Thread thread, int timeout)
|
||||||
{
|
{
|
||||||
Thread = thread;
|
Thread = thread;
|
||||||
|
@ -87,16 +92,10 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This event is called whenever a tracked thread is stopped or
|
/// This event is called whenever a tracked thread is
|
||||||
/// has not called UpdateThread() in time
|
/// stopped or has not called UpdateThread() in time<
|
||||||
/// </summary>
|
/// /summary>
|
||||||
/// <param name="thread">The thread that has been identified as dead</param>
|
public static event Action<ThreadWatchdogInfo> OnWatchdogTimeout;
|
||||||
/// <param name="lastTick">The last time this thread called UpdateThread()</param>
|
|
||||||
public delegate void WatchdogTimeout(Thread thread, int lastTick);
|
|
||||||
|
|
||||||
/// <summary>This event is called whenever a tracked thread is
|
|
||||||
/// stopped or has not called UpdateThread() in time</summary>
|
|
||||||
public static event WatchdogTimeout OnWatchdogTimeout;
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private static Dictionary<int, ThreadWatchdogInfo> m_threads;
|
private static Dictionary<int, ThreadWatchdogInfo> m_threads;
|
||||||
|
@ -123,7 +122,7 @@ namespace OpenSim.Framework
|
||||||
public static Thread StartThread(
|
public static Thread StartThread(
|
||||||
ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout)
|
ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout)
|
||||||
{
|
{
|
||||||
return StartThread(start, name, priority, isBackground, alarmIfTimeout, WATCHDOG_TIMEOUT_MS);
|
return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, WATCHDOG_TIMEOUT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -135,17 +134,24 @@ namespace OpenSim.Framework
|
||||||
/// <param name="isBackground">True to run this thread as a background
|
/// <param name="isBackground">True to run this thread as a background
|
||||||
/// thread, otherwise false</param>
|
/// thread, otherwise false</param>
|
||||||
/// <param name="alarmIfTimeout">Trigger an alarm function is we have timed out</param>
|
/// <param name="alarmIfTimeout">Trigger an alarm function is we have timed out</param>
|
||||||
|
/// <param name="alarmMethod">
|
||||||
|
/// Alarm method to call if alarmIfTimeout is true and there is a timeout.
|
||||||
|
/// Normally, this will just return some useful debugging information.
|
||||||
|
/// </param>
|
||||||
/// <param name="timeout">Number of milliseconds to wait until we issue a warning about timeout.</param>
|
/// <param name="timeout">Number of milliseconds to wait until we issue a warning about timeout.</param>
|
||||||
/// <returns>The newly created Thread object</returns>
|
/// <returns>The newly created Thread object</returns>
|
||||||
public static Thread StartThread(
|
public static Thread StartThread(
|
||||||
ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout, int timeout)
|
ThreadStart start, string name, ThreadPriority priority, bool isBackground,
|
||||||
|
bool alarmIfTimeout, Func<string> alarmMethod, int timeout)
|
||||||
{
|
{
|
||||||
Thread thread = new Thread(start);
|
Thread thread = new Thread(start);
|
||||||
thread.Name = name;
|
thread.Name = name;
|
||||||
thread.Priority = priority;
|
thread.Priority = priority;
|
||||||
thread.IsBackground = isBackground;
|
thread.IsBackground = isBackground;
|
||||||
|
|
||||||
ThreadWatchdogInfo twi = new ThreadWatchdogInfo(thread, timeout) { AlarmIfTimeout = alarmIfTimeout };
|
ThreadWatchdogInfo twi
|
||||||
|
= new ThreadWatchdogInfo(thread, timeout)
|
||||||
|
{ AlarmIfTimeout = alarmIfTimeout, AlarmMethod = alarmMethod };
|
||||||
|
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[WATCHDOG]: Started tracking thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId);
|
"[WATCHDOG]: Started tracking thread {0}, ID {1}", twi.Thread.Name, twi.Thread.ManagedThreadId);
|
||||||
|
@ -258,7 +264,7 @@ namespace OpenSim.Framework
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
private static void WatchdogTimerElapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
WatchdogTimeout callback = OnWatchdogTimeout;
|
Action<ThreadWatchdogInfo> callback = OnWatchdogTimeout;
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
{
|
{
|
||||||
|
@ -296,7 +302,7 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
if (callbackInfos != null)
|
if (callbackInfos != null)
|
||||||
foreach (ThreadWatchdogInfo callbackInfo in callbackInfos)
|
foreach (ThreadWatchdogInfo callbackInfo in callbackInfos)
|
||||||
callback(callbackInfo.Thread, callbackInfo.LastTick);
|
callback(callbackInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_watchdogTimer.Start();
|
m_watchdogTimer.Start();
|
||||||
|
|
|
@ -438,12 +438,16 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WatchdogTimeoutHandler(System.Threading.Thread thread, int lastTick)
|
private void WatchdogTimeoutHandler(Watchdog.ThreadWatchdogInfo twi)
|
||||||
{
|
{
|
||||||
int now = Environment.TickCount & Int32.MaxValue;
|
int now = Environment.TickCount & Int32.MaxValue;
|
||||||
|
|
||||||
m_log.ErrorFormat("[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago",
|
m_log.ErrorFormat(
|
||||||
thread.Name, thread.ThreadState, now - lastTick);
|
"[WATCHDOG]: Timeout detected for thread \"{0}\". ThreadState={1}. Last tick was {2}ms ago. {3}",
|
||||||
|
twi.Thread.Name,
|
||||||
|
twi.Thread.ThreadState,
|
||||||
|
now - twi.LastTick,
|
||||||
|
twi.AlarmMethod != null ? string.Format("Data: {0}", twi.AlarmMethod()) : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Console Commands
|
#region Console Commands
|
||||||
|
|
|
@ -163,6 +163,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private int m_malformedCount = 0; // Guard against a spamming attack
|
private int m_malformedCount = 0; // Guard against a spamming attack
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Record current outgoing client for monitoring purposes.
|
||||||
|
/// </summary>
|
||||||
|
private IClientAPI m_currentOutgoingClient;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Recording current incoming client for monitoring purposes.
|
||||||
|
/// </summary>
|
||||||
|
private IClientAPI m_currentIncomingClient;
|
||||||
|
|
||||||
public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
|
public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
|
||||||
: base(listenIP, (int)port)
|
: base(listenIP, (int)port)
|
||||||
{
|
{
|
||||||
|
@ -244,19 +254,56 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (m_scene == null)
|
if (m_scene == null)
|
||||||
throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference");
|
throw new InvalidOperationException("[LLUDPSERVER]: Cannot LLUDPServer.Start() without an IScene reference");
|
||||||
|
|
||||||
m_log.Info("[LLUDPSERVER]: Starting the LLUDP server in " + (m_asyncPacketHandling ? "asynchronous" : "synchronous") + " mode");
|
m_log.InfoFormat(
|
||||||
|
"[LLUDPSERVER]: Starting the LLUDP server in {0} mode",
|
||||||
|
m_asyncPacketHandling ? "asynchronous" : "synchronous");
|
||||||
|
|
||||||
base.Start(m_recvBufferSize, m_asyncPacketHandling);
|
base.Start(m_recvBufferSize, m_asyncPacketHandling);
|
||||||
|
|
||||||
// Start the packet processing threads
|
// Start the packet processing threads
|
||||||
Watchdog.StartThread(
|
Watchdog.StartThread(
|
||||||
IncomingPacketHandler, "Incoming Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true);
|
IncomingPacketHandler,
|
||||||
|
string.Format("Incoming Packets ({0})", m_scene.RegionInfo.RegionName),
|
||||||
|
ThreadPriority.Normal,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
GetWatchdogIncomingAlarmData,
|
||||||
|
Watchdog.WATCHDOG_TIMEOUT_MS);
|
||||||
|
|
||||||
Watchdog.StartThread(
|
Watchdog.StartThread(
|
||||||
OutgoingPacketHandler, "Outgoing Packets (" + m_scene.RegionInfo.RegionName + ")", ThreadPriority.Normal, false, true);
|
OutgoingPacketHandler,
|
||||||
|
string.Format("Outgoing Packets ({0})", m_scene.RegionInfo.RegionName),
|
||||||
|
ThreadPriority.Normal,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
GetWatchdogOutgoingAlarmData,
|
||||||
|
Watchdog.WATCHDOG_TIMEOUT_MS);
|
||||||
|
|
||||||
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
m_elapsedMSSinceLastStatReport = Environment.TickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private string GetWatchdogIncomingAlarmData()
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
"Client is {0}",
|
||||||
|
m_currentIncomingClient != null ? m_currentIncomingClient.Name : "none");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If the outgoing UDP thread times out, then return client that was being processed to help with debugging.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private string GetWatchdogOutgoingAlarmData()
|
||||||
|
{
|
||||||
|
return string.Format(
|
||||||
|
"Client is {0}",
|
||||||
|
m_currentOutgoingClient != null ? m_currentOutgoingClient.Name : "none");
|
||||||
|
}
|
||||||
|
|
||||||
public new void Stop()
|
public new void Stop()
|
||||||
{
|
{
|
||||||
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
|
m_log.Info("[LLUDPSERVER]: Shutting down the LLUDP server for " + m_scene.RegionInfo.RegionName);
|
||||||
|
@ -1067,6 +1114,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
client.IsLoggingOut = true;
|
client.IsLoggingOut = true;
|
||||||
client.Close();
|
client.Close();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.WarnFormat(
|
||||||
|
"[LLUDPSERVER]: Tried to remove client with id {0} but not such client in {1}",
|
||||||
|
udpClient.AgentID, m_scene.RegionInfo.RegionName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void IncomingPacketHandler()
|
private void IncomingPacketHandler()
|
||||||
|
@ -1173,6 +1226,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// client. m_packetSent will be set to true if a packet is sent
|
// client. m_packetSent will be set to true if a packet is sent
|
||||||
m_scene.ForEachClient(clientPacketHandler);
|
m_scene.ForEachClient(clientPacketHandler);
|
||||||
|
|
||||||
|
m_currentOutgoingClient = null;
|
||||||
|
|
||||||
// If nothing was sent, sleep for the minimum amount of time before a
|
// If nothing was sent, sleep for the minimum amount of time before a
|
||||||
// token bucket could get more tokens
|
// token bucket could get more tokens
|
||||||
if (!m_packetSent)
|
if (!m_packetSent)
|
||||||
|
@ -1191,6 +1246,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
|
|
||||||
private void ClientOutgoingPacketHandler(IClientAPI client)
|
private void ClientOutgoingPacketHandler(IClientAPI client)
|
||||||
{
|
{
|
||||||
|
m_currentOutgoingClient = client;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (client is LLClientView)
|
if (client is LLClientView)
|
||||||
|
@ -1216,8 +1273,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.Error("[LLUDPSERVER]: OutgoingPacketHandler iteration for " + client.Name +
|
m_log.Error(
|
||||||
" threw an exception: " + ex.Message, ex);
|
string.Format("[LLUDPSERVER]: OutgoingPacketHandler iteration for {0} threw ", client.Name), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1243,6 +1300,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
nticks++;
|
nticks++;
|
||||||
watch1.Start();
|
watch1.Start();
|
||||||
|
m_currentOutgoingClient = client;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (client is LLClientView)
|
if (client is LLClientView)
|
||||||
|
@ -1344,6 +1403,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
// Make sure this client is still alive
|
// Make sure this client is still alive
|
||||||
if (m_scene.TryGetClient(udpClient.AgentID, out client))
|
if (m_scene.TryGetClient(udpClient.AgentID, out client))
|
||||||
{
|
{
|
||||||
|
m_currentIncomingClient = client;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Process this packet
|
// Process this packet
|
||||||
|
@ -1361,6 +1422,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type);
|
m_log.ErrorFormat("[LLUDPSERVER]: Client packet handler for {0} for packet {1} threw an exception", udpClient.AgentID, packet.Type);
|
||||||
m_log.Error(e.Message, e);
|
m_log.Error(e.Message, e);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
m_currentIncomingClient = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
"set terrain heights <corner> <min> <max> [<x>] [<y>]",
|
"set terrain heights <corner> <min> <max> [<x>] [<y>]",
|
||||||
"Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
|
"Sets the terrain texture heights on corner #<corner> to <min>/<max>, if <x> or <y> are specified, it will only " +
|
||||||
"set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
|
"set it on regions with a matching coordinate. Specify -1 in <x> or <y> to wildcard" +
|
||||||
" that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.",
|
" that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3, all corners = -1.",
|
||||||
consoleSetTerrainHeights);
|
consoleSetTerrainHeights);
|
||||||
|
|
||||||
m_module.Scene.AddCommand(
|
m_module.Scene.AddCommand(
|
||||||
|
@ -143,6 +143,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||||
|
|
||||||
switch (corner)
|
switch (corner)
|
||||||
{
|
{
|
||||||
|
case -1:
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation1NW = lowValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation2NW = highValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation1SE = lowValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation2SE = highValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation1NE = lowValue;
|
||||||
|
m_module.Scene.RegionInfo.RegionSettings.Elevation2NE = highValue;
|
||||||
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
|
m_module.Scene.RegionInfo.RegionSettings.Elevation1SW = lowValue;
|
||||||
m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
|
m_module.Scene.RegionInfo.RegionSettings.Elevation2SW = highValue;
|
||||||
|
|
|
@ -178,8 +178,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
|
||||||
// int sztmp = bs.ReadInt16() + 1;
|
// int sztmp = bs.ReadInt16() + 1;
|
||||||
// fileWidth = sztmp;
|
// fileWidth = sztmp;
|
||||||
// fileHeight = sztmp;
|
// fileHeight = sztmp;
|
||||||
bs.ReadInt16();
|
|
||||||
bs.ReadInt16();
|
|
||||||
bs.ReadInt16();
|
bs.ReadInt16();
|
||||||
bs.ReadInt16();
|
bs.ReadInt16();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -84,7 +84,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
Debug.Assert(heightRanges.Length == 4);
|
Debug.Assert(heightRanges.Length == 4);
|
||||||
|
|
||||||
Bitmap[] detailTexture = new Bitmap[4];
|
Bitmap[] detailTexture = new Bitmap[4];
|
||||||
|
Bitmap output = null;
|
||||||
|
BitmapData outputData = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (textureTerrain)
|
if (textureTerrain)
|
||||||
{
|
{
|
||||||
// Swap empty terrain textureIDs with default IDs
|
// Swap empty terrain textureIDs with default IDs
|
||||||
|
@ -138,7 +142,12 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
|
|
||||||
// Make sure this texture is the correct size, otherwise resize
|
// Make sure this texture is the correct size, otherwise resize
|
||||||
if (bitmap.Width != 256 || bitmap.Height != 256)
|
if (bitmap.Width != 256 || bitmap.Height != 256)
|
||||||
bitmap = ImageUtils.ResizeImage(bitmap, 256, 256);
|
{
|
||||||
|
using (Bitmap origBitmap = bitmap)
|
||||||
|
{
|
||||||
|
bitmap = ImageUtils.ResizeImage(origBitmap, 256, 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save the decoded and resized texture to the cache
|
// Save the decoded and resized texture to the cache
|
||||||
byte[] data;
|
byte[] data;
|
||||||
|
@ -241,8 +250,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
|
|
||||||
#region Texture Compositing
|
#region Texture Compositing
|
||||||
|
|
||||||
Bitmap output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
|
||||||
BitmapData outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
|
||||||
|
|
||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
|
@ -297,6 +306,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
detailTexture[i].UnlockBits(datas[i]);
|
detailTexture[i].UnlockBits(datas[i]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
if (detailTexture[i] != null)
|
||||||
|
detailTexture[i].Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
output.UnlockBits(outputData);
|
output.UnlockBits(outputData);
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
private static readonly UUID TEXTURE_METADATA_MAGIC = new UUID("802dc0e0-f080-4931-8b57-d1be8611c4f3");
|
private static readonly UUID TEXTURE_METADATA_MAGIC = new UUID("802dc0e0-f080-4931-8b57-d1be8611c4f3");
|
||||||
private static readonly Color4 WATER_COLOR = new Color4(29, 72, 96, 216);
|
private static readonly Color4 WATER_COLOR = new Color4(29, 72, 96, 216);
|
||||||
|
|
||||||
private static readonly ILog m_log =
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private Scene m_scene;
|
private Scene m_scene;
|
||||||
private IRendering m_primMesher;
|
private IRendering m_primMesher;
|
||||||
|
@ -88,11 +87,11 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
if (renderers.Count > 0)
|
if (renderers.Count > 0)
|
||||||
{
|
{
|
||||||
m_primMesher = RenderingLoader.LoadRenderer(renderers[0]);
|
m_primMesher = RenderingLoader.LoadRenderer(renderers[0]);
|
||||||
m_log.Debug("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString());
|
m_log.DebugFormat("[WARP 3D IMAGE MODULE]: Loaded prim mesher {0}", m_primMesher);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.Debug("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled");
|
m_log.Debug("[WARP 3D IMAGE MODULE]: No prim mesher loaded, prim rendering will be disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.RegisterModuleInterface<IMapImageGenerator>(this);
|
m_scene.RegisterModuleInterface<IMapImageGenerator>(this);
|
||||||
|
@ -150,7 +149,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
m_log.Warn("[MAPTILE]: Failed to load StartupConfig");
|
m_log.Warn("[WARP 3D IMAGE MODULE]: Failed to load StartupConfig");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_colors.Clear();
|
m_colors.Clear();
|
||||||
|
@ -204,7 +203,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
Bitmap bitmap = renderer.Scene.getImage();
|
Bitmap bitmap = renderer.Scene.getImage();
|
||||||
|
|
||||||
if (m_useAntiAliasing)
|
if (m_useAntiAliasing)
|
||||||
bitmap = ImageUtils.ResizeImage(bitmap, viewport.Width, viewport.Height);
|
{
|
||||||
|
using (Bitmap origBitmap = bitmap)
|
||||||
|
bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height);
|
||||||
|
}
|
||||||
|
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +221,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// JPEG2000 encoder failed
|
// JPEG2000 encoder failed
|
||||||
m_log.Error("[MAPTILE]: Failed generating terrain map: " + e);
|
m_log.Error("[WARP 3D IMAGE MODULE]: Failed generating terrain map: ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -318,8 +320,17 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
uint globalX, globalY;
|
uint globalX, globalY;
|
||||||
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);
|
Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);
|
||||||
|
|
||||||
Bitmap image = TerrainSplat.Splat(heightmap, textureIDs, startHeights, heightRanges, new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain);
|
warp_Texture texture;
|
||||||
warp_Texture texture = new warp_Texture(image);
|
|
||||||
|
using (
|
||||||
|
Bitmap image
|
||||||
|
= TerrainSplat.Splat(
|
||||||
|
heightmap, textureIDs, startHeights, heightRanges,
|
||||||
|
new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain))
|
||||||
|
{
|
||||||
|
texture = new warp_Texture(image);
|
||||||
|
}
|
||||||
|
|
||||||
warp_Material material = new warp_Material(texture);
|
warp_Material material = new warp_Material(texture);
|
||||||
material.setReflectivity(50);
|
material.setReflectivity(50);
|
||||||
renderer.Scene.addMaterial("TerrainColor", material);
|
renderer.Scene.addMaterial("TerrainColor", material);
|
||||||
|
@ -546,12 +557,15 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream);
|
int pixelBytes;
|
||||||
|
|
||||||
|
using (Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream))
|
||||||
|
{
|
||||||
width = bitmap.Width;
|
width = bitmap.Width;
|
||||||
height = bitmap.Height;
|
height = bitmap.Height;
|
||||||
|
|
||||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
|
||||||
int pixelBytes = (bitmap.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
|
pixelBytes = (bitmap.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
|
||||||
|
|
||||||
// Sum up the individual channels
|
// Sum up the individual channels
|
||||||
unsafe
|
unsafe
|
||||||
|
@ -586,6 +600,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the averages for each channel
|
// Get the averages for each channel
|
||||||
const decimal OO_255 = 1m / 255m;
|
const decimal OO_255 = 1m / 255m;
|
||||||
|
@ -603,7 +618,10 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.WarnFormat("[MAPTILE]: Error decoding JPEG2000 texture {0} ({1} bytes): {2}", textureID, j2kData.Length, ex.Message);
|
m_log.WarnFormat(
|
||||||
|
"[WARP 3D IMAGE MODULE]: Error decoding JPEG2000 texture {0} ({1} bytes): {2}",
|
||||||
|
textureID, j2kData.Length, ex.Message);
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
height = 0;
|
height = 0;
|
||||||
return new Color4(0.5f, 0.5f, 0.5f, 1.0f);
|
return new Color4(0.5f, 0.5f, 0.5f, 1.0f);
|
|
@ -1343,14 +1343,14 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
if (terrain == null)
|
if (terrain == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
m_log.DebugFormat("[WORLDMAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
byte[] data = terrain.WriteJpeg2000Image();
|
byte[] data = terrain.WriteJpeg2000Image();
|
||||||
if (data == null)
|
if (data == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte[] overlay = GenerateOverlay();
|
byte[] overlay = GenerateOverlay();
|
||||||
|
|
||||||
m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE");
|
|
||||||
|
|
||||||
UUID terrainImageID = UUID.Random();
|
UUID terrainImageID = UUID.Random();
|
||||||
UUID parcelImageID = UUID.Zero;
|
UUID parcelImageID = UUID.Zero;
|
||||||
|
|
||||||
|
@ -1365,7 +1365,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
asset.Flags = AssetFlags.Maptile;
|
asset.Flags = AssetFlags.Maptile;
|
||||||
|
|
||||||
// Store the new one
|
// Store the new one
|
||||||
m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID);
|
m_log.DebugFormat("[WORLDMAP]: Storing map tile {0} for {1}", asset.ID, m_scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
m_scene.AssetService.Store(asset);
|
m_scene.AssetService.Store(asset);
|
||||||
|
|
||||||
if (overlay != null)
|
if (overlay != null)
|
||||||
|
|
|
@ -113,14 +113,15 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
|
||||||
if (!m_Enabled)
|
if (!m_Enabled)
|
||||||
return new Byte[0];
|
return new Byte[0];
|
||||||
|
|
||||||
Bitmap bmp = m_Generator.CreateViewImage(pos, rot, fov, width,
|
using (Bitmap bmp = m_Generator.CreateViewImage(pos, rot, fov, width, height, usetex))
|
||||||
height, usetex);
|
{
|
||||||
|
using (MemoryStream str = new MemoryStream())
|
||||||
MemoryStream str = new MemoryStream();
|
{
|
||||||
|
|
||||||
bmp.Save(str, ImageFormat.Jpeg);
|
bmp.Save(str, ImageFormat.Jpeg);
|
||||||
|
|
||||||
return str.ToArray();
|
return str.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue