diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | 81 |
1 files changed, 69 insertions, 12 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index acaeb90..b232a44 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -32,12 +32,10 @@ using Nini.Config; | |||
32 | using NUnit.Framework; | 32 | using NUnit.Framework; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
37 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
39 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
40 | using OpenSim.Tests.Common.Mock; | ||
41 | using System.Threading; | 39 | using System.Threading; |
42 | 40 | ||
43 | namespace OpenSim.Region.Framework.Scenes.Tests | 41 | namespace OpenSim.Region.Framework.Scenes.Tests |
@@ -73,6 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
73 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); | 71 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); |
74 | Assert.That(part.GetSittingAvatars(), Is.Null); | 72 | Assert.That(part.GetSittingAvatars(), Is.Null); |
75 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); | 73 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); |
74 | Assert.AreEqual(startPos, m_sp.AbsolutePosition); | ||
76 | } | 75 | } |
77 | 76 | ||
78 | [Test] | 77 | [Test] |
@@ -87,15 +86,21 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
87 | 86 | ||
88 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; | 87 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
89 | 88 | ||
89 | // We need to preserve this here because phys actor is removed by the sit. | ||
90 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; | ||
90 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 91 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
91 | 92 | ||
92 | Assert.That(m_sp.PhysicsActor, Is.Null); | 93 | Assert.That(m_sp.PhysicsActor, Is.Null); |
93 | 94 | ||
95 | Assert.That( | ||
96 | m_sp.AbsolutePosition, | ||
97 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); | ||
98 | |||
94 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | 99 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
95 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); | 100 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
96 | HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); | 101 | HashSet<ScenePresence> sittingAvatars = part.GetSittingAvatars(); |
97 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); | 102 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); |
98 | Assert.That(sittingAvatars.Contains(m_sp.UUID)); | 103 | Assert.That(sittingAvatars.Contains(m_sp)); |
99 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); | 104 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
100 | } | 105 | } |
101 | 106 | ||
@@ -111,15 +116,43 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
111 | 116 | ||
112 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; | 117 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
113 | 118 | ||
119 | // We need to preserve this here because phys actor is removed by the sit. | ||
120 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; | ||
121 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | ||
122 | |||
123 | Assert.That( | ||
124 | m_sp.AbsolutePosition, | ||
125 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); | ||
126 | |||
127 | m_sp.StandUp(); | ||
128 | |||
129 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); | ||
130 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); | ||
131 | Assert.That(part.GetSittingAvatars(), Is.Null); | ||
132 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); | ||
133 | Assert.That(m_sp.PhysicsActor, Is.Not.Null); | ||
134 | } | ||
135 | |||
136 | [Test] | ||
137 | public void TestSitAndStandWithNoSitTargetChildPrim() | ||
138 | { | ||
139 | TestHelpers.InMethod(); | ||
140 | // log4net.Config.XmlConfigurator.Configure(); | ||
141 | |||
142 | // Make sure we're within range to sit | ||
143 | Vector3 startPos = new Vector3(1, 1, 1); | ||
144 | m_sp.AbsolutePosition = startPos; | ||
145 | |||
146 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene, 2, m_sp.UUID, "part", 0x10).Parts[1]; | ||
147 | part.OffsetPosition = new Vector3(2, 3, 4); | ||
148 | |||
149 | // We need to preserve this here because phys actor is removed by the sit. | ||
150 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; | ||
114 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); | 151 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
115 | 152 | ||
116 | // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the | ||
117 | // default avatar. | ||
118 | // Curiously, Vector3.ToString() will not display the last two places of the float. For example, | ||
119 | // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337> | ||
120 | Assert.That( | 153 | Assert.That( |
121 | m_sp.AbsolutePosition, | 154 | m_sp.AbsolutePosition, |
122 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); | 155 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); |
123 | 156 | ||
124 | m_sp.StandUp(); | 157 | m_sp.StandUp(); |
125 | 158 | ||
@@ -147,15 +180,39 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
147 | 180 | ||
148 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); | 181 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); |
149 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); | 182 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
183 | |||
184 | // This section is copied from ScenePresence.HandleAgentSit(). Correctness is not guaranteed. | ||
185 | double x, y, z, m1, m2; | ||
186 | |||
187 | Quaternion r = part.SitTargetOrientation;; | ||
188 | m1 = r.X * r.X + r.Y * r.Y; | ||
189 | m2 = r.Z * r.Z + r.W * r.W; | ||
190 | |||
191 | // Rotate the vector <0, 0, 1> | ||
192 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
193 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
194 | z = m2 - m1; | ||
195 | |||
196 | // Set m to be the square of the norm of r. | ||
197 | double m = m1 + m2; | ||
198 | |||
199 | // This constant is emperically determined to be what is used in SL. | ||
200 | // See also http://opensimulator.org/mantis/view.php?id=7096 | ||
201 | double offset = 0.05; | ||
202 | |||
203 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
204 | Vector3 sitOffset = up * (float)offset; | ||
205 | // End of copied section. | ||
206 | |||
150 | Assert.That( | 207 | Assert.That( |
151 | m_sp.AbsolutePosition, | 208 | m_sp.AbsolutePosition, |
152 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); | 209 | Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition - sitOffset + ScenePresence.SIT_TARGET_ADJUSTMENT)); |
153 | Assert.That(m_sp.PhysicsActor, Is.Null); | 210 | Assert.That(m_sp.PhysicsActor, Is.Null); |
154 | 211 | ||
155 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); | 212 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
156 | HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); | 213 | HashSet<ScenePresence> sittingAvatars = part.GetSittingAvatars(); |
157 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); | 214 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); |
158 | Assert.That(sittingAvatars.Contains(m_sp.UUID)); | 215 | Assert.That(sittingAvatars.Contains(m_sp)); |
159 | 216 | ||
160 | m_sp.StandUp(); | 217 | m_sp.StandUp(); |
161 | 218 | ||