From 0ee69707ea8c0948b79aeba5dbe078fe28dc6482 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sat, 24 May 2008 23:11:07 +0000
Subject: * Refactor: Collapse some multiple remove object paths * Push some
delete functionality into InnerScene to match what's already there for adding
objects
---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 41 ++++++++++---
.../Region/Environment/Scenes/Scene.Inventory.cs | 8 +--
OpenSim/Region/Environment/Scenes/Scene.cs | 71 +++++++++-------------
3 files changed, 65 insertions(+), 55 deletions(-)
(limited to 'OpenSim/Region/Environment/Scenes')
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 63f7f17..b03ffe2 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -204,18 +204,45 @@ namespace OpenSim.Region.Environment.Scenes
/// Add an object to the scene.
///
///
- public void AddSceneObject(SceneObjectGroup sceneObject)
+ /// true if the object was added, false if an object with the same uuid was already in the scene
+ ///
+ public bool AddSceneObject(SceneObjectGroup sceneObject)
{
- if (!Entities.ContainsKey(sceneObject.UUID))
+ lock (Entities)
{
- // QuadTree.AddSceneObject(sceneObject);
- lock (Entities)
+ if (!Entities.ContainsKey(sceneObject.UUID))
{
+ // QuadTree.AddSceneObject(sceneObject);
Entities.Add(sceneObject.UUID, sceneObject);
+ m_numPrim++;
+
+ return true;
}
- m_numPrim++;
+
+ return false;
}
}
+
+ ///
+ /// Delete an object from the scene
+ ///
+ ///
+ /// true if the object was deleted, false if there was no object to delete
+ public bool DeleteSceneObject(LLUUID uuid)
+ {
+ lock (Entities)
+ {
+ if (Entities.ContainsKey(uuid))
+ {
+ Entities.Remove(uuid);
+ m_numPrim--;
+
+ return true;
+ }
+ }
+
+ return false;
+ }
///
/// Add an entity to the list of prims to process on the next update
@@ -376,7 +403,6 @@ namespace OpenSim.Region.Environment.Scenes
// To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID??
public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient)
{
-
if (itemID == LLUUID.Zero) // If this happened, someone made a mistake....
return;
@@ -392,11 +418,10 @@ namespace OpenSim.Region.Environment.Scenes
group.DetachToInventoryPrep();
m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID);
- m_parentScene.DeleteSceneObjectGroup(group);
+ m_parentScene.DeleteSceneObject(group);
}
}
}
-
}
public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos)
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 816b01d..82e112f 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -1251,14 +1251,12 @@ namespace OpenSim.Region.Environment.Scenes
}
}
-
if (permissionToDelete)
{
- DeleteSceneObjectGroup(objectGroup);
+ DeleteSceneObject(objectGroup);
}
}
- }
-
+ }
}
public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID)
@@ -1790,7 +1788,7 @@ namespace OpenSim.Region.Environment.Scenes
returnobjects[i] = null;
- DeleteSceneObjectGroup(ObjectDeleting);
+ DeleteSceneObject(ObjectDeleting);
ObjectDeleting = null;
}
else
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index bbe8bd9..e30813c 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1335,22 +1335,40 @@ namespace OpenSim.Region.Environment.Scenes
public void AddSceneObject(SceneObjectGroup sceneObject)
{
m_innerScene.AddSceneObject(sceneObject);
- }
+ }
///
- /// Remove an object from the scene
+ /// Delete this object from the scene.
///
- ///
- public void RemoveSceneObject(SceneObjectGroup sceneObject)
+ ///
+ public void DeleteSceneObject(SceneObjectGroup group)
{
- if (Entities.ContainsKey(sceneObject.UUID))
+ 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))
{
- EventManager.TriggerObjectBeingRemovedFromScene(sceneObject);
- Entities.Remove(sceneObject.UUID);
+ EventManager.TriggerObjectBeingRemovedFromScene(group);
EventManager.TriggerParcelPrimCountTainted();
- m_innerScene.RemoveAPrimCount();
}
- }
+
+ group.DeleteParts();
+
+ // In case anybody else retains a reference to this group, signal deletion by changing the name
+ // to null. We can't zero out the UUID because this is taken from the root part, which has already
+ // been removed.
+ // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race
+ // conditions where a user deletes an entity while it is being stored. Really, the update
+ // code needs a redesign.
+ group.Name = null;
+ }
public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset)
{
@@ -1411,7 +1429,7 @@ namespace OpenSim.Region.Environment.Scenes
// We remove the object here
try
{
- DeleteSceneObjectGroup(grp);
+ DeleteSceneObject(grp);
}
catch (Exception)
{
@@ -1473,7 +1491,7 @@ namespace OpenSim.Region.Environment.Scenes
// We remove the object here
try
{
- DeleteSceneObjectGroup(grp);
+ DeleteSceneObject(grp);
}
catch (Exception)
{
@@ -3142,37 +3160,6 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// Delete this object from the scene.
- ///
- ///
- public void DeleteSceneObjectGroup(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();
-
- lock (Entities)
- {
- RemoveSceneObject(group);
- }
- group.DeleteParts();
-
- // In case anybody else retains a reference to this group, signal deletion by changing the name
- // to null. We can't zero out the UUID because this is taken from the root part, which has already
- // been removed.
- // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race
- // conditions where a user deletes an entity while it is being stored. Really, the update
- // code needs a redesign.
- group.Name = null;
- }
-
- ///
///
///
///
--
cgit v1.1