Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs
	OpenSim/Region/Framework/Scenes/Scene.cs
	OpenSim/Region/Framework/Scenes/SimStatsReporter.cs
avinationmerge
Melanie 2012-06-06 13:07:05 +01:00
commit e733fb32cf
17 changed files with 523 additions and 441 deletions

View File

@ -971,8 +971,7 @@ namespace OpenSim
if (showParams.Length > 1 && showParams[1] == "full") if (showParams.Length > 1 && showParams[1] == "full")
{ {
agents = m_sceneManager.GetCurrentScenePresences(); agents = m_sceneManager.GetCurrentScenePresences();
} } else
else
{ {
agents = m_sceneManager.GetCurrentSceneAvatars(); agents = m_sceneManager.GetCurrentSceneAvatars();
} }
@ -981,7 +980,8 @@ namespace OpenSim
MainConsole.Instance.Output( MainConsole.Instance.Output(
String.Format("{0,-16} {1,-16} {2,-37} {3,-11} {4,-16} {5,-30}", "Firstname", "Lastname", String.Format("{0,-16} {1,-16} {2,-37} {3,-11} {4,-16} {5,-30}", "Firstname", "Lastname",
"Agent ID", "Root/Child", "Region", "Position")); "Agent ID", "Root/Child", "Region", "Position")
);
foreach (ScenePresence presence in agents) foreach (ScenePresence presence in agents)
{ {
@ -991,8 +991,7 @@ namespace OpenSim
if (regionInfo == null) if (regionInfo == null)
{ {
regionName = "Unresolvable"; regionName = "Unresolvable";
} } else
else
{ {
regionName = regionInfo.RegionName; regionName = regionInfo.RegionName;
} }
@ -1005,7 +1004,8 @@ namespace OpenSim
presence.UUID, presence.UUID,
presence.IsChildAgent ? "Child" : "Root", presence.IsChildAgent ? "Child" : "Root",
regionName, regionName,
presence.AbsolutePosition.ToString())); presence.AbsolutePosition.ToString())
);
} }
MainConsole.Instance.Output(String.Empty); MainConsole.Instance.Output(String.Empty);
@ -1014,16 +1014,20 @@ namespace OpenSim
case "connections": case "connections":
System.Text.StringBuilder connections = new System.Text.StringBuilder("Connections:\n"); System.Text.StringBuilder connections = new System.Text.StringBuilder("Connections:\n");
m_sceneManager.ForEachScene( m_sceneManager.ForEachScene(
delegate(Scene scene) delegate(Scene scene) {
{ scene.ForEachClient(
scene.ForEachClient( delegate(IClientAPI client) {
delegate(IClientAPI client) connections.AppendFormat(
{ "{0}: {1} ({2}) from {3} on circuit {4}\n",
connections.AppendFormat("{0}: {1} ({2}) from {3} on circuit {4}\n", scene.RegionInfo.RegionName,
scene.RegionInfo.RegionName, client.Name, client.AgentId, client.RemoteEndPoint, client.CircuitCode); client.Name,
} client.AgentId,
client.RemoteEndPoint,
client.CircuitCode
); );
} }
);
}
); );
MainConsole.Instance.Output(connections.ToString()); MainConsole.Instance.Output(connections.ToString());
@ -1032,13 +1036,17 @@ namespace OpenSim
case "circuits": case "circuits":
System.Text.StringBuilder acd = new System.Text.StringBuilder("Agent Circuits:\n"); System.Text.StringBuilder acd = new System.Text.StringBuilder("Agent Circuits:\n");
m_sceneManager.ForEachScene( m_sceneManager.ForEachScene(
delegate(Scene scene) delegate(Scene scene) {
{ //this.HttpServer.
//this.HttpServer. acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName);
acd.AppendFormat("{0}:\n", scene.RegionInfo.RegionName); foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.GetAgentCircuits().Values)
foreach (AgentCircuitData aCircuit in scene.AuthenticateHandler.GetAgentCircuits().Values) acd.AppendFormat(
acd.AppendFormat("\t{0} {1} ({2})\n", aCircuit.firstname, aCircuit.lastname, (aCircuit.child ? "Child" : "Root")); "\t{0} {1} ({2})\n",
} aCircuit.firstname,
aCircuit.lastname,
(aCircuit.child ? "Child" : "Root")
);
}
); );
MainConsole.Instance.Output(acd.ToString()); MainConsole.Instance.Output(acd.ToString());
@ -1079,17 +1087,29 @@ namespace OpenSim
} }
m_sceneManager.ForEachScene( m_sceneManager.ForEachScene(
delegate(Scene scene) delegate(Scene scene) {
m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:");
foreach (IRegionModule module in scene.Modules.Values)
{ {
m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:"); if (!module.IsSharedModule)
foreach (IRegionModule module in scene.Modules.Values)
{ {
if (!module.IsSharedModule) m_log.Error("Region Module: " + module.Name);
{
m_log.Error("Region Module: " + module.Name);
}
} }
}); }
}
);
m_sceneManager.ForEachScene(
delegate(Scene scene) {
MainConsole.Instance.Output("Loaded new region modules in" + scene.RegionInfo.RegionName + " are:");
foreach (IRegionModuleBase module in scene.RegionModules.Values)
{
Type type = module.GetType().GetInterface("ISharedRegionModule");
string module_type = type != null ? "Shared" : "Non-Shared";
MainConsole.Instance.OutputFormat("New Region Module ({0}): {1}", module_type, module.Name);
}
}
);
MainConsole.Instance.Output(""); MainConsole.Instance.Output("");
break; break;

View File

