From 06552f217ebd9301fd487c788a13fd75d61a46de Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 21 Apr 2012 00:54:48 +0100 Subject: [PATCH 1/5] Add TestSetPhysics() to SOP status tests --- .../Framework/Scenes/SceneObjectPart.cs | 9 ++++++--- .../Scenes/Tests/SceneObjectStatusTests.cs | 20 +++++++++++++++++++ OpenSim/Tests/Common/Helpers/SceneHelpers.cs | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 046553ba6a..d2cd37dc8d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1706,6 +1706,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { + if (ParentGroup.Scene == null) + return; + if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) return; @@ -4161,7 +4164,7 @@ namespace OpenSim.Region.Framework.Scenes // For now, we use the NINJA naming scheme for identifying joints. // In the future, we can support other joint specification schemes such as a // custom checkbox in the viewer GUI. - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { string hingeString = "hingejoint"; return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); @@ -4177,7 +4180,7 @@ namespace OpenSim.Region.Framework.Scenes // For now, we use the NINJA naming scheme for identifying joints. // In the future, we can support other joint specification schemes such as a // custom checkbox in the viewer GUI. - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { string ballString = "balljoint"; return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); @@ -4193,7 +4196,7 @@ namespace OpenSim.Region.Framework.Scenes // For now, we use the NINJA naming scheme for identifying joints. // In the future, we can support other joint specification schemes such as a // custom checkbox in the viewer GUI. - if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) + if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) { return IsHingeJoint() || IsBallJoint(); } diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 2a342d50c8..16e8b63378 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -62,5 +62,25 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } + + [Test] + public void TestSetPhysics() + { + TestHelpers.InMethod(); + +// Scene scene = SceneSetupHelpers.SetupScene(); + SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); + SceneObjectPart rootPart = so.RootPart; + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + + so.ScriptSetPhysicsStatus(true); + +// Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + + so.ScriptSetPhysicsStatus(false); + + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + } } } \ No newline at end of file diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs index 318758d984..7a6b1cf8d5 100644 --- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs @@ -153,7 +153,7 @@ namespace OpenSim.Tests.Common PhysicsPluginManager physicsPluginManager = new PhysicsPluginManager(); physicsPluginManager.LoadPluginsFromAssembly("Physics/OpenSim.Region.Physics.BasicPhysicsPlugin.dll"); testScene.PhysicsScene - = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); + = physicsPluginManager.GetPhysicsScene("basicphysics", "ZeroMesher", new IniConfigSource(), "test"); testScene.RegionInfo.EstateSettings = new EstateSettings(); testScene.LoginsDisabled = false; From 71900968b221b89860d1cef162f3b0d1236e1c73 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 21 Apr 2012 01:01:24 +0100 Subject: [PATCH 2/5] refactor: extract common setup code in SceneObjectStatusTests --- .../Scenes/Tests/SceneObjectStatusTests.cs | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 16e8b63378..b8e1b92c21 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -43,22 +43,30 @@ namespace OpenSim.Region.Framework.Scenes.Tests [TestFixture] public class SceneObjectStatusTests { + private TestScene m_scene; + private SceneObjectGroup m_so1; + + [SetUp] + public void Init() + { + m_scene = SceneHelpers.SetupScene(); + SceneObjectGroup m_so1 = SceneHelpers.CreateSceneObject(1, UUID.Zero); + } + [Test] public void TestSetPhantom() { TestHelpers.InMethod(); -// Scene scene = SceneSetupHelpers.SetupScene(); - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); - SceneObjectPart rootPart = so.RootPart; + SceneObjectPart rootPart = m_so1.RootPart; Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); - so.ScriptSetPhantomStatus(true); + m_so1.ScriptSetPhantomStatus(true); // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); - so.ScriptSetPhantomStatus(false); + m_so1.ScriptSetPhantomStatus(false); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } @@ -68,17 +76,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests { TestHelpers.InMethod(); -// Scene scene = SceneSetupHelpers.SetupScene(); - SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); - SceneObjectPart rootPart = so.RootPart; + SceneObjectPart rootPart = m_so1.RootPart; Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); - so.ScriptSetPhysicsStatus(true); + m_so1.ScriptSetPhysicsStatus(true); // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); - so.ScriptSetPhysicsStatus(false); + m_so1.ScriptSetPhysicsStatus(false); Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); } From 17bf2a62db39ba58ca691a6754bf79fe6b3ee474 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 21 Apr 2012 01:09:19 +0100 Subject: [PATCH 3/5] Add test for correct physics status on linking two physics objects Also fixes last build break. --- .../Scenes/Tests/SceneObjectStatusTests.cs | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index b8e1b92c21..6270ac148d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections.Generic; using System.Reflection; using NUnit.Framework; using OpenMetaverse; @@ -44,13 +45,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests public class SceneObjectStatusTests { private TestScene m_scene; + private UUID m_ownerId = TestHelpers.ParseTail(0x1); private SceneObjectGroup m_so1; + private SceneObjectGroup m_so2; [SetUp] public void Init() { m_scene = SceneHelpers.SetupScene(); - SceneObjectGroup m_so1 = SceneHelpers.CreateSceneObject(1, UUID.Zero); + m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10); + m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20); } [Test] @@ -86,7 +90,27 @@ namespace OpenSim.Region.Framework.Scenes.Tests m_so1.ScriptSetPhysicsStatus(false); - Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); + } + + /// + /// Test that linking results in the correct physical status for all linkees. + /// + [Test] + public void TestLinkPhysicsBothPhysical() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_so1.ScriptSetPhysicsStatus(true); + m_so2.ScriptSetPhysicsStatus(true); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); } } } \ No newline at end of file From 9ac48b2aff2ddd00821b7e6ecd71ce134f7a0f25 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 21 Apr 2012 01:43:09 +0100 Subject: [PATCH 4/5] Fix a bug where linking a non-physical prim with a physical prim as root would make the non-physical prim phantom rather than part of the physics object. On region restart, the whole object would become physical as expected. Observed behaviour from elsewhere is that all prims in a new linkset should take on the status of the root prim. Add regression test for this behaviour. --- .../Framework/Scenes/SceneObjectGroup.cs | 3 +++ .../Scenes/Tests/SceneObjectStatusTests.cs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8e786c150e..49a3485183 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -2010,6 +2010,7 @@ namespace OpenSim.Region.Framework.Scenes linkPart.CreateSelected = true; linkPart.LinkNum = linkNum++; + linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); SceneObjectPart[] ogParts = objectGroup.Parts; Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) @@ -2220,6 +2221,8 @@ namespace OpenSim.Region.Framework.Scenes oldRot = part.RotationOffset; Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; part.RotationOffset = newRot; + + part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); } /// diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 6270ac148d..91f4a3433d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -112,5 +112,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); } + + /// + /// Test that linking results in the correct physical status for all linkees. + /// + [Test] + public void TestLinkPhysicsRootPhysicalOnly() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_so1.ScriptSetPhysicsStatus(true); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); + } } } \ No newline at end of file From d5c724e5b8cc15ce278b80070238e72a2e4ea0e8 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Sat, 21 Apr 2012 01:51:57 +0100 Subject: [PATCH 5/5] Add regression test for prim status when root prim in a new linkset is non-physical --- .../Framework/Scenes/SceneObjectPart.cs | 2 +- .../Scenes/Tests/SceneObjectStatusTests.cs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d2cd37dc8d..1592131dc2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1708,7 +1708,7 @@ namespace OpenSim.Region.Framework.Scenes { if (ParentGroup.Scene == null) return; - + if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) return; diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 91f4a3433d..8cdd64507e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs @@ -131,5 +131,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); } + + /// + /// Test that linking results in the correct physical status for all linkees. + /// + [Test] + public void TestLinkPhysicsChildPhysicalOnly() + { + TestHelpers.InMethod(); + + m_scene.AddSceneObject(m_so1); + m_scene.AddSceneObject(m_so2); + + m_so2.ScriptSetPhysicsStatus(true); + + m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List() { m_so2.LocalId }); + + Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); + Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); + } } } \ No newline at end of file