First pass at cleaning up thread safety in EntityManager and SceneGraph
parent
9609faa8eb
commit
dd277a0d02
|
@ -40,15 +40,4 @@ namespace OpenSim.Data
|
|||
void Initialise(string connect);
|
||||
bool Delete(string id);
|
||||
}
|
||||
|
||||
public class AssetDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public AssetDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
IAssetDataPlugin p = plugin as IAssetDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,15 +155,4 @@ namespace OpenSim.Data
|
|||
/// </returns>
|
||||
List<InventoryItemBase> fetchActiveGestures(UUID avatarID);
|
||||
}
|
||||
|
||||
public class InventoryDataInitialiser : PluginInitialiserBase
|
||||
{
|
||||
private string connect;
|
||||
public InventoryDataInitialiser (string s) { connect = s; }
|
||||
public override void Initialise (IPlugin plugin)
|
||||
{
|
||||
IInventoryDataPlugin p = plugin as IInventoryDataPlugin;
|
||||
p.Initialise (connect);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -436,7 +436,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
|
||||
// We can NOT use the dictionries here, as we are looking
|
||||
// for an entity by the fromAssetID, which is NOT the prim UUID
|
||||
List<EntityBase> detachEntities = m_scene.GetEntities();
|
||||
EntityBase[] detachEntities = m_scene.GetEntities();
|
||||
SceneObjectGroup group;
|
||||
|
||||
foreach (EntityBase entity in detachEntities)
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
{
|
||||
Dictionary<UUID, AssetType> assetUuids = new Dictionary<UUID, AssetType>();
|
||||
|
||||
List<EntityBase> entities = m_scene.GetEntities();
|
||||
EntityBase[] entities = m_scene.GetEntities();
|
||||
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
|
||||
|
||||
/*
|
||||
|
|
|
@ -794,7 +794,8 @@ namespace OpenSim.Region.CoreModules.World.Land
|
|||
public void EventManagerOnParcelPrimCountUpdate()
|
||||
{
|
||||
ResetAllLandPrimCounts();
|
||||
foreach (EntityBase obj in m_scene.Entities)
|
||||
EntityBase[] entities = m_scene.Entities.GetEntities();
|
||||
foreach (EntityBase obj in entities)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
|
|||
{
|
||||
string xmlstream = "<scene>";
|
||||
|
||||
List<EntityBase> EntityList = scene.GetEntities();
|
||||
EntityBase[] EntityList = scene.GetEntities();
|
||||
List<string> EntityXml = new List<string>();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
|
|
|
@ -165,12 +165,12 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
|
|||
return SceneXmlLoader.SaveGroupToXml2(grp);
|
||||
}
|
||||
|
||||
public void SavePrimListToXml2(List<EntityBase> entityList, string fileName)
|
||||
public void SavePrimListToXml2(EntityBase[] entityList, string fileName)
|
||||
{
|
||||
SceneXmlLoader.SavePrimListToXml2(entityList, fileName);
|
||||
}
|
||||
|
||||
public void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, Vector3 min, Vector3 max)
|
||||
public void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
SceneXmlLoader.SavePrimListToXml2(entityList, stream, min, max);
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
double[,] hm = whichScene.Heightmap.GetDoubles();
|
||||
tc = Environment.TickCount;
|
||||
m_log.Info("[MAPTILE]: Generating Maptile Step 2: Object Volume Profile");
|
||||
List<EntityBase> objs = whichScene.GetEntities();
|
||||
EntityBase[] objs = whichScene.GetEntities();
|
||||
Dictionary<uint, DrawStruct> z_sort = new Dictionary<uint, DrawStruct>();
|
||||
//SortedList<float, RectangleDrawStruct> z_sort = new SortedList<float, RectangleDrawStruct>();
|
||||
List<float> z_sortheights = new List<float>();
|
||||
|
|
|
@ -101,7 +101,8 @@ namespace OpenSim.Region.DataSnapshot.Providers
|
|||
XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "objectdata", "");
|
||||
XmlNode node;
|
||||
|
||||
foreach (EntityBase entity in m_scene.Entities)
|
||||
EntityBase[] entities = m_scene.Entities.GetEntities();
|
||||
foreach (EntityBase entity in entities)
|
||||
{
|
||||
// only objects, not avatars
|
||||
if (entity is SceneObjectGroup)
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// </summary>
|
||||
/// <param name="entityList"></param>
|
||||
/// <param name="fileName"></param>
|
||||
void SavePrimListToXml2(List<EntityBase> entityList, string fileName);
|
||||
void SavePrimListToXml2(EntityBase[] entityList, string fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Save a set of prims in the xml2 format, optionally specifying a bounding box for which
|
||||
|
@ -101,7 +101,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <param name="stream"></param>
|
||||
/// <param name="min"></param>
|
||||
/// <param name="max"></param>
|
||||
void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, Vector3 min, Vector3 max);
|
||||
void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max);
|
||||
|
||||
void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName);
|
||||
|
||||
|
|
|
@ -34,238 +34,128 @@ using OpenMetaverse;
|
|||
|
||||
namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
public class EntityManager : IEnumerable<EntityBase>
|
||||
public class EntityManager //: IEnumerable<EntityBase>
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>();
|
||||
private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>();
|
||||
//private readonly Dictionary<UUID, ScenePresence> m_pres_uuid = new Dictionary<UUID, ScenePresence>();
|
||||
private readonly Object m_lock = new Object();
|
||||
private readonly DoubleDictionary<UUID, uint, EntityBase> m_entities = new DoubleDictionary<UUID, uint, EntityBase>();
|
||||
|
||||
[Obsolete("Use Add() instead.")]
|
||||
public void Add(UUID id, EntityBase eb)
|
||||
public int Count
|
||||
{
|
||||
Add(eb);
|
||||
get { return m_entities.Count; }
|
||||
}
|
||||
|
||||
public void Add(EntityBase entity)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_eb_uuid.Add(entity.UUID, entity);
|
||||
m_eb_localID.Add(entity.LocalId, entity);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("Add Entity failed: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertOrReplace(EntityBase entity)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_eb_uuid[entity.UUID] = entity;
|
||||
m_eb_localID[entity.LocalId] = entity;
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
m_entities.Add(entity.UUID, entity.LocalId, entity);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
m_eb_uuid.Clear();
|
||||
m_eb_localID.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_eb_uuid.Count;
|
||||
}
|
||||
m_entities.Clear();
|
||||
}
|
||||
|
||||
public bool ContainsKey(UUID id)
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_eb_uuid.ContainsKey(id);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_entities.ContainsKey(id);
|
||||
}
|
||||
|
||||
public bool ContainsKey(uint localID)
|
||||
{
|
||||
try
|
||||
{
|
||||
return m_eb_localID.ContainsKey(localID);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return m_entities.ContainsKey(localID);
|
||||
}
|
||||
|
||||
public bool Remove(uint localID)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool a = false;
|
||||
EntityBase entity;
|
||||
if (m_eb_localID.TryGetValue(localID, out entity))
|
||||
a = m_eb_uuid.Remove(entity.UUID);
|
||||
|
||||
bool b = m_eb_localID.Remove(localID);
|
||||
return a && b;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("Remove Entity failed for {0}", localID, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return m_entities.Remove(localID);
|
||||
}
|
||||
|
||||
public bool Remove(UUID id)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool a = false;
|
||||
EntityBase entity;
|
||||
if (m_eb_uuid.TryGetValue(id, out entity))
|
||||
a = m_eb_localID.Remove(entity.LocalId);
|
||||
|
||||
bool b = m_eb_uuid.Remove(id);
|
||||
return a && b;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("Remove Entity failed for {0}", id, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return m_entities.Remove(id);
|
||||
}
|
||||
|
||||
public List<EntityBase> GetAllByType<T>()
|
||||
public EntityBase[] GetAllByType<T>()
|
||||
{
|
||||
List<EntityBase> tmp = new List<EntityBase>();
|
||||
|
||||
lock (m_lock)
|
||||
m_entities.ForEach(
|
||||
delegate(EntityBase entity)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (KeyValuePair<UUID, EntityBase> pair in m_eb_uuid)
|
||||
{
|
||||
if (pair.Value is T)
|
||||
{
|
||||
tmp.Add(pair.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("GetAllByType failed for {0}", e);
|
||||
tmp = null;
|
||||
if (entity is T)
|
||||
tmp.Add(entity);
|
||||
}
|
||||
);
|
||||
|
||||
return tmp.ToArray();
|
||||
}
|
||||
|
||||
return tmp;
|
||||
public EntityBase[] GetEntities()
|
||||
{
|
||||
List<EntityBase> tmp = new List<EntityBase>(m_entities.Count);
|
||||
m_entities.ForEach(delegate(EntityBase entity) { tmp.Add(entity); });
|
||||
return tmp.ToArray();
|
||||
}
|
||||
|
||||
public List<EntityBase> GetEntities()
|
||||
public void ForEach(Action<EntityBase> action)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
return new List<EntityBase>(m_eb_uuid.Values);
|
||||
m_entities.ForEach(action);
|
||||
}
|
||||
|
||||
public EntityBase Find(Predicate<EntityBase> predicate)
|
||||
{
|
||||
return m_entities.FindValue(predicate);
|
||||
}
|
||||
|
||||
public EntityBase this[UUID id]
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
EntityBase entity;
|
||||
if (m_eb_uuid.TryGetValue(id, out entity))
|
||||
m_entities.TryGetValue(id, out entity);
|
||||
return entity;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
InsertOrReplace(value);
|
||||
Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public EntityBase this[uint localID]
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
EntityBase entity;
|
||||
if (m_eb_localID.TryGetValue(localID, out entity))
|
||||
m_entities.TryGetValue(localID, out entity);
|
||||
return entity;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
InsertOrReplace(value);
|
||||
Add(value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetValue(UUID key, out EntityBase obj)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
return m_eb_uuid.TryGetValue(key, out obj);
|
||||
}
|
||||
return m_entities.TryGetValue(key, out obj);
|
||||
}
|
||||
|
||||
public bool TryGetValue(uint key, out EntityBase obj)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
return m_eb_localID.TryGetValue(key, out obj);
|
||||
}
|
||||
return m_entities.TryGetValue(key, out obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This could be optimised to work on the list 'live' rather than making a safe copy and iterating that.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerator<EntityBase> GetEnumerator()
|
||||
{
|
||||
return GetEntities().GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
//public IEnumerator<EntityBase> GetEnumerator()
|
||||
//{
|
||||
// return GetEntities().GetEnumerator();
|
||||
//}
|
||||
|
||||
//IEnumerator IEnumerable.GetEnumerator()
|
||||
//{
|
||||
// return GetEnumerator();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
m_log.Info("[PRIM INVENTORY]: Starting scripts in scene");
|
||||
|
||||
foreach (EntityBase group in Entities)
|
||||
EntityBase[] entities = Entities.GetEntities();
|
||||
foreach (EntityBase group in entities)
|
||||
{
|
||||
if (group is SceneObjectGroup)
|
||||
{
|
||||
|
|
|
@ -116,9 +116,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="remoteClient"></param>
|
||||
public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
|
@ -138,9 +137,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="remoteClient"></param>
|
||||
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
|
@ -259,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
EntityBase[] EntityList = GetEntities();
|
||||
|
||||
SurfaceTouchEventArgs surfaceArg = null;
|
||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||
|
@ -303,7 +301,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public virtual void ProcessObjectGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
EntityBase[] EntityList = GetEntities();
|
||||
|
||||
SurfaceTouchEventArgs surfaceArg = null;
|
||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||
|
@ -343,7 +341,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
EntityBase[] EntityList = GetEntities();
|
||||
|
||||
SurfaceTouchEventArgs surfaceArg = null;
|
||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||
|
|
|
@ -1029,29 +1029,30 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (ScriptEngine)
|
||||
{
|
||||
m_log.Info("Stopping all Scripts in Scene");
|
||||
foreach (EntityBase ent in Entities)
|
||||
|
||||
EntityBase[] entities = Entities.GetEntities();
|
||||
foreach (EntityBase ent in entities)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup)ent).RemoveScriptInstances(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Info("Starting all Scripts in Scene");
|
||||
lock (Entities)
|
||||
{
|
||||
foreach (EntityBase ent in Entities)
|
||||
|
||||
EntityBase[] entities = Entities.GetEntities();
|
||||
foreach (EntityBase ent in entities)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
|
||||
((SceneObjectGroup)ent).ResumeScripts();
|
||||
}
|
||||
SceneObjectGroup sog = (SceneObjectGroup)ent;
|
||||
sog.CreateScriptInstances(0, false, DefaultScriptEngine, 0);
|
||||
sog.ResumeScripts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_scripts_enabled = !ScriptEngine;
|
||||
m_log.Info("[TOTEDD]: Here is the method to trigger disabling of the scripting engine");
|
||||
}
|
||||
|
@ -1098,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
shuttingdown = true;
|
||||
|
||||
m_log.Debug("[SCENE]: Persisting changed objects");
|
||||
List<EntityBase> entities = GetEntities();
|
||||
EntityBase[] entities = GetEntities();
|
||||
foreach (EntityBase entity in entities)
|
||||
{
|
||||
if (!entity.IsDeleted && entity is SceneObjectGroup && ((SceneObjectGroup)entity).HasGroupChanged)
|
||||
|
@ -2037,8 +2038,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
lock (Entities)
|
||||
{
|
||||
ICollection<EntityBase> entities = new List<EntityBase>(Entities);
|
||||
|
||||
EntityBase[] entities = Entities.GetEntities();
|
||||
foreach (EntityBase e in entities)
|
||||
{
|
||||
if (e is SceneObjectGroup)
|
||||
|
@ -3977,9 +3977,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </summary>
|
||||
public void ForceClientUpdate()
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
|
@ -3997,9 +3996,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
m_log.Debug("Searching for Primitive: '" + cmdparams[2] + "'");
|
||||
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
|
@ -4368,7 +4366,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// will not affect the original list of objects in the scene.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<EntityBase> GetEntities()
|
||||
public EntityBase[] GetEntities()
|
||||
{
|
||||
return m_sceneGraph.GetEntities();
|
||||
}
|
||||
|
@ -4402,9 +4400,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void CleanTempObjects()
|
||||
{
|
||||
List<EntityBase> objs = GetEntities();
|
||||
|
||||
foreach (EntityBase obj in objs)
|
||||
EntityBase[] entities = GetEntities();
|
||||
foreach (EntityBase obj in entities)
|
||||
{
|
||||
if (obj is SceneObjectGroup)
|
||||
{
|
||||
|
|
|
@ -348,20 +348,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
|
||||
return false;
|
||||
|
||||
lock (sceneObject)
|
||||
{
|
||||
if (Entities.ContainsKey(sceneObject.UUID))
|
||||
{
|
||||
// m_log.WarnFormat(
|
||||
// "[SCENE GRAPH]: Scene object {0} {1} was already in region {2} on add request",
|
||||
// sceneObject.Name, sceneObject.UUID, m_parentScene.RegionInfo.RegionName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[SCENE GRAPH]: Adding object {0} {1} to region {2}",
|
||||
// sceneObject.Name, sceneObject.UUID, m_parentScene.RegionInfo.RegionName);
|
||||
|
||||
// Clamp child prim sizes and add child prims to the m_numPrim count
|
||||
lock (sceneObject.Children)
|
||||
{
|
||||
if (m_parentScene.m_clampPrimSize)
|
||||
|
@ -410,7 +400,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
foreach (SceneObjectPart part in sceneObject.Children.Values)
|
||||
SceneObjectGroupsByLocalID[part.LocalId] = sceneObject;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -421,9 +410,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <returns>true if the object was deleted, false if there was no object to delete</returns>
|
||||
public bool DeleteSceneObject(UUID uuid, bool resultOfObjectLinked)
|
||||
{
|
||||
if (Entities.ContainsKey(uuid))
|
||||
{
|
||||
SceneObjectGroup grp = (SceneObjectGroup)Entities[uuid];
|
||||
EntityBase entity;
|
||||
if (!Entities.TryGetValue(uuid, out entity) && entity is SceneObjectGroup)
|
||||
return false;
|
||||
|
||||
SceneObjectGroup grp = (SceneObjectGroup)entity;
|
||||
|
||||
if (!resultOfObjectLinked)
|
||||
{
|
||||
|
@ -442,6 +433,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
SceneObjectGroupsByFullID.Remove(part.UUID);
|
||||
SceneObjectGroupsByFullID.Remove(grp.RootPart.UUID);
|
||||
}
|
||||
|
||||
lock (SceneObjectGroupsByLocalID)
|
||||
{
|
||||
foreach (SceneObjectPart part in grp.Children.Values)
|
||||
|
@ -449,14 +441,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
SceneObjectGroupsByLocalID.Remove(grp.RootPart.LocalId);
|
||||
}
|
||||
|
||||
Entities.Remove(uuid);
|
||||
//SceneObjectGroup part;
|
||||
//((part.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Entities.Remove(uuid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -468,10 +453,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
protected internal void AddToUpdateList(SceneObjectGroup obj)
|
||||
{
|
||||
lock (m_updateList)
|
||||
{
|
||||
m_updateList[obj.UUID] = obj;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process all pending updates
|
||||
|
@ -480,7 +463,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
if (!Monitor.TryEnter(m_updateLock))
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
List<SceneObjectGroup> updates;
|
||||
|
||||
// Some updates add more updates to the updateList.
|
||||
|
@ -507,8 +491,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
"[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Monitor.Exit(m_updateLock);
|
||||
}
|
||||
}
|
||||
|
||||
protected internal void AddPhysicalPrim(int number)
|
||||
{
|
||||
|
@ -864,8 +852,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <returns>null if no scene object group containing that prim is found</returns>
|
||||
public SceneObjectGroup GetGroupByPrim(uint localID)
|
||||
{
|
||||
if (Entities.ContainsKey(localID))
|
||||
return Entities[localID] as SceneObjectGroup;
|
||||
EntityBase entity;
|
||||
if (Entities.TryGetValue(localID, out entity))
|
||||
return entity as SceneObjectGroup;
|
||||
|
||||
//m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID);
|
||||
SceneObjectGroup sog;
|
||||
|
@ -879,23 +868,22 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
//m_log.DebugFormat("Looking at entity {0}", ent.UUID);
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup)ent).HasChildPrim(localID))
|
||||
{
|
||||
sog = (SceneObjectGroup)ent;
|
||||
lock (SceneObjectGroupsByLocalID)
|
||||
if (sog.HasChildPrim(localID))
|
||||
{
|
||||
lock (SceneObjectGroupsByLocalID)
|
||||
SceneObjectGroupsByLocalID[localID] = sog;
|
||||
}
|
||||
return sog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -921,23 +909,21 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
if (((SceneObjectGroup)ent).HasChildPrim(fullID))
|
||||
{
|
||||
sog = (SceneObjectGroup)ent;
|
||||
lock (SceneObjectGroupsByFullID)
|
||||
if (sog.HasChildPrim(fullID))
|
||||
{
|
||||
lock (SceneObjectGroupsByFullID)
|
||||
SceneObjectGroupsByFullID[fullID] = sog;
|
||||
}
|
||||
return sog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -946,7 +932,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// Primitive Ray Tracing
|
||||
float closestDistance = 280f;
|
||||
EntityIntersection result = new EntityIntersection();
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
EntityBase[] EntityList = GetEntities();
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
|
@ -984,23 +970,28 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <returns>null if the part was not found</returns>
|
||||
protected internal SceneObjectPart GetSceneObjectPart(string name)
|
||||
{
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
SceneObjectPart sop = null;
|
||||
|
||||
// FIXME: use a dictionary here
|
||||
foreach (EntityBase ent in EntityList)
|
||||
Entities.Find(
|
||||
delegate(EntityBase entity)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
if (entity is SceneObjectGroup)
|
||||
{
|
||||
foreach (SceneObjectPart p in ((SceneObjectGroup) ent).GetParts())
|
||||
foreach (SceneObjectPart p in ((SceneObjectGroup)entity).GetParts())
|
||||
{
|
||||
if (p.Name == name)
|
||||
{
|
||||
return p;
|
||||
sop = p;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
);
|
||||
|
||||
return sop;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1021,7 +1012,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// it
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected internal List<EntityBase> GetEntities()
|
||||
protected internal EntityBase[] GetEntities()
|
||||
{
|
||||
return Entities.GetEntities();
|
||||
}
|
||||
|
@ -1030,7 +1021,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
|
||||
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
EntityBase[] EntityList = GetEntities();
|
||||
int limit = 0;
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
|
@ -1726,8 +1717,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
UUID objid = UUID.Zero;
|
||||
SceneObjectPart obj = null;
|
||||
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
|
|
|
@ -75,7 +75,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
lock(m_pendingObjects)
|
||||
{
|
||||
foreach (EntityBase e in m_presence.Scene.Entities)
|
||||
EntityBase[] entities = m_presence.Scene.Entities.GetEntities();
|
||||
foreach (EntityBase e in entities)
|
||||
{
|
||||
if (e != null && e is SceneObjectGroup)
|
||||
m_pendingObjects.Enqueue((SceneObjectGroup)e);
|
||||
|
|
|
@ -84,9 +84,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
||||
List<EntityBase> EntityList = scene.GetEntities();
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
foreach (EntityBase ent in entityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
|
@ -204,16 +203,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
|
||||
public static void SavePrimsToXml2(Scene scene, string fileName)
|
||||
{
|
||||
List<EntityBase> EntityList = scene.GetEntities();
|
||||
|
||||
SavePrimListToXml2(EntityList, fileName);
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
SavePrimListToXml2(entityList, fileName);
|
||||
}
|
||||
|
||||
public static void SavePrimsToXml2(Scene scene, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
List<EntityBase> EntityList = scene.GetEntities();
|
||||
|
||||
SavePrimListToXml2(EntityList, stream, min, max);
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
SavePrimListToXml2(entityList, stream, min, max);
|
||||
}
|
||||
|
||||
public static void SaveNamedPrimsToXml2(Scene scene, string primName, string fileName)
|
||||
|
@ -222,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
"[SERIALISER]: Saving prims with name {0} in xml2 format for region {1} to {2}",
|
||||
primName, scene.RegionInfo.RegionName, fileName);
|
||||
|
||||
List<EntityBase> entityList = scene.GetEntities();
|
||||
EntityBase[] entityList = scene.GetEntities();
|
||||
List<EntityBase> primList = new List<EntityBase>();
|
||||
|
||||
foreach (EntityBase ent in entityList)
|
||||
|
@ -236,10 +233,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
}
|
||||
}
|
||||
|
||||
SavePrimListToXml2(primList, fileName);
|
||||
SavePrimListToXml2(primList.ToArray(), fileName);
|
||||
}
|
||||
|
||||
public static void SavePrimListToXml2(List<EntityBase> entityList, string fileName)
|
||||
public static void SavePrimListToXml2(EntityBase[] entityList, string fileName)
|
||||
{
|
||||
FileStream file = new FileStream(fileName, FileMode.Create);
|
||||
try
|
||||
|
@ -260,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
}
|
||||
}
|
||||
|
||||
public static void SavePrimListToXml2(List<EntityBase> entityList, TextWriter stream, Vector3 min, Vector3 max)
|
||||
public static void SavePrimListToXml2(EntityBase[] entityList, TextWriter stream, Vector3 min, Vector3 max)
|
||||
{
|
||||
int primCount = 0;
|
||||
stream.WriteLine("<scene>\n");
|
||||
|
|
|
@ -375,8 +375,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
|||
|
||||
private void IRC_SendNamesReply()
|
||||
{
|
||||
List<EntityBase> users = m_scene.Entities.GetAllByType<ScenePresence>();
|
||||
|
||||
EntityBase[] users = m_scene.Entities.GetAllByType<ScenePresence>();
|
||||
foreach (EntityBase user in users)
|
||||
{
|
||||
SendServerCommand("353 " + m_nick + " = " + IrcRegionName + " :" + user.Name.Replace(" ", ""));
|
||||
|
@ -386,8 +385,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
|||
|
||||
private void IRC_SendWhoReply()
|
||||
{
|
||||
List<EntityBase> users = m_scene.Entities.GetAllByType<ScenePresence>();
|
||||
|
||||
EntityBase[] users = m_scene.Entities.GetAllByType<ScenePresence>();
|
||||
foreach (EntityBase user in users)
|
||||
{
|
||||
/*SendServerCommand(String.Format("352 {0} {1} {2} {3} {4} {5} :0 {6}", IrcRegionName,
|
||||
|
@ -415,11 +413,11 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
|||
|
||||
private void IRC_SendReplyUsers()
|
||||
{
|
||||
List<EntityBase> users = m_scene.Entities.GetAllByType<ScenePresence>();
|
||||
EntityBase[] users = m_scene.Entities.GetAllByType<ScenePresence>();
|
||||
|
||||
SendServerCommand("392 :UserID Terminal Host");
|
||||
|
||||
if (users.Count == 0)
|
||||
if (users.Length == 0)
|
||||
{
|
||||
SendServerCommand("395 :Nobody logged in");
|
||||
return;
|
||||
|
|
|
@ -111,7 +111,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
}
|
||||
|
||||
// Check if there are SceneObjectGroups in the list that do not have corresponding ContentManagementGroups in the CMEntityHash
|
||||
public System.Collections.ArrayList CheckForMissingEntities(System.Collections.Generic.List<EntityBase> currList)
|
||||
public System.Collections.ArrayList CheckForMissingEntities(EntityBase[] currList)
|
||||
{
|
||||
System.Collections.ArrayList missingList = new System.Collections.ArrayList();
|
||||
SceneObjectGroup temp = null;
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
/// </summary>
|
||||
public void FindDifferences()
|
||||
{
|
||||
System.Collections.Generic.List<EntityBase> sceneEntityList = m_Entity.Scene.GetEntities();
|
||||
List<EntityBase> sceneEntityList = new List<EntityBase>(m_Entity.Scene.GetEntities());
|
||||
DiffersFromSceneGroup = false;
|
||||
// if group is not contained in scene's list
|
||||
if (!ContainsKey(sceneEntityList, m_UnchangedEntity.UUID))
|
||||
|
|
|
@ -41,12 +41,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
private readonly Scene m_scene;
|
||||
private readonly IEnumerator<EntityBase> m_sogEnum;
|
||||
private readonly ISecurityCredential m_security;
|
||||
private readonly List<EntityBase> m_entities;
|
||||
|
||||
public IObjEnum(Scene scene, ISecurityCredential security)
|
||||
{
|
||||
m_scene = scene;
|
||||
m_security = security;
|
||||
m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator();
|
||||
m_entities = new List<EntityBase>(m_scene.Entities.GetEntities());
|
||||
m_sogEnum = m_entities.GetEnumerator();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
@ -205,10 +205,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
|
|||
{
|
||||
get
|
||||
{
|
||||
List<EntityBase> ents = m_internalScene.Entities.GetAllByType<ScenePresence>();
|
||||
IAvatar[] rets = new IAvatar[ents.Count];
|
||||
EntityBase[] ents = m_internalScene.Entities.GetAllByType<ScenePresence>();
|
||||
IAvatar[] rets = new IAvatar[ents.Length];
|
||||
|
||||
for (int i = 0; i < ents.Count; i++)
|
||||
for (int i = 0; i < ents.Length; i++)
|
||||
{
|
||||
EntityBase ent = ents[i];
|
||||
rets[i] = new SPAvatar(m_internalScene, ent.UUID, m_security);
|
||||
|
|
|
@ -568,8 +568,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
|
|||
{
|
||||
m_copse = new List<Copse>();
|
||||
|
||||
List<EntityBase> objs = m_scene.GetEntities();
|
||||
|
||||
EntityBase[] objs = m_scene.GetEntities();
|
||||
foreach (EntityBase obj in objs)
|
||||
{
|
||||
if (obj is SceneObjectGroup)
|
||||
|
|
|
@ -286,7 +286,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
|||
}
|
||||
else
|
||||
{
|
||||
Entities = m_CmdManager.m_ScriptEngine.World.GetEntities();
|
||||
Entities = new List<EntityBase>(m_CmdManager.m_ScriptEngine.World.GetEntities());
|
||||
}
|
||||
SceneObjectPart SensePoint = ts.host;
|
||||
|
||||
|
|
|
@ -69,7 +69,10 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
public void OnMakeRootAgent(ScenePresence sp)
|
||||
{
|
||||
m_log.DebugFormat("[SIMIAN ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
|
||||
Util.FireAndForget(delegate(object o)
|
||||
{
|
||||
m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnNewClient(IClientAPI client)
|
||||
|
|
Loading…
Reference in New Issue