1
0

SceneObjectStatusTests.cs 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using NUnit.Framework;
  31. using OpenMetaverse;
  32. using OpenSim.Framework;
  33. using OpenSim.Region.Framework.Scenes;
  34. using OpenSim.Tests.Common;
  35. namespace OpenSim.Region.Framework.Scenes.Tests
  36. {
  37. /// <summary>
  38. /// Basic scene object status tests
  39. /// </summary>
  40. [TestFixture]
  41. public class SceneObjectStatusTests : OpenSimTestCase
  42. {
  43. private TestScene m_scene;
  44. private UUID m_ownerId = TestHelpers.ParseTail(0x1);
  45. private SceneObjectGroup m_so1;
  46. private SceneObjectGroup m_so2;
  47. [SetUp]
  48. public void Init()
  49. {
  50. m_scene = new SceneHelpers().SetupScene();
  51. m_so1 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so1", 0x10);
  52. m_so2 = SceneHelpers.CreateSceneObject(1, m_ownerId, "so2", 0x20);
  53. }
  54. [Test]
  55. public void TestSetTemporary()
  56. {
  57. TestHelpers.InMethod();
  58. m_scene.AddSceneObject(m_so1);
  59. m_so1.ScriptSetTemporaryStatus(true);
  60. // Is this really the correct flag?
  61. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.TemporaryOnRez));
  62. Assert.That(m_so1.Backup, Is.False);
  63. // Test setting back to non-temporary
  64. m_so1.ScriptSetTemporaryStatus(false);
  65. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  66. Assert.That(m_so1.Backup, Is.True);
  67. }
  68. [Test]
  69. public void TestSetPhantomSinglePrim()
  70. {
  71. TestHelpers.InMethod();
  72. m_scene.AddSceneObject(m_so1);
  73. SceneObjectPart rootPart = m_so1.RootPart;
  74. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  75. m_so1.ScriptSetPhantomStatus(true);
  76. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  77. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom));
  78. m_so1.ScriptSetPhantomStatus(false);
  79. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  80. }
  81. [Test]
  82. public void TestSetNonPhysicsVolumeDetectSinglePrim()
  83. {
  84. TestHelpers.InMethod();
  85. m_scene.AddSceneObject(m_so1);
  86. SceneObjectPart rootPart = m_so1.RootPart;
  87. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  88. m_so1.ScriptSetVolumeDetect(true);
  89. // Console.WriteLine("so.RootPart.Flags [{0}]", so.RootPart.Flags);
  90. // PrimFlags.JointLP2P is incorrect it now means VolumeDetect (as defined by viewers)
  91. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.JointLP2P));
  92. m_so1.ScriptSetVolumeDetect(false);
  93. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  94. }
  95. [Test]
  96. public void TestSetPhysicsSinglePrim()
  97. {
  98. TestHelpers.InMethod();
  99. m_scene.AddSceneObject(m_so1);
  100. SceneObjectPart rootPart = m_so1.RootPart;
  101. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  102. m_so1.ScriptSetPhysicsStatus(true);
  103. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  104. m_so1.ScriptSetPhysicsStatus(false);
  105. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  106. }
  107. [Test]
  108. public void TestSetPhysicsVolumeDetectSinglePrim()
  109. {
  110. TestHelpers.InMethod();
  111. m_scene.AddSceneObject(m_so1);
  112. SceneObjectPart rootPart = m_so1.RootPart;
  113. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.None));
  114. m_so1.ScriptSetPhysicsStatus(true);
  115. m_so1.ScriptSetVolumeDetect(true);
  116. // PrimFlags.JointLP2P is incorrect it now means VolumeDetect (as defined by viewers)
  117. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Phantom | PrimFlags.Physics | PrimFlags.JointLP2P));
  118. m_so1.ScriptSetVolumeDetect(false);
  119. Assert.That(rootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  120. }
  121. [Test]
  122. public void TestSetPhysicsLinkset()
  123. {
  124. TestHelpers.InMethod();
  125. m_scene.AddSceneObject(m_so1);
  126. m_scene.AddSceneObject(m_so2);
  127. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  128. m_so1.ScriptSetPhysicsStatus(true);
  129. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  130. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  131. m_so1.ScriptSetPhysicsStatus(false);
  132. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  133. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  134. m_so1.ScriptSetPhysicsStatus(true);
  135. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  136. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  137. }
  138. /// <summary>
  139. /// Test that linking results in the correct physical status for all linkees.
  140. /// </summary>
  141. [Test]
  142. public void TestLinkPhysicsBothPhysical()
  143. {
  144. TestHelpers.InMethod();
  145. m_scene.AddSceneObject(m_so1);
  146. m_scene.AddSceneObject(m_so2);
  147. m_so1.ScriptSetPhysicsStatus(true);
  148. m_so2.ScriptSetPhysicsStatus(true);
  149. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  150. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  151. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  152. }
  153. /// <summary>
  154. /// Test that linking results in the correct physical status for all linkees.
  155. /// </summary>
  156. [Test]
  157. public void TestLinkPhysicsRootPhysicalOnly()
  158. {
  159. TestHelpers.InMethod();
  160. m_scene.AddSceneObject(m_so1);
  161. m_scene.AddSceneObject(m_so2);
  162. m_so1.ScriptSetPhysicsStatus(true);
  163. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  164. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.Physics));
  165. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.Physics));
  166. }
  167. /// <summary>
  168. /// Test that linking results in the correct physical status for all linkees.
  169. /// </summary>
  170. [Test]
  171. public void TestLinkPhysicsChildPhysicalOnly()
  172. {
  173. TestHelpers.InMethod();
  174. m_scene.AddSceneObject(m_so1);
  175. m_scene.AddSceneObject(m_so2);
  176. m_so2.ScriptSetPhysicsStatus(true);
  177. m_scene.LinkObjects(m_ownerId, m_so1.LocalId, new List<uint>() { m_so2.LocalId });
  178. Assert.That(m_so1.RootPart.Flags, Is.EqualTo(PrimFlags.None));
  179. Assert.That(m_so1.Parts[1].Flags, Is.EqualTo(PrimFlags.None));
  180. }
  181. }
  182. }