From 33a894f3d2cc95a7a512b86f39f3c6a6afabb015 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 00:15:21 +0100 Subject: refactor: move SOP.IsAttachment and AttachmentPoint up into SOG to avoid pointless duplication of identical values --- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 8 ++-- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 44 +++++++++------------ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 46 ++++++---------------- .../Framework/Scenes/SceneObjectPartInventory.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++-- OpenSim/Region/Framework/Scenes/SceneViewer.cs | 3 +- 7 files changed, 42 insertions(+), 73 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 2a76755..33407ec 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -122,7 +122,7 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)entity; - if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) + if (sop.ParentGroup.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) return 1; } @@ -135,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)entity; - if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) + if (sop.ParentGroup.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) return 1; } @@ -148,7 +148,7 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)entity; - if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) + if (sop.ParentGroup.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) return 1; } @@ -171,7 +171,7 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { // Attachments are high priority, - if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) + if (((SceneObjectPart)entity).ParentGroup.IsAttachment) return 1; // Non physical prims are lower priority than physical prims diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 513c0ea..45d1a0e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4223,7 +4223,7 @@ namespace OpenSim.Region.Framework.Scenes // their scripts will actually run. // -- Leaf, Tue Aug 12 14:17:05 EDT 2008 SceneObjectPart parent = part.ParentGroup.RootPart; - if (parent != null && parent.IsAttachment) + if (parent != null && part.ParentGroup.IsAttachment) return ScriptDanger(parent, parent.GetWorldPosition()); else return ScriptDanger(part, part.GetWorldPosition()); @@ -5030,7 +5030,7 @@ namespace OpenSim.Region.Framework.Scenes delete = true; } - if (delete && !rootPart.IsAttachment && !deletes.Contains(g)) + if (delete && !g.IsAttachment && !deletes.Contains(g)) deletes.Add(g); }); break; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fada688..34f484d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -146,27 +146,11 @@ namespace OpenSim.Region.Framework.Scenes return true; return false; } - + /// /// Is this scene object acting as an attachment? /// - /// - /// We return false if the group has already been deleted. - /// - /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I - /// presume either all or no parts in a linkset can be part of an attachment (in which - /// case the value would get proprogated down into all the descendent parts). - /// - public bool IsAttachment - { - get - { - if (!IsDeleted) - return m_rootPart.IsAttachment; - - return false; - } - } + public bool IsAttachment { get; set; } /// /// The avatar to which this scene object is attached. @@ -177,6 +161,14 @@ namespace OpenSim.Region.Framework.Scenes public UUID AttachedAvatar { get; set; } /// + /// Attachment point of this scene object to an avatar. + /// + /// + /// 0 if we're not attached to anything + /// + public uint AttachmentPoint; + + /// /// Is this scene object phantom? /// /// @@ -354,11 +346,13 @@ namespace OpenSim.Region.Framework.Scenes /// /// Check both the attachment property and the relevant properties of the underlying root part. /// + /// /// This is necessary in some cases, particularly when a scene object has just crossed into a region and doesn't /// have the IsAttachment property yet checked. /// /// FIXME: However, this should be fixed so that this property /// propertly reflects the underlying status. + /// /// public bool IsAttachmentCheckFull() { @@ -987,11 +981,11 @@ namespace OpenSim.Region.Framework.Scenes return m_rootPart.Shape.State; } - public void SetAttachmentPoint(byte point) + public void SetAttachmentPoint(uint point) { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].SetAttachmentPoint(point); + AttachmentPoint = point; + IsAttachment = point != 0; + m_rootPart.Shape.State = (byte)point; } public void ClearPartAttachmentData() @@ -1424,16 +1418,16 @@ namespace OpenSim.Region.Framework.Scenes // This is only necessary when userExposed is false! - bool previousAttachmentStatus = dupe.RootPart.IsAttachment; + bool previousAttachmentStatus = dupe.IsAttachment; if (!userExposed) - dupe.RootPart.IsAttachment = true; + dupe.IsAttachment = true; dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); if (!userExposed) { - dupe.RootPart.IsAttachment = previousAttachmentStatus; + dupe.IsAttachment = previousAttachmentStatus; } dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e510611..71023a9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -213,10 +213,7 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_fromUserInventoryItemID; } } - - public bool IsAttachment; - public scriptEvents AggregateScriptEvents; @@ -224,9 +221,6 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 AttachedPos; - public uint AttachmentPoint; - - public Vector3 RotationAxis = Vector3.One; @@ -723,7 +717,7 @@ namespace OpenSim.Region.Framework.Scenes m_groupPosition = actor.Position; } - if (IsAttachment) + if (m_parentGroup.IsAttachment) { ScenePresence sp = m_parentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); if (sp != null) @@ -807,7 +801,7 @@ namespace OpenSim.Region.Framework.Scenes { if (IsRoot) { - if (IsAttachment) + if (m_parentGroup.IsAttachment) return AttachedPos; else return AbsolutePosition; @@ -1090,7 +1084,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (IsAttachment) + if (m_parentGroup.IsAttachment) return GroupPosition; return m_offsetPosition + m_groupPosition; @@ -1588,7 +1582,7 @@ namespace OpenSim.Region.Framework.Scenes // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition // or flexible - if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) + if (!isPhantom && !m_parentGroup.IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) { try { @@ -2880,7 +2874,7 @@ namespace OpenSim.Region.Framework.Scenes public void rotLookAt(Quaternion target, float strength, float damping) { - if (IsAttachment) + if (m_parentGroup.IsAttachment) { /* ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); @@ -3014,7 +3008,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsRoot) { - if (IsAttachment) + if (m_parentGroup.IsAttachment) { SendFullUpdateToClient(remoteClient, AttachedPos, clientFlags); } @@ -3076,7 +3070,7 @@ namespace OpenSim.Region.Framework.Scenes { // Suppress full updates during attachment editing // - if (ParentGroup.IsSelected && IsAttachment) + if (ParentGroup.IsSelected && ParentGroup.IsAttachment) return; if (ParentGroup.IsDeleted) @@ -3254,26 +3248,6 @@ namespace OpenSim.Region.Framework.Scenes }); } - public void SetAttachmentPoint(uint AttachmentPoint) - { - this.AttachmentPoint = AttachmentPoint; - - if (AttachmentPoint != 0) - { - IsAttachment = true; - } - else - { - IsAttachment = false; - } - - // save the attachment point. - //if (AttachmentPoint != 0) - //{ - m_shape.State = (byte)AttachmentPoint; - //} - } - public void SetAxisRotation(int axis, int rotate) { if (m_parentGroup != null) @@ -4497,7 +4471,9 @@ namespace OpenSim.Region.Framework.Scenes } } - if (SetPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints + if (SetPhantom + || ParentGroup.IsAttachment + || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints { AddFlag(PrimFlags.Phantom); if (PhysActor != null) @@ -4928,7 +4904,7 @@ namespace OpenSim.Region.Framework.Scenes if (ParentGroup == null || ParentGroup.IsDeleted) return; - if (IsAttachment && ParentGroup.RootPart != this) + if (ParentGroup.IsAttachment && ParentGroup.RootPart != this) return; // Causes this thread to dig into the Client Thread Data. diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3b60f8c..108089e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -201,7 +201,7 @@ namespace OpenSim.Region.Framework.Scenes // Don't let this set the HasGroupChanged flag for attachments // as this happens during rez and we don't want a new asset // for each attachment each time - if (!m_part.ParentGroup.RootPart.IsAttachment) + if (!m_part.ParentGroup.IsAttachment) { HasInventoryChanged = true; m_part.ParentGroup.HasGroupChanged = true; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index fc89473..93782ce 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3178,7 +3178,7 @@ namespace OpenSim.Region.Framework.Scenes ISceneObject clone = sog.CloneForNewScene(); // Attachment module assumes that GroupPosition holds the offsets...! ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos; - ((SceneObjectGroup)clone).RootPart.IsAttachment = false; + ((SceneObjectGroup)clone).IsAttachment = false; cAgent.AttachmentObjects.Add(clone); string state = sog.GetStateSnapshot(); cAgent.AttachmentObjectStates.Add(state); @@ -3477,7 +3477,7 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectGroup so in m_attachments) { - if (attachmentPoint == so.RootPart.AttachmentPoint) + if (attachmentPoint == so.AttachmentPoint) attachments.Add(so); } } @@ -3869,12 +3869,12 @@ namespace OpenSim.Region.Framework.Scenes { if (grp.HasGroupChanged) // Resizer scripts? { - grp.RootPart.IsAttachment = false; + grp.IsAttachment = false; grp.AbsolutePosition = grp.RootPart.AttachedPos; // grp.DetachToInventoryPrep(); attachmentsModule.UpdateKnownItem(ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); - grp.RootPart.IsAttachment = true; + grp.IsAttachment = true; } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 7c067ca..997845b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs @@ -120,8 +120,7 @@ namespace OpenSim.Region.Framework.Scenes // We deal with the possibility that two updates occur at // the same unix time at the update point itself. - if ((update.LastFullUpdateTime < part.TimeStampFull) || - part.IsAttachment) + if ((update.LastFullUpdateTime < part.TimeStampFull) || part.ParentGroup.IsAttachment) { // m_log.DebugFormat( // "[SCENE PRESENCE]: Fully updating prim {0}, {1} - part timestamp {2}", -- cgit v1.1 From 1615e7d29fb6961a3ffe791fde4318f819c1a4b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 00:33:24 +0100 Subject: Eliminate duplicate AttachmentPoint properties by always using the one stored in the root part's state field. --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 34f484d..c453366 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -166,7 +166,24 @@ namespace OpenSim.Region.Framework.Scenes /// /// 0 if we're not attached to anything /// - public uint AttachmentPoint; + public uint AttachmentPoint + { + get + { + return m_rootPart.Shape.State; + } + + set + { + IsAttachment = value != 0; + m_rootPart.Shape.State = (byte)value; + } + } + + public void ClearPartAttachmentData() + { + AttachmentPoint = 0; + } /// /// Is this scene object phantom? @@ -976,23 +993,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public byte GetAttachmentPoint() - { - return m_rootPart.Shape.State; - } - - public void SetAttachmentPoint(uint point) - { - AttachmentPoint = point; - IsAttachment = point != 0; - m_rootPart.Shape.State = (byte)point; - } - - public void ClearPartAttachmentData() - { - SetAttachmentPoint((Byte)0); - } - /// /// /// -- cgit v1.1 From d4d894c20f3a44783172f8e52385d871b03e1aef Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 27 Aug 2011 01:28:33 +0100 Subject: Stop avatars returning from neighbouring regions from stalling on the border crossing. On making a root agent, we need to reset the ScenePresence.m_movement_flag so that it doesn't remember the movement registered to the client when it exited the initial region. If this is remember, then the client avatar movement isn't updated and it appears to stall in mid-air, though this is resolved with a prod/release of any other direction key. This bug was probably introduced a few weeks ago. Surprised that nobody brought it up. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 93782ce..4148d4b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -965,6 +965,11 @@ namespace OpenSim.Region.Framework.Scenes presence.Animator.SendAnimPackToClient(ControllingClient); }); + // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will + // stall on the border crossing since the existing child agent will still have the last movement + // recorded, which stops the input from being processed. + m_movementflag = 0; + m_scene.EventManager.TriggerOnMakeRootAgent(this); } @@ -1247,6 +1252,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { +// m_log.DebugFormat("[SCENE PRESENCE]: Received agent update from {0}", remoteClient.Name); + //if (m_isChildAgent) //{ // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); @@ -1445,6 +1452,8 @@ namespace OpenSim.Region.Framework.Scenes { m_movementflag |= (byte)nudgehack; } + +// m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with {1}", Name, DCF); m_movementflag += (byte)(uint)DCF; update_movementflag = true; } @@ -1456,6 +1465,7 @@ namespace OpenSim.Region.Framework.Scenes && ((m_movementflag & (byte)nudgehack) == nudgehack)) ) // This or is for Nudge forward { +// m_log.DebugFormat("[SCENE PRESENCE]: Updating m_movementflag for {0} with lack of {1}", Name, DCF); m_movementflag -= ((byte)(uint)DCF); update_movementflag = true; @@ -1520,12 +1530,21 @@ namespace OpenSim.Region.Framework.Scenes // which occurs later in the main scene loop if (update_movementflag || (update_rotation && DCFlagKeyPressed)) { - // m_log.DebugFormat("{0} {1}", update_movementflag, (update_rotation && DCFlagKeyPressed)); - // m_log.DebugFormat( - // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, ur = {4}", +// m_scene.RegionInfo.RegionName, agent_control_v3, Name, update_movementflag, update_rotation); AddNewMovement(agent_control_v3); } +// else +// { +// if (!update_movementflag) +// { +// m_log.DebugFormat( +// "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", +// m_scene.RegionInfo.RegionName, agent_control_v3, Name); +// } +// } if (update_movementflag && m_parentID == 0) Animator.UpdateMovementAnimations(); -- cgit v1.1 From 795b56e695976575eacfd5505830a94f32ca2d28 Mon Sep 17 00:00:00 2001 From: Makopoppo Date: Sat, 27 Aug 2011 12:16:46 +0900 Subject: Related to #4689 - Adding missing null check for SceneObjectPart Signed-off-by: BlueWall --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 ++++++++ OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9358e7b..addc20c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -223,6 +223,8 @@ namespace OpenSim.Region.Framework.Scenes // Retrieve group SceneObjectPart part = GetSceneObjectPart(primId); + if (part == null) + return new ArrayList(); SceneObjectGroup group = part.ParentGroup; if (null == group) { @@ -967,6 +969,8 @@ namespace OpenSim.Region.Framework.Scenes public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) { SceneObjectPart part = GetSceneObjectPart(localID); + if (part == null) + return; SceneObjectGroup group = part.ParentGroup; if (group != null) { @@ -2028,6 +2032,8 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint localID in localIDs) { SceneObjectPart part = GetSceneObjectPart(localID); + if (part == null) + continue; if (!groups.Contains(part.ParentGroup)) groups.Add(part.ParentGroup); } @@ -2073,6 +2079,8 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint localID in localIDs) { SceneObjectPart part = GetSceneObjectPart(localID); + if (part == null) + continue; part.GetProperties(remoteClient); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f40b373..0582586 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1546,8 +1546,11 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) { SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); - part.ClickAction = Convert.ToByte(clickAction); - group.HasGroupChanged = true; + if (part != null) + { + part.ClickAction = Convert.ToByte(clickAction); + group.HasGroupChanged = true; + } } } } @@ -1560,8 +1563,11 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) { SceneObjectPart part = m_parentScene.GetSceneObjectPart(primLocalID); - part.Material = Convert.ToByte(material); - group.HasGroupChanged = true; + if (part != null) + { + part.Material = Convert.ToByte(material); + group.HasGroupChanged = true; + } } } } -- cgit v1.1