From 9ba4511d3e6b63d51f951519151aaae1c59250d6 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 21:53:12 +0100
Subject: add SOG helper properties IsPhantom, IsTemporary, etc. to improve
code readability
use these in some sog methods
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 66 +++++++++++++++-------
1 file changed, 46 insertions(+), 20 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fe96152..079148f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -167,6 +167,44 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ ///
+ /// Is this scene object phantom?
+ ///
+ ///
+ /// Updating must currently take place through UpdatePrimFlags()
+ ///
+ public bool IsPhantom
+ {
+ get { return (RootPart.Flags & PrimFlags.Phantom) != 0; }
+ }
+
+ ///
+ /// Does this scene object use physics?
+ ///
+ ///
+ /// Updating must currently take place through UpdatePrimFlags()
+ ///
+ public bool UsesPhysics
+ {
+ get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
+ }
+
+ ///
+ /// Is this scene object temporary?
+ ///
+ ///
+ /// Updating must currently take place through UpdatePrimFlags()
+ ///
+ public bool IsTemporary
+ {
+ get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; }
+ }
+
+ public bool IsVolumeDetect
+ {
+ get { return RootPart.VolumeDetectActive; }
+ }
+
public float scriptScore;
private Vector3 lastPhysGroupPos;
@@ -1510,36 +1548,24 @@ namespace OpenSim.Region.Framework.Scenes
SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
}
- public void ScriptSetPhysicsStatus(bool UsePhysics)
+ public void ScriptSetPhysicsStatus(bool usePhysics)
{
- bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
- bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
- bool IsVolumeDetect = RootPart.VolumeDetectActive;
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
+ UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect);
}
- public void ScriptSetTemporaryStatus(bool TemporaryStatus)
+ public void ScriptSetTemporaryStatus(bool makeTemporary)
{
- bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
- bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
- bool IsVolumeDetect = RootPart.VolumeDetectActive;
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect);
+ UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect);
}
- public void ScriptSetPhantomStatus(bool PhantomStatus)
+ public void ScriptSetPhantomStatus(bool makePhantom)
{
- bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
- bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
- bool IsVolumeDetect = RootPart.VolumeDetectActive;
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect);
+ UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect);
}
- public void ScriptSetVolumeDetect(bool VDStatus)
+ public void ScriptSetVolumeDetect(bool makeVolumeDetect)
{
- bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
- bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0);
- bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0);
- UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus);
+ UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect);
/*
ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore
--
cgit v1.1
From 6d4432f44009d7f7f3e52c56e8ccc994494ec529 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Aug 2011 22:34:26 +0100
Subject: refactor: simplify EntityBase.IsDeleted property
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 079148f..8f0fa55 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1832,7 +1832,7 @@ namespace OpenSim.Region.Framework.Scenes
// an object has been deleted from a scene before update was processed.
// A more fundamental overhaul of the update mechanism is required to eliminate all
// the race conditions.
- if (m_isDeleted)
+ if (IsDeleted)
return;
// Even temporary objects take part in physics (e.g. temp-on-rez bullets)
@@ -2142,7 +2142,7 @@ namespace OpenSim.Region.Framework.Scenes
}
m_scene.UnlinkSceneObject(objectGroup, true);
- objectGroup.m_isDeleted = true;
+ objectGroup.IsDeleted = true;
objectGroup.m_parts.Clear();
@@ -3385,7 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual ISceneObject CloneForNewScene()
{
SceneObjectGroup sog = Copy(false);
- sog.m_isDeleted = false;
+ sog.IsDeleted = false;
return sog;
}
--
cgit v1.1
From 002313bf132e7eca3d33fdd0c695152146d469b4 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:02:23 +0100
Subject: refactor: move sog.DetachToInventoryPrep() into
AttachmentsModule.DetachSingleAttachmentToInv()
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 32 +++-------------------
1 file changed, 4 insertions(+), 28 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 8f0fa55..00e3363 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -147,15 +147,16 @@ namespace OpenSim.Region.Framework.Scenes
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
@@ -1017,31 +1018,6 @@ namespace OpenSim.Region.Framework.Scenes
m_rootPart.ClearUndoState();
}
- public void DetachToInventoryPrep()
- {
- ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
- //Vector3 detachedpos = new Vector3(127f, 127f, 127f);
- if (avatar != null)
- {
- //detachedpos = avatar.AbsolutePosition;
- avatar.RemoveAttachment(this);
- }
-
- m_rootPart.AttachedAvatar = UUID.Zero;
-
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].AttachedAvatar = UUID.Zero;
-
- m_rootPart.SetParentLocalId(0);
- //m_rootPart.SetAttachmentPoint((byte)0);
- m_rootPart.IsAttachment = false;
- AbsolutePosition = m_rootPart.AttachedPos;
- //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
- //AttachToBackup();
- //m_rootPart.ScheduleFullUpdate();
- }
-
///
///
///
--
cgit v1.1
From 5f3ffc195f60ac54492ccb389843f292b0be7511 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 22:49:11 +0100
Subject: refactor: move SOG.DetachToGround() to
AttachmentsModule.DetachSceneObjectToGround() and remove redundant code
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 46 +++-------------------
1 file changed, 6 insertions(+), 40 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 00e3363..e3b8fc8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -979,43 +979,16 @@ namespace OpenSim.Region.Framework.Scenes
return m_rootPart.Shape.State;
}
- public void ClearPartAttachmentData()
- {
- SetAttachmentPoint((Byte)0);
- }
-
- public void DetachToGround()
+ public void SetAttachmentPoint(byte point)
{
- ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
- if (avatar == null)
- return;
-
- avatar.RemoveAttachment(this);
-
- Vector3 detachedpos = new Vector3(127f,127f,127f);
- if (avatar == null)
- return;
-
- detachedpos = avatar.AbsolutePosition;
- RootPart.FromItemID = UUID.Zero;
-
- AbsolutePosition = detachedpos;
- m_rootPart.AttachedAvatar = UUID.Zero;
-
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
- parts[i].AttachedAvatar = UUID.Zero;
+ parts[i].SetAttachmentPoint(point);
+ }
- m_rootPart.SetParentLocalId(0);
- SetAttachmentPoint((byte)0);
- m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim);
- HasGroupChanged = true;
- RootPart.Rezzed = DateTime.Now;
- RootPart.RemFlag(PrimFlags.TemporaryOnRez);
- AttachToBackup();
- m_scene.EventManager.TriggerParcelPrimCountTainted();
- m_rootPart.ScheduleFullUpdate();
- m_rootPart.ClearUndoState();
+ public void ClearPartAttachmentData()
+ {
+ SetAttachmentPoint((Byte)0);
}
///
@@ -3349,13 +3322,6 @@ namespace OpenSim.Region.Framework.Scenes
return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition);
}
- public void SetAttachmentPoint(byte point)
- {
- SceneObjectPart[] parts = m_parts.GetArray();
- for (int i = 0; i < parts.Length; i++)
- parts[i].SetAttachmentPoint(point);
- }
-
#region ISceneObject
public virtual ISceneObject CloneForNewScene()
--
cgit v1.1
From 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 26 Aug 2011 23:06:41 +0100
Subject: refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar
This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP
---
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index e3b8fc8..fada688 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -169,6 +169,14 @@ namespace OpenSim.Region.Framework.Scenes
}
///
+ /// The avatar to which this scene object is attached.
+ ///
+ ///
+ /// If we're not attached to an avatar then this is UUID.Zero
+ ///
+ public UUID AttachedAvatar { get; set; }
+
+ ///
/// Is this scene object phantom?
///
///
@@ -1540,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (IsAttachment)
{
- ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
+ ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
avatar.PushForce(impulse);
@@ -1622,7 +1630,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (IsAttachment)
{
- ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
+ ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar);
if (avatar != null)
{
avatar.MoveToTarget(target, false);
--
cgit v1.1