diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 295 |
1 files changed, 292 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 358ce22..0cbad41 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -27,12 +27,13 @@ | |||
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using NUnit.Framework; | 29 | using NUnit.Framework; |
30 | using OpenSim.Framework; | ||
30 | using OpenSim.Tests.Common; | 31 | using OpenSim.Tests.Common; |
31 | using OpenSim.Region.ScriptEngine.Shared; | 32 | using OpenSim.Region.ScriptEngine.Shared; |
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 OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using System; | 38 | using System; |
38 | using OpenSim.Tests.Common.Mock; | 39 | using OpenSim.Tests.Common.Mock; |
@@ -47,6 +48,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
47 | { | 48 | { |
48 | 49 | ||
49 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; | 50 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; |
51 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; | ||
52 | private const float FLOAT_ACCURACY = 0.00005f; | ||
50 | private LSL_Api m_lslApi; | 53 | private LSL_Api m_lslApi; |
51 | 54 | ||
52 | [SetUp] | 55 | [SetUp] |
@@ -57,8 +60,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
57 | IConfig config = initConfigSource.AddConfig("XEngine"); | 60 | IConfig config = initConfigSource.AddConfig("XEngine"); |
58 | config.Set("Enabled", "true"); | 61 | config.Set("Enabled", "true"); |
59 | 62 | ||
60 | Scene scene = SceneSetupHelpers.SetupScene(); | 63 | Scene scene = SceneHelpers.SetupScene(); |
61 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | 64 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene); |
62 | 65 | ||
63 | XEngine.XEngine engine = new XEngine.XEngine(); | 66 | XEngine.XEngine engine = new XEngine.XEngine(); |
64 | engine.Initialise(initConfigSource); | 67 | engine.Initialise(initConfigSource); |
@@ -134,5 +137,291 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
134 | 137 | ||
135 | #endregion | 138 | #endregion |
136 | 139 | ||
140 | [Test] | ||
141 | // llRot2Euler test. | ||
142 | public void TestllRot2Euler() | ||
143 | { | ||
144 | // 180, 90 and zero degree rotations. | ||
145 | CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 0.0f, 0.0f, 0.0f), new LSL_Types.Vector3(Math.PI, 0.0f, 0.0f)); | ||
146 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 1.0f, 0.0f, 0.0f), new LSL_Types.Vector3(Math.PI, 0.0f, Math.PI)); | ||
147 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 1.0f, 0.0f), new LSL_Types.Vector3(0.0f, 0.0f, Math.PI)); | ||
148 | CheckllRot2Euler(new LSL_Types.Quaternion(0.0f, 0.0f, 0.0f, 1.0f), new LSL_Types.Vector3(0.0f, 0.0f, 0.0f)); | ||
149 | CheckllRot2Euler(new LSL_Types.Quaternion(-0.5f, -0.5f, 0.5f, 0.5f), new LSL_Types.Vector3(0, -Math.PI / 2.0f, Math.PI / 2.0f)); | ||
150 | CheckllRot2Euler(new LSL_Types.Quaternion(-0.707107f, 0.0f, 0.0f, -0.707107f), new LSL_Types.Vector3(Math.PI / 2.0f, 0.0f, 0.0f)); | ||
151 | // A couple of messy rotations. | ||
152 | CheckllRot2Euler(new LSL_Types.Quaternion(1.0f, 5.651f, -3.1f, 67.023f), new LSL_Types.Vector3(0.037818f, 0.166447f, -0.095595f)); | ||
153 | CheckllRot2Euler(new LSL_Types.Quaternion(0.719188f, -0.408934f, -0.363998f, -0.427841f), new LSL_Types.Vector3(-1.954769f, -0.174533f, 1.151917f)); | ||
154 | } | ||
155 | |||
156 | private void CheckllRot2Euler(LSL_Types.Quaternion rot, LSL_Types.Vector3 eulerCheck) | ||
157 | { | ||
158 | // Call LSL function to convert quaternion rotaion to euler radians. | ||
159 | LSL_Types.Vector3 eulerCalc = m_lslApi.llRot2Euler(rot); | ||
160 | // Check upper and lower bounds of x, y and z. | ||
161 | // This type of check is performed as opposed to comparing for equal numbers, in order to allow slight | ||
162 | // differences in accuracy. | ||
163 | Assert.Greater(eulerCalc.x, eulerCheck.x - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler X lower bounds check fail"); | ||
164 | Assert.Less(eulerCalc.x, eulerCheck.x + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler X upper bounds check fail"); | ||
165 | Assert.Greater(eulerCalc.y, eulerCheck.y - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Y lower bounds check fail"); | ||
166 | Assert.Less(eulerCalc.y, eulerCheck.y + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Y upper bounds check fail"); | ||
167 | Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail"); | ||
168 | Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail"); | ||
169 | } | ||
170 | |||
171 | [Test] | ||
172 | // llSetPrimitiveParams and llGetPrimitiveParams test. | ||
173 | public void TestllSetPrimitiveParams() | ||
174 | { | ||
175 | // Create Prim1. | ||
176 | Scene scene = SceneHelpers.SetupScene(); | ||
177 | string obj1Name = "Prim1"; | ||
178 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | ||
179 | SceneObjectPart part1 = | ||
180 | new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, | ||
181 | Vector3.Zero, Quaternion.Identity, | ||
182 | Vector3.Zero) { Name = obj1Name, UUID = objUuid }; | ||
183 | Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); | ||
184 | |||
185 | // Note that prim hollow check is passed with the other prim params in order to allow the | ||
186 | // specification of a different check value from the prim param. A cylinder, prism, sphere, | ||
187 | // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below | ||
188 | // specifies a value of 95% and checks to see if 70% was properly returned. | ||
189 | |||
190 | // Test a sphere. | ||
191 | CheckllSetPrimitiveParams( | ||
192 | "test 1", // Prim test identification string | ||
193 | new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size | ||
194 | ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type | ||
195 | ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type | ||
196 | new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut | ||
197 | 0.80f, // Prim hollow | ||
198 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
199 | new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple | ||
200 | 0.80f); // Prim hollow check | ||
201 | |||
202 | // Test a prism. | ||
203 | CheckllSetPrimitiveParams( | ||
204 | "test 2", // Prim test identification string | ||
205 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
206 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
207 | ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type | ||
208 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
209 | 0.90f, // Prim hollow | ||
210 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
211 | new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper | ||
212 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
213 | 0.90f); // Prim hollow check | ||
214 | |||
215 | // Test a box. | ||
216 | CheckllSetPrimitiveParams( | ||
217 | "test 3", // Prim test identification string | ||
218 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
219 | ScriptBaseClass.PRIM_TYPE_BOX, // Prim type | ||
220 | ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type | ||
221 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
222 | 0.95f, // Prim hollow | ||
223 | new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist | ||
224 | new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper | ||
225 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
226 | 0.95f); // Prim hollow check | ||
227 | |||
228 | // Test a tube. | ||
229 | CheckllSetPrimitiveParams( | ||
230 | "test 4", // Prim test identification string | ||
231 | new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size | ||
232 | ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type | ||
233 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
234 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
235 | 0.00f, // Prim hollow | ||
236 | new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist | ||
237 | new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size | ||
238 | // Expression for y selected to test precision problems during byte | ||
239 | // cast in SetPrimitiveShapeParams. | ||
240 | new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear | ||
241 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut | ||
242 | // Expression for y selected to test precision problems during sbyte | ||
243 | // cast in SetPrimitiveShapeParams. | ||
244 | new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper | ||
245 | 1.11f, // Prim revolutions | ||
246 | 0.88f, // Prim radius | ||
247 | 0.95f, // Prim skew | ||
248 | 0.00f); // Prim hollow check | ||
249 | |||
250 | // Test a prism. | ||
251 | CheckllSetPrimitiveParams( | ||
252 | "test 5", // Prim test identification string | ||
253 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
254 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
255 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
256 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
257 | 0.95f, // Prim hollow | ||
258 | // Expression for x selected to test precision problems during sbyte | ||
259 | // cast in SetPrimitiveShapeBlockParams. | ||
260 | new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist | ||
261 | // Expression for y selected to test precision problems during sbyte | ||
262 | // cast in SetPrimitiveShapeParams. | ||
263 | new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper | ||
264 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
265 | 0.70f); // Prim hollow check | ||
266 | |||
267 | // Test a sculpted prim. | ||
268 | CheckllSetPrimitiveParams( | ||
269 | "test 6", // Prim test identification string | ||
270 | new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size | ||
271 | ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type | ||
272 | "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map | ||
273 | ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type | ||
274 | } | ||
275 | |||
276 | // Set prim params for a box, cylinder or prism and check results. | ||
277 | public void CheckllSetPrimitiveParams(string primTest, | ||
278 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
279 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, | ||
280 | float primHollowCheck) | ||
281 | { | ||
282 | // Set the prim params. | ||
283 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
284 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
285 | primCut, primHollow, primTwist, primTaper, primShear)); | ||
286 | |||
287 | // Get params for prim to validate settings. | ||
288 | LSL_Types.list primParams = | ||
289 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
290 | |||
291 | // Validate settings. | ||
292 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
293 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
294 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
295 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
296 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
297 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
298 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
299 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
300 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
301 | CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); | ||
302 | CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
303 | } | ||
304 | |||
305 | // Set prim params for a sphere and check results. | ||
306 | public void CheckllSetPrimitiveParams(string primTest, | ||
307 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
308 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) | ||
309 | { | ||
310 | // Set the prim params. | ||
311 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
312 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
313 | primCut, primHollow, primTwist, primDimple)); | ||
314 | |||
315 | // Get params for prim to validate settings. | ||
316 | LSL_Types.list primParams = | ||
317 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
318 | |||
319 | // Validate settings. | ||
320 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
321 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
322 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
323 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
324 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
325 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
326 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
327 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
328 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
329 | CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); | ||
330 | } | ||
331 | |||
332 | // Set prim params for a torus, tube or ring and check results. | ||
333 | public void CheckllSetPrimitiveParams(string primTest, | ||
334 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
335 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, | ||
336 | LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, | ||
337 | float primRev, float primRadius, float primSkew, float primHollowCheck) | ||
338 | { | ||
339 | // Set the prim params. | ||
340 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
341 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
342 | primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, | ||
343 | primTaper, primRev, primRadius, primSkew)); | ||
344 | |||
345 | // Get params for prim to validate settings. | ||
346 | LSL_Types.list primParams = | ||
347 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
348 | |||
349 | // Valdate settings. | ||
350 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
351 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
352 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
353 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
354 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
355 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
356 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
357 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
358 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
359 | CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); | ||
360 | CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
361 | CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut"); | ||
362 | CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper"); | ||
363 | Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY, | ||
364 | "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); | ||
365 | Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY, | ||
366 | "TestllSetPrimitiveParams " + primTest + " prim radius fail"); | ||
367 | Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY, | ||
368 | "TestllSetPrimitiveParams " + primTest + " prim skew fail"); | ||
369 | } | ||
370 | |||
371 | // Set prim params for a sculpted prim and check results. | ||
372 | public void CheckllSetPrimitiveParams(string primTest, | ||
373 | LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) | ||
374 | { | ||
375 | // Set the prim params. | ||
376 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
377 | ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); | ||
378 | |||
379 | // Get params for prim to validate settings. | ||
380 | LSL_Types.list primParams = | ||
381 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
382 | |||
383 | // Validate settings. | ||
384 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
385 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
386 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
387 | Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2), | ||
388 | "TestllSetPrimitiveParams " + primTest + " prim map check fail"); | ||
389 | Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3), | ||
390 | "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); | ||
391 | } | ||
392 | |||
393 | public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) | ||
394 | { | ||
395 | // Check each vector component against expected result. | ||
396 | Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, | ||
397 | "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); | ||
398 | Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, | ||
399 | "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); | ||
400 | Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, | ||
401 | "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); | ||
402 | } | ||
403 | |||
404 | [Test] | ||
405 | // llVecNorm test. | ||
406 | public void TestllVecNorm() | ||
407 | { | ||
408 | // Check special case for normalizing zero vector. | ||
409 | CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); | ||
410 | // Check various vectors. | ||
411 | CheckllVecNorm(new LSL_Types.Vector3(10.0d, 25.0d, 0.0d), new LSL_Types.Vector3(0.371391d, 0.928477d, 0.0d)); | ||
412 | CheckllVecNorm(new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), new LSL_Types.Vector3(1.0d, 0.0d, 0.0d)); | ||
413 | CheckllVecNorm(new LSL_Types.Vector3(-90.0d, 55.0d, 2.0d), new LSL_Types.Vector3(-0.853128d, 0.521356d, 0.018958d)); | ||
414 | CheckllVecNorm(new LSL_Types.Vector3(255.0d, 255.0d, 255.0d), new LSL_Types.Vector3(0.577350d, 0.577350d, 0.577350d)); | ||
415 | } | ||
416 | |||
417 | public void CheckllVecNorm(LSL_Types.Vector3 vec, LSL_Types.Vector3 vecNormCheck) | ||
418 | { | ||
419 | // Call LSL function to normalize the vector. | ||
420 | LSL_Types.Vector3 vecNorm = m_lslApi.llVecNorm(vec); | ||
421 | // Check each vector component against expected result. | ||
422 | Assert.AreEqual(vecNorm.x, vecNormCheck.x, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on x component"); | ||
423 | Assert.AreEqual(vecNorm.y, vecNormCheck.y, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on y component"); | ||
424 | Assert.AreEqual(vecNorm.z, vecNormCheck.z, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on z component"); | ||
425 | } | ||
137 | } | 426 | } |
138 | } | 427 | } |