mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
Merge branch 'master' into httptests
This commit is contained in:
@@ -374,9 +374,11 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
|
||||
if (channel == DEBUG_CHANNEL)
|
||||
return;
|
||||
|
||||
// Is id an avatar?
|
||||
ScenePresence sp = m_scene.GetScenePresence(target);
|
||||
if(target == UUID.Zero)
|
||||
return;
|
||||
|
||||
// Is target an avatar?
|
||||
ScenePresence sp = m_scene.GetScenePresence(target);
|
||||
if (sp != null)
|
||||
{
|
||||
// Send message to avatar
|
||||
@@ -401,19 +403,22 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
|
||||
foreach (SceneObjectGroup sog in attachments)
|
||||
{
|
||||
if (!sog.IsDeleted)
|
||||
targets.Add(sog.UUID);
|
||||
{
|
||||
SceneObjectPart[] parts = sog.Parts;
|
||||
foreach(SceneObjectPart p in parts)
|
||||
targets.Add(p.UUID);
|
||||
}
|
||||
}
|
||||
|
||||
// Need to check each attachment
|
||||
foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
|
||||
{
|
||||
if (li.GetHostID().Equals(id))
|
||||
UUID liHostID = li.GetHostID();
|
||||
if (liHostID.Equals(id))
|
||||
continue;
|
||||
|
||||
if (m_scene.GetSceneObjectPart(li.GetHostID()) == null)
|
||||
if (m_scene.GetSceneObjectPart(liHostID) == null)
|
||||
continue;
|
||||
|
||||
if (targets.Contains(li.GetHostID()))
|
||||
|
||||
if (targets.Contains(liHostID))
|
||||
QueueMessage(new ListenerInfo(li, name, id, msg));
|
||||
}
|
||||
|
||||
@@ -426,16 +431,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm
|
||||
|
||||
foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg))
|
||||
{
|
||||
UUID liHostID = li.GetHostID();
|
||||
// Dont process if this message is from yourself!
|
||||
if (li.GetHostID().Equals(id))
|
||||
if (liHostID.Equals(id))
|
||||
continue;
|
||||
|
||||
SceneObjectPart sPart = m_scene.GetSceneObjectPart(
|
||||
li.GetHostID());
|
||||
if (sPart == null)
|
||||
if (m_scene.GetSceneObjectPart(liHostID) == null)
|
||||
continue;
|
||||
|
||||
if (li.GetHostID().Equals(target))
|
||||
if (liHostID.Equals(target))
|
||||
{
|
||||
QueueMessage(new ListenerInfo(li, name, id, msg));
|
||||
break;
|
||||
|
||||
@@ -227,8 +227,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
if (boOption != m_boundingOrigin)
|
||||
{
|
||||
m_boundingOrigin = boOption;
|
||||
m_boundingBox = true;
|
||||
}
|
||||
m_boundingBox = true;
|
||||
}
|
||||
|
||||
if (options.ContainsKey("bounding-size"))
|
||||
@@ -936,14 +936,24 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
|
||||
if (m_assetService.GetMetadata(uuid) != null)
|
||||
{
|
||||
sbyte asype = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
||||
if(asype == -2)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[ARCHIVER]: found existing asset {0}",uuid);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (ArchiveConstants.EXTENSION_TO_ASSET_TYPE.ContainsKey(extension))
|
||||
{
|
||||
sbyte assetType = ArchiveConstants.EXTENSION_TO_ASSET_TYPE[extension];
|
||||
|
||||
if(assetType == -2)
|
||||
{
|
||||
|
||||
}
|
||||
if (assetType == (sbyte)AssetType.Unknown)
|
||||
{
|
||||
m_log.WarnFormat("[ARCHIVER]: Importing {0} byte asset {1} with unknown type", data.Length, uuid);
|
||||
|
||||
@@ -285,10 +285,15 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
if (m_foundAssetUuids.Count + m_notFoundAssetUuids.Count >= m_repliesRequired)
|
||||
{
|
||||
m_requestState = RequestState.Completed;
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[ARCHIVER]: Successfully added {0} assets ({1} assets not found but these may be expected invalid references)",
|
||||
if(m_notFoundAssetUuids.Count == 0)
|
||||
m_log.DebugFormat(
|
||||
"[ARCHIVER]: Successfully added {0} assets",
|
||||
m_foundAssetUuids.Count);
|
||||
else
|
||||
m_log.DebugFormat(
|
||||
"[ARCHIVER]: Successfully added {0} assets ({1} assets not found but these may be expected invalid references)",
|
||||
m_foundAssetUuids.Count, m_notFoundAssetUuids.Count);
|
||||
|
||||
|
||||
// We want to stop using the asset cache thread asap
|
||||
// as we now need to do the work of producing the rest of the archive
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
@@ -43,12 +44,16 @@ namespace OpenSim.Region.CoreModules.World
|
||||
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private uint m_frame = 0;
|
||||
private int m_frameUpdateRate = 1000;
|
||||
private Random m_rndnums = new Random(Environment.TickCount);
|
||||
private Random m_rndnums;
|
||||
private Scene m_scene = null;
|
||||
private bool m_ready = false;
|
||||
private bool m_enabled = false;
|
||||
private float m_cloudDensity = 1.0F;
|
||||
private float[] cloudCover = new float[16 * 16];
|
||||
private int m_dataVersion;
|
||||
private bool m_busy;
|
||||
private object cloudlock = new object();
|
||||
|
||||
|
||||
public void Initialise(IConfigSource config)
|
||||
{
|
||||
@@ -70,11 +75,17 @@ namespace OpenSim.Region.CoreModules.World
|
||||
|
||||
m_scene = scene;
|
||||
|
||||
scene.EventManager.OnNewClient += CloudsToClient;
|
||||
scene.RegisterModuleInterface<ICloudModule>(this);
|
||||
scene.EventManager.OnFrame += CloudUpdate;
|
||||
int seed = Environment.TickCount;
|
||||
seed += (int)(scene.RegionInfo.RegionLocX << 16);
|
||||
seed += (int)(scene.RegionInfo.RegionLocY);
|
||||
m_rndnums = new Random(seed);
|
||||
|
||||
GenerateCloudCover();
|
||||
m_dataVersion = (int)m_scene.AllocateLocalId();
|
||||
|
||||
scene.EventManager.OnNewClient += CloudsToClient;
|
||||
scene.EventManager.OnFrame += CloudUpdate;
|
||||
|
||||
m_ready = true;
|
||||
}
|
||||
@@ -89,7 +100,6 @@ namespace OpenSim.Region.CoreModules.World
|
||||
m_scene.EventManager.OnNewClient -= CloudsToClient;
|
||||
m_scene.EventManager.OnFrame -= CloudUpdate;
|
||||
m_scene.UnregisterModuleInterface<ICloudModule>(this);
|
||||
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
@@ -127,7 +137,8 @@ namespace OpenSim.Region.CoreModules.World
|
||||
|
||||
if (cloudCover != null)
|
||||
{
|
||||
cover = cloudCover[y * 16 + x];
|
||||
lock(cloudlock)
|
||||
cover = cloudCover[y * 16 + x];
|
||||
}
|
||||
|
||||
return cover;
|
||||
@@ -188,22 +199,47 @@ namespace OpenSim.Region.CoreModules.World
|
||||
}
|
||||
}
|
||||
Array.Copy(newCover, cloudCover, 16 * 16);
|
||||
m_dataVersion++;
|
||||
}
|
||||
|
||||
private void CloudUpdate()
|
||||
{
|
||||
if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready || (m_cloudDensity == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
UpdateCloudCover();
|
||||
private void CloudUpdate()
|
||||
{
|
||||
if ((!m_ready || m_busy || m_cloudDensity == 0 ||
|
||||
(m_frame++ % m_frameUpdateRate) != 0))
|
||||
return;
|
||||
|
||||
if(Monitor.TryEnter(cloudlock))
|
||||
{
|
||||
m_busy = true;
|
||||
Util.FireAndForget(delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
lock(cloudlock)
|
||||
{
|
||||
UpdateCloudCover();
|
||||
m_scene.ForEachClient(delegate(IClientAPI client)
|
||||
{
|
||||
client.SendCloudData(m_dataVersion, cloudCover);
|
||||
});
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_busy = false;
|
||||
}
|
||||
},
|
||||
null, "CloudModuleUpdate");
|
||||
Monitor.Exit(cloudlock);
|
||||
}
|
||||
}
|
||||
|
||||
public void CloudsToClient(IClientAPI client)
|
||||
{
|
||||
if (m_ready)
|
||||
{
|
||||
client.SendCloudData(cloudCover);
|
||||
lock(cloudlock)
|
||||
client.SendCloudData(m_dataVersion, cloudCover);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1360,7 +1360,8 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||
|
||||
public void sendRegionInfoPacketToAll()
|
||||
{
|
||||
Scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
// Scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
Scene.ForEachClient(delegate(IClientAPI client)
|
||||
{
|
||||
HandleRegionInfoRequest(client);
|
||||
});
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
|
||||
sr.Close();
|
||||
body = body.Trim();
|
||||
|
||||
m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);
|
||||
// m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
@@ -212,7 +212,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
client.OnParcelReclaim += ClientOnParcelReclaim;
|
||||
client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
|
||||
client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
|
||||
client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
|
||||
client.OnParcelEjectUser += ClientOnParcelEjectUser;
|
||||
client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
|
||||
client.OnSetStartLocationRequest += ClientOnSetHome;
|
||||
@@ -223,10 +222,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
avatar.currentParcelUUID = UUID.Zero;
|
||||
}
|
||||
|
||||
void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
public void WindUpdate(uint frame)
|
||||
public bool WindUpdate(uint frame)
|
||||
{
|
||||
double avgAng = m_avgDirection * (Math.PI/180.0f);
|
||||
double varDir = m_varDirection * (Math.PI/180.0f);
|
||||
@@ -125,10 +125,8 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
offset = Math.Sin(theta) * Math.Sin(theta*4) + (Math.Sin(theta*13) / 3);
|
||||
double windSpeed = m_avgStrength + (m_varStrength * offset);
|
||||
|
||||
if (windSpeed<0)
|
||||
windSpeed=0;
|
||||
|
||||
|
||||
if (windSpeed < 0)
|
||||
windSpeed = -windSpeed;
|
||||
|
||||
m_curPredominateWind.X = (float)Math.Cos(windDir);
|
||||
m_curPredominateWind.Y = (float)Math.Sin(windDir);
|
||||
@@ -144,6 +142,7 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
m_windSpeeds[y * 16 + x] = m_curPredominateWind;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector3 WindSpeed(float fX, float fY, float fZ)
|
||||
|
||||
@@ -82,22 +82,23 @@ namespace OpenSim.Region.CoreModules.World.Wind.Plugins
|
||||
}
|
||||
}
|
||||
|
||||
public void WindUpdate(uint frame)
|
||||
public bool WindUpdate(uint frame)
|
||||
{
|
||||
//Make sure our object is valid (we haven't been disposed of yet)
|
||||
if (m_windSpeeds != null)
|
||||
if (m_windSpeeds == null)
|
||||
return false;
|
||||
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
for (int y = 0; y < 16; y++)
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].X *= m_strength;
|
||||
m_windSpeeds[y * 16 + x].Y *= m_strength;
|
||||
}
|
||||
m_windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||
m_windSpeeds[y * 16 + x].X *= m_strength;
|
||||
m_windSpeeds[y * 16 + x].Y *= m_strength;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Vector3 WindSpeed(float fX, float fY, float fZ)
|
||||
|
||||
@@ -46,11 +46,13 @@ namespace OpenSim.Region.CoreModules
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private uint m_frame = 0;
|
||||
private uint m_frameLastUpdateClientArray = 0;
|
||||
private int m_dataVersion = 0;
|
||||
private int m_regionID = 0;
|
||||
private int m_frameUpdateRate = 150;
|
||||
//private Random m_rndnums = new Random(Environment.TickCount);
|
||||
private Scene m_scene = null;
|
||||
private bool m_ready = false;
|
||||
private bool m_inUpdate = false;
|
||||
|
||||
private bool m_enabled = false;
|
||||
private IConfig m_windConfig;
|
||||
@@ -96,7 +98,6 @@ namespace OpenSim.Region.CoreModules
|
||||
|
||||
m_scene = scene;
|
||||
m_frame = 0;
|
||||
|
||||
// Register all the Wind Model Plug-ins
|
||||
foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false))
|
||||
{
|
||||
@@ -118,7 +119,6 @@ namespace OpenSim.Region.CoreModules
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// if the plug-in wasn't found, default to no wind.
|
||||
if (m_activeWindPlugin == null)
|
||||
{
|
||||
@@ -154,14 +154,14 @@ namespace OpenSim.Region.CoreModules
|
||||
|
||||
// Register event handlers for when Avatars enter the region, and frame ticks
|
||||
m_scene.EventManager.OnFrame += WindUpdate;
|
||||
m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion;
|
||||
|
||||
// Register the wind module
|
||||
m_scene.RegisterModuleInterface<IWindModule>(this);
|
||||
|
||||
// Generate initial wind values
|
||||
GenWindPos();
|
||||
|
||||
GenWind();
|
||||
// hopefully this will not be the same for all regions on same instance
|
||||
m_dataVersion = (int)m_scene.AllocateLocalId();
|
||||
// Mark Module Ready for duty
|
||||
m_ready = true;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace OpenSim.Region.CoreModules
|
||||
|
||||
// Remove our hooks
|
||||
m_scene.EventManager.OnFrame -= WindUpdate;
|
||||
m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
|
||||
// m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion;
|
||||
|
||||
}
|
||||
|
||||
@@ -416,67 +416,43 @@ namespace OpenSim.Region.CoreModules
|
||||
/// </summary>
|
||||
public void WindUpdate()
|
||||
{
|
||||
if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready)
|
||||
{
|
||||
if ((!m_ready || m_inUpdate || (m_frame++ % m_frameUpdateRate) != 0))
|
||||
return;
|
||||
}
|
||||
|
||||
GenWindPos();
|
||||
|
||||
SendWindAllClients();
|
||||
}
|
||||
|
||||
public void OnAgentEnteredRegion(ScenePresence avatar)
|
||||
{
|
||||
if (m_ready)
|
||||
m_inUpdate = true;
|
||||
Util.FireAndForget(delegate
|
||||
{
|
||||
if (m_activeWindPlugin != null)
|
||||
try
|
||||
{
|
||||
// Ask wind plugin to generate a LL wind array to be cached locally
|
||||
// Try not to update this too often, as it may involve array copies
|
||||
if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate))
|
||||
GenWind();
|
||||
m_scene.ForEachClient(delegate(IClientAPI client)
|
||||
{
|
||||
windSpeeds = m_activeWindPlugin.WindLLClientArray();
|
||||
m_frameLastUpdateClientArray = m_frame;
|
||||
}
|
||||
}
|
||||
|
||||
avatar.ControllingClient.SendWindData(windSpeeds);
|
||||
}
|
||||
}
|
||||
|
||||
private void SendWindAllClients()
|
||||
{
|
||||
if (m_ready)
|
||||
{
|
||||
if (m_scene.GetRootAgentCount() > 0)
|
||||
{
|
||||
// Ask wind plugin to generate a LL wind array to be cached locally
|
||||
// Try not to update this too often, as it may involve array copies
|
||||
if (m_frame >= (m_frameLastUpdateClientArray + m_frameUpdateRate))
|
||||
{
|
||||
windSpeeds = m_activeWindPlugin.WindLLClientArray();
|
||||
m_frameLastUpdateClientArray = m_frame;
|
||||
}
|
||||
|
||||
m_scene.ForEachRootClient(delegate(IClientAPI client)
|
||||
{
|
||||
client.SendWindData(windSpeeds);
|
||||
client.SendWindData(m_dataVersion, windSpeeds);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_inUpdate = false;
|
||||
}
|
||||
},
|
||||
null, "WindModuleUpdate");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculate the sun's orbital position and its velocity.
|
||||
/// Calculate new wind
|
||||
/// returns false if no change
|
||||
/// </summary>
|
||||
|
||||
private void GenWindPos()
|
||||
private bool GenWind()
|
||||
{
|
||||
if (m_activeWindPlugin != null)
|
||||
if (m_activeWindPlugin != null && m_activeWindPlugin.WindUpdate(m_frame))
|
||||
{
|
||||
// Tell Wind Plugin to update it's wind data
|
||||
m_activeWindPlugin.WindUpdate(m_frame);
|
||||
windSpeeds = m_activeWindPlugin.WindLLClientArray();
|
||||
m_dataVersion++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user