From d69e992665495b98fac4ae8c74266294e85804e6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Tue, 24 Aug 2010 23:25:19 +0100
Subject: 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
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 33 ++++++--------------
OpenSim/Region/Framework/Scenes/Scene.cs | 18 ++++++++++-
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 36 ++++++++++++++++++++++
3 files changed, 62 insertions(+), 25 deletions(-)
(limited to 'OpenSim/Region')
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
group.ResetIDs();
- AddNewSceneObject(group, true);
-
- // we set it's position in world.
- group.AbsolutePosition = pos;
-
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
// Since renaming the item in the inventory does not affect the name stored
@@ -2027,31 +2022,21 @@ namespace OpenSim.Region.Framework.Scenes
part.NextOwnerMask = item.NextPermissions;
}
- rootPart.TrimPermissions();
-
- if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
- {
- group.ClearPartAttachmentData();
- }
-
- group.UpdateGroupRotationR(rot);
-
- //group.ApplyPhysics(m_physicalPrim);
- if (group.RootPart.PhysActor != null && group.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
- {
- group.RootPart.ApplyImpulse((vel * group.GetMass()), false);
- group.Velocity = vel;
- rootPart.ScheduleFullUpdate();
- }
-
- group.CreateScriptInstances(param, true, DefaultScriptEngine, 2);
- rootPart.ScheduleFullUpdate();
+ rootPart.TrimPermissions();
if (!Permissions.BypassPermissions())
{
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
sourcePart.Inventory.RemoveInventoryItem(item.ItemID);
}
+
+ AddNewSceneObject(group, true, pos, rot, vel);
+
+ // We can only call this after adding the scene object, since the scene object references the scene
+ // to find out if scripts should be activated at all.
+ group.CreateScriptInstances(param, true, DefaultScriptEngine, 2);
+
+ group.ScheduleGroupForFullUpdate();
return rootPart.ParentGroup;
}
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;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenSim.Framework.Communications;
-
using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Scripting;
@@ -2008,6 +2007,23 @@ namespace OpenSim.Region.Framework.Scenes
{
return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates);
}
+
+ ///
+ /// Add a newly created object to the scene.
+ ///
+ ///
+ /// This method does not send updates to the client - callers need to handle this themselves.
+ ///
+ ///
+ /// Position of the object
+ /// Rotation of the object
+ /// Velocity of the object. This parameter only has an effect if the object is physical
+ ///
+ public bool AddNewSceneObject(
+ SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
+ {
+ return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel);
+ }
///
/// 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
return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
}
+
+ ///
+ /// Add a newly created object to the scene.
+ ///
+ ///
+ /// This method does not send updates to the client - callers need to handle this themselves.
+ ///
+ ///
+ /// Position of the object
+ /// Rotation of the object
+ /// Velocity of the object. This parameter only has an effect if the object is physical
+ ///
+ public bool AddNewSceneObject(
+ SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
+ {
+ AddNewSceneObject(sceneObject, true, false);
+
+ // we set it's position in world.
+ sceneObject.AbsolutePosition = pos;
+
+ if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim)
+ {
+ sceneObject.ClearPartAttachmentData();
+ }
+
+ sceneObject.UpdateGroupRotationR(rot);
+
+ //group.ApplyPhysics(m_physicalPrim);
+ if (sceneObject.RootPart.PhysActor != null && sceneObject.RootPart.PhysActor.IsPhysical && vel != Vector3.Zero)
+ {
+ sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false);
+ sceneObject.Velocity = vel;
+ }
+
+ return true;
+ }
///
/// Add an object to the scene. This will both update the scene, and send information about the
--
cgit v1.1