From bc92d72828925d8b3df72cf66b003ae73731a352 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Sun, 25 May 2008 00:09:08 +0000 Subject: * Refactor: Collapses parts of different code paths in scene used when deleting and unlinking an object --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 10 ----- .../Region/Environment/Scenes/Scene.Inventory.cs | 1 - OpenSim/Region/Environment/Scenes/Scene.cs | 52 +++++++++++----------- .../Region/Environment/Scenes/SceneObjectGroup.cs | 4 +- 4 files changed, 27 insertions(+), 40 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index b03ffe2..65012ad 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -590,16 +590,6 @@ namespace OpenSim.Region.Environment.Scenes } } - public void RemoveAPrimCount() - { - m_numPrim--; - } - - public void AddAPrimCount() - { - m_numPrim++; - } - public int GetChildAgentCount() { // some network situations come in where child agents get closed twice. diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 82e112f..921770d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1145,7 +1145,6 @@ namespace OpenSim.Region.Environment.Scenes if (permissionToTake) { - string sceneObjectXml = objectGroup.ToXmlString(); CachedUserInfo userInfo = diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index e30813c..1e88018 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -1335,7 +1335,7 @@ namespace OpenSim.Region.Environment.Scenes public void AddSceneObject(SceneObjectGroup sceneObject) { m_innerScene.AddSceneObject(sceneObject); - } + } /// /// Delete this object from the scene. @@ -1344,21 +1344,20 @@ namespace OpenSim.Region.Environment.Scenes public void DeleteSceneObject(SceneObjectGroup group) { SceneObjectPart rootPart = (group).GetChildPart(group.UUID); + if (rootPart.PhysActor != null) { PhysicsScene.RemovePrim(rootPart.PhysActor); rootPart.PhysActor = null; - } + } - m_storageManager.DataStore.RemoveObject(group.UUID, m_regInfo.RegionID); - group.DeleteGroup(); - - if (m_innerScene.DeleteSceneObject(group.UUID)) + if (UnlinkSceneObject(group.UUID)) { EventManager.TriggerObjectBeingRemovedFromScene(group); EventManager.TriggerParcelPrimCountTainted(); - } - + } + + group.DeleteGroup(); group.DeleteParts(); // In case anybody else retains a reference to this group, signal deletion by changing the name @@ -1368,7 +1367,25 @@ namespace OpenSim.Region.Environment.Scenes // conditions where a user deletes an entity while it is being stored. Really, the update // code needs a redesign. group.Name = null; - } + } + + /// + /// Unlink the given object from the scene. Unlike delete, this just removes the record of the object - the + /// object itself is not destroyed. + /// + /// + /// true if the object was in the scene, false if it was not + public bool UnlinkSceneObject(LLUUID uuid) + { + if (m_innerScene.DeleteSceneObject(uuid)) + { + m_storageManager.DataStore.RemoveObject(uuid, m_regInfo.RegionID); + + return true; + } + + return false; + } public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset) { @@ -1971,23 +1988,6 @@ namespace OpenSim.Region.Environment.Scenes #region Entities - /// - /// - /// - /// - /// - public bool DeleteEntity(LLUUID entID) - { - if (Entities.ContainsKey(entID)) - { - Entities.Remove(entID); - m_storageManager.DataStore.RemoveObject(entID, m_regInfo.RegionID); - m_innerScene.RemoveAPrimCount(); - return true; - } - return false; - } - public void SendKillObject(uint localID) { Broadcast(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index f4e1ef4..3407d4e 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -1744,9 +1744,7 @@ namespace OpenSim.Region.Environment.Scenes part.ClearUndoState(); } - DetachFromBackup(objectGroup); - - m_scene.DeleteEntity(objectGroup.UUID); + m_scene.UnlinkSceneObject(objectGroup.UUID); // TODO Deleting the parts may cause problems later on if they have already // made it into the update queue. However, sending out updates for those parts is now -- cgit v1.1