diff options
author | Sean Dague | 2009-02-09 20:06:06 +0000 |
---|---|---|
committer | Sean Dague | 2009-02-09 20:06:06 +0000 |
commit | 66dc421be7974c6aafb12f318a7649dca99f0989 (patch) | |
tree | 5415c8ef9ad05f38d1f4d0673be39e29d9e5ac44 /OpenSim/Region/ScriptEngine/Shared/Tests | |
parent | add a script for fixing line endings (at least from linux) (diff) | |
download | opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.zip opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.tar.gz opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.tar.bz2 opensim-SC_OLD-66dc421be7974c6aafb12f318a7649dca99f0989.tar.xz |
a last set of files that seem to have embedded ^M in them
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 280 |
1 files changed, 140 insertions, 140 deletions
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 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using OpenSim.Tests.Common; | 30 | using OpenSim.Tests.Common; |
31 | using OpenSim.Region.ScriptEngine.Shared; | 31 | using OpenSim.Region.ScriptEngine.Shared; |
32 | using OpenSim.Tests.Common.Setup; | 32 | using OpenSim.Tests.Common.Setup; |
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Region.ScriptEngine.Shared.Api; | 35 | using OpenSim.Region.ScriptEngine.Shared.Api; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using System; | 37 | using System; |
38 | 38 | ||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 39 | namespace 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 | } |