diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneGraph.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index ef13c98..3c2203c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -68,7 +68,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
68 | 68 | ||
69 | #region Fields | 69 | #region Fields |
70 | 70 | ||
71 | protected object m_presenceLock = new object(); | 71 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); |
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 | ||
@@ -133,13 +133,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | 133 | ||
134 | protected internal void Close() | 134 | protected internal void Close() |
135 | { | 135 | { |
136 | lock (m_presenceLock) | 136 | m_scenePresencesLock.EnterWriteLock(); |
137 | try | ||
137 | { | 138 | { |
138 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 139 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
139 | List<ScenePresence> newlist = new List<ScenePresence>(); | 140 | List<ScenePresence> newlist = new List<ScenePresence>(); |
140 | m_scenePresenceMap = newmap; | 141 | m_scenePresenceMap = newmap; |
141 | m_scenePresenceArray = newlist; | 142 | m_scenePresenceArray = newlist; |
142 | } | 143 | } |
144 | finally | ||
145 | { | ||
146 | m_scenePresencesLock.ExitWriteLock(); | ||
147 | } | ||
143 | 148 | ||
144 | lock (m_dictionary_lock) | 149 | lock (m_dictionary_lock) |
145 | { | 150 | { |
@@ -228,6 +233,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | protected internal bool AddRestoredSceneObject( | 233 | protected internal bool AddRestoredSceneObject( |
229 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) | 234 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted) |
230 | { | 235 | { |
236 | // KF: Check for out-of-region, move inside and make static. | ||
237 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
238 | sceneObject.RootPart.GroupPosition.Y, | ||
239 | sceneObject.RootPart.GroupPosition.Z); | ||
240 | if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || | ||
241 | npos.X > Constants.RegionSize || | ||
242 | npos.Y > Constants.RegionSize)) | ||
243 | { | ||
244 | if (npos.X < 0.0) npos.X = 1.0f; | ||
245 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
246 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
247 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
248 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
249 | |||
250 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
251 | { | ||
252 | part.GroupPosition = npos; | ||
253 | } | ||
254 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
255 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
256 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
257 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
258 | } | ||
259 | |||
231 | if (!alreadyPersisted) | 260 | if (!alreadyPersisted) |
232 | { | 261 | { |
233 | sceneObject.ForceInventoryPersistence(); | 262 | sceneObject.ForceInventoryPersistence(); |
@@ -521,7 +550,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
521 | 550 | ||
522 | Entities[presence.UUID] = presence; | 551 | Entities[presence.UUID] = presence; |
523 | 552 | ||
524 | lock (m_presenceLock) | 553 | m_scenePresencesLock.EnterWriteLock(); |
554 | try | ||
525 | { | 555 | { |
526 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 556 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
527 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 557 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -545,6 +575,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
545 | m_scenePresenceMap = newmap; | 575 | m_scenePresenceMap = newmap; |
546 | m_scenePresenceArray = newlist; | 576 | m_scenePresenceArray = newlist; |
547 | } | 577 | } |
578 | finally | ||
579 | { | ||
580 | m_scenePresencesLock.ExitWriteLock(); | ||
581 | } | ||
548 | } | 582 | } |
549 | 583 | ||
550 | /// <summary> | 584 | /// <summary> |
@@ -559,7 +593,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
559 | agentID); | 593 | agentID); |
560 | } | 594 | } |
561 | 595 | ||
562 | lock (m_presenceLock) | 596 | m_scenePresencesLock.EnterWriteLock(); |
597 | try | ||
563 | { | 598 | { |
564 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 599 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
565 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 600 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -580,6 +615,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
580 | m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 615 | m_log.WarnFormat("[SCENE] Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
581 | } | 616 | } |
582 | } | 617 | } |
618 | finally | ||
619 | { | ||
620 | m_scenePresencesLock.ExitWriteLock(); | ||
621 | } | ||
583 | } | 622 | } |
584 | 623 | ||
585 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 624 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |