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/Scenes')
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