From 7da10850b063d4b31ad48cf3448b9a76bc5bd835 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 13 Nov 2013 23:25:54 +0000 Subject: Fix bug where removing a physical linkset would only decrement the Active Objects statistic by 1 instead of by the number of prims removed. Unlike LL, OpenSimulator currently uses this stat to record the number of prims in the physics simulation, even when they are at rest. Added regression test for this case. --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 4 +- .../Framework/Scenes/Tests/SceneStatisticsTests.cs | 71 ++++++++++++++++++++++ 2 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 0a5bfd2..1aecce5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -519,12 +519,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal void AddPhysicalPrim(int number) { - m_physicalPrim++; + m_physicalPrim += number; } protected internal void RemovePhysicalPrim(int number) { - m_physicalPrim--; + m_physicalPrim -= number; } protected internal void AddToScriptLPS(int number) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs new file mode 100644 index 0000000..1667002 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneStatisticsTests.cs @@ -0,0 +1,71 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using NUnit.Framework; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Communications; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.Framework.Scenes.Tests +{ + [TestFixture] + public class SceneStatisticsTests : OpenSimTestCase + { + private TestScene m_scene; + + [SetUp] + public void Init() + { + m_scene = new SceneHelpers().SetupScene(); + } + + [Test] + public void TestAddRemovePhysicalLinkset() + { + Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(0)); + + UUID ownerId = TestHelpers.ParseTail(0x1); + SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(3, ownerId, "so1", 0x10); + so1.ScriptSetPhysicsStatus(true); + m_scene.AddSceneObject(so1); + + Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(3)); + Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(3)); + + m_scene.DeleteSceneObject(so1, false); + + Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(0)); + Assert.That(m_scene.SceneGraph.GetActiveObjectsCount(), Is.EqualTo(0)); + } + } +} \ No newline at end of file -- cgit v1.1 From 7cab41f4223b7febd3fdd42fa7cfefef25e4a9c9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Nov 2013 21:45:08 +0000 Subject: refactor: replace verbose checks with String.IsNullOrEmpty where applicable. Thanks to Kira for this patch from http://opensimulator.org/mantis/view.php?id=6845 --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- .../Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 9e6c25d..dcbb509 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -473,7 +473,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (CreatorData != null && CreatorData != string.Empty) + if (!string.IsNullOrEmpty(CreatorData)) return CreatorID.ToString() + ';' + CreatorData; else return CreatorID.ToString(); diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3ea936c..f07dee9 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1223,7 +1223,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "CreatorID", sop.CreatorID, options); - if (sop.CreatorData != null && sop.CreatorData != string.Empty) + if (!string.IsNullOrEmpty(sop.CreatorData)) writer.WriteElementString("CreatorData", sop.CreatorData); else if (options.ContainsKey("home")) { @@ -1396,7 +1396,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization WriteUUID(writer, "CreatorID", item.CreatorID, options); - if (item.CreatorData != null && item.CreatorData != string.Empty) + if (!string.IsNullOrEmpty(item.CreatorData)) writer.WriteElementString("CreatorData", item.CreatorData); else if (options.ContainsKey("home")) { -- cgit v1.1 From ff4e7de7769b7eaa1b4fd3917e59f362b708226a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 00:53:09 +0000 Subject: Fix issue where sitting on non-root linked prims would send camera to wrong position in third-person and mouselook We now specify sits as offsets from the root prim, as the viewer expects. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7243db1..ea8e4fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2312,8 +2312,10 @@ namespace OpenSim.Region.Framework.Scenes cameraEyeOffset = part.GetCameraEyeOffset(); forceMouselook = part.GetForceMouselook(); + // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is + // being sat upon. ControllingClient.SendSitResponse( - part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); + part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); m_requestedSitTargetUUID = part.UUID; @@ -2592,7 +2594,10 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_pos -= part.AbsolutePosition; + // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is + // being sat upon. + m_pos -= part.GroupPosition; + ParentPosition = part.AbsolutePosition; // m_log.DebugFormat( -- cgit v1.1 From ed1029712a85206430fee1d4897d473517728dab Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 01:18:07 +0000 Subject: Add line accidentally left out of recent non-root prim sit fix Original commit is ff4e7de7 --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ea8e4fe..17b6126 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2314,6 +2314,8 @@ namespace OpenSim.Region.Framework.Scenes // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is // being sat upon. + offset += part.OffsetPosition; + ControllingClient.SendSitResponse( part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); -- cgit v1.1 From 70e651a8d1d0c2a48c4f26cd1c70bee098c11a57 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 01:32:29 +0000 Subject: Fix non-root prim sit positions for prims where a sit target has been specified as well. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 17b6126..127ad40 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2590,7 +2590,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - part.GroupPosition; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; } -- cgit v1.1 From 78649eb0999a5f97cc541c94ec98d1d06ed957cb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 01:35:08 +0000 Subject: Refix fix for sitting on non-root linked prims with explicit sit targets. I forgot that m_post is being set inconsistently between non-explicit and explicit ragets --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 127ad40..c88025c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2590,7 +2590,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - part.GroupPosition; + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT + part.OffsetPosition; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; } -- cgit v1.1 From 65304260af283211443a2872c46f6609d3e45649 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 02:09:03 +0000 Subject: fix avatar rotation when sitting on a linked part Need to take into account rotation of linked prim now that we are always specifying sits wrt the root prim --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c88025c..7a1017f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2591,7 +2591,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT + part.OffsetPosition; - Rotation = sitTargetOrient; + Rotation = part.RotationOffset * sitTargetOrient; ParentPosition = part.AbsolutePosition; } else -- cgit v1.1 From 5aa3236ebeb4bbbdd5b539bfe0841029cf01fb9f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 02:27:03 +0000 Subject: Revert "fix avatar rotation when sitting on a linked part" Reverting for now to place on separate branch This reverts commit 65304260af283211443a2872c46f6609d3e45649. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7a1017f..c88025c 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2591,7 +2591,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT + part.OffsetPosition; - Rotation = part.RotationOffset * sitTargetOrient; + Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; } else -- cgit v1.1 From 910f07dffa001fbb6c3dd7f5ae3cfbaad161864e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 02:27:26 +0000 Subject: Revert "Refix fix for sitting on non-root linked prims with explicit sit targets." This reverts commit 78649eb0999a5f97cc541c94ec98d1d06ed957cb. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c88025c..127ad40 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2590,7 +2590,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT + part.OffsetPosition; + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - part.GroupPosition; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; } -- cgit v1.1 From eb172be5412a631db115346b4e75e5731b989920 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 02:28:30 +0000 Subject: Revert "Fix non-root prim sit positions for prims where a sit target has been specified as well." Revert to place on separate branch for now This reverts commit 70e651a8d1d0c2a48c4f26cd1c70bee098c11a57. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 127ad40..17b6126 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2590,7 +2590,7 @@ namespace OpenSim.Region.Framework.Scenes //Quaternion result = (sitTargetOrient * vq) * nq; - m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - part.GroupPosition; + m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; Rotation = sitTargetOrient; ParentPosition = part.AbsolutePosition; } -- cgit v1.1 From 1999b218fd679166d64c9c7bfabb0c16fbf8aa92 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 02:31:17 +0000 Subject: Revert "Add line accidentally left out of recent non-root prim sit fix" Reverting to place on new branch This reverts commit ed1029712a85206430fee1d4897d473517728dab. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 -- 1 file changed, 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 17b6126..ea8e4fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2314,8 +2314,6 @@ namespace OpenSim.Region.Framework.Scenes // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is // being sat upon. - offset += part.OffsetPosition; - ControllingClient.SendSitResponse( part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); -- cgit v1.1 From 60e049ea39f9b347ac1395c2373d17a983ab7ff3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 23 Nov 2013 02:31:39 +0000 Subject: Revert "Fix issue where sitting on non-root linked prims would send camera to wrong position in third-person and mouselook" Reverting to place on separate branch This reverts commit ff4e7de7769b7eaa1b4fd3917e59f362b708226a. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ea8e4fe..7243db1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2312,10 +2312,8 @@ namespace OpenSim.Region.Framework.Scenes cameraEyeOffset = part.GetCameraEyeOffset(); forceMouselook = part.GetForceMouselook(); - // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is - // being sat upon. ControllingClient.SendSitResponse( - part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); + part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); m_requestedSitTargetUUID = part.UUID; @@ -2594,10 +2592,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is - // being sat upon. - m_pos -= part.GroupPosition; - + m_pos -= part.AbsolutePosition; ParentPosition = part.AbsolutePosition; // m_log.DebugFormat( -- cgit v1.1