diff options
author | John Hurliman | 2010-09-10 12:41:36 -0700 |
---|---|---|
committer | John Hurliman | 2010-09-10 12:41:36 -0700 |
commit | b597a295c489cef217b9dca6bd22df1340ca39ce (patch) | |
tree | dbd74bb48f962fb7b64cc67db6df890451859782 /OpenSim/Region/Framework/Scenes/SceneGraph.cs | |
parent | First pass at cleaning up thread safety in EntityManager and SceneGraph (diff) | |
download | opensim-SC-b597a295c489cef217b9dca6bd22df1340ca39ce.zip opensim-SC-b597a295c489cef217b9dca6bd22df1340ca39ce.tar.gz opensim-SC-b597a295c489cef217b9dca6bd22df1340ca39ce.tar.bz2 opensim-SC-b597a295c489cef217b9dca6bd22df1340ca39ce.tar.xz |
Second pass at cleaning up thread safety in EntityManager and SceneGraph
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 3d3e822..f779a6d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -72,10 +72,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); | 72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); |
73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
74 | 74 | ||
75 | // SceneObjects is not currently populated or used. | ||
76 | //public Dictionary<UUID, SceneObjectGroup> SceneObjects; | ||
77 | protected internal EntityManager Entities = new EntityManager(); | 75 | protected internal EntityManager Entities = new EntityManager(); |
78 | // protected internal Dictionary<UUID, EntityBase> Entities = new Dictionary<UUID, EntityBase>(); | ||
79 | protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); | 76 | protected internal Dictionary<UUID, ScenePresence> RestorePresences = new Dictionary<UUID, ScenePresence>(); |
80 | 77 | ||
81 | protected RegionInfo m_regInfo; | 78 | protected RegionInfo m_regInfo; |
@@ -351,28 +348,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | if (Entities.ContainsKey(sceneObject.UUID)) | 348 | if (Entities.ContainsKey(sceneObject.UUID)) |
352 | return false; | 349 | return false; |
353 | 350 | ||
354 | // Clamp child prim sizes and add child prims to the m_numPrim count | 351 | List<SceneObjectPart> children; |
355 | lock (sceneObject.Children) | 352 | lock (sceneObject.Children) |
353 | children = new List<SceneObjectPart>(sceneObject.Children.Values); | ||
354 | |||
355 | // Clamp child prim sizes and add child prims to the m_numPrim count | ||
356 | if (m_parentScene.m_clampPrimSize) | ||
356 | { | 357 | { |
357 | if (m_parentScene.m_clampPrimSize) | 358 | foreach (SceneObjectPart part in children) |
358 | { | 359 | { |
359 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 360 | Vector3 scale = part.Shape.Scale; |
360 | { | ||
361 | Vector3 scale = part.Shape.Scale; | ||
362 | 361 | ||
363 | if (scale.X > m_parentScene.m_maxNonphys) | 362 | if (scale.X > m_parentScene.m_maxNonphys) |
364 | scale.X = m_parentScene.m_maxNonphys; | 363 | scale.X = m_parentScene.m_maxNonphys; |
365 | if (scale.Y > m_parentScene.m_maxNonphys) | 364 | if (scale.Y > m_parentScene.m_maxNonphys) |
366 | scale.Y = m_parentScene.m_maxNonphys; | 365 | scale.Y = m_parentScene.m_maxNonphys; |
367 | if (scale.Z > m_parentScene.m_maxNonphys) | 366 | if (scale.Z > m_parentScene.m_maxNonphys) |
368 | scale.Z = m_parentScene.m_maxNonphys; | 367 | scale.Z = m_parentScene.m_maxNonphys; |
369 | 368 | ||
370 | part.Shape.Scale = scale; | 369 | part.Shape.Scale = scale; |
371 | } | ||
372 | } | 370 | } |
373 | |||
374 | m_numPrim += sceneObject.Children.Count; | ||
375 | } | 371 | } |
372 | m_numPrim += children.Count; | ||
376 | 373 | ||
377 | sceneObject.AttachToScene(m_parentScene); | 374 | sceneObject.AttachToScene(m_parentScene); |
378 | 375 | ||
@@ -390,14 +387,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
390 | lock (SceneObjectGroupsByFullID) | 387 | lock (SceneObjectGroupsByFullID) |
391 | { | 388 | { |
392 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; | 389 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; |
393 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 390 | foreach (SceneObjectPart part in children) |
394 | SceneObjectGroupsByFullID[part.UUID] = sceneObject; | 391 | SceneObjectGroupsByFullID[part.UUID] = sceneObject; |
395 | } | 392 | } |
396 | 393 | ||
397 | lock (SceneObjectGroupsByLocalID) | 394 | lock (SceneObjectGroupsByLocalID) |
398 | { | 395 | { |
399 | SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; | 396 | SceneObjectGroupsByLocalID[sceneObject.LocalId] = sceneObject; |
400 | foreach (SceneObjectPart part in sceneObject.Children.Values) | 397 | foreach (SceneObjectPart part in children) |
401 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; | 398 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; |
402 | } | 399 | } |
403 | 400 | ||
@@ -859,13 +856,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
859 | //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); | 856 | //m_log.DebugFormat("Entered GetGroupByPrim with localID {0}", localID); |
860 | SceneObjectGroup sog; | 857 | SceneObjectGroup sog; |
861 | lock (SceneObjectGroupsByLocalID) | 858 | lock (SceneObjectGroupsByLocalID) |
859 | SceneObjectGroupsByLocalID.TryGetValue(localID, out sog); | ||
860 | |||
861 | if (sog != null) | ||
862 | { | 862 | { |
863 | if (SceneObjectGroupsByLocalID.TryGetValue(localID, out sog)) | 863 | if (sog.HasChildPrim(localID)) |
864 | { | 864 | return sog; |
865 | if (sog.HasChildPrim(localID)) | 865 | SceneObjectGroupsByLocalID.Remove(localID); |
866 | return sog; | ||
867 | SceneObjectGroupsByLocalID.Remove(localID); | ||
868 | } | ||
869 | } | 866 | } |
870 | 867 | ||
871 | EntityBase[] entityList = GetEntities(); | 868 | EntityBase[] entityList = GetEntities(); |
@@ -896,17 +893,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | { | 893 | { |
897 | SceneObjectGroup sog; | 894 | SceneObjectGroup sog; |
898 | lock (SceneObjectGroupsByFullID) | 895 | lock (SceneObjectGroupsByFullID) |
896 | SceneObjectGroupsByFullID.TryGetValue(fullID, out sog); | ||
897 | |||
898 | if (sog != null) | ||
899 | { | 899 | { |
900 | if (SceneObjectGroupsByFullID.TryGetValue(fullID, out sog)) | 900 | lock (sog.Children) |
901 | { | 901 | { |
902 | lock (sog.Children) | 902 | if (sog.Children.ContainsKey(fullID)) |
903 | { | 903 | return sog; |
904 | if (sog.Children.ContainsKey(fullID)) | ||
905 | return sog; | ||
906 | } | ||
907 | |||
908 | SceneObjectGroupsByFullID.Remove(fullID); | ||
909 | } | 904 | } |
905 | |||
906 | lock (SceneObjectGroupsByFullID) | ||
907 | SceneObjectGroupsByFullID.Remove(fullID); | ||
910 | } | 908 | } |
911 | 909 | ||
912 | EntityBase[] entityList = GetEntities(); | 910 | EntityBase[] entityList = GetEntities(); |