From a3c723ee30db61e4c2c5375fa3c8c677336ca113 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Apr 2013 23:48:55 +0100 Subject: Fix minor race condition where SOP.GetGeometricCenter() and GetCenterOfMass() could return results which were never the case if these values were changed whilst the method was running No need to create new Vector3s since these are structs. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ec9e87e..2fcb199 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2136,9 +2136,9 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = PhysActor; if (pa != null) - return new Vector3(pa.GeometricCenter.X, pa.GeometricCenter.Y, pa.GeometricCenter.Z); + return pa.GeometricCenter; else - return new Vector3(0, 0, 0); + return Vector3.Zero; } public Vector3 GetCenterOfMass() @@ -2146,9 +2146,9 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = PhysActor; if (pa != null) - return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); + return pa.CenterOfMass; else - return new Vector3(0, 0, 0); + return Vector3.Zero; } public float GetMass() -- cgit v1.1 From 3332af4060960a4b649d3d5237988e0f410b54e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Apr 2013 00:01:06 +0100 Subject: minor: Make SOP.UpdateOffset() more consistent by checking against the same old OffsetPosition rather than one which may vary if it simultaneously changes. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2fcb199..d412702 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3915,17 +3915,17 @@ namespace OpenSim.Region.Framework.Scenes } /// - /// + /// Update this part's offset position. /// /// - public void UpdateOffSet(Vector3 pos) + public void UpdateOffSet(Vector3 newPos) { - if ((pos.X != OffsetPosition.X) || - (pos.Y != OffsetPosition.Y) || - (pos.Z != OffsetPosition.Z)) - { - Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); + Vector3 oldPos = OffsetPosition; + if ((newPos.X != oldPos.X) || + (newPos.Y != oldPos.Y) || + (newPos.Z != oldPos.Z)) + { if (ParentGroup.RootPart.GetStatusSandbox()) { if (Util.GetDistanceTo(ParentGroup.RootPart.StatusSandboxPos, newPos) > 10) -- cgit v1.1 From c0319daa403f68427bb80b4845a92eb37f21a7b7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Apr 2013 00:09:28 +0100 Subject: fix minor race condition in SOP.SitTargetPositionLL where inconsistency could occur if the sit target position changed whilst the property was fetched --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d412702..3e816fc 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1146,7 +1146,7 @@ namespace OpenSim.Region.Framework.Scenes // the mappings more consistant. public Vector3 SitTargetPositionLL { - get { return new Vector3(m_sitTargetPosition.X, m_sitTargetPosition.Y,m_sitTargetPosition.Z); } + get { return m_sitTargetPosition; } set { m_sitTargetPosition = value; } } -- cgit v1.1 From 97f0c9da84f9a3a73a63c209012260fa2c59c0de Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Apr 2013 00:23:20 +0100 Subject: Use consistent GroupPosition value Make SOP.UpdateGroupPosition() rather than one that could change whilst the method is being executed. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 3e816fc..7697411 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -3902,13 +3902,14 @@ namespace OpenSim.Region.Framework.Scenes } } - public void UpdateGroupPosition(Vector3 pos) + public void UpdateGroupPosition(Vector3 newPos) { - if ((pos.X != GroupPosition.X) || - (pos.Y != GroupPosition.Y) || - (pos.Z != GroupPosition.Z)) + Vector3 oldPos = GroupPosition; + + if ((newPos.X != oldPos.X) || + (newPos.Y != oldPos.Y) || + (newPos.Z != oldPos.Z)) { - Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); GroupPosition = newPos; ScheduleTerseUpdate(); } -- cgit v1.1 From 7bf1986e9138df4629aa9323d3ba9fab5c884400 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Apr 2013 00:24:33 +0100 Subject: Fix minor race condition in SOP.SitTargetOrientationLL where inconsistent values could be returned if the sit orientation was changed whilst the property was being fetched. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7697411..93d4da0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1152,17 +1152,8 @@ namespace OpenSim.Region.Framework.Scenes public Quaternion SitTargetOrientationLL { - get - { - return new Quaternion( - m_sitTargetOrientation.X, - m_sitTargetOrientation.Y, - m_sitTargetOrientation.Z, - m_sitTargetOrientation.W - ); - } - - set { m_sitTargetOrientation = new Quaternion(value.X, value.Y, value.Z, value.W); } + get { return m_sitTargetOrientation; } + set { m_sitTargetOrientation = value; } } public bool Stopped -- cgit v1.1