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
prebuild-update
Justin Clark-Casey (justincc) 2010-08-24 23:25:19 +01:00
parent 78f452050a
commit d69e992665
3 changed files with 62 additions and 25 deletions

View File

@ -1983,11 +1983,6 @@ namespace OpenSim.Region.Framework.Scenes
group.ResetIDs(); group.ResetIDs();
AddNewSceneObject(group, true);
// we set it's position in world.
group.AbsolutePosition = pos;
SceneObjectPart rootPart = group.GetChildPart(group.UUID); SceneObjectPart rootPart = group.GetChildPart(group.UUID);
// Since renaming the item in the inventory does not affect the name stored // 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; part.NextOwnerMask = item.NextPermissions;
} }
rootPart.TrimPermissions(); 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();
if (!Permissions.BypassPermissions()) if (!Permissions.BypassPermissions())
{ {
if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
sourcePart.Inventory.RemoveInventoryItem(item.ItemID); 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; return rootPart.ParentGroup;
} }

View File

@ -42,7 +42,6 @@ using OpenMetaverse.Imaging;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Scripting; using OpenSim.Region.Framework.Scenes.Scripting;
@ -2008,6 +2007,23 @@ namespace OpenSim.Region.Framework.Scenes
{ {
return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates);
} }
/// <summary>
/// Add a newly created object to the scene.
/// </summary>
///
/// This method does not send updates to the client - callers need to handle this themselves.
/// <param name="sceneObject"></param>
/// <param name="attachToBackup"></param>
/// <param name="pos">Position of the object</param>
/// <param name="rot">Rotation of the object</param>
/// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param>
/// <returns></returns>
public bool AddNewSceneObject(
SceneObjectGroup sceneObject, bool attachToBackup, Vector3 pos, Quaternion rot, Vector3 vel)
{
return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, pos, rot, vel);
}
/// <summary> /// <summary>
/// Delete every object from the scene. This does not include attachments worn by avatars. /// Delete every object from the scene. This does not include attachments worn by avatars.

View File

@ -292,6 +292,42 @@ namespace OpenSim.Region.Framework.Scenes
return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
} }
/// <summary>
/// Add a newly created object to the scene.
/// </summary>
///
/// This method does not send updates to the client - callers need to handle this themselves.
/// <param name="sceneObject"></param>
/// <param name="attachToBackup"></param>
/// <param name="pos">Position of the object</param>
/// <param name="rot">Rotation of the object</param>
/// <param name="vel">Velocity of the object. This parameter only has an effect if the object is physical</param>
/// <returns></returns>
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;
}
/// <summary> /// <summary>
/// Add an object to the scene. This will both update the scene, and send information about the /// Add an object to the scene. This will both update the scene, and send information about the