diff options
author | Teravus Ovares | 2008-12-21 16:16:47 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-12-21 16:16:47 +0000 |
commit | 8444528bdc7bf9756fc45877396c1b058b7ff5dd (patch) | |
tree | 35a28c426d8b9924b17fae117ef1da792433ecda /OpenSim/Region/Environment/Scenes/Tests | |
parent | * Fixes linking multiple linksets together. They no longer explode (diff) | |
download | opensim-SC-8444528bdc7bf9756fc45877396c1b058b7ff5dd.zip opensim-SC-8444528bdc7bf9756fc45877396c1b058b7ff5dd.tar.gz opensim-SC-8444528bdc7bf9756fc45877396c1b058b7ff5dd.tar.bz2 opensim-SC-8444528bdc7bf9756fc45877396c1b058b7ff5dd.tar.xz |
* Adding a two prim linking/delinking test. This test is likely to get on people's nerves since linking/delinking is easily broken. But.. that's why we have tests!
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Tests')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs index 62a828e..c084943 100644 --- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs +++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs | |||
@@ -99,6 +99,79 @@ namespace OpenSim.Region.Environment.Scenes.Tests | |||
99 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | 99 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); |
100 | Assert.That(retrievedPart2, Is.Null); | 100 | Assert.That(retrievedPart2, Is.Null); |
101 | } | 101 | } |
102 | |||
103 | [Test] | ||
104 | public void TestLinkDelink2SceneObjects() | ||
105 | { | ||
106 | bool debugtest = false; | ||
107 | |||
108 | Scene scene = SceneTestUtils.SetupScene(); | ||
109 | SceneObjectPart part1 = SceneTestUtils.AddSceneObject(scene); | ||
110 | SceneObjectGroup grp1 = part1.ParentGroup; | ||
111 | SceneObjectPart part2 = SceneTestUtils.AddSceneObject(scene); | ||
112 | SceneObjectGroup grp2 = part2.ParentGroup; | ||
113 | |||
114 | |||
115 | grp1.AbsolutePosition = new Vector3(10, 10, 10); | ||
116 | grp2.AbsolutePosition = Vector3.Zero; | ||
117 | |||
118 | // <90,0,0> | ||
119 | grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0)); | ||
120 | |||
121 | // <180,0,0> | ||
122 | grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0)); | ||
123 | |||
124 | // Required for linking | ||
125 | grp1.RootPart.UpdateFlag = 0; | ||
126 | grp2.RootPart.UpdateFlag = 0; | ||
127 | |||
128 | // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated. | ||
129 | grp1.LinkToGroup(grp2); | ||
130 | |||
131 | Assert.That(grp1.Children.Count == 2); | ||
132 | |||
133 | if (debugtest) | ||
134 | { | ||
135 | System.Console.WriteLine("parts: {0}", grp1.Children.Count); | ||
136 | System.Console.WriteLine("Group1: Pos:{0}, Rot:{1}", grp1.AbsolutePosition, grp1.Rotation); | ||
137 | System.Console.WriteLine("Group1: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part1.OffsetPosition, part1.RotationOffset); | ||
138 | System.Console.WriteLine("Group1: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part2.OffsetPosition, part2.RotationOffset); | ||
139 | } | ||
140 | |||
141 | // root part should have no offset position or rotation | ||
142 | Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity); | ||
143 | |||
144 | // offset position should be root part position - part2.absolute position. | ||
145 | Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10)); | ||
146 | |||
147 | float roll = 0; | ||
148 | float pitch = 0; | ||
149 | float yaw = 0; | ||
150 | |||
151 | // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180. | ||
152 | part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); | ||
153 | Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); | ||
154 | |||
155 | if (debugtest) | ||
156 | System.Console.WriteLine(rotEuler1); | ||
157 | |||
158 | part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw); | ||
159 | Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG); | ||
160 | |||
161 | if (debugtest) | ||
162 | System.Console.WriteLine(rotEuler2); | ||
163 | |||
164 | Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f)); | ||
165 | |||
166 | // Delink part 2 | ||
167 | grp1.DelinkFromGroup(part2.LocalId); | ||
168 | |||
169 | if (debugtest) | ||
170 | System.Console.WriteLine("Group2: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part2.AbsolutePosition, part2.RotationOffset); | ||
171 | |||
172 | Assert.That(part2.AbsolutePosition == Vector3.Zero); | ||
173 | |||
174 | } | ||
102 | 175 | ||
103 | /// <summary> | 176 | /// <summary> |
104 | /// Test deleting an object asynchronously to user inventory. | 177 | /// Test deleting an object asynchronously to user inventory. |