opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 | |||
28 | using System; |
||
29 | using System.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | using Nini.Config; |
||
32 | using NUnit.Framework; |
||
33 | using OpenMetaverse; |
||
34 | using OpenSim.Framework; |
||
35 | using OpenSim.Framework.Communications; |
||
36 | using OpenSim.Framework.Servers; |
||
37 | using OpenSim.Region.Framework.Interfaces; |
||
38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
||
39 | using OpenSim.Tests.Common; |
||
40 | using OpenSim.Tests.Common.Mock; |
||
41 | using System.Threading; |
||
42 | |||
43 | namespace OpenSim.Region.Framework.Scenes.Tests |
||
44 | { |
||
45 | [TestFixture] |
||
46 | public class ScenePresenceSitTests : OpenSimTestCase |
||
47 | { |
||
48 | private TestScene m_scene; |
||
49 | private ScenePresence m_sp; |
||
50 | |||
51 | [SetUp] |
||
52 | public void Init() |
||
53 | { |
||
54 | m_scene = new SceneHelpers().SetupScene(); |
||
55 | m_sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); |
||
56 | } |
||
57 | |||
58 | [Test] |
||
59 | public void TestSitOutsideRangeNoTarget() |
||
60 | { |
||
61 | TestHelpers.InMethod(); |
||
62 | // log4net.Config.XmlConfigurator.Configure(); |
||
63 | |||
64 | // More than 10 meters away from 0, 0, 0 (default part position) |
||
65 | Vector3 startPos = new Vector3(10.1f, 0, 0); |
||
66 | m_sp.AbsolutePosition = startPos; |
||
67 | |||
68 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
||
69 | |||
70 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
||
71 | |||
72 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
||
73 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); |
||
74 | Assert.That(part.GetSittingAvatars(), Is.Null); |
||
75 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); |
||
76 | } |
||
77 | |||
78 | [Test] |
||
79 | public void TestSitWithinRangeNoTarget() |
||
80 | { |
||
81 | TestHelpers.InMethod(); |
||
82 | // log4net.Config.XmlConfigurator.Configure(); |
||
83 | |||
84 | // Less than 10 meters away from 0, 0, 0 (default part position) |
||
85 | Vector3 startPos = new Vector3(9.9f, 0, 0); |
||
86 | m_sp.AbsolutePosition = startPos; |
||
87 | |||
88 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
||
89 | |||
90 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
||
91 | |||
92 | Assert.That(m_sp.PhysicsActor, Is.Null); |
||
93 | |||
94 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
||
95 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
||
96 | HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); |
||
97 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); |
||
98 | Assert.That(sittingAvatars.Contains(m_sp.UUID)); |
||
99 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
||
100 | } |
||
101 | |||
102 | [Test] |
||
103 | public void TestSitAndStandWithNoSitTarget() |
||
104 | { |
||
105 | TestHelpers.InMethod(); |
||
106 | // log4net.Config.XmlConfigurator.Configure(); |
||
107 | |||
108 | // Make sure we're within range to sit |
||
109 | Vector3 startPos = new Vector3(1, 1, 1); |
||
110 | m_sp.AbsolutePosition = startPos; |
||
111 | |||
112 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
||
113 | |||
114 | // We need to preserve this here because phys actor is removed by the sit. |
||
115 | Vector3 spPhysActorSize = m_sp.PhysicsActor.Size; |
||
116 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
||
117 | |||
118 | Assert.That( |
||
119 | m_sp.AbsolutePosition, |
||
120 | Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, spPhysActorSize.Z / 2))); |
||
121 | |||
122 | m_sp.StandUp(); |
||
123 | |||
124 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
||
125 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); |
||
126 | Assert.That(part.GetSittingAvatars(), Is.Null); |
||
127 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); |
||
128 | Assert.That(m_sp.PhysicsActor, Is.Not.Null); |
||
129 | } |
||
130 | |||
131 | [Test] |
||
132 | public void TestSitAndStandWithSitTarget() |
||
133 | { |
||
134 | TestHelpers.InMethod(); |
||
135 | // log4net.Config.XmlConfigurator.Configure(); |
||
136 | |||
137 | // If a prim has a sit target then we can sit from any distance away |
||
138 | Vector3 startPos = new Vector3(128, 128, 30); |
||
139 | m_sp.AbsolutePosition = startPos; |
||
140 | |||
141 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
||
142 | part.SitTargetPosition = new Vector3(0, 0, 1); |
||
143 | |||
144 | m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); |
||
145 | |||
146 | Assert.That(part.SitTargetAvatar, Is.EqualTo(m_sp.UUID)); |
||
147 | Assert.That(m_sp.ParentID, Is.EqualTo(part.LocalId)); |
||
148 | // Assert.That( |
||
149 | // m_sp.AbsolutePosition, |
||
150 | // Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); |
||
151 | Assert.That(m_sp.PhysicsActor, Is.Null); |
||
152 | |||
153 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(1)); |
||
154 | HashSet<UUID> sittingAvatars = part.GetSittingAvatars(); |
||
155 | Assert.That(sittingAvatars.Count, Is.EqualTo(1)); |
||
156 | Assert.That(sittingAvatars.Contains(m_sp.UUID)); |
||
157 | |||
158 | m_sp.StandUp(); |
||
159 | |||
160 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
||
161 | Assert.That(m_sp.ParentID, Is.EqualTo(0)); |
||
162 | Assert.That(m_sp.PhysicsActor, Is.Not.Null); |
||
163 | |||
164 | Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); |
||
165 | Assert.That(part.GetSittingAvatarsCount(), Is.EqualTo(0)); |
||
166 | Assert.That(part.GetSittingAvatars(), Is.Null); |
||
167 | } |
||
168 | |||
169 | [Test] |
||
170 | public void TestSitAndStandOnGround() |
||
171 | { |
||
172 | TestHelpers.InMethod(); |
||
173 | // log4net.Config.XmlConfigurator.Configure(); |
||
174 | |||
175 | // If a prim has a sit target then we can sit from any distance away |
||
176 | // Vector3 startPos = new Vector3(128, 128, 30); |
||
177 | // sp.AbsolutePosition = startPos; |
||
178 | |||
179 | m_sp.HandleAgentSitOnGround(); |
||
180 | |||
181 | Assert.That(m_sp.SitGround, Is.True); |
||
182 | Assert.That(m_sp.PhysicsActor, Is.Null); |
||
183 | |||
184 | m_sp.StandUp(); |
||
185 | |||
186 | Assert.That(m_sp.SitGround, Is.False); |
||
187 | Assert.That(m_sp.PhysicsActor, Is.Not.Null); |
||
188 | } |
||
189 | } |
||
190 | } |