diff options
author | Justin Clarke Casey | 2008-05-24 23:11:07 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-24 23:11:07 +0000 |
commit | 0ee69707ea8c0948b79aeba5dbe078fe28dc6482 (patch) | |
tree | d470d18bdac7f6be37103710400bb4deb8f9871b | |
parent | * Refactor: Remove some unused methods in Scene/InnerScene (diff) | |
download | opensim-SC_OLD-0ee69707ea8c0948b79aeba5dbe078fe28dc6482.zip opensim-SC_OLD-0ee69707ea8c0948b79aeba5dbe078fe28dc6482.tar.gz opensim-SC_OLD-0ee69707ea8c0948b79aeba5dbe078fe28dc6482.tar.bz2 opensim-SC_OLD-0ee69707ea8c0948b79aeba5dbe078fe28dc6482.tar.xz |
* Refactor: Collapse some multiple remove object paths
* Push some delete functionality into InnerScene to match what's already there for adding objects
6 files changed, 68 insertions, 58 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs index c56ed08..fc3b9dd 100644 --- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs | |||
@@ -179,7 +179,7 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator | |||
179 | 179 | ||
180 | if (Util.RandomClass.NextDouble() < killLikelyhood) | 180 | if (Util.RandomClass.NextDouble() < killLikelyhood) |
181 | { | 181 | { |
182 | m_scene.RemoveSceneObject(selectedTree.ParentGroup); | 182 | m_scene.DeleteSceneObject(selectedTree.ParentGroup); |
183 | m_trees.Remove(selectedTree.ParentGroup.UUID); | 183 | m_trees.Remove(selectedTree.ParentGroup.UUID); |
184 | 184 | ||
185 | m_scene.ForEachClient(delegate(IClientAPI controller) | 185 | m_scene.ForEachClient(delegate(IClientAPI controller) |
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 | |||
204 | /// Add an object to the scene. | 204 | /// Add an object to the scene. |
205 | /// </summary> | 205 | /// </summary> |
206 | /// <param name="sceneObject"></param> | 206 | /// <param name="sceneObject"></param> |
207 | public void AddSceneObject(SceneObjectGroup sceneObject) | 207 | /// <returns>true if the object was added, false if an object with the same uuid was already in the scene |
208 | /// </returns> | ||
209 | public bool AddSceneObject(SceneObjectGroup sceneObject) | ||
208 | { | 210 | { |
209 | if (!Entities.ContainsKey(sceneObject.UUID)) | 211 | lock (Entities) |
210 | { | 212 | { |
211 | // QuadTree.AddSceneObject(sceneObject); | 213 | if (!Entities.ContainsKey(sceneObject.UUID)) |
212 | lock (Entities) | ||
213 | { | 214 | { |
215 | // QuadTree.AddSceneObject(sceneObject); | ||
214 | Entities.Add(sceneObject.UUID, sceneObject); | 216 | Entities.Add(sceneObject.UUID, sceneObject); |
217 | m_numPrim++; | ||
218 | |||
219 | return true; | ||
215 | } | 220 | } |
216 | m_numPrim++; | 221 | |
222 | return false; | ||
217 | } | 223 | } |
218 | } | 224 | } |
225 | |||
226 | /// <summary> | ||
227 | /// Delete an object from the scene | ||
228 | /// </summary> | ||
229 | /// <param name="sceneObject"></param> | ||
230 | /// <returns>true if the object was deleted, false if there was no object to delete</returns> | ||
231 | public bool DeleteSceneObject(LLUUID uuid) | ||
232 | { | ||
233 | lock (Entities) | ||
234 | { | ||
235 | if (Entities.ContainsKey(uuid)) | ||
236 | { | ||
237 | Entities.Remove(uuid); | ||
238 | m_numPrim--; | ||
239 | |||
240 | return true; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | return false; | ||
245 | } | ||
219 | 246 | ||
220 | /// <summary> | 247 | /// <summary> |
221 | /// Add an entity to the list of prims to process on the next update | 248 | /// Add an entity to the list of prims to process on the next update |
@@ -376,7 +403,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
376 | // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID?? | 403 | // To LocalId or LLUUID, *THAT* is the question. How now Brown LLUUID?? |
377 | public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient) | 404 | public void DetachSingleAttachmentToInv(LLUUID itemID, IClientAPI remoteClient) |
378 | { | 405 | { |
379 | |||
380 | if (itemID == LLUUID.Zero) // If this happened, someone made a mistake.... | 406 | if (itemID == LLUUID.Zero) // If this happened, someone made a mistake.... |
381 | return; | 407 | return; |
382 | 408 | ||
@@ -392,11 +418,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
392 | group.DetachToInventoryPrep(); | 418 | group.DetachToInventoryPrep(); |
393 | m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); | 419 | m_log.Debug("[DETACH]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); |
394 | m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID); | 420 | m_parentScene.updateKnownAsset(remoteClient, group, group.GetFromAssetID(),group.OwnerID); |
395 | m_parentScene.DeleteSceneObjectGroup(group); | 421 | m_parentScene.DeleteSceneObject(group); |
396 | } | 422 | } |
397 | } | 423 | } |
398 | } | 424 | } |
399 | |||
400 | } | 425 | } |
401 | 426 | ||
402 | public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, LLQuaternion rot, LLVector3 attachPos) | 427 | 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 | |||
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | 1253 | ||
1254 | |||
1255 | if (permissionToDelete) | 1254 | if (permissionToDelete) |
1256 | { | 1255 | { |
1257 | DeleteSceneObjectGroup(objectGroup); | 1256 | DeleteSceneObject(objectGroup); |
1258 | } | 1257 | } |
1259 | } | 1258 | } |
1260 | } | 1259 | } |
1261 | |||
1262 | } | 1260 | } |
1263 | 1261 | ||
1264 | public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID) | 1262 | public void updateKnownAsset(IClientAPI remoteClient, SceneObjectGroup grp, LLUUID assetID, LLUUID agentID) |
@@ -1790,7 +1788,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1790 | 1788 | ||
1791 | returnobjects[i] = null; | 1789 | returnobjects[i] = null; |
1792 | 1790 | ||
1793 | DeleteSceneObjectGroup(ObjectDeleting); | 1791 | DeleteSceneObject(ObjectDeleting); |
1794 | ObjectDeleting = null; | 1792 | ObjectDeleting = null; |
1795 | } | 1793 | } |
1796 | else | 1794 | 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 | |||
1335 | public void AddSceneObject(SceneObjectGroup sceneObject) | 1335 | public void AddSceneObject(SceneObjectGroup sceneObject) |
1336 | { | 1336 | { |
1337 | m_innerScene.AddSceneObject(sceneObject); | 1337 | m_innerScene.AddSceneObject(sceneObject); |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | /// <summary> | 1340 | /// <summary> |
1341 | /// Remove an object from the scene | 1341 | /// Delete this object from the scene. |
1342 | /// </summary> | 1342 | /// </summary> |
1343 | /// <param name="sceneObject"></param> | 1343 | /// <param name="group"></param> |
1344 | public void RemoveSceneObject(SceneObjectGroup sceneObject) | 1344 | public void DeleteSceneObject(SceneObjectGroup group) |
1345 | { | 1345 | { |
1346 | if (Entities.ContainsKey(sceneObject.UUID)) | 1346 | SceneObjectPart rootPart = (group).GetChildPart(group.UUID); |
1347 | if (rootPart.PhysActor != null) | ||
1348 | { | ||
1349 | PhysicsScene.RemovePrim(rootPart.PhysActor); | ||
1350 | rootPart.PhysActor = null; | ||
1351 | } | ||
1352 | |||
1353 | m_storageManager.DataStore.RemoveObject(group.UUID, m_regInfo.RegionID); | ||
1354 | group.DeleteGroup(); | ||
1355 | |||
1356 | if (m_innerScene.DeleteSceneObject(group.UUID)) | ||
1347 | { | 1357 | { |
1348 | EventManager.TriggerObjectBeingRemovedFromScene(sceneObject); | 1358 | EventManager.TriggerObjectBeingRemovedFromScene(group); |
1349 | Entities.Remove(sceneObject.UUID); | ||
1350 | EventManager.TriggerParcelPrimCountTainted(); | 1359 | EventManager.TriggerParcelPrimCountTainted(); |
1351 | m_innerScene.RemoveAPrimCount(); | ||
1352 | } | 1360 | } |
1353 | } | 1361 | |
1362 | group.DeleteParts(); | ||
1363 | |||
1364 | // In case anybody else retains a reference to this group, signal deletion by changing the name | ||
1365 | // to null. We can't zero out the UUID because this is taken from the root part, which has already | ||
1366 | // been removed. | ||
1367 | // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race | ||
1368 | // conditions where a user deletes an entity while it is being stored. Really, the update | ||
1369 | // code needs a redesign. | ||
1370 | group.Name = null; | ||
1371 | } | ||
1354 | 1372 | ||
1355 | public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset) | 1373 | public void LoadPrimsFromXml(string fileName, bool newIdsFlag, LLVector3 loadOffset) |
1356 | { | 1374 | { |
@@ -1411,7 +1429,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1411 | // We remove the object here | 1429 | // We remove the object here |
1412 | try | 1430 | try |
1413 | { | 1431 | { |
1414 | DeleteSceneObjectGroup(grp); | 1432 | DeleteSceneObject(grp); |
1415 | } | 1433 | } |
1416 | catch (Exception) | 1434 | catch (Exception) |
1417 | { | 1435 | { |
@@ -1473,7 +1491,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1473 | // We remove the object here | 1491 | // We remove the object here |
1474 | try | 1492 | try |
1475 | { | 1493 | { |
1476 | DeleteSceneObjectGroup(grp); | 1494 | DeleteSceneObject(grp); |
1477 | } | 1495 | } |
1478 | catch (Exception) | 1496 | catch (Exception) |
1479 | { | 1497 | { |
@@ -3142,37 +3160,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
3142 | } | 3160 | } |
3143 | 3161 | ||
3144 | /// <summary> | 3162 | /// <summary> |
3145 | /// Delete this object from the scene. | ||
3146 | /// </summary> | ||
3147 | /// <param name="group"></param> | ||
3148 | public void DeleteSceneObjectGroup(SceneObjectGroup group) | ||
3149 | { | ||
3150 | SceneObjectPart rootPart = (group).GetChildPart(group.UUID); | ||
3151 | if (rootPart.PhysActor != null) | ||
3152 | { | ||
3153 | PhysicsScene.RemovePrim(rootPart.PhysActor); | ||
3154 | rootPart.PhysActor = null; | ||
3155 | } | ||
3156 | |||
3157 | m_storageManager.DataStore.RemoveObject(group.UUID, m_regInfo.RegionID); | ||
3158 | group.DeleteGroup(); | ||
3159 | |||
3160 | lock (Entities) | ||
3161 | { | ||
3162 | RemoveSceneObject(group); | ||
3163 | } | ||
3164 | group.DeleteParts(); | ||
3165 | |||
3166 | // In case anybody else retains a reference to this group, signal deletion by changing the name | ||
3167 | // to null. We can't zero out the UUID because this is taken from the root part, which has already | ||
3168 | // been removed. | ||
3169 | // FIXME: This is a really poor temporary solution, since it still leaves plenty of scope for race | ||
3170 | // conditions where a user deletes an entity while it is being stored. Really, the update | ||
3171 | // code needs a redesign. | ||
3172 | group.Name = null; | ||
3173 | } | ||
3174 | |||
3175 | /// <summary> | ||
3176 | /// | 3163 | /// |
3177 | /// </summary> | 3164 | /// </summary> |
3178 | /// <param name="action"></param> | 3165 | /// <param name="action"></param> |
diff --git a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs index 87a5ffc..d83bba6 100644 --- a/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs +++ b/OpenSim/Region/Examples/SimpleModule/ComplexObject.cs | |||
@@ -126,7 +126,7 @@ namespace OpenSim.Region.Examples.SimpleModule | |||
126 | if (m_parts.Count == 1) | 126 | if (m_parts.Count == 1) |
127 | { | 127 | { |
128 | m_parts.Remove(m_rootPart.UUID); | 128 | m_parts.Remove(m_rootPart.UUID); |
129 | m_scene.RemoveSceneObject(this); | 129 | m_scene.DeleteSceneObject(this); |
130 | remoteClient.SendKillObject(m_regionHandle, m_rootPart.LocalId); | 130 | remoteClient.SendKillObject(m_regionHandle, m_rootPart.LocalId); |
131 | remoteClient.AddMoney(50); | 131 | remoteClient.AddMoney(50); |
132 | remoteClient.SendChatMessage("KABLAM!!!", 1, AbsolutePosition, "Groupie Groupie", LLUUID.Zero, (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); | 132 | remoteClient.SendChatMessage("KABLAM!!!", 1, AbsolutePosition, "Groupie Groupie", LLUUID.Zero, (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); |
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs index ab91424..3fa65f5 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs | |||
@@ -704,7 +704,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
704 | public void llDie() | 704 | public void llDie() |
705 | { | 705 | { |
706 | m_host.AddScriptLPS(1); | 706 | m_host.AddScriptLPS(1); |
707 | World.DeleteSceneObjectGroup(m_host.ParentGroup); | 707 | World.DeleteSceneObject(m_host.ParentGroup); |
708 | } | 708 | } |
709 | 709 | ||
710 | public double llGround(LSL_Types.Vector3 offset) | 710 | public double llGround(LSL_Types.Vector3 offset) |