aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-12-21 20:09:47 +0000
committerTeravus Ovares2008-12-21 20:09:47 +0000
commit2ee8f81e15e717adae952969c5561c48c3eb6ace (patch)
treed273ced9c10c250b0daa0339e682baa816377625 /OpenSim
parentAn initial implementation of llMinEventDelay in XEngine. (diff)
downloadopensim-SC_OLD-2ee8f81e15e717adae952969c5561c48c3eb6ace.zip
opensim-SC_OLD-2ee8f81e15e717adae952969c5561c48c3eb6ace.tar.gz
opensim-SC_OLD-2ee8f81e15e717adae952969c5561c48c3eb6ace.tar.bz2
opensim-SC_OLD-2ee8f81e15e717adae952969c5561c48c3eb6ace.tar.xz
* Commit linkset Group (multiprim) linked/delinked to another linkset group (multiprim) test.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs126
1 files changed, 126 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
index c084943..9fad6e6 100644
--- a/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
+++ b/OpenSim/Region/Environment/Scenes/Tests/SceneObjectTests.cs
@@ -172,6 +172,132 @@ namespace OpenSim.Region.Environment.Scenes.Tests
172 Assert.That(part2.AbsolutePosition == Vector3.Zero); 172 Assert.That(part2.AbsolutePosition == Vector3.Zero);
173 173
174 } 174 }
175
176 [Test]
177 public void TestLinkDelink2groups4SceneObjects()
178 {
179 bool debugtest = false;
180
181 Scene scene = SceneTestUtils.SetupScene();
182 SceneObjectPart part1 = SceneTestUtils.AddSceneObject(scene);
183 SceneObjectGroup grp1 = part1.ParentGroup;
184 SceneObjectPart part2 = SceneTestUtils.AddSceneObject(scene);
185 SceneObjectGroup grp2 = part2.ParentGroup;
186 SceneObjectPart part3 = SceneTestUtils.AddSceneObject(scene);
187 SceneObjectGroup grp3 = part3.ParentGroup;
188 SceneObjectPart part4 = SceneTestUtils.AddSceneObject(scene);
189 SceneObjectGroup grp4 = part4.ParentGroup;
190
191
192 grp1.AbsolutePosition = new Vector3(10, 10, 10);
193 grp2.AbsolutePosition = Vector3.Zero;
194 grp3.AbsolutePosition = new Vector3(20, 20, 20);
195 grp4.AbsolutePosition = new Vector3(40, 40, 40);
196
197 // <90,0,0>
198 grp1.Rotation = (Quaternion.CreateFromEulers(90 * Utils.DEG_TO_RAD, 0, 0));
199
200 // <180,0,0>
201 grp2.UpdateGroupRotation(Quaternion.CreateFromEulers(180 * Utils.DEG_TO_RAD, 0, 0));
202
203 // <270,0,0>
204 grp3.Rotation = (Quaternion.CreateFromEulers(270 * Utils.DEG_TO_RAD, 0, 0));
205
206 // <0,90,0>
207 grp4.UpdateGroupRotation(Quaternion.CreateFromEulers(0, 90 * Utils.DEG_TO_RAD, 0));
208
209 // Required for linking
210 grp1.RootPart.UpdateFlag = 0;
211 grp2.RootPart.UpdateFlag = 0;
212 grp3.RootPart.UpdateFlag = 0;
213 grp4.RootPart.UpdateFlag = 0;
214
215 // Link grp2 to grp1. part2 becomes child prim to grp1. grp2 is eliminated.
216 grp1.LinkToGroup(grp2);
217
218 // Link grp4 to grp3.
219 grp3.LinkToGroup(grp4);
220
221 // Required for linking
222 grp1.RootPart.UpdateFlag = 0;
223 grp3.RootPart.UpdateFlag = 0;
224
225 // At this point we should have 4 parts total in two groups.
226
227 Assert.That(grp1.Children.Count == 2);
228 Assert.That(grp3.Children.Count == 2);
229
230
231 if (debugtest)
232 {
233 System.Console.WriteLine("--------After Link-------");
234 System.Console.WriteLine("Group1: parts: {0}", grp1.Children.Count);
235 System.Console.WriteLine("Group1: Pos:{0}, Rot:{1}", grp1.AbsolutePosition, grp1.Rotation);
236 System.Console.WriteLine("Group1: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part1.OffsetPosition, part1.RotationOffset);
237 System.Console.WriteLine("Group1: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part2.OffsetPosition, part2.RotationOffset);
238
239 System.Console.WriteLine("Group3: parts: {0}", grp3.Children.Count);
240 System.Console.WriteLine("Group3: Pos:{0}, Rot:{1}", grp3.AbsolutePosition, grp3.Rotation);
241 System.Console.WriteLine("Group3: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part3.OffsetPosition, part3.RotationOffset);
242 System.Console.WriteLine("Group3: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part4.OffsetPosition, part4.RotationOffset);
243 }
244
245 // root part should have no offset position or rotation
246 Assert.That(part1.OffsetPosition == Vector3.Zero && part1.RotationOffset == Quaternion.Identity);
247
248 // offset position should be root part position - part2.absolute position.
249 Assert.That(part2.OffsetPosition == new Vector3(-10, -10, -10));
250
251 float roll = 0;
252 float pitch = 0;
253 float yaw = 0;
254
255 // There's a euler anomoly at 180, 0, 0 so expect 180 to turn into -180.
256 part1.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
257 Vector3 rotEuler1 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG);
258
259 if (debugtest)
260 System.Console.WriteLine(rotEuler1);
261
262 part2.RotationOffset.GetEulerAngles(out roll, out pitch, out yaw);
263 Vector3 rotEuler2 = new Vector3(roll * Utils.RAD_TO_DEG, pitch * Utils.RAD_TO_DEG, yaw * Utils.RAD_TO_DEG);
264
265 if (debugtest)
266 System.Console.WriteLine(rotEuler2);
267
268 Assert.That(rotEuler2.ApproxEquals(new Vector3(-180, 0, 0), 0.001f) || rotEuler2.ApproxEquals(new Vector3(180, 0, 0), 0.001f));
269
270 // Now we're linking the first group to the second group. This will make the second group child parts of the first one.
271 grp3.LinkToGroup(grp1);
272
273 // Delink part 2
274 grp1.DelinkFromGroup(part2.LocalId);
275
276 grp1.DelinkFromGroup(part3.LocalId);
277
278 if (debugtest)
279 {
280 System.Console.WriteLine("--------After De-Link-------");
281 System.Console.WriteLine("Group1: parts: {0}", grp1.Children.Count);
282 System.Console.WriteLine("Group1: Pos:{0}, Rot:{1}", grp1.AbsolutePosition, grp1.Rotation);
283 System.Console.WriteLine("Group1: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part1.OffsetPosition, part1.RotationOffset);
284 System.Console.WriteLine("NoGroup: Prim2: AbsolutePosition:{0}, OffsetRotation:{1}", part2.AbsolutePosition, part2.RotationOffset);
285
286 System.Console.WriteLine("Group3: parts: {0}", grp3.Children.Count);
287 System.Console.WriteLine("Group3: Pos:{0}, Rot:{1}", grp3.AbsolutePosition, grp3.Rotation);
288 System.Console.WriteLine("Group3: Prim1: OffsetPosition:{0}, OffsetRotation:{1}", part3.OffsetPosition, part3.RotationOffset);
289 System.Console.WriteLine("Group3: Prim2: OffsetPosition:{0}, OffsetRotation:{1}", part4.OffsetPosition, part4.RotationOffset);
290 }
291
292 Assert.That(part2.AbsolutePosition == Vector3.Zero);
293 Assert.That(part4.OffsetPosition == new Vector3(20, 20, 20));
294 Quaternion compareQuaternion = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
295 Assert.That((part4.RotationOffset.X - compareQuaternion.X < 0.00003)
296 && (part4.RotationOffset.Y - compareQuaternion.Y < 0.00003)
297 && (part4.RotationOffset.Z - compareQuaternion.Z < 0.00003)
298 && (part4.RotationOffset.W - compareQuaternion.W < 0.00003));
299
300 }
175 301
176 /// <summary> 302 /// <summary>
177 /// Test deleting an object asynchronously to user inventory. 303 /// Test deleting an object asynchronously to user inventory.