@ -155,7 +155,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private int m_defaultRTO = 0; private int m_defaultRTO = 0;
private int m_maxRTO = 0; private int m_maxRTO = 0;
private int m_ackTimeout = 0;
private int m_pausedAckTimeout = 0;
private bool m_disableFacelights = false; private bool m_disableFacelights = false;
public Socket Server { get { return null; } } public Socket Server { get { return null; } }
@ -198,11 +199,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_defaultRTO = config.GetInt("DefaultRTO", 0); m_defaultRTO = config.GetInt("DefaultRTO", 0);
m_maxRTO = config.GetInt("MaxRTO", 0); m_maxRTO = config.GetInt("MaxRTO", 0);
m_disableFacelights = config.GetBoolean("DisableFacelights", false); m_disableFacelights = config.GetBoolean("DisableFacelights", false);
m_ackTimeout = 1000 * config.GetInt("AckTimeout", 60);
m_pausedAckTimeout = 1000 * config.GetInt("PausedAckTimeout", 300);
} }
else else
{ {
PrimUpdatesPerCallback = 100; PrimUpdatesPerCallback = 100;
TextureSendLimit = 20; TextureSendLimit = 20;
m_ackTimeout = 1000 * 60; // 1 minute
m_pausedAckTimeout = 1000 * 300; // 5 minutes
} }
#region BinaryStats #region BinaryStats
@ -491,8 +496,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
return; return;
// Disconnect an agent if no packets are received for some time // Disconnect an agent if no packets are received for some time
//FIXME: Make 60 an .ini setting int timeoutTicks = m_ackTimeout;
if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > 1000 * 60)
// Allow more slack if the client is "paused" eg file upload dialogue is open
// Some sort of limit is needed in case the client crashes, loses its network connection
// or some other disaster prevents it from sendung the AgentResume
if (udpClient.IsPaused)
timeoutTicks = m_pausedAckTimeout;
if ((Environment.TickCount & Int32.MaxValue) - udpClient.TickLastPacketReceived > timeoutTicks)
{ {
m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID); m_log.Warn("[LLUDPSERVER]: Ack timeout, disconnecting " + udpClient.AgentID);
StatsManager.SimExtraStats.AddAbnormalClientThreadTermination(); StatsManager.SimExtraStats.AddAbnormalClientThreadTermination();

View File

@ -57,14 +57,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Profile
public void Initialise(IConfigSource config) public void Initialise(IConfigSource config)
{ {
// This can be reduced later as the loader will determine
// whether we are needed
if (config.Configs["Profile"] != null)
{
if (config.Configs["Profile"].GetString("Module", string.Empty) != "BasicProfileModule")
return;
}
m_log.DebugFormat("[PROFILE MODULE]: Basic Profile Module enabled"); m_log.DebugFormat("[PROFILE MODULE]: Basic Profile Module enabled");
m_Enabled = true; m_Enabled = true;
} }

View File

@ -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;

View File

@ -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;

View File

@ -84,218 +84,234 @@ 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;
if (textureTerrain) try
{ {
// Swap empty terrain textureIDs with default IDs if (textureTerrain)
for (int i = 0; i < textureIDs.Length; i++)
{ {
if (textureIDs[i] == UUID.Zero) // Swap empty terrain textureIDs with default IDs
textureIDs[i] = DEFAULT_TERRAIN_DETAIL[i]; for (int i = 0; i < textureIDs.Length; i++)
}
#region Texture Fetching
if (assetService != null)
{
for (int i = 0; i < 4; i++)
{ {
AssetBase asset; if (textureIDs[i] == UUID.Zero)
UUID cacheID = UUID.Combine(TERRAIN_CACHE_MAGIC, textureIDs[i]); textureIDs[i] = DEFAULT_TERRAIN_DETAIL[i];
}
// Try to fetch a cached copy of the decoded/resized version of this texture #region Texture Fetching
asset = assetService.GetCached(cacheID.ToString());
if (asset != null)
{
try
{
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(asset.Data))
detailTexture[i] = (Bitmap)Image.FromStream(stream);
}
catch (Exception ex)
{
m_log.Warn("Failed to decode cached terrain texture " + cacheID +
" (textureID: " + textureIDs[i] + "): " + ex.Message);
}
}
if (detailTexture[i] == null) if (assetService != null)
{
for (int i = 0; i < 4; i++)
{ {
// Try to fetch the original JPEG2000 texture, resize if needed, and cache as PNG AssetBase asset;
asset = assetService.Get(textureIDs[i].ToString()); UUID cacheID = UUID.Combine(TERRAIN_CACHE_MAGIC, textureIDs[i]);
// Try to fetch a cached copy of the decoded/resized version of this texture
asset = assetService.GetCached(cacheID.ToString());
if (asset != null) if (asset != null)
{ {
try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); } try
{
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(asset.Data))
detailTexture[i] = (Bitmap)Image.FromStream(stream);
}
catch (Exception ex) catch (Exception ex)
{ {
m_log.Warn("Failed to decode terrain texture " + asset.ID + ": " + ex.Message); m_log.Warn("Failed to decode cached terrain texture " + cacheID +
" (textureID: " + textureIDs[i] + "): " + ex.Message);
} }
} }
if (detailTexture[i] != null) if (detailTexture[i] == null)
{ {
Bitmap bitmap = detailTexture[i]; // Try to fetch the original JPEG2000 texture, resize if needed, and cache as PNG
asset = assetService.Get(textureIDs[i].ToString());
// Make sure this texture is the correct size, otherwise resize if (asset != null)
if (bitmap.Width != 256 || bitmap.Height != 256)
bitmap = ImageUtils.ResizeImage(bitmap, 256, 256);
// Save the decoded and resized texture to the cache
byte[] data;
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{ {
bitmap.Save(stream, ImageFormat.Png); try { detailTexture[i] = (Bitmap)CSJ2K.J2kImage.FromBytes(asset.Data); }
data = stream.ToArray(); catch (Exception ex)
{
m_log.Warn("Failed to decode terrain texture " + asset.ID + ": " + ex.Message);
}
} }
// Cache a PNG copy of this terrain texture if (detailTexture[i] != null)
AssetBase newAsset = new AssetBase
{ {
Data = data, Bitmap bitmap = detailTexture[i];
Description = "PNG",
Flags = AssetFlags.Collectable, // Make sure this texture is the correct size, otherwise resize
FullID = cacheID, if (bitmap.Width != 256 || bitmap.Height != 256)
ID = cacheID.ToString(), {
Local = true, using (Bitmap origBitmap = bitmap)
Name = String.Empty, {
Temporary = true, bitmap = ImageUtils.ResizeImage(origBitmap, 256, 256);
Type = (sbyte)AssetType.Unknown }
}; }
newAsset.Metadata.ContentType = "image/png";
assetService.Store(newAsset); // Save the decoded and resized texture to the cache
byte[] data;
using (System.IO.MemoryStream stream = new System.IO.MemoryStream())
{
bitmap.Save(stream, ImageFormat.Png);
data = stream.ToArray();
}
// Cache a PNG copy of this terrain texture
AssetBase newAsset = new AssetBase
{
Data = data,
Description = "PNG",
Flags = AssetFlags.Collectable,
FullID = cacheID,
ID = cacheID.ToString(),
Local = true,
Name = String.Empty,
Temporary = true,
Type = (sbyte)AssetType.Unknown
};
newAsset.Metadata.ContentType = "image/png";
assetService.Store(newAsset);
}
} }
} }
} }
#endregion Texture Fetching
}
// Fill in any missing textures with a solid color
for (int i = 0; i < 4; i++)
{
if (detailTexture[i] == null)
{
// Create a solid color texture for this layer
detailTexture[i] = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
using (Graphics gfx = Graphics.FromImage(detailTexture[i]))
{
using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i]))
gfx.FillRectangle(brush, 0, 0, 256, 256);
}
}
} }
#endregion Texture Fetching #region Layer Map
}
// Fill in any missing textures with a solid color float[] layermap = new float[256 * 256];
for (int i = 0; i < 4; i++)
{
if (detailTexture[i] == null)
{
// Create a solid color texture for this layer
detailTexture[i] = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
using (Graphics gfx = Graphics.FromImage(detailTexture[i]))
{
using (SolidBrush brush = new SolidBrush(DEFAULT_TERRAIN_COLOR[i]))
gfx.FillRectangle(brush, 0, 0, 256, 256);
}
}
}
#region Layer Map
float[] layermap = new float[256 * 256];
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x++)
{
float height = heightmap[y * 256 + x];
float pctX = (float)x / 255f;
float pctY = (float)y / 255f;
// Use bilinear interpolation between the four corners of start height and
// height range to select the current values at this position
float startHeight = ImageUtils.Bilinear(
startHeights[0],
startHeights[2],
startHeights[1],
startHeights[3],
pctX, pctY);
startHeight = Utils.Clamp(startHeight, 0f, 255f);
float heightRange = ImageUtils.Bilinear(
heightRanges[0],
heightRanges[2],
heightRanges[1],
heightRanges[3],
pctX, pctY);
heightRange = Utils.Clamp(heightRange, 0f, 255f);
// Generate two frequencies of perlin noise based on our global position
// The magic values were taken from http://opensimulator.org/wiki/Terrain_Splatting
Vector3 vec = new Vector3
(
((float)regionPosition.X + x) * 0.20319f,
((float)regionPosition.Y + y) * 0.20319f,
height * 0.25f
);
float lowFreq = Perlin.noise2(vec.X * 0.222222f, vec.Y * 0.222222f) * 6.5f;
float highFreq = Perlin.turbulence2(vec.X, vec.Y, 2f) * 2.25f;
float noise = (lowFreq + highFreq) * 2f;
// Combine the current height, generated noise, start height, and height range parameters, then scale all of it
float layer = ((height + noise - startHeight) / heightRange) * 4f;
if (Single.IsNaN(layer)) layer = 0f;
layermap[y * 256 + x] = Utils.Clamp(layer, 0f, 3f);
}
}
#endregion Layer Map
#region Texture Compositing
Bitmap output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
BitmapData outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
unsafe
{
// Get handles to all of the texture data arrays
BitmapData[] datas = new BitmapData[]
{
detailTexture[0].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[0].PixelFormat),
detailTexture[1].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[1].PixelFormat),
detailTexture[2].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[2].PixelFormat),
detailTexture[3].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[3].PixelFormat)
};
int[] comps = new int[]
{
(datas[0].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
(datas[1].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
(datas[2].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
(datas[3].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3
};
for (int y = 0; y < 256; y++) for (int y = 0; y < 256; y++)
{ {
for (int x = 0; x < 256; x++) for (int x = 0; x < 256; x++)
{ {
float layer = layermap[y * 256 + x]; float height = heightmap[y * 256 + x];
// Select two textures float pctX = (float)x / 255f;
int l0 = (int)Math.Floor(layer); float pctY = (float)y / 255f;
int l1 = Math.Min(l0 + 1, 3);
byte* ptrA = (byte*)datas[l0].Scan0 + y * datas[l0].Stride + x * comps[l0]; // Use bilinear interpolation between the four corners of start height and
byte* ptrB = (byte*)datas[l1].Scan0 + y * datas[l1].Stride + x * comps[l1]; // height range to select the current values at this position
byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride + x * 3; float startHeight = ImageUtils.Bilinear(
startHeights[0],
startHeights[2],
startHeights[1],
startHeights[3],
pctX, pctY);
startHeight = Utils.Clamp(startHeight, 0f, 255f);
float aB = *(ptrA + 0); float heightRange = ImageUtils.Bilinear(
float aG = *(ptrA + 1); heightRanges[0],
float aR = *(ptrA + 2); heightRanges[2],
heightRanges[1],
heightRanges[3],
pctX, pctY);
heightRange = Utils.Clamp(heightRange, 0f, 255f);
float bB = *(ptrB + 0); // Generate two frequencies of perlin noise based on our global position
float bG = *(ptrB + 1); // The magic values were taken from http://opensimulator.org/wiki/Terrain_Splatting
float bR = *(ptrB + 2); Vector3 vec = new Vector3
(
((float)regionPosition.X + x) * 0.20319f,
((float)regionPosition.Y + y) * 0.20319f,
height * 0.25f
);
float layerDiff = layer - l0; float lowFreq = Perlin.noise2(vec.X * 0.222222f, vec.Y * 0.222222f) * 6.5f;
float highFreq = Perlin.turbulence2(vec.X, vec.Y, 2f) * 2.25f;
float noise = (lowFreq + highFreq) * 2f;
// Interpolate between the two selected textures // Combine the current height, generated noise, start height, and height range parameters, then scale all of it
*(ptrO + 0) = (byte)Math.Floor(aB + layerDiff * (bB - aB)); float layer = ((height + noise - startHeight) / heightRange) * 4f;
*(ptrO + 1) = (byte)Math.Floor(aG + layerDiff * (bG - aG)); if (Single.IsNaN(layer)) layer = 0f;
*(ptrO + 2) = (byte)Math.Floor(aR + layerDiff * (bR - aR)); layermap[y * 256 + x] = Utils.Clamp(layer, 0f, 3f);
} }
} }
#endregion Layer Map
#region Texture Compositing
output = new Bitmap(256, 256, PixelFormat.Format24bppRgb);
outputData = output.LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.WriteOnly, PixelFormat.Format24bppRgb);
unsafe
{
// Get handles to all of the texture data arrays
BitmapData[] datas = new BitmapData[]
{
detailTexture[0].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[0].PixelFormat),
detailTexture[1].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[1].PixelFormat),
detailTexture[2].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[2].PixelFormat),
detailTexture[3].LockBits(new Rectangle(0, 0, 256, 256), ImageLockMode.ReadOnly, detailTexture[3].PixelFormat)
};
int[] comps = new int[]
{
(datas[0].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
(datas[1].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
(datas[2].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3,
(datas[3].PixelFormat == PixelFormat.Format32bppArgb) ? 4 : 3
};
for (int y = 0; y < 256; y++)
{
for (int x = 0; x < 256; x++)
{
float layer = layermap[y * 256 + x];
// Select two textures
int l0 = (int)Math.Floor(layer);
int l1 = Math.Min(l0 + 1, 3);
byte* ptrA = (byte*)datas[l0].Scan0 + y * datas[l0].Stride + x * comps[l0];
byte* ptrB = (byte*)datas[l1].Scan0 + y * datas[l1].Stride + x * comps[l1];
byte* ptrO = (byte*)outputData.Scan0 + y * outputData.Stride + x * 3;
float aB = *(ptrA + 0);
float aG = *(ptrA + 1);
float aR = *(ptrA + 2);
float bB = *(ptrB + 0);
float bG = *(ptrB + 1);
float bR = *(ptrB + 2);
float layerDiff = layer - l0;
// Interpolate between the two selected textures
*(ptrO + 0) = (byte)Math.Floor(aB + layerDiff * (bB - aB));
*(ptrO + 1) = (byte)Math.Floor(aG + layerDiff * (bG - aG));
*(ptrO + 2) = (byte)Math.Floor(aR + layerDiff * (bR - aR));
}
}
for (int i = 0; i < 4; i++)
detailTexture[i].UnlockBits(datas[i]);
}
}
finally
{
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
detailTexture[i].UnlockBits(datas[i]); if (detailTexture[i] != null)
detailTexture[i].Dispose();
} }
output.UnlockBits(outputData); output.UnlockBits(outputData);

View File

@ -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;
@ -164,7 +163,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();
@ -218,7 +217,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;
} }
@ -233,7 +235,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;
@ -332,8 +334,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);
@ -560,42 +571,46 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
{ {
try try
{ {
Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream); int pixelBytes;
width = bitmap.Width;
height = bitmap.Height;
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat); using (Bitmap bitmap = (Bitmap)J2kImage.FromStream(stream))
int pixelBytes = (bitmap.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
// Sum up the individual channels
unsafe
{ {
if (pixelBytes == 4) width = bitmap.Width;
{ height = bitmap.Height;
for (int y = 0; y < height; y++)
{
byte* row = (byte*)bitmapData.Scan0 + (y * bitmapData.Stride);
for (int x = 0; x < width; x++) BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, bitmap.PixelFormat);
pixelBytes = (bitmap.PixelFormat == PixelFormat.Format24bppRgb) ? 3 : 4;
// Sum up the individual channels
unsafe
{
if (pixelBytes == 4)
{
for (int y = 0; y < height; y++)
{ {
b += row[x * pixelBytes + 0]; byte* row = (byte*)bitmapData.Scan0 + (y * bitmapData.Stride);
g += row[x * pixelBytes + 1];
r += row[x * pixelBytes + 2]; for (int x = 0; x < width; x++)
a += row[x * pixelBytes + 3]; {
b += row[x * pixelBytes + 0];
g += row[x * pixelBytes + 1];
r += row[x * pixelBytes + 2];
a += row[x * pixelBytes + 3];
}
} }
} }
} else
else
{
for (int y = 0; y < height; y++)
{ {
byte* row = (byte*)bitmapData.Scan0 + (y * bitmapData.Stride); for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
{ {
b += row[x * pixelBytes + 0]; byte* row = (byte*)bitmapData.Scan0 + (y * bitmapData.Stride);
g += row[x * pixelBytes + 1];
r += row[x * pixelBytes + 2]; for (int x = 0; x < width; x++)
{
b += row[x * pixelBytes + 0];
g += row[x * pixelBytes + 1];
r += row[x * pixelBytes + 2];
}
} }
} }
} }
@ -617,7 +632,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);

View File

@ -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)

View File

@ -947,7 +947,7 @@ namespace OpenSim.Region.Framework.Scenes
OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted;
if (handlerTerrainTainted != null) if (handlerTerrainTainted != null)
{ {
foreach (OnTerrainTickDelegate d in handlerTerrainTainted.GetInvocationList()) foreach (OnTerrainTaintedDelegate d in handlerTerrainTainted.GetInvocationList())
{ {
try try
{ {

View File

@ -222,6 +222,7 @@ namespace OpenSim.Region.Framework.Scenes
private int backupMS; private int backupMS;
private int terrainMS; private int terrainMS;
private int landMS; private int landMS;
private int spareMS;
/// <summary> /// <summary>
/// Tick at which the last frame was processed. /// Tick at which the last frame was processed.
@ -1408,45 +1409,41 @@ namespace OpenSim.Region.Framework.Scenes
endFrame = Frame + frames; endFrame = Frame + frames;
float physicsFPS = 0f; float physicsFPS = 0f;
int tmpPhysicsMS, tmpPhysicsMS2, tmpAgentMS, tmpTempOnRezMS, evMS, backMS, terMS; int previousFrameTick, tmpMS;
int previousFrameTick; int maintc = Util.EnvironmentTickCount();
int maintc;
int sleepMS;
int framestart;
while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) while (!m_shuttingDown && (endFrame == null || Frame < endFrame))
{ {
framestart = Util.EnvironmentTickCount();
++Frame; ++Frame;
// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0;
try try
{ {
// Apply taints in terrain module to terrain in physics scene // Apply taints in terrain module to terrain in physics scene
if (Frame % m_update_terrain == 0) if (Frame % m_update_terrain == 0)
{ {
terMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
UpdateTerrain(); UpdateTerrain();
terrainMS = Util.EnvironmentTickCountSubtract(terMS); terrainMS = Util.EnvironmentTickCountSubtract(tmpMS);
} }
tmpPhysicsMS2 = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
if ((Frame % m_update_physics == 0) && m_physics_enabled) if ((Frame % m_update_physics == 0) && m_physics_enabled)
m_sceneGraph.UpdatePreparePhysics(); m_sceneGraph.UpdatePreparePhysics();
physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); physicsMS2 = Util.EnvironmentTickCountSubtract(tmpMS);
// Apply any pending avatar force input to the avatar's velocity // Apply any pending avatar force input to the avatar's velocity
tmpAgentMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
if (Frame % m_update_entitymovement == 0) if (Frame % m_update_entitymovement == 0)
m_sceneGraph.UpdateScenePresenceMovement(); m_sceneGraph.UpdateScenePresenceMovement();
agentMS = Util.EnvironmentTickCountSubtract(tmpAgentMS); agentMS = Util.EnvironmentTickCountSubtract(tmpMS);
// Perform the main physics update. This will do the actual work of moving objects and avatars according to their // Perform the main physics update. This will do the actual work of moving objects and avatars according to their
// velocity // velocity
tmpPhysicsMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
if (Frame % m_update_physics == 0) if (Frame % m_update_physics == 0)
{ {
if (m_physics_enabled) if (m_physics_enabled)
@ -1455,9 +1452,9 @@ namespace OpenSim.Region.Framework.Scenes
if (SynchronizeScene != null) if (SynchronizeScene != null)
SynchronizeScene(this); SynchronizeScene(this);
} }
physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); physicsMS = Util.EnvironmentTickCountSubtract(tmpMS);
tmpAgentMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
// Check if any objects have reached their targets // Check if any objects have reached their targets
CheckAtTargets(); CheckAtTargets();
@ -1472,29 +1469,29 @@ namespace OpenSim.Region.Framework.Scenes
if (Frame % m_update_presences == 0) if (Frame % m_update_presences == 0)
m_sceneGraph.UpdatePresences(); m_sceneGraph.UpdatePresences();
agentMS += Util.EnvironmentTickCountSubtract(tmpAgentMS); agentMS += Util.EnvironmentTickCountSubtract(tmpMS);
// Delete temp-on-rez stuff // Delete temp-on-rez stuff
if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps)
{ {
tmpTempOnRezMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
m_cleaningTemps = true; m_cleaningTemps = true;
Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; });
tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS);
} }
if (Frame % m_update_events == 0) if (Frame % m_update_events == 0)
{ {
evMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
UpdateEvents(); UpdateEvents();
eventMS = Util.EnvironmentTickCountSubtract(evMS); eventMS = Util.EnvironmentTickCountSubtract(tmpMS);
} }
if (Frame % m_update_backup == 0) if (Frame % m_update_backup == 0)
{ {
backMS = Util.EnvironmentTickCount(); tmpMS = Util.EnvironmentTickCount();
UpdateStorageBackup(); UpdateStorageBackup();
backupMS = Util.EnvironmentTickCountSubtract(backMS); backupMS = Util.EnvironmentTickCountSubtract(tmpMS);
} }
//if (Frame % m_update_land == 0) //if (Frame % m_update_land == 0)
@ -1504,24 +1501,6 @@ namespace OpenSim.Region.Framework.Scenes
// landMS = Util.EnvironmentTickCountSubtract(ldMS); // landMS = Util.EnvironmentTickCountSubtract(ldMS);
//} //}
// frameMS = Util.EnvironmentTickCountSubtract(maintc);
otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
// if (Frame%m_update_avatars == 0)
// UpdateInWorldTime();
StatsReporter.AddPhysicsFPS(physicsFPS);
StatsReporter.AddTimeDilation(TimeDilation);
StatsReporter.AddFPS(1);
// frameMS currently records work frame times, not total frame times (work + any required sleep to
// reach min frame time.
// StatsReporter.addFrameMS(frameMS);
StatsReporter.addAgentMS(agentMS);
StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
StatsReporter.addOtherMS(otherMS);
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
if (LoginsDisabled && Frame == 20) if (LoginsDisabled && Frame == 20)
{ {
// m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock); // m_log.DebugFormat("{0} {1} {2}", LoginsDisabled, m_sceneGraph.GetActiveScriptsCount(), LoginLock);
@ -1571,23 +1550,36 @@ namespace OpenSim.Region.Framework.Scenes
previousFrameTick = m_lastFrameTick; previousFrameTick = m_lastFrameTick;
m_lastFrameTick = Util.EnvironmentTickCount(); m_lastFrameTick = Util.EnvironmentTickCount();
maintc = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc);
maintc = (int)(MinFrameTime * 1000) - maintc; tmpMS = (int)(MinFrameTime * 1000) - tmpMS;
m_firstHeartbeat = false; m_firstHeartbeat = false;
if (tmpMS > 0)
{
Thread.Sleep(tmpMS);
spareMS += tmpMS;
}
sleepMS = Util.EnvironmentTickCount(); frameMS = Util.EnvironmentTickCountSubtract(maintc);
maintc = Util.EnvironmentTickCount();
if (maintc > 0) otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
Thread.Sleep(maintc);
// if (Frame%m_update_avatars == 0)
// UpdateInWorldTime();
StatsReporter.AddPhysicsFPS(physicsFPS);
StatsReporter.AddTimeDilation(TimeDilation);
StatsReporter.AddFPS(1);
sleepMS = Util.EnvironmentTickCountSubtract(sleepMS);
frameMS = Util.EnvironmentTickCountSubtract(framestart);
StatsReporter.addSleepMS(sleepMS);
StatsReporter.addFrameMS(frameMS); StatsReporter.addFrameMS(frameMS);
StatsReporter.addAgentMS(agentMS);
StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
StatsReporter.addOtherMS(otherMS);
StatsReporter.AddSpareMS(spareMS);
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
// Optionally warn if a frame takes double the amount of time that it should. // Optionally warn if a frame takes double the amount of time that it should.
if (DebugUpdates if (DebugUpdates
&& Util.EnvironmentTickCountSubtract( && Util.EnvironmentTickCountSubtract(
m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2)) m_lastFrameTick, previousFrameTick) > (int)(MinFrameTime * 1000 * 2))

View File

@ -56,10 +56,17 @@ namespace OpenSim.Region.Framework.Scenes
public event YourStatsAreWrong OnStatsIncorrect; public event YourStatsAreWrong OnStatsIncorrect;
private SendStatResult handlerSendStatResult = null; private SendStatResult handlerSendStatResult;
private YourStatsAreWrong handlerStatsIncorrect = null; private YourStatsAreWrong handlerStatsIncorrect;
/// <summary>
/// These are the IDs of stats sent in the StatsPacket to the viewer.
/// </summary>
/// <remarks>
/// Some of these are not relevant to OpenSimulator since it is architected differently to other simulators
/// (e.g. script instructions aren't executed as part of the frame loop so 'script time' is tricky).
/// </remarks>
public enum Stats : uint public enum Stats : uint
{ {
TimeDilation = 0, TimeDilation = 0,
@ -83,20 +90,20 @@ namespace OpenSim.Region.Framework.Scenes
OutPacketsPerSecond = 18, OutPacketsPerSecond = 18,
PendingDownloads = 19, PendingDownloads = 19,
PendingUploads = 20, PendingUploads = 20,
VirtualSizeKB = 21, VirtualSizeKb = 21,
ResidentSizeKB = 22, ResidentSizeKb = 22,
PendingLocalUploads = 23, PendingLocalUploads = 23,
UnAckedBytes = 24, UnAckedBytes = 24,
PhysicsPinnedTasks = 25, PhysicsPinnedTasks = 25,
PhysicsLODTasks = 26, PhysicsLodTasks = 26,
PhysicsStepMS = 27, SimPhysicsStepMs = 27,
PhysicsShapeMS = 28, SimPhysicsShapeMs = 28,
PhysicsOtherMS = 29, SimPhysicsOtherMs = 29,
PhysicsMemory = 30, SimPhysicsMemory = 30,
ScriptEPS = 31, ScriptEps = 31,
SimSpareTime = 32, SimSpareMs = 32,
SimSleepTime = 33, SimSleepMs = 33,
IOPumpTime = 34 SimIoPumpTime = 34
} }
/// <summary> /// <summary>
@ -130,10 +137,15 @@ namespace OpenSim.Region.Framework.Scenes
private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>(); private Dictionary<string, float> m_lastReportedExtraSimStats = new Dictionary<string, float>();
// Sending a stats update every 3 seconds- // Sending a stats update every 3 seconds-
private int statsUpdatesEveryMS = 3000; private int m_statsUpdatesEveryMS = 3000;
private float statsUpdateFactor = 0; private float m_statsUpdateFactor;
private float m_timeDilation = 0; private float m_timeDilation;
private int m_fps = 0; private int m_fps;
/// <summary>
/// Number of the last frame on which we processed a stats udpate.
/// </summary>
private uint m_lastUpdateFrame;
/// <summary> /// <summary>
/// Our nominal fps target, as expected in fps stats when a sim is running normally. /// Our nominal fps target, as expected in fps stats when a sim is running normally.
@ -151,43 +163,42 @@ namespace OpenSim.Region.Framework.Scenes
private float m_reportedFpsCorrectionFactor = 5; private float m_reportedFpsCorrectionFactor = 5;
// saved last reported value so there is something available for llGetRegionFPS // saved last reported value so there is something available for llGetRegionFPS
private float lastReportedSimFPS = 0; private float lastReportedSimFPS;
private float[] lastReportedSimStats = new float[23]; private float[] lastReportedSimStats = new float[22];
private float m_pfps = 0; private float m_pfps;
/// <summary> /// <summary>
/// Number of agent updates requested in this stats cycle /// Number of agent updates requested in this stats cycle
/// </summary> /// </summary>
private int m_agentUpdates = 0; private int m_agentUpdates;
/// <summary> /// <summary>
/// Number of object updates requested in this stats cycle /// Number of object updates requested in this stats cycle
/// </summary> /// </summary>
private int m_objectUpdates; private int m_objectUpdates;
private int m_frameMS = 0; private int m_frameMS;
private int m_netMS = 0; private int m_spareMS;
private int m_agentMS = 0; private int m_netMS;
private int m_physicsMS = 0; private int m_agentMS;
private int m_imageMS = 0; private int m_physicsMS;
private int m_otherMS = 0; private int m_imageMS;
private int m_sleeptimeMS = 0; private int m_otherMS;
//Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed.
//Ckrinke private int m_scriptMS = 0; //Ckrinke private int m_scriptMS = 0;
private int m_rootAgents = 0; private int m_rootAgents;
private int m_childAgents = 0; private int m_childAgents;
private int m_numPrim = 0; private int m_numPrim;
private int m_inPacketsPerSecond = 0; private int m_inPacketsPerSecond;
private int m_outPacketsPerSecond = 0; private int m_outPacketsPerSecond;
private int m_activePrim = 0; private int m_activePrim;
private int m_unAckedBytes = 0; private int m_unAckedBytes;
private int m_pendingDownloads = 0; private int m_pendingDownloads;
private int m_pendingUploads = 0; private int m_pendingUploads = 0; // FIXME: Not currently filled in
private int m_activeScripts = 0; private int m_activeScripts;
private int m_scriptLinesPerSecond = 0; private int m_scriptLinesPerSecond;
private int m_objectCapacity = 45000; private int m_objectCapacity = 45000;
@ -203,13 +214,13 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_scene = scene; m_scene = scene;
m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps; m_reportedFpsCorrectionFactor = scene.MinFrameTime * m_nominalReportedFps;
statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
ReportingRegion = scene.RegionInfo; ReportingRegion = scene.RegionInfo;
m_objectCapacity = scene.RegionInfo.ObjectCapacity; m_objectCapacity = scene.RegionInfo.ObjectCapacity;
m_report.AutoReset = true; m_report.AutoReset = true;
m_report.Interval = statsUpdatesEveryMS; m_report.Interval = m_statsUpdatesEveryMS;
m_report.Elapsed += statsHeartBeat; m_report.Elapsed += TriggerStatsHeartbeat;
m_report.Enabled = true; m_report.Enabled = true;
if (StatsManager.SimExtraStats != null) if (StatsManager.SimExtraStats != null)
@ -218,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes
public void Close() public void Close()
{ {
m_report.Elapsed -= statsHeartBeat; m_report.Elapsed -= TriggerStatsHeartbeat;
m_report.Close(); m_report.Close();
} }
@ -228,14 +239,28 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name='ms'></param> /// <param name='ms'></param>
public void SetUpdateMS(int ms) public void SetUpdateMS(int ms)
{ {
statsUpdatesEveryMS = ms; m_statsUpdatesEveryMS = ms;
statsUpdateFactor = (float)(statsUpdatesEveryMS / 1000); m_statsUpdateFactor = (float)(m_statsUpdatesEveryMS / 1000);
m_report.Interval = statsUpdatesEveryMS; m_report.Interval = m_statsUpdatesEveryMS;
}
private void TriggerStatsHeartbeat(object sender, EventArgs args)
{
try
{
statsHeartBeat(sender, args);
}
catch (Exception e)
{
m_log.Warn(string.Format(
"[SIM STATS REPORTER] Update for {0} failed with exception ",
m_scene.RegionInfo.RegionName), e);
}
} }
private void statsHeartBeat(object sender, EventArgs e) private void statsHeartBeat(object sender, EventArgs e)
{ {
SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22];
SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock();
// Know what's not thread safe in Mono... modifying timers. // Know what's not thread safe in Mono... modifying timers.
@ -262,7 +287,7 @@ namespace OpenSim.Region.Framework.Scenes
int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor); int reportedFPS = (int)(m_fps * m_reportedFpsCorrectionFactor);
// save the reported value so there is something available for llGetRegionFPS // save the reported value so there is something available for llGetRegionFPS
lastReportedSimFPS = reportedFPS / statsUpdateFactor; lastReportedSimFPS = reportedFPS / m_statsUpdateFactor;
float physfps = ((m_pfps / 1000)); float physfps = ((m_pfps / 1000));
@ -273,7 +298,6 @@ namespace OpenSim.Region.Framework.Scenes
physfps = 0; physfps = 0;
#endregion #endregion
float factor = 1 / statsUpdateFactor;
if (reportedFPS <= 0) if (reportedFPS <= 0)
reportedFPS = 1; reportedFPS = 1;
@ -284,21 +308,9 @@ namespace OpenSim.Region.Framework.Scenes
float targetframetime = 1100.0f / (float)m_nominalReportedFps; float targetframetime = 1100.0f / (float)m_nominalReportedFps;
float sparetime; float sparetime;
float sleeptime;
if (TotalFrameTime > targetframetime) if (TotalFrameTime > targetframetime)
{ {
sparetime = 0; sparetime = 0;
sleeptime = 0;
}
else
{
sparetime = m_frameMS - m_physicsMS - m_agentMS;
sparetime *= perframe;
if (sparetime < 0)
sparetime = 0;
else if (sparetime > TotalFrameTime)
sparetime = TotalFrameTime;
sleeptime = m_sleeptimeMS * perframe;
} }
m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); m_rootAgents = m_scene.SceneGraph.GetRootAgentCount();
@ -315,11 +327,19 @@ namespace OpenSim.Region.Framework.Scenes
// m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS;
// m_imageMS m_netMS are not included in m_frameMS // m_imageMS m_netMS are not included in m_frameMS
m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; m_otherMS = m_frameMS - m_physicsMS - m_agentMS;
if (m_otherMS < 0) if (m_otherMS < 0)
m_otherMS = 0; m_otherMS = 0;
for (int i = 0; i < 23; i++) uint thisFrame = m_scene.Frame;
float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor;
m_lastUpdateFrame = thisFrame;
// Avoid div-by-zero if somehow we've not updated any frames.
if (framesUpdated == 0)
framesUpdated = 1;
for (int i = 0; i < 22; i++)
{ {
sb[i] = new SimStatsPacket.StatBlock(); sb[i] = new SimStatsPacket.StatBlock();
} }
@ -328,13 +348,13 @@ namespace OpenSim.Region.Framework.Scenes
sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor)); sb[0].StatValue = (Single.IsNaN(m_timeDilation)) ? 0.1f : m_timeDilation ; //((((m_timeDilation + (0.10f * statsUpdateFactor)) /10) / statsUpdateFactor));
sb[1].StatID = (uint) Stats.SimFPS; sb[1].StatID = (uint) Stats.SimFPS;
sb[1].StatValue = reportedFPS / statsUpdateFactor; sb[1].StatValue = reportedFPS / m_statsUpdateFactor;
sb[2].StatID = (uint) Stats.PhysicsFPS; sb[2].StatID = (uint) Stats.PhysicsFPS;
sb[2].StatValue = physfps / statsUpdateFactor; sb[2].StatValue = physfps / m_statsUpdateFactor;
sb[3].StatID = (uint) Stats.AgentUpdates; sb[3].StatID = (uint) Stats.AgentUpdates;
sb[3].StatValue = (m_agentUpdates / statsUpdateFactor); sb[3].StatValue = (m_agentUpdates / m_statsUpdateFactor);
sb[4].StatID = (uint) Stats.Agents; sb[4].StatID = (uint) Stats.Agents;
sb[4].StatValue = m_rootAgents; sb[4].StatValue = m_rootAgents;
@ -349,38 +369,31 @@ namespace OpenSim.Region.Framework.Scenes
sb[7].StatValue = m_activePrim; sb[7].StatValue = m_activePrim;
sb[8].StatID = (uint)Stats.FrameMS; sb[8].StatID = (uint)Stats.FrameMS;
// sb[8].StatValue = m_frameMS / statsUpdateFactor; sb[8].StatValue = m_frameMS / framesUpdated;
sb[8].StatValue = TotalFrameTime;
sb[9].StatID = (uint)Stats.NetMS; sb[9].StatID = (uint)Stats.NetMS;
// sb[9].StatValue = m_netMS / statsUpdateFactor; sb[9].StatValue = m_netMS / framesUpdated;
sb[9].StatValue = m_netMS * perframe;
sb[10].StatID = (uint)Stats.PhysicsMS; sb[10].StatID = (uint)Stats.PhysicsMS;
// sb[10].StatValue = m_physicsMS / statsUpdateFactor; sb[10].StatValue = m_physicsMS / framesUpdated;
sb[10].StatValue = m_physicsMS * perframe;
sb[11].StatID = (uint)Stats.ImageMS ; sb[11].StatID = (uint)Stats.ImageMS ;
// sb[11].StatValue = m_imageMS / statsUpdateFactor; sb[11].StatValue = m_imageMS / framesUpdated;
sb[11].StatValue = m_imageMS * perframe;
sb[12].StatID = (uint)Stats.OtherMS; sb[12].StatID = (uint)Stats.OtherMS;
// sb[12].StatValue = m_otherMS / statsUpdateFactor; sb[12].StatValue = m_otherMS / framesUpdated;
sb[12].StatValue = m_otherMS * perframe;
sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatID = (uint)Stats.InPacketsPerSecond;
sb[13].StatValue = (m_inPacketsPerSecond / statsUpdateFactor); sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor);
sb[14].StatID = (uint)Stats.OutPacketsPerSecond; sb[14].StatID = (uint)Stats.OutPacketsPerSecond;
sb[14].StatValue = (m_outPacketsPerSecond / statsUpdateFactor); sb[14].StatValue = (m_outPacketsPerSecond / m_statsUpdateFactor);
sb[15].StatID = (uint)Stats.UnAckedBytes; sb[15].StatID = (uint)Stats.UnAckedBytes;
sb[15].StatValue = m_unAckedBytes; sb[15].StatValue = m_unAckedBytes;
sb[16].StatID = (uint)Stats.AgentMS; sb[16].StatID = (uint)Stats.AgentMS;
// sb[16].StatValue = m_agentMS / statsUpdateFactor; sb[16].StatValue = m_agentMS / framesUpdated;
sb[16].StatValue = m_agentMS * perframe;
sb[17].StatID = (uint)Stats.PendingDownloads; sb[17].StatID = (uint)Stats.PendingDownloads;
sb[17].StatValue = m_pendingDownloads; sb[17].StatValue = m_pendingDownloads;
@ -392,15 +405,12 @@ namespace OpenSim.Region.Framework.Scenes
sb[19].StatValue = m_activeScripts; sb[19].StatValue = m_activeScripts;
sb[20].StatID = (uint)Stats.ScriptLinesPerSecond; sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor; sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor;
sb[21].StatID = (uint)Stats.SimSpareTime; sb[21].StatID = (uint)Stats.SimSpareMs;
sb[21].StatValue = sparetime; sb[21].StatValue = m_spareMS / framesUpdated;
sb[22].StatID = (uint)Stats.SimSleepTime; for (int i = 0; i < 22; i++)
sb[22].StatValue = sleeptime;
for (int i = 0; i < 23; i++)
{ {
lastReportedSimStats[i] = sb[i].StatValue; lastReportedSimStats[i] = sb[i].StatValue;
} }
@ -419,7 +429,7 @@ namespace OpenSim.Region.Framework.Scenes
// Extra statistics that aren't currently sent to clients // Extra statistics that aren't currently sent to clients
lock (m_lastReportedExtraSimStats) lock (m_lastReportedExtraSimStats)
{ {
m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / statsUpdateFactor; m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor;
Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats();
@ -427,16 +437,22 @@ namespace OpenSim.Region.Framework.Scenes
{ {
foreach (KeyValuePair<string, float> tuple in physicsStats) foreach (KeyValuePair<string, float> tuple in physicsStats)
{ {
m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / statsUpdateFactor; // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second
// Need to change things so that stats source can indicate whether they are per second or
// per frame.
if (tuple.Key.EndsWith("MS"))
m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated;
else
m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor;
} }
} }
} }
resetvalues(); ResetValues();
} }
} }
private void resetvalues() private void ResetValues()
{ {
m_timeDilation = 0; m_timeDilation = 0;
m_fps = 0; m_fps = 0;
@ -454,7 +470,7 @@ namespace OpenSim.Region.Framework.Scenes
m_physicsMS = 0; m_physicsMS = 0;
m_imageMS = 0; m_imageMS = 0;
m_otherMS = 0; m_otherMS = 0;
m_sleeptimeMS = 0; m_spareMS = 0;
//Ckrinke This variable is not used, so comment to remove compiler warning until it is used. //Ckrinke This variable is not used, so comment to remove compiler warning until it is used.
//Ckrinke m_scriptMS = 0; //Ckrinke m_scriptMS = 0;
@ -533,6 +549,11 @@ namespace OpenSim.Region.Framework.Scenes
m_frameMS += ms; m_frameMS += ms;
} }
public void AddSpareMS(int ms)
{
m_spareMS += ms;
}
public void addNetMS(int ms) public void addNetMS(int ms)
{ {
m_netMS += ms; m_netMS += ms;
@ -558,11 +579,6 @@ namespace OpenSim.Region.Framework.Scenes
m_otherMS += ms; m_otherMS += ms;
} }
public void addSleepMS(int ms)
{
m_sleeptimeMS += ms;
}
public void AddPendingDownloads(int count) public void AddPendingDownloads(int count)
{ {
m_pendingDownloads += count; m_pendingDownloads += count;

View File

@ -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())
{
bmp.Save(str, ImageFormat.Jpeg);
MemoryStream str = new MemoryStream(); return str.ToArray();
}
bmp.Save(str, ImageFormat.Jpeg); }
return str.ToArray();
} }
} }
} }

