diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
3 files changed, 129 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cb0a57a..2882463 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -2673,6 +2673,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2673 | } | 2673 | } |
2674 | 2674 | ||
2675 | linkPart.LinkNum = linkNum++; | 2675 | linkPart.LinkNum = linkNum++; |
2676 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | ||
2676 | 2677 | ||
2677 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2678 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2678 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2679 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
@@ -2908,6 +2909,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2908 | oldRot = part.RotationOffset; | 2909 | oldRot = part.RotationOffset; |
2909 | Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; | 2910 | Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; |
2910 | part.RotationOffset = newRot; | 2911 | part.RotationOffset = newRot; |
2912 | |||
2913 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | ||
2911 | } | 2914 | } |
2912 | 2915 | ||
2913 | /// <summary> | 2916 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c73fc98..cd22def 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2074,6 +2074,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2074 | /// <param name="isNew"></param> | 2074 | /// <param name="isNew"></param> |
2075 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) | 2075 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) |
2076 | { | 2076 | { |
2077 | if (ParentGroup.Scene == null) | ||
2078 | return; | ||
2079 | |||
2077 | if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) | 2080 | if (!ParentGroup.Scene.PhysicalPrims && UsePhysics) |
2078 | return; | 2081 | return; |
2079 | 2082 | ||
@@ -4531,7 +4534,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4531 | // For now, we use the NINJA naming scheme for identifying joints. | 4534 | // For now, we use the NINJA naming scheme for identifying joints. |
4532 | // In the future, we can support other joint specification schemes such as a | 4535 | // In the future, we can support other joint specification schemes such as a |
4533 | // custom checkbox in the viewer GUI. | 4536 | // custom checkbox in the viewer GUI. |
4534 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4537 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4535 | { | 4538 | { |
4536 | string hingeString = "hingejoint"; | 4539 | string hingeString = "hingejoint"; |
4537 | return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); | 4540 | return (Name.Length >= hingeString.Length && Name.Substring(0, hingeString.Length) == hingeString); |
@@ -4547,7 +4550,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4547 | // For now, we use the NINJA naming scheme for identifying joints. | 4550 | // For now, we use the NINJA naming scheme for identifying joints. |
4548 | // In the future, we can support other joint specification schemes such as a | 4551 | // In the future, we can support other joint specification schemes such as a |
4549 | // custom checkbox in the viewer GUI. | 4552 | // custom checkbox in the viewer GUI. |
4550 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4553 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4551 | { | 4554 | { |
4552 | string ballString = "balljoint"; | 4555 | string ballString = "balljoint"; |
4553 | return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); | 4556 | return (Name.Length >= ballString.Length && Name.Substring(0, ballString.Length) == ballString); |
@@ -4563,7 +4566,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4563 | // For now, we use the NINJA naming scheme for identifying joints. | 4566 | // For now, we use the NINJA naming scheme for identifying joints. |
4564 | // In the future, we can support other joint specification schemes such as a | 4567 | // In the future, we can support other joint specification schemes such as a |
4565 | // custom checkbox in the viewer GUI. | 4568 | // custom checkbox in the viewer GUI. |
4566 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | 4569 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) |
4567 | { | 4570 | { |
4568 | return IsHingeJoint() || IsBallJoint(); | 4571 | return IsHingeJoint() || IsBallJoint(); |
4569 | } | 4572 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 2a342d5..882031c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using NUnit.Framework; | 31 | using NUnit.Framework; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
@@ -43,24 +44,137 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
43 | [TestFixture] | 44 | [TestFixture] |
44 | public class SceneObjectStatusTests | 45 | public class SceneObjectStatusTests |
45 | { | 46 | { |
47 | private TestScene m_scene; | ||
48 | private UUID m_ownerId = TestHelpers.ParseTail(0x1); | ||
49 | private SceneObjectGroup m_so1; | ||
50 | private SceneObjectGroup m_so2; | ||
51 | |||
52 | [SetUp] | ||
53 | public void Init() | ||
54 | { | ||
55 | m_scene = SceneHelpers.SetupScene(); | ||
56 | m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10); | ||
57 | m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20); | ||
58 | } | ||
59 | |||
46 | [Test] | 60 | [Test] |
47 | public void TestSetPhantom() | 61 | public void TestSetPhantomSinglePrim() |
48 | { | 62 | { |
49 | TestHelpers.InMethod(); | 63 | TestHelpers.InMethod(); |
50 | 64 | ||
51 | // Scene scene = SceneSetupHelpers.SetupScene(); | 65 | SceneObjectPart rootPart = m_so1.RootPart; |
52 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, UUID.Zero); | ||
53 | SceneObjectPart rootPart = so.RootPart; | ||
54 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | 66 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); |
55 | 67 | ||
56 | so.ScriptSetPhantomStatus(true); | 68 | m_so1.ScriptSetPhantomStatus(true); |
57 | 69 | ||
58 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | 70 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); |
59 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); | 71 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom)); |
60 | 72 | ||
61 | so.ScriptSetPhantomStatus(false); | 73 | m_so1.ScriptSetPhantomStatus(false); |
62 | 74 | ||
63 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | 75 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); |
64 | } | 76 | } |
77 | |||
78 | [Test] | ||
79 | public void TestSetPhysicsSinglePrim() | ||
80 | { | ||
81 | TestHelpers.InMethod(); | ||
82 | |||
83 | SceneObjectPart rootPart = m_so1.RootPart; | ||
84 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
85 | |||
86 | m_so1.ScriptSetPhysicsStatus(true); | ||
87 | |||
88 | // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags); | ||
89 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
90 | |||
91 | m_so1.ScriptSetPhysicsStatus(false); | ||
92 | |||
93 | Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
94 | } | ||
95 | |||
96 | [Test] | ||
97 | public void TestSetPhysicsLinkset() | ||
98 | { | ||
99 | TestHelpers.InMethod(); | ||
100 | |||
101 | m_scene.AddSceneObject(m_so1); | ||
102 | m_scene.AddSceneObject(m_so2); | ||
103 | |||
104 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
105 | |||
106 | m_so1.ScriptSetPhysicsStatus(true); | ||
107 | |||
108 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
109 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
110 | |||
111 | m_so1.ScriptSetPhysicsStatus(false); | ||
112 | |||
113 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
114 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
115 | |||
116 | m_so1.ScriptSetPhysicsStatus(true); | ||
117 | |||
118 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
119 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
120 | } | ||
121 | |||
122 | /// <summary> | ||
123 | /// Test that linking results in the correct physical status for all linkees. | ||
124 | /// </summary> | ||
125 | [Test] | ||
126 | public void TestLinkPhysicsBothPhysical() | ||
127 | { | ||
128 | TestHelpers.InMethod(); | ||
129 | |||
130 | m_scene.AddSceneObject(m_so1); | ||
131 | m_scene.AddSceneObject(m_so2); | ||
132 | |||
133 | m_so1.ScriptSetPhysicsStatus(true); | ||
134 | m_so2.ScriptSetPhysicsStatus(true); | ||
135 | |||
136 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
137 | |||
138 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
139 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
140 | } | ||
141 | |||
142 | /// <summary> | ||
143 | /// Test that linking results in the correct physical status for all linkees. | ||
144 | /// </summary> | ||
145 | [Test] | ||
146 | public void TestLinkPhysicsRootPhysicalOnly() | ||
147 | { | ||
148 | TestHelpers.InMethod(); | ||
149 | |||
150 | m_scene.AddSceneObject(m_so1); | ||
151 | m_scene.AddSceneObject(m_so2); | ||
152 | |||
153 | m_so1.ScriptSetPhysicsStatus(true); | ||
154 | |||
155 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
156 | |||
157 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics)); | ||
158 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics)); | ||
159 | } | ||
160 | |||
161 | /// <summary> | ||
162 | /// Test that linking results in the correct physical status for all linkees. | ||
163 | /// </summary> | ||
164 | [Test] | ||
165 | public void TestLinkPhysicsChildPhysicalOnly() | ||
166 | { | ||
167 | TestHelpers.InMethod(); | ||
168 | |||
169 | m_scene.AddSceneObject(m_so1); | ||
170 | m_scene.AddSceneObject(m_so2); | ||
171 | |||
172 | m_so2.ScriptSetPhysicsStatus(true); | ||
173 | |||
174 | m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId }); | ||
175 | |||
176 | Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None)); | ||
177 | Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None)); | ||
178 | } | ||
65 | } | 179 | } |
66 | } \ No newline at end of file | 180 | } \ No newline at end of file |