From 5caae0293ab0f69cced21923c36db230698c7970 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 3 Mar 2010 22:14:06 +0000
Subject: Fix bug where approximately half the time, attachments would rez only
their root prim until right clicked (or otherwise updated). The root cause of
this problem was that multiple ObjectUpdates were being sent on attachment
which differed enough to confuse the client. Sometimes these would eliminate
each other and sometimes not, depending on whether the scheduler looked at
the queued updates. The solution here is to only schedule the ObjectUpdate
once the attachment code has done all it needs to do.
Backport from head.
---
OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 44 ++++++++++++---
OpenSim/Region/Framework/Scenes/Scene.cs | 40 +++++++++++---
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 62 ++++++++++++++--------
.../Region/Framework/Scenes/SceneObjectGroup.cs | 35 +++++++++---
bin/OpenSim.exe.config | 2 +-
5 files changed, 139 insertions(+), 44 deletions(-)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index c6cee75..5b21332 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -2339,9 +2339,18 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerOnAttach(localID, itemID, avatarID);
}
- public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID,
- uint AttachmentPt)
+ ///
+ /// Called when the client receives a request to rez a single attachment on to the avatar from inventory
+ /// (RezSingleAttachmentFromInv packet).
+ ///
+ ///
+ ///
+ ///
+ ///
+ public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
+ m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
+
SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt);
if (att == null)
@@ -2353,9 +2362,20 @@ namespace OpenSim.Region.Framework.Scenes
return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt);
}
- public UUID RezSingleAttachment(SceneObjectGroup att,
- IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
+ ///
+ /// Update the user inventory to reflect an attachment
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
{
+ m_log.DebugFormat(
+ "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
+ remoteClient.Name, att.Name, itemID);
+
if (!att.IsDeleted)
AttachmentPt = att.RootPart.AttachmentPoint;
@@ -2394,8 +2414,19 @@ namespace OpenSim.Region.Framework.Scenes
return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent);
}
+ ///
+ /// This registers the item as attached in a user's inventory
+ ///
+ ///
+ ///
+ ///
+ ///
public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
{
+// m_log.DebugFormat(
+// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
+// att.Name, remoteClient.Name, AttachmentPt, itemID);
+
if (UUID.Zero == itemID)
{
m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
@@ -2423,10 +2454,7 @@ namespace OpenSim.Region.Framework.Scenes
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
if (m_AvatarFactory != null)
- {
m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
- }
-
}
}
@@ -2509,6 +2537,7 @@ namespace OpenSim.Region.Framework.Scenes
{
sog.SetOwnerId(ownerID);
sog.SetGroup(groupID, remoteClient);
+ sog.ScheduleGroupForFullUpdate();
foreach (SceneObjectPart child in sog.Children.Values)
child.Inventory.ChangeInventoryOwner(ownerID);
@@ -2530,6 +2559,7 @@ namespace OpenSim.Region.Framework.Scenes
sog.SetOwnerId(groupID);
sog.ApplyNextOwnerPermissions();
}
+
}
foreach (uint localID in localIDs)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 41fd1e1..7796b8d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1813,14 +1813,22 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat(
// "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);
+ SceneObjectGroup sceneObject = null;
+
// If an entity creator has been registered for this prim type then use that
if (m_entityCreators.ContainsKey((PCode)shape.PCode))
- return m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
+ {
+ sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
+ }
+ else
+ {
+ // Otherwise, use this default creation code;
+ sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
+ AddNewSceneObject(sceneObject, true);
+ sceneObject.SetGroup(groupID, null);
+ }
- // Otherwise, use this default creation code;
- SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
- AddNewSceneObject(sceneObject, true);
- sceneObject.SetGroup(groupID, null);
+ sceneObject.ScheduleGroupForFullUpdate();
return sceneObject;
}
@@ -1848,7 +1856,7 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Add a newly created object to the scene
+ /// Add a newly created object to the scene. Updates are also sent to viewers.
///
///
///
@@ -1857,8 +1865,25 @@ namespace OpenSim.Region.Framework.Scenes
///
public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
{
- return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup);
+ return AddNewSceneObject(sceneObject, attachToBackup, true);
}
+
+ ///
+ /// Add a newly created object to the scene
+ ///
+ ///
+ ///
+ /// If true, the object is made persistent into the scene.
+ /// If false, the object will not persist over server restarts
+ ///
+ ///
+ /// If true, updates for the new scene object are sent to all viewers in range.
+ /// If false, it is left to the caller to schedule the update
+ ///
+ public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
+ {
+ return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates);
+ }
///
/// Delete every object from the scene
@@ -3322,7 +3347,6 @@ namespace OpenSim.Region.Framework.Scenes
}
else
m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
-
}
///
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 321cc45..d31b45e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -228,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
sceneObject.HasGroupChanged = true;
}
- return AddSceneObject(sceneObject, attachToBackup);
+ return AddSceneObject(sceneObject, attachToBackup, true);
}
///
@@ -243,12 +243,12 @@ namespace OpenSim.Region.Framework.Scenes
///
/// true if the object was added, false if an object with the same uuid was already in the scene
///
- protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
+ protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
{
// Ensure that we persist this new scene object
sceneObject.HasGroupChanged = true;
- return AddSceneObject(sceneObject, attachToBackup);
+ return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
}
///
@@ -260,12 +260,19 @@ namespace OpenSim.Region.Framework.Scenes
/// If true, the object is made persistent into the scene.
/// If false, the object will not persist over server restarts
///
- /// true if the object was added, false if an object with the same uuid was already in the scene
+ ///
+ /// If true, updates for the new scene object are sent to all viewers in range.
+ /// If false, it is left to the caller to schedule the update
+ ///
+ ///
+ /// true if the object was added, false if an object with the same uuid was already in the scene
///
- protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
+ protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
{
if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
return false;
+
+ bool alreadyExisted = false;
if (m_parentScene.m_clampPrimSize)
{
@@ -286,6 +293,9 @@ namespace OpenSim.Region.Framework.Scenes
sceneObject.AttachToScene(m_parentScene);
+ if (sendClientUpdates)
+ sceneObject.ScheduleGroupForFullUpdate();
+
lock (sceneObject)
{
if (!Entities.ContainsKey(sceneObject.UUID))
@@ -309,12 +319,14 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroupsByLocalID[part.LocalId] = sceneObject;
}
}
-
- return true;
+ }
+ else
+ {
+ alreadyExisted = true;
}
}
- return false;
+ return alreadyExisted;
}
///
@@ -521,26 +533,34 @@ namespace OpenSim.Region.Framework.Scenes
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, remoteClient.AgentId, true);
+// m_log.DebugFormat(
+// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}",
+// objatt.Name, remoteClient.Name, AttachmentPt);
+
if (objatt != null)
{
bool tainted = false;
if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
tainted = true;
- if (AttachObject(
- remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false))
- {
- objatt.ScheduleGroupForFullUpdate();
- if (tainted)
- objatt.HasGroupChanged = true;
-
- // Fire after attach, so we don't get messy perms dialogs
- // 3 == AttachedRez
- objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
+ AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
+ //objatt.ScheduleGroupForFullUpdate();
- // Do this last so that event listeners have access to all the effects of the attachment
- m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
- }
+ if (tainted)
+ objatt.HasGroupChanged = true;
+
+ // Fire after attach, so we don't get messy perms dialogs
+ // 3 == AttachedRez
+ objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
+
+ // Do this last so that event listeners have access to all the effects of the attachment
+ m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
+ }
+ else
+ {
+ m_log.WarnFormat(
+ "[SCENE GRAPH]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
+ itemID, remoteClient.Name, AttachmentPt);
}
return objatt;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index c5a6171..c14b39a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -567,8 +567,10 @@ namespace OpenSim.Region.Framework.Scenes
}
ApplyPhysics(m_scene.m_physicalPrim);
-
- ScheduleGroupForFullUpdate();
+
+ // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
+ // for the same object with very different properties. The caller must schedule the update.
+ //ScheduleGroupForFullUpdate();
}
public Vector3 GroupScale()
@@ -956,10 +958,11 @@ namespace OpenSim.Region.Framework.Scenes
// don't attach attachments to child agents
if (avatar.IsChildAgent) return;
+// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
+
DetachFromBackup();
// Remove from database and parcel prim count
- //
m_scene.DeleteFromStorage(UUID);
m_scene.EventManager.TriggerParcelPrimCountTainted();
@@ -985,7 +988,6 @@ namespace OpenSim.Region.Framework.Scenes
SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(this);
- m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID);
if (!silent)
{
@@ -1002,6 +1004,12 @@ namespace OpenSim.Region.Framework.Scenes
ScheduleGroupForFullUpdate();
}
}
+ else
+ {
+ m_log.WarnFormat(
+ "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
+ UUID, agentID, Scene.RegionInfo.RegionName);
+ }
}
public byte GetAttachmentPoint()
@@ -1986,6 +1994,8 @@ namespace OpenSim.Region.Framework.Scenes
public void ScheduleFullUpdateToAvatar(ScenePresence presence)
{
+// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
+
RootPart.AddFullUpdateToAvatar(presence);
lock (m_parts)
@@ -2000,6 +2010,8 @@ namespace OpenSim.Region.Framework.Scenes
public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
{
+// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
+
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
@@ -2014,6 +2026,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ScheduleGroupForFullUpdate()
{
+// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID);
+
checkAtTargets();
RootPart.ScheduleFullUpdate();
@@ -2032,6 +2046,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void ScheduleGroupForTerseUpdate()
{
+// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
+
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
@@ -2045,9 +2061,11 @@ namespace OpenSim.Region.Framework.Scenes
/// Immediately send a full update for this scene object.
///
public void SendGroupFullUpdate()
- {
+ {
if (IsDeleted)
return;
+
+// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID);
RootPart.SendFullUpdateToAllClients();
@@ -2064,7 +2082,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Immediately send an update for this scene object's root prim only.
/// This is for updates regarding the object as a whole, and none of its parts in particular.
- /// Note: this may not be cused by opensim (it probably should) but it's used by
+ /// Note: this may not be used by opensim (it probably should) but it's used by
/// external modules.
///
public void SendGroupRootTerseUpdate()
@@ -2079,6 +2097,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_scene == null) // Need to check here as it's null during object creation
return;
+
m_scene.SceneGraph.AddToUpdateList(this);
}
@@ -3557,7 +3576,9 @@ namespace OpenSim.Region.Framework.Scenes
HasGroupChanged = true;
}
- ScheduleGroupForFullUpdate();
+ // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
+ // for the same object with very different properties. The caller must schedule the update.
+ //ScheduleGroupForFullUpdate();
}
public void TriggerScriptChangedEvent(Changed val)
diff --git a/bin/OpenSim.exe.config b/bin/OpenSim.exe.config
index 3c7adf5..4e7ef51 100755
--- a/bin/OpenSim.exe.config
+++ b/bin/OpenSim.exe.config
@@ -12,7 +12,7 @@
-
+
--
cgit v1.1