View File

@ -61,7 +61,7 @@ namespace OpenSim.Region.RegionCombinerModule
/// <summary> /// <summary>
/// Is this module enabled? /// Is this module enabled?
/// </summary> /// </summary>
private bool enabledYN = false; private bool m_combineContiguousRegions = false;
/// <summary> /// <summary>
/// This holds the root regions for the megaregions. /// This holds the root regions for the megaregions.
@ -79,14 +79,12 @@ namespace OpenSim.Region.RegionCombinerModule
public void Initialise(IConfigSource source) public void Initialise(IConfigSource source)
{ {
IConfig myConfig = source.Configs["Startup"]; IConfig myConfig = source.Configs["Startup"];
enabledYN = myConfig.GetBoolean("CombineContiguousRegions", false); m_combineContiguousRegions = myConfig.GetBoolean("CombineContiguousRegions", false);
if (enabledYN) MainConsole.Instance.Commands.AddCommand(
{ "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms",
MainConsole.Instance.Commands.AddCommand( "Fixes phantom objects after an import to a megaregion or a change from a megaregion back to normal regions",
"RegionCombinerModule", false, "fix-phantoms", "fix-phantoms", FixPhantoms);
"Fixes phantom objects after an import to megaregions", FixPhantoms);
}
} }
public void Close() public void Close()
@ -95,7 +93,7 @@ namespace OpenSim.Region.RegionCombinerModule
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{ {
if (enabledYN) if (m_combineContiguousRegions)
scene.RegisterModuleInterface<IRegionCombinerModule>(this); scene.RegisterModuleInterface<IRegionCombinerModule>(this);
} }
@ -105,7 +103,10 @@ namespace OpenSim.Region.RegionCombinerModule
public void RegionLoaded(Scene scene) public void RegionLoaded(Scene scene)
{ {
if (enabledYN) lock (m_startingScenes)
m_startingScenes.Add(scene.RegionInfo.originRegionID, scene);
if (m_combineContiguousRegions)
{ {
RegionLoadedDoWork(scene); RegionLoadedDoWork(scene);
@ -208,7 +209,6 @@ namespace OpenSim.Region.RegionCombinerModule
{ {
return; return;
} }
} }
} }
@ -220,8 +220,6 @@ namespace OpenSim.Region.RegionCombinerModule
return; return;
// //
*/ */
lock (m_startingScenes)
m_startingScenes.Add(scene.RegionInfo.originRegionID, scene);
// Give each region a standard set of non-infinite borders // Give each region a standard set of non-infinite borders
Border northBorder = new Border(); Border northBorder = new Border();
@ -1068,6 +1066,8 @@ namespace OpenSim.Region.RegionCombinerModule
foreach (Scene s in scenes) foreach (Scene s in scenes)
{ {
MainConsole.Instance.OutputFormat("Fixing phantoms for {0}", s.RegionInfo.RegionName);
s.ForEachSOG(so => so.AbsolutePosition = so.AbsolutePosition); s.ForEachSOG(so => so.AbsolutePosition = so.AbsolutePosition);
} }
} }

