aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSean Dague2009-02-09 20:06:06 +0000
committerSean Dague2009-02-09 20:06:06 +0000
commit66dc421be7974c6aafb12f318a7649dca99f0989 (patch)
tree5415c8ef9ad05f38d1f4d0673be39e29d9e5ac44 /OpenSim
parentadd a script for fixing line endings (at least from linux) (diff)
downloadopensim-SC-66dc421be7974c6aafb12f318a7649dca99f0989.zip
opensim-SC-66dc421be7974c6aafb12f318a7649dca99f0989.tar.gz
opensim-SC-66dc421be7974c6aafb12f318a7649dca99f0989.tar.bz2
opensim-SC-66dc421be7974c6aafb12f318a7649dca99f0989.tar.xz
a last set of files that seem to have embedded ^M in them
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs384
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs280
4 files changed, 343 insertions, 343 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
index 35969c7..7249029 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
@@ -1,192 +1,192 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using System.Net; 30using System.Net;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using OpenSim.Framework.Communications; 32using OpenSim.Framework.Communications;
33using OpenMetaverse; 33using OpenMetaverse;
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36 36
37namespace OpenSim.Region.Framework.Scenes.Hypergrid 37namespace OpenSim.Region.Framework.Scenes.Hypergrid
38{ 38{
39 public class HGHyperlink 39 public class HGHyperlink
40 { 40 {
41 private static readonly ILog m_log = 41 private static readonly ILog m_log =
42 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 private static Random random = new Random(); 43 private static Random random = new Random();
44 44
45 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) 45 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
46 { 46 {
47 string host = "127.0.0.1"; 47 string host = "127.0.0.1";
48 string portstr; 48 string portstr;
49 string regionName = ""; 49 string regionName = "";
50 uint port = 9000; 50 uint port = 9000;
51 string[] parts = mapName.Split(new char[] { ':' }); 51 string[] parts = mapName.Split(new char[] { ':' });
52 if (parts.Length >= 1) 52 if (parts.Length >= 1)
53 { 53 {
54 host = parts[0]; 54 host = parts[0];
55 } 55 }
56 if (parts.Length >= 2) 56 if (parts.Length >= 2)
57 { 57 {
58 portstr = parts[1]; 58 portstr = parts[1];
59 if (!UInt32.TryParse(portstr, out port)) 59 if (!UInt32.TryParse(portstr, out port))
60 regionName = parts[1]; 60 regionName = parts[1];
61 } 61 }
62 // always take the last one 62 // always take the last one
63 if (parts.Length >= 3) 63 if (parts.Length >= 3)
64 { 64 {
65 regionName = parts[2]; 65 regionName = parts[2];
66 } 66 }
67 67
68 // Sanity check. Don't ever link to this sim. 68 // Sanity check. Don't ever link to this sim.
69 IPAddress ipaddr = null; 69 IPAddress ipaddr = null;
70 try 70 try
71 { 71 {
72 ipaddr = Util.GetHostFromDNS(host); 72 ipaddr = Util.GetHostFromDNS(host);
73 } 73 }
74 catch { } 74 catch { }
75 75
76 if ((ipaddr != null) && 76 if ((ipaddr != null) &&
77 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) 77 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
78 { 78 {
79 RegionInfo regInfo; 79 RegionInfo regInfo;
80 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); 80 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
81 if (success) 81 if (success)
82 { 82 {
83 regInfo.RegionName = mapName; 83 regInfo.RegionName = mapName;
84 return regInfo; 84 return regInfo;
85 } 85 }
86 } 86 }
87 87
88 return null; 88 return null;
89 } 89 }
90 90
91 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) 91 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
92 { 92 {
93 uint xloc = (uint)(random.Next(0, Int16.MaxValue)); 93 uint xloc = (uint)(random.Next(0, Int16.MaxValue));
94 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); 94 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
95 } 95 }
96 96
97 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, 97 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
98 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo) 98 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
99 { 99 {
100 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); 100 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
101 101
102 regInfo = new RegionInfo(); 102 regInfo = new RegionInfo();
103 regInfo.RegionName = externalRegionName; 103 regInfo.RegionName = externalRegionName;
104 regInfo.HttpPort = externalPort; 104 regInfo.HttpPort = externalPort;
105 regInfo.ExternalHostName = externalHostName; 105 regInfo.ExternalHostName = externalHostName;
106 regInfo.RegionLocX = xloc; 106 regInfo.RegionLocX = xloc;
107 regInfo.RegionLocY = yloc; 107 regInfo.RegionLocY = yloc;
108 108
109 try 109 try
110 { 110 {
111 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0); 111 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
112 } 112 }
113 catch (Exception e) 113 catch (Exception e)
114 { 114 {
115 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message); 115 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
116 return false; 116 return false;
117 } 117 }
118 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString(); 118 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
119 119
120 // Finally, link it 120 // Finally, link it
121 try 121 try
122 { 122 {
123 m_scene.CommsManager.GridService.RegisterRegion(regInfo); 123 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
124 } 124 }
125 catch (Exception e) 125 catch (Exception e)
126 { 126 {
127 m_log.Warn("[HGrid]: Unable to link region: " + e.Message); 127 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
128 return false; 128 return false;
129 } 129 }
130 130
131 uint x, y; 131 uint x, y;
132 if (!Check4096(m_scene, regInfo, out x, out y)) 132 if (!Check4096(m_scene, regInfo, out x, out y))
133 { 133 {
134 m_scene.CommsManager.GridService.DeregisterRegion(regInfo); 134 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
135 if (client != null) 135 if (client != null)
136 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")"); 136 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
137 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")"); 137 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
138 return false; 138 return false;
139 } 139 }
140 140
141 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y)) 141 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
142 { 142 {
143 m_scene.CommsManager.GridService.DeregisterRegion(regInfo); 143 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
144 if (client != null) 144 if (client != null)
145 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")"); 145 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
146 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")"); 146 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
147 return false; 147 return false;
148 } 148 }
149 149
150 m_log.Debug("[HGrid]: link region succeeded"); 150 m_log.Debug("[HGrid]: link region succeeded");
151 return true; 151 return true;
152 } 152 }
153 153
154 /// <summary> 154 /// <summary>
155 /// Cope with this viewer limitation. 155 /// Cope with this viewer limitation.
156 /// </summary> 156 /// </summary>
157 /// <param name="regInfo"></param> 157 /// <param name="regInfo"></param>
158 /// <returns></returns> 158 /// <returns></returns>
159 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y) 159 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
160 { 160 {
161 ulong realHandle; 161 ulong realHandle;
162 if (UInt64.TryParse(regInfo.regionSecret, out realHandle)) 162 if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
163 { 163 {
164 Utils.LongToUInts(realHandle, out x, out y); 164 Utils.LongToUInts(realHandle, out x, out y);
165 x = x / Constants.RegionSize; 165 x = x / Constants.RegionSize;
166 y = y / Constants.RegionSize; 166 y = y / Constants.RegionSize;
167 167
168 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || 168 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
169 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) 169 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
170 { 170 {
171 return false; 171 return false;
172 } 172 }
173 return true; 173 return true;
174 } 174 }
175 else 175 else
176 { 176 {
177 m_scene.CommsManager.GridService.RegisterRegion(regInfo); 177 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
178 m_log.Debug("[HGrid]: Gnomes. Region deregistered."); 178 m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
179 x = y = 0; 179 x = y = 0;
180 return false; 180 return false;
181 } 181 }
182 } 182 }
183 183
184 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y) 184 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
185 { 185 {
186 if ((thisx == x) && (thisy == y)) 186 if ((thisx == x) && (thisy == y))
187 return false; 187 return false;
188 return true; 188 return true;
189 } 189 }
190 190
191 } 191 }
192} 192}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ba2b55e..d3b9626 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1023,7 +1023,7 @@ namespace OpenSim.Region.Framework.Scenes
1023 // at region startup 1023 // at region startup
1024 1024
1025 // teravus: After this was removed from the linking algorithm, Linked prims no longer collided 1025 // teravus: After this was removed from the linking algorithm, Linked prims no longer collided
1026 // properly when non-physical if they havn't been moved. This breaks ALL builds. 1026 // properly when non-physical if they havn't been moved. This breaks ALL builds.
1027 // see: http://opensimulator.org/mantis/view.php?id=3108 1027 // see: http://opensimulator.org/mantis/view.php?id=3108
1028 1028
1029 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the 1029 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
@@ -2074,12 +2074,12 @@ namespace OpenSim.Region.Framework.Scenes
2074 // Can't do this yet since backup still makes use of the root part without any synchronization 2074 // Can't do this yet since backup still makes use of the root part without any synchronization
2075// objectGroup.m_rootPart = null; 2075// objectGroup.m_rootPart = null;
2076 2076
2077 AttachToBackup(); 2077 AttachToBackup();
2078 2078
2079 2079
2080 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the 2080 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
2081 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and 2081 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and
2082 // unmoved prims! 2082 // unmoved prims!
2083 ResetChildPrimPhysicsPositions(); 2083 ResetChildPrimPhysicsPositions();
2084 2084
2085 HasGroupChanged = true; 2085 HasGroupChanged = true;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 63e4611..e9f93a6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1019,10 +1019,10 @@ namespace OpenSim.Region.Framework.Scenes
1019 } 1019 }
1020 1020
1021 //m_log.DebugFormat("Completed movement"); 1021 //m_log.DebugFormat("Completed movement");
1022 } 1022 }
1023 1023
1024 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1024 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1025 1025
1026 } 1026 }
1027 1027
1028 /// <summary> 1028 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index 291efd2..534e8b3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -1,140 +1,140 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Tests.Common; 30using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared; 31using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Tests.Common.Setup; 32using OpenSim.Tests.Common.Setup;
33using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
36using OpenMetaverse; 36using OpenMetaverse;
37using System; 37using System;
38 38
39namespace OpenSim.Region.ScriptEngine.Shared.Tests 39namespace OpenSim.Region.ScriptEngine.Shared.Tests
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// Tests for LSL_Api 42 /// Tests for LSL_Api
43 /// </summary> 43 /// </summary>
44 [TestFixture] 44 [TestFixture]
45 public class LSL_ApiTest 45 public class LSL_ApiTest
46 { 46 {
47 47
48 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-7; 48 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-7;
49 private LSL_Api lslApi; 49 private LSL_Api lslApi;
50 50
51 [SetUp] 51 [SetUp]
52 public void SetUp() 52 public void SetUp()
53 { 53 {
54 54
55 IniConfigSource initConfigSource = new IniConfigSource(); 55 IniConfigSource initConfigSource = new IniConfigSource();
56 IConfig config = initConfigSource.AddConfig("XEngine"); 56 IConfig config = initConfigSource.AddConfig("XEngine");
57 config.Set("Enabled", "true"); 57 config.Set("Enabled", "true");
58 58
59 Scene scene = SceneSetupHelpers.SetupScene(); 59 Scene scene = SceneSetupHelpers.SetupScene();
60 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); 60 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
61 61
62 XEngine.XEngine engine = new XEngine.XEngine(); 62 XEngine.XEngine engine = new XEngine.XEngine();
63 engine.Initialise(scene, initConfigSource); 63 engine.Initialise(scene, initConfigSource);
64 64
65 lslApi = new LSL_Api(); 65 lslApi = new LSL_Api();
66 lslApi.Initialize(engine, part, part.LocalId, part.UUID); 66 lslApi.Initialize(engine, part, part.LocalId, part.UUID);
67 67
68 } 68 }
69 69
70 [Test] 70 [Test]
71 public void TestllAngleBetween() 71 public void TestllAngleBetween()
72 { 72 {
73 TestllAngleBetween(new Vector3(1, 0, 0), 0); 73 TestllAngleBetween(new Vector3(1, 0, 0), 0);
74 TestllAngleBetween(new Vector3(1, 0, 0), 90); 74 TestllAngleBetween(new Vector3(1, 0, 0), 90);
75 TestllAngleBetween(new Vector3(1, 0, 0), 180); 75 TestllAngleBetween(new Vector3(1, 0, 0), 180);
76 TestllAngleBetween(new Vector3(1, 0, 0), 270); 76 TestllAngleBetween(new Vector3(1, 0, 0), 270);
77 77
78 TestllAngleBetween(new Vector3(0, 1, 0), 0); 78 TestllAngleBetween(new Vector3(0, 1, 0), 0);
79 TestllAngleBetween(new Vector3(0, 1, 0), 90); 79 TestllAngleBetween(new Vector3(0, 1, 0), 90);
80 TestllAngleBetween(new Vector3(0, 1, 0), 180); 80 TestllAngleBetween(new Vector3(0, 1, 0), 180);
81 TestllAngleBetween(new Vector3(0, 1, 0), 270); 81 TestllAngleBetween(new Vector3(0, 1, 0), 270);
82 82
83 TestllAngleBetween(new Vector3(0, 0, 1), 0); 83 TestllAngleBetween(new Vector3(0, 0, 1), 0);
84 TestllAngleBetween(new Vector3(0, 0, 1), 90); 84 TestllAngleBetween(new Vector3(0, 0, 1), 90);
85 TestllAngleBetween(new Vector3(0, 0, 1), 180); 85 TestllAngleBetween(new Vector3(0, 0, 1), 180);
86 TestllAngleBetween(new Vector3(0, 0, 1), 270); 86 TestllAngleBetween(new Vector3(0, 0, 1), 270);
87 87
88 TestllAngleBetween(new Vector3(1, 1, 1), 0); 88 TestllAngleBetween(new Vector3(1, 1, 1), 0);
89 TestllAngleBetween(new Vector3(1, 1, 1), 90); 89 TestllAngleBetween(new Vector3(1, 1, 1), 90);
90 TestllAngleBetween(new Vector3(1, 1, 1), 180); 90 TestllAngleBetween(new Vector3(1, 1, 1), 180);
91 TestllAngleBetween(new Vector3(1, 1, 1), 270); 91 TestllAngleBetween(new Vector3(1, 1, 1), 270);
92 } 92 }
93 93
94 private void TestllAngleBetween(Vector3 axis,float originalAngle) 94 private void TestllAngleBetween(Vector3 axis,float originalAngle)
95 { 95 {
96 Quaternion rotation1 = Quaternion.CreateFromAxisAngle(axis, 0); 96 Quaternion rotation1 = Quaternion.CreateFromAxisAngle(axis, 0);
97 Quaternion rotation2 = Quaternion.CreateFromAxisAngle(axis, ToRadians(originalAngle)); 97 Quaternion rotation2 = Quaternion.CreateFromAxisAngle(axis, ToRadians(originalAngle));
98 98
99 double deducedAngle = FromLslFloat(lslApi.llAngleBetween(ToLslQuaternion(rotation2), ToLslQuaternion(rotation1))); 99 double deducedAngle = FromLslFloat(lslApi.llAngleBetween(ToLslQuaternion(rotation2), ToLslQuaternion(rotation1)));
100 100
101 Assert.Greater(deducedAngle, ToRadians(originalAngle) - ANGLE_ACCURACY_IN_RADIANS); 101 Assert.Greater(deducedAngle, ToRadians(originalAngle) - ANGLE_ACCURACY_IN_RADIANS);
102 Assert.Less(deducedAngle, ToRadians(originalAngle) + ANGLE_ACCURACY_IN_RADIANS); 102 Assert.Less(deducedAngle, ToRadians(originalAngle) + ANGLE_ACCURACY_IN_RADIANS);
103 } 103 }
104 104
105 #region Conversions to and from LSL_Types 105 #region Conversions to and from LSL_Types
106 106
107 private float ToRadians(double degrees) 107 private float ToRadians(double degrees)
108 { 108 {
109 return (float)(Math.PI * degrees / 180); 109 return (float)(Math.PI * degrees / 180);
110 } 110 }
111 111
112 // private double FromRadians(float radians) 112 // private double FromRadians(float radians)
113 // { 113 // {
114 // return radians * 180 / Math.PI; 114 // return radians * 180 / Math.PI;
115 // } 115 // }
116 116
117 private double FromLslFloat(LSL_Types.LSLFloat lslFloat) 117 private double FromLslFloat(LSL_Types.LSLFloat lslFloat)
118 { 118 {
119 return lslFloat.value; 119 return lslFloat.value;
120 } 120 }
121 121
122 // private LSL_Types.LSLFloat ToLslFloat(double value) 122 // private LSL_Types.LSLFloat ToLslFloat(double value)
123 // { 123 // {
124 // return new LSL_Types.LSLFloat(value); 124 // return new LSL_Types.LSLFloat(value);
125 // } 125 // }
126 126
127 // private Quaternion FromLslQuaternion(LSL_Types.Quaternion lslQuaternion) 127 // private Quaternion FromLslQuaternion(LSL_Types.Quaternion lslQuaternion)
128 // { 128 // {
129 // return new Quaternion((float)lslQuaternion.x, (float)lslQuaternion.y, (float)lslQuaternion.z, (float)lslQuaternion.s); 129 // return new Quaternion((float)lslQuaternion.x, (float)lslQuaternion.y, (float)lslQuaternion.z, (float)lslQuaternion.s);
130 // } 130 // }
131 131
132 private LSL_Types.Quaternion ToLslQuaternion(Quaternion quaternion) 132 private LSL_Types.Quaternion ToLslQuaternion(Quaternion quaternion)
133 { 133 {
134 return new LSL_Types.Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W); 134 return new LSL_Types.Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
135 } 135 }
136 136
137 #endregion 137 #endregion
138 138
139 } 139 }
140} 140}