diff options
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 98 |
1 files changed, 77 insertions, 21 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 736b696..9fea2a0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -42,7 +42,6 @@ using OpenMetaverse.Imaging; | |||
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Services.Interfaces; | 43 | using OpenSim.Services.Interfaces; |
44 | using OpenSim.Framework.Communications; | 44 | using OpenSim.Framework.Communications; |
45 | |||
46 | using OpenSim.Framework.Console; | 45 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 46 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes.Scripting; | 47 | using OpenSim.Region.Framework.Scenes.Scripting; |
@@ -399,6 +398,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
399 | private bool m_firstHeartbeat = true; | 398 | private bool m_firstHeartbeat = true; |
400 | 399 | ||
401 | private object m_deleting_scene_object = new object(); | 400 | private object m_deleting_scene_object = new object(); |
401 | private object m_cleaningAttachments = new object(); | ||
402 | 402 | ||
403 | // the minimum time that must elapse before a changed object will be considered for persisted | 403 | // the minimum time that must elapse before a changed object will be considered for persisted |
404 | public long m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE * 10000000L; | 404 | public long m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE * 10000000L; |
@@ -1790,8 +1790,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1790 | 1790 | ||
1791 | if (group.RootPart == null) | 1791 | if (group.RootPart == null) |
1792 | { | 1792 | { |
1793 | m_log.ErrorFormat("[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children", | 1793 | m_log.ErrorFormat( |
1794 | group.Children == null ? 0 : group.Children.Count); | 1794 | "[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children", |
1795 | group.Children == null ? 0 : group.PrimCount); | ||
1795 | } | 1796 | } |
1796 | 1797 | ||
1797 | AddRestoredSceneObject(group, true, true); | 1798 | AddRestoredSceneObject(group, true, true); |
@@ -2050,7 +2051,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2050 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 2051 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
2051 | { | 2052 | { |
2052 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 2053 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
2053 | } | 2054 | } |
2055 | |||
2056 | /// <summary> | ||
2057 | /// Add a newly created object to the scene. | ||
2058 | /// </summary> | ||
2059 | /// | ||
2060 | /// This method does not send updates to the client - callers need to handle this themselves. | ||
2061 | /// <param name="sceneObject"></param> | ||
2062 | /// <param name="attachToBackup"></param> | ||
2063 | /// <param name="pos">Position of the object</param> | ||
2064 | /// <param name="rot">Rotation of the object</param> | ||
2065 | /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param> | ||
2066 | /// <returns></returns> | ||
2067 | public bool AddNewSceneObject( | ||
2068 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) | ||
2069 | { | ||
2070 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel); | ||
2071 | } | ||
2054 | 2072 | ||
2055 | /// <summary> | 2073 | /// <summary> |
2056 | /// Delete every object from the scene. This does not include attachments worn by avatars. | 2074 | /// Delete every object from the scene. This does not include attachments worn by avatars. |
@@ -2113,7 +2131,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2113 | group.RemoveScriptInstances(true); | 2131 | group.RemoveScriptInstances(true); |
2114 | } | 2132 | } |
2115 | 2133 | ||
2116 | foreach (SceneObjectPart part in group.Children.Values) | 2134 | List<SceneObjectPart> partList = null; |
2135 | lock (group.Children) | ||
2136 | partList = new List<SceneObjectPart>(group.Children.Values); | ||
2137 | |||
2138 | foreach (SceneObjectPart part in partList) | ||
2117 | { | 2139 | { |
2118 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) | 2140 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2119 | { | 2141 | { |
@@ -2125,6 +2147,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2125 | part.PhysActor = null; | 2147 | part.PhysActor = null; |
2126 | } | 2148 | } |
2127 | } | 2149 | } |
2150 | |||
2128 | // if (rootPart.PhysActor != null) | 2151 | // if (rootPart.PhysActor != null) |
2129 | // { | 2152 | // { |
2130 | // PhysicsScene.RemovePrim(rootPart.PhysActor); | 2153 | // PhysicsScene.RemovePrim(rootPart.PhysActor); |
@@ -2481,14 +2504,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2481 | 2504 | ||
2482 | // Force allocation of new LocalId | 2505 | // Force allocation of new LocalId |
2483 | // | 2506 | // |
2484 | foreach (SceneObjectPart p in sceneObject.Children.Values) | 2507 | lock (sceneObject.Children) |
2485 | p.LocalId = 0; | 2508 | { |
2509 | foreach (SceneObjectPart p in sceneObject.Children.Values) | ||
2510 | p.LocalId = 0; | ||
2511 | } | ||
2486 | 2512 | ||
2487 | if (sceneObject.IsAttachmentCheckFull()) // Attachment | 2513 | if (sceneObject.IsAttachmentCheckFull()) // Attachment |
2488 | { | 2514 | { |
2489 | sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); | 2515 | sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez); |
2490 | sceneObject.RootPart.AddFlag(PrimFlags.Phantom); | 2516 | sceneObject.RootPart.AddFlag(PrimFlags.Phantom); |
2491 | |||
2492 | 2517 | ||
2493 | // Don't sent a full update here because this will cause full updates to be sent twice for | 2518 | // Don't sent a full update here because this will cause full updates to be sent twice for |
2494 | // attachments on region crossings, resulting in viewer glitches. | 2519 | // attachments on region crossings, resulting in viewer glitches. |
@@ -2502,7 +2527,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2502 | 2527 | ||
2503 | if (sp != null) | 2528 | if (sp != null) |
2504 | { | 2529 | { |
2505 | |||
2506 | SceneObjectGroup grp = sceneObject; | 2530 | SceneObjectGroup grp = sceneObject; |
2507 | 2531 | ||
2508 | m_log.DebugFormat( | 2532 | m_log.DebugFormat( |
@@ -3210,6 +3234,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | 3234 | m_log.Debug("[Scene] Beginning OnRemovePresence"); |
3211 | m_eventManager.TriggerOnRemovePresence(agentID); | 3235 | m_eventManager.TriggerOnRemovePresence(agentID); |
3212 | m_log.Debug("[Scene] Finished OnRemovePresence"); | 3236 | m_log.Debug("[Scene] Finished OnRemovePresence"); |
3237 | |||
3213 | ForEachClient( | 3238 | ForEachClient( |
3214 | delegate(IClientAPI client) | 3239 | delegate(IClientAPI client) |
3215 | { | 3240 | { |
@@ -3245,6 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3245 | } | 3270 | } |
3246 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | 3271 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); |
3247 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3272 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3273 | CleanDroppedAttachments(); | ||
3248 | m_log.Debug("[Scene] The avatar has left the building"); | 3274 | m_log.Debug("[Scene] The avatar has left the building"); |
3249 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3275 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3250 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3276 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
@@ -3443,6 +3469,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3443 | 3469 | ||
3444 | if (vialogin) | 3470 | if (vialogin) |
3445 | { | 3471 | { |
3472 | CleanDroppedAttachments(); | ||
3473 | |||
3446 | if (TestBorderCross(agent.startpos, Cardinals.E)) | 3474 | if (TestBorderCross(agent.startpos, Cardinals.E)) |
3447 | { | 3475 | { |
3448 | Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); | 3476 | Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); |
@@ -3694,18 +3722,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3694 | return true; | 3722 | return true; |
3695 | } | 3723 | } |
3696 | 3724 | ||
3697 | private ILandObject GetParcelAtPoint(float x, float y) | ||
3698 | { | ||
3699 | foreach (var parcel in AllParcels()) | ||
3700 | { | ||
3701 | if (parcel.ContainsPoint((int)x,(int)y)) | ||
3702 | { | ||
3703 | return parcel; | ||
3704 | } | ||
3705 | } | ||
3706 | return null; | ||
3707 | } | ||
3708 | |||
3709 | /// <summary> | 3725 | /// <summary> |
3710 | /// Update an AgentCircuitData object with new information | 3726 | /// Update an AgentCircuitData object with new information |
3711 | /// </summary> | 3727 | /// </summary> |
@@ -5041,5 +5057,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
5041 | throw new Exception(error); | 5057 | throw new Exception(error); |
5042 | } | 5058 | } |
5043 | } | 5059 | } |
5060 | |||
5061 | public void CleanDroppedAttachments() | ||
5062 | { | ||
5063 | List<SceneObjectGroup> objectsToDelete = | ||
5064 | new List<SceneObjectGroup>(); | ||
5065 | |||
5066 | lock (m_cleaningAttachments) | ||
5067 | { | ||
5068 | ForEachSOG(delegate (SceneObjectGroup grp) | ||
5069 | { | ||
5070 | if (grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5071 | { | ||
5072 | UUID agentID = grp.OwnerID; | ||
5073 | if (agentID == UUID.Zero) | ||
5074 | { | ||
5075 | objectsToDelete.Add(grp); | ||
5076 | return; | ||
5077 | } | ||
5078 | |||
5079 | ScenePresence sp = GetScenePresence(agentID); | ||
5080 | if (sp == null) | ||
5081 | { | ||
5082 | objectsToDelete.Add(grp); | ||
5083 | return; | ||
5084 | } | ||
5085 | } | ||
5086 | }); | ||
5087 | } | ||
5088 | |||
5089 | if (objectsToDelete.Count > 0) | ||
5090 | { | ||
5091 | m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); | ||
5092 | foreach (SceneObjectGroup grp in objectsToDelete) | ||
5093 | { | ||
5094 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5095 | DeleteSceneObject(grp, true); | ||
5096 | } | ||
5097 | m_log.Debug("[SCENE]: Finished dropped attachment deletion"); | ||
5098 | } | ||
5099 | } | ||
5044 | } | 5100 | } |
5045 | } | 5101 | } |