View File

@ -6038,7 +6038,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
} }
List<UUID> presenceIds = new List<UUID>();
World.ForEachRootScenePresence( World.ForEachRootScenePresence(
delegate (ScenePresence ssp) delegate (ScenePresence ssp)

View File

@ -536,6 +536,19 @@
; ;
;DisableFacelights = false ;DisableFacelights = false
; The time to wait before disconecting an unresponsive client.
; The time is in seconds. The default is one minute
;
;AckTimeout = 60
; The time to wait before disconecting an unresponsive paused client.
; A client can be paused when the file selection dialog is open during file upload.
; This gives extra time to find files via the dialog but will still disconnect if
; the client crashes or loses its network connection
; The time is in seconds. The default is five minutes.
;
;PausedAckTimeout = 300
[ClientStack.LindenCaps] [ClientStack.LindenCaps]
;; Long list of capabilities taken from ;; Long list of capabilities taken from
;; http://wiki.secondlife.com/wiki/Current_Sim_Capabilities ;; http://wiki.secondlife.com/wiki/Current_Sim_Capabilities

View File

@ -29,9 +29,6 @@
SimulationServiceInConnector = true SimulationServiceInConnector = true
LibraryModule = true LibraryModule = true
[Profile]
Module = "BasicProfileModule"
[SimulationDataStore] [SimulationDataStore]
LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService" LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService"

View File

@ -25,9 +25,6 @@
GridInfoServiceInConnector = true GridInfoServiceInConnector = true
MapImageServiceInConnector = true MapImageServiceInConnector = true
[Profile]
Module = "BasicProfileModule"
[SimulationDataStore] [SimulationDataStore]
LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService" LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService"