diff options
author | Justin Clark-Casey (justincc) | 2010-08-24 23:25:19 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-08-24 23:25:19 +0100 |
commit | d69e992665495b98fac4ae8c74266294e85804e6 (patch) | |
tree | df7607ffc030aba10a5fba671248541d4bb29005 | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-d69e992665495b98fac4ae8c74266294e85804e6.zip opensim-SC-d69e992665495b98fac4ae8c74266294e85804e6.tar.gz opensim-SC-d69e992665495b98fac4ae8c74266294e85804e6.tar.bz2 opensim-SC-d69e992665495b98fac4ae8c74266294e85804e6.tar.xz |
Split out actual scene object insertion code from Scene.Inventory.RezObject and move into SceneGraph.AddNewSceneObject()
The new SceneGraph method is more consumable by region modules that want to extract objects from inventory and add them to the scene in separate stages.
This change also reduces the number of redundant client updates scheduled when an object is rezzed directly by a script or region module
This code does not touch direct rez by a user
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 33 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 18 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 36 |
3 files changed, 62 insertions, 25 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9c62ad3..01be491 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1983,11 +1983,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1983 | 1983 | ||
1984 | group.ResetIDs(); | 1984 | group.ResetIDs(); |
1985 | 1985 | ||
1986 | AddNewSceneObject(group, true); | ||
1987 | |||
1988 | // we set it's position in world. | ||
1989 | group.AbsolutePosition = pos; | ||
1990 | |||
1991 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); | 1986 | SceneObjectPart rootPart = group.GetChildPart(group.UUID); |
1992 | 1987 | ||
1993 | // Since renaming the item in the inventory does not affect the name stored | 1988 | // Since renaming the item in the inventory does not affect the name stored |
@@ -2027,31 +2022,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
2027 | part.NextOwnerMask = item.NextPermissions; | 2022 | part.NextOwnerMask = item.NextPermissions; |
2028 | } | 2023 | } |
2029 | 2024 | ||
2030 | rootPart.TrimPermissions(); | 2025 | rootPart.TrimPermissions(); |
2031 | |||
2032 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
2033 | { | ||
2034 | group.ClearPartAttachmentData(); | ||
2035 | } | ||
2036 | |||
2037 | group.UpdateGroupRotationR(rot); | ||
2038 | |||
2039 | //group.ApplyPhysics(m_physicalPrim); | ||
2040 | if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) | ||
2041 | { | ||
2042 | group.RootPart.ApplyImpulse((vel * group.GetMass()), false); | ||
2043 | group.Velocity = vel; | ||
2044 | rootPart.ScheduleFullUpdate(); | ||
2045 | } | ||
2046 | |||
2047 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); | ||
2048 | rootPart.ScheduleFullUpdate(); | ||
2049 | 2026 | ||
2050 | if (!Permissions.BypassPermissions()) | 2027 | if (!Permissions.BypassPermissions()) |
2051 | { | 2028 | { |
2052 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 2029 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) |
2053 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); | 2030 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); |
2054 | } | 2031 | } |
2032 | |||
2033 | AddNewSceneObject(group, true, pos, rot, vel); | ||
2034 | |||
2035 | // We can only call this after adding the scene object, since the scene object references the scene | ||
2036 | // to find out if scripts should be activated at all. | ||
2037 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 2); | ||
2038 | |||
2039 | group.ScheduleGroupForFullUpdate(); | ||
2055 | 2040 | ||
2056 | return rootPart.ParentGroup; | 2041 | return rootPart.ParentGroup; |
2057 | } | 2042 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a147628..b808c6d 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; |
@@ -2008,6 +2007,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2008 | { | 2007 | { |
2009 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 2008 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
2010 | } | 2009 | } |
2010 | |||
2011 | /// <summary> | ||
2012 | /// Add a newly created object to the scene. | ||
2013 | /// </summary> | ||
2014 | /// | ||
2015 | /// This method does not send updates to the client - callers need to handle this themselves. | ||
2016 | /// <param name="sceneObject"></param> | ||
2017 | /// <param name="attachToBackup"></param> | ||
2018 | /// <param name="pos">Position of the object</param> | ||
2019 | /// <param name="rot">Rotation of the object</param> | ||
2020 | /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param> | ||
2021 | /// <returns></returns> | ||
2022 | public bool AddNewSceneObject( | ||
2023 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) | ||
2024 | { | ||
2025 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel); | ||
2026 | } | ||
2011 | 2027 | ||
2012 | /// <summary> | 2028 | /// <summary> |
2013 | /// Delete every object from the scene. This does not include attachments worn by avatars. | 2029 | /// Delete every object from the scene. This does not include attachments worn by avatars. |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 9f38a99..31faeec 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -292,6 +292,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | 292 | ||
293 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 293 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
294 | } | 294 | } |
295 | |||
296 | /// <summary> | ||
297 | /// Add a newly created object to the scene. | ||
298 | /// </summary> | ||
299 | /// | ||
300 | /// This method does not send updates to the client - callers need to handle this themselves. | ||
301 | /// <param name="sceneObject"></param> | ||
302 | /// <param name="attachToBackup"></param> | ||
303 | /// <param name="pos">Position of the object</param> | ||
304 | /// <param name="rot">Rotation of the object</param> | ||
305 | /// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param> | ||
306 | /// <returns></returns> | ||
307 | public bool AddNewSceneObject( | ||
308 | SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel) | ||
309 | { | ||
310 | AddNewSceneObject(sceneObject, true, false); | ||
311 | |||
312 | // we set it's position in world. | ||
313 | sceneObject.AbsolutePosition = pos; | ||
314 | |||
315 | if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
316 | { | ||
317 | sceneObject.ClearPartAttachmentData(); | ||
318 | } | ||
319 | |||
320 | sceneObject.UpdateGroupRotationR(rot); | ||
321 | |||
322 | //group.ApplyPhysics(m_physicalPrim); | ||
323 | if (sceneObject.RootPart.PhysActor != null && sceneObject.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero) | ||
324 | { | ||
325 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | ||
326 | sceneObject.Velocity = vel; | ||
327 | } | ||
328 | |||
329 | return true; | ||
330 | } | ||
295 | 331 | ||
296 | /// <summary> | 332 | /// <summary> |
297 | /// Add an object to the scene. This will both update the scene, and send information about the | 333 | /// Add an object to the scene. This will both update the scene, and send information about the |