diff options
author | teravus | 2013-10-04 16:52:55 -0500 |
---|---|---|
committer | teravus | 2013-10-04 16:52:55 -0500 |
commit | 28d704599e94f4016a984b45db1ec328ff741573 (patch) | |
tree | 1881effba2b4417cbce3e39fe35d3319e5f3cf8b /OpenSim/Region/ScriptEngine | |
parent | Merge branch 'master' of careminster:/var/git/careminster (diff) | |
parent | Merge branch 'master' into careminster (diff) | |
download | opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.zip opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.tar.gz opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.tar.bz2 opensim-SC_OLD-28d704599e94f4016a984b45db1ec328ff741573.tar.xz |
Merge branch 'master' of careminster:/var/git/careminster
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
4 files changed, 407 insertions, 242 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f05aaa9..8892b69 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -8900,8 +8900,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8900 | int idx=0; | 8900 | int idx=0; |
8901 | while (idx < rules.Length) | 8901 | while (idx < rules.Length) |
8902 | { | 8902 | { |
8903 | int code=(int)rules.GetLSLIntegerItem(idx++); | 8903 | int code = (int)rules.GetLSLIntegerItem(idx++); |
8904 | int remain=rules.Length-idx; | 8904 | int remain = rules.Length - idx; |
8905 | 8905 | ||
8906 | switch (code) | 8906 | switch (code) |
8907 | { | 8907 | { |
@@ -8974,7 +8974,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8974 | break; | 8974 | break; |
8975 | 8975 | ||
8976 | case ScriptBaseClass.PRIM_TYPE_SCULPT: | 8976 | case ScriptBaseClass.PRIM_TYPE_SCULPT: |
8977 | res.Add(Shape.SculptTexture.ToString()); | 8977 | res.Add(new LSL_String(Shape.SculptTexture.ToString())); |
8978 | res.Add(new LSL_Integer(Shape.SculptType)); | 8978 | res.Add(new LSL_Integer(Shape.SculptType)); |
8979 | break; | 8979 | break; |
8980 | 8980 | ||
@@ -9316,7 +9316,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9316 | )); | 9316 | )); |
9317 | break; | 9317 | break; |
9318 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 9318 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
9319 | if(remain < 3) | 9319 | |
9320 | // TODO: Should be issuing a runtime script warning in this case. | ||
9321 | if (remain < 2) | ||
9320 | return null; | 9322 | return null; |
9321 | 9323 | ||
9322 | return rules.GetSublist(idx, -1); | 9324 | return rules.GetSublist(idx, -1); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f4e4f44..5c57971 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3043,7 +3043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3043 | sp.ControllingClient.Kick(alert); | 3043 | sp.ControllingClient.Kick(alert); |
3044 | 3044 | ||
3045 | // ...and close on our side | 3045 | // ...and close on our side |
3046 | sp.Scene.IncomingCloseAgent(sp.UUID, false); | 3046 | sp.Scene.CloseAgent(sp.UUID, false); |
3047 | } | 3047 | } |
3048 | }); | 3048 | }); |
3049 | } | 3049 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs new file mode 100644 index 0000000..ed61dc0 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiObjectTests.cs | |||
@@ -0,0 +1,399 @@ | |||
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 System.Text; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using NUnit.Framework; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.Assets; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
40 | using OpenSim.Region.OptionalModules.World.NPC; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | using OpenSim.Region.ScriptEngine.Shared; | ||
43 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.Instance; | ||
45 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
46 | using OpenSim.Services.Interfaces; | ||
47 | using OpenSim.Tests.Common; | ||
48 | using OpenSim.Tests.Common.Mock; | ||
49 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
50 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
51 | |||
52 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
53 | { | ||
54 | [TestFixture] | ||
55 | public class LSL_ApiObjectTests : OpenSimTestCase | ||
56 | { | ||
57 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; | ||
58 | private const float FLOAT_ACCURACY = 0.00005f; | ||
59 | |||
60 | protected Scene m_scene; | ||
61 | protected XEngine.XEngine m_engine; | ||
62 | |||
63 | [SetUp] | ||
64 | public override void SetUp() | ||
65 | { | ||
66 | base.SetUp(); | ||
67 | |||
68 | IConfigSource initConfigSource = new IniConfigSource(); | ||
69 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
70 | config.Set("Enabled", "true"); | ||
71 | |||
72 | m_scene = new SceneHelpers().SetupScene(); | ||
73 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource); | ||
74 | |||
75 | m_engine = new XEngine.XEngine(); | ||
76 | m_engine.Initialise(initConfigSource); | ||
77 | m_engine.AddRegion(m_scene); | ||
78 | } | ||
79 | |||
80 | [Test] | ||
81 | public void TestllGetLinkPrimitiveParams() | ||
82 | { | ||
83 | TestHelpers.InMethod(); | ||
84 | TestHelpers.EnableLogging(); | ||
85 | |||
86 | UUID ownerId = TestHelpers.ParseTail(0x1); | ||
87 | |||
88 | SceneObjectGroup grp1 = SceneHelpers.CreateSceneObject(2, ownerId, "grp1-", 0x10); | ||
89 | grp1.AbsolutePosition = new Vector3(10, 11, 12); | ||
90 | m_scene.AddSceneObject(grp1); | ||
91 | |||
92 | LSL_Api apiGrp1 = new LSL_Api(); | ||
93 | apiGrp1.Initialize(m_engine, grp1.RootPart, null, null); | ||
94 | |||
95 | // Check simple 1 prim case | ||
96 | { | ||
97 | LSL_List resList | ||
98 | = apiGrp1.llGetLinkPrimitiveParams(1, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
99 | |||
100 | Assert.That(resList.Length, Is.EqualTo(1)); | ||
101 | } | ||
102 | |||
103 | // Check 2 prim case | ||
104 | { | ||
105 | LSL_List resList | ||
106 | = apiGrp1.llGetLinkPrimitiveParams( | ||
107 | 1, | ||
108 | new LSL_List( | ||
109 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), | ||
110 | new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), | ||
111 | new LSL_Integer(2), | ||
112 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
113 | |||
114 | Assert.That(resList.Length, Is.EqualTo(2)); | ||
115 | } | ||
116 | |||
117 | // Check invalid parameters are ignored | ||
118 | { | ||
119 | LSL_List resList | ||
120 | = apiGrp1.llGetLinkPrimitiveParams(3, new LSL_List(new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
121 | |||
122 | Assert.That(resList.Length, Is.EqualTo(0)); | ||
123 | } | ||
124 | |||
125 | // Check all parameters are ignored if an initial bad link is given | ||
126 | { | ||
127 | LSL_List resList | ||
128 | = apiGrp1.llGetLinkPrimitiveParams( | ||
129 | 3, | ||
130 | new LSL_List( | ||
131 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), | ||
132 | new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), | ||
133 | new LSL_Integer(1), | ||
134 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
135 | |||
136 | Assert.That(resList.Length, Is.EqualTo(0)); | ||
137 | } | ||
138 | |||
139 | // Check only subsequent parameters are ignored when we hit the first bad link number | ||
140 | { | ||
141 | LSL_List resList | ||
142 | = apiGrp1.llGetLinkPrimitiveParams( | ||
143 | 1, | ||
144 | new LSL_List( | ||
145 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION), | ||
146 | new LSL_Integer(ScriptBaseClass.PRIM_LINK_TARGET), | ||
147 | new LSL_Integer(3), | ||
148 | new LSL_Integer(ScriptBaseClass.PRIM_ROTATION))); | ||
149 | |||
150 | Assert.That(resList.Length, Is.EqualTo(1)); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | [Test] | ||
155 | // llSetPrimitiveParams and llGetPrimitiveParams test. | ||
156 | public void TestllSetPrimitiveParams() | ||
157 | { | ||
158 | TestHelpers.InMethod(); | ||
159 | |||
160 | // Create Prim1. | ||
161 | Scene scene = new SceneHelpers().SetupScene(); | ||
162 | string obj1Name = "Prim1"; | ||
163 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | ||
164 | SceneObjectPart part1 = | ||
165 | new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, | ||
166 | Vector3.Zero, Quaternion.Identity, | ||
167 | Vector3.Zero) { Name = obj1Name, UUID = objUuid }; | ||
168 | Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); | ||
169 | |||
170 | LSL_Api apiGrp1 = new LSL_Api(); | ||
171 | apiGrp1.Initialize(m_engine, part1, null, null); | ||
172 | |||
173 | // Note that prim hollow check is passed with the other prim params in order to allow the | ||
174 | // specification of a different check value from the prim param. A cylinder, prism, sphere, | ||
175 | // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below | ||
176 | // specifies a value of 95% and checks to see if 70% was properly returned. | ||
177 | |||
178 | // Test a sphere. | ||
179 | CheckllSetPrimitiveParams( | ||
180 | apiGrp1, | ||
181 | "test 1", // Prim test identification string | ||
182 | new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size | ||
183 | ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type | ||
184 | ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type | ||
185 | new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut | ||
186 | 0.80f, // Prim hollow | ||
187 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
188 | new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple | ||
189 | 0.80f); // Prim hollow check | ||
190 | |||
191 | // Test a prism. | ||
192 | CheckllSetPrimitiveParams( | ||
193 | apiGrp1, | ||
194 | "test 2", // Prim test identification string | ||
195 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
196 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
197 | ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type | ||
198 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
199 | 0.90f, // Prim hollow | ||
200 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
201 | new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper | ||
202 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
203 | 0.90f); // Prim hollow check | ||
204 | |||
205 | // Test a box. | ||
206 | CheckllSetPrimitiveParams( | ||
207 | apiGrp1, | ||
208 | "test 3", // Prim test identification string | ||
209 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
210 | ScriptBaseClass.PRIM_TYPE_BOX, // Prim type | ||
211 | ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type | ||
212 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
213 | 0.95f, // Prim hollow | ||
214 | new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist | ||
215 | new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper | ||
216 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
217 | 0.95f); // Prim hollow check | ||
218 | |||
219 | // Test a tube. | ||
220 | CheckllSetPrimitiveParams( | ||
221 | apiGrp1, | ||
222 | "test 4", // Prim test identification string | ||
223 | new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size | ||
224 | ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type | ||
225 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
226 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
227 | 0.00f, // Prim hollow | ||
228 | new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist | ||
229 | new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size | ||
230 | // Expression for y selected to test precision problems during byte | ||
231 | // cast in SetPrimitiveShapeParams. | ||
232 | new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear | ||
233 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut | ||
234 | // Expression for y selected to test precision problems during sbyte | ||
235 | // cast in SetPrimitiveShapeParams. | ||
236 | new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper | ||
237 | 1.11f, // Prim revolutions | ||
238 | 0.88f, // Prim radius | ||
239 | 0.95f, // Prim skew | ||
240 | 0.00f); // Prim hollow check | ||
241 | |||
242 | // Test a prism. | ||
243 | CheckllSetPrimitiveParams( | ||
244 | apiGrp1, | ||
245 | "test 5", // Prim test identification string | ||
246 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
247 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
248 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
249 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
250 | 0.95f, // Prim hollow | ||
251 | // Expression for x selected to test precision problems during sbyte | ||
252 | // cast in SetPrimitiveShapeBlockParams. | ||
253 | new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist | ||
254 | // Expression for y selected to test precision problems during sbyte | ||
255 | // cast in SetPrimitiveShapeParams. | ||
256 | new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper | ||
257 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
258 | 0.70f); // Prim hollow check | ||
259 | |||
260 | // Test a sculpted prim. | ||
261 | CheckllSetPrimitiveParams( | ||
262 | apiGrp1, | ||
263 | "test 6", // Prim test identification string | ||
264 | new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size | ||
265 | ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type | ||
266 | "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map | ||
267 | ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type | ||
268 | } | ||
269 | |||
270 | // Set prim params for a box, cylinder or prism and check results. | ||
271 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
272 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
273 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, | ||
274 | float primHollowCheck) | ||
275 | { | ||
276 | // Set the prim params. | ||
277 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
278 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
279 | primCut, primHollow, primTwist, primTaper, primShear)); | ||
280 | |||
281 | // Get params for prim to validate settings. | ||
282 | LSL_Types.list primParams = | ||
283 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
284 | |||
285 | // Validate settings. | ||
286 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
287 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
288 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
289 | Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), | ||
290 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
291 | CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
292 | Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
293 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
294 | CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
295 | CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 6), primTest + " prim taper"); | ||
296 | CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
297 | } | ||
298 | |||
299 | // Set prim params for a sphere and check results. | ||
300 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
301 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
302 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) | ||
303 | { | ||
304 | // Set the prim params. | ||
305 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
306 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
307 | primCut, primHollow, primTwist, primDimple)); | ||
308 | |||
309 | // Get params for prim to validate settings. | ||
310 | LSL_Types.list primParams = | ||
311 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
312 | |||
313 | // Validate settings. | ||
314 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
315 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
316 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
317 | Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), | ||
318 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
319 | CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
320 | Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
321 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
322 | CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
323 | CheckllSetPrimitiveParamsVector(primDimple, api.llList2Vector(primParams, 6), primTest + " prim dimple"); | ||
324 | } | ||
325 | |||
326 | // Set prim params for a torus, tube or ring and check results. | ||
327 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
328 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
329 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, | ||
330 | LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, | ||
331 | float primRev, float primRadius, float primSkew, float primHollowCheck) | ||
332 | { | ||
333 | // Set the prim params. | ||
334 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
335 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
336 | primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, | ||
337 | primTaper, primRev, primRadius, primSkew)); | ||
338 | |||
339 | // Get params for prim to validate settings. | ||
340 | LSL_Types.list primParams = | ||
341 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
342 | |||
343 | // Valdate settings. | ||
344 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
345 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
346 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
347 | Assert.AreEqual(primHoleType, api.llList2Integer(primParams, 2), | ||
348 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
349 | CheckllSetPrimitiveParamsVector(primCut, api.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
350 | Assert.AreEqual(primHollowCheck, api.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
351 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
352 | CheckllSetPrimitiveParamsVector(primTwist, api.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
353 | CheckllSetPrimitiveParamsVector(primHoleSize, api.llList2Vector(primParams, 6), primTest + " prim hole size"); | ||
354 | CheckllSetPrimitiveParamsVector(primShear, api.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
355 | CheckllSetPrimitiveParamsVector(primProfCut, api.llList2Vector(primParams, 8), primTest + " prim profile cut"); | ||
356 | CheckllSetPrimitiveParamsVector(primTaper, api.llList2Vector(primParams, 9), primTest + " prim taper"); | ||
357 | Assert.AreEqual(primRev, api.llList2Float(primParams, 10), FLOAT_ACCURACY, | ||
358 | "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); | ||
359 | Assert.AreEqual(primRadius, api.llList2Float(primParams, 11), FLOAT_ACCURACY, | ||
360 | "TestllSetPrimitiveParams " + primTest + " prim radius fail"); | ||
361 | Assert.AreEqual(primSkew, api.llList2Float(primParams, 12), FLOAT_ACCURACY, | ||
362 | "TestllSetPrimitiveParams " + primTest + " prim skew fail"); | ||
363 | } | ||
364 | |||
365 | // Set prim params for a sculpted prim and check results. | ||
366 | public void CheckllSetPrimitiveParams(LSL_Api api, string primTest, | ||
367 | LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) | ||
368 | { | ||
369 | // Set the prim params. | ||
370 | api.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
371 | ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); | ||
372 | |||
373 | // Get params for prim to validate settings. | ||
374 | LSL_Types.list primParams = | ||
375 | api.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
376 | |||
377 | // Validate settings. | ||
378 | CheckllSetPrimitiveParamsVector(primSize, api.llList2Vector(primParams, 0), primTest + " prim size"); | ||
379 | Assert.AreEqual(primType, api.llList2Integer(primParams, 1), | ||
380 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
381 | Assert.AreEqual(primMap, (string)api.llList2String(primParams, 2), | ||
382 | "TestllSetPrimitiveParams " + primTest + " prim map check fail"); | ||
383 | Assert.AreEqual(primSculptType, api.llList2Integer(primParams, 3), | ||
384 | "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); | ||
385 | } | ||
386 | |||
387 | public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) | ||
388 | { | ||
389 | // Check each vector component against expected result. | ||
390 | Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, | ||
391 | "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); | ||
392 | Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, | ||
393 | "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); | ||
394 | Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, | ||
395 | "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); | ||
396 | } | ||
397 | |||
398 | } | ||
399 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index e97ae06..7e3726a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs | |||
@@ -47,9 +47,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
47 | [TestFixture, LongRunning] | 47 | [TestFixture, LongRunning] |
48 | public class LSL_ApiTest | 48 | public class LSL_ApiTest |
49 | { | 49 | { |
50 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; | ||
51 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; | 50 | private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; |
52 | private const float FLOAT_ACCURACY = 0.00005f; | 51 | private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; |
53 | private LSL_Api m_lslApi; | 52 | private LSL_Api m_lslApi; |
54 | 53 | ||
55 | [SetUp] | 54 | [SetUp] |
@@ -255,241 +254,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
255 | } | 254 | } |
256 | 255 | ||
257 | [Test] | 256 | [Test] |
258 | // llSetPrimitiveParams and llGetPrimitiveParams test. | ||
259 | public void TestllSetPrimitiveParams() | ||
260 | { | ||
261 | TestHelpers.InMethod(); | ||
262 | |||
263 | // Create Prim1. | ||
264 | Scene scene = new SceneHelpers().SetupScene(); | ||
265 | string obj1Name = "Prim1"; | ||
266 | UUID objUuid = new UUID("00000000-0000-0000-0000-000000000001"); | ||
267 | SceneObjectPart part1 = | ||
268 | new SceneObjectPart(UUID.Zero, PrimitiveBaseShape.Default, | ||
269 | Vector3.Zero, Quaternion.Identity, | ||
270 | Vector3.Zero) { Name = obj1Name, UUID = objUuid }; | ||
271 | Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); | ||
272 | |||
273 | // Note that prim hollow check is passed with the other prim params in order to allow the | ||
274 | // specification of a different check value from the prim param. A cylinder, prism, sphere, | ||
275 | // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below | ||
276 | // specifies a value of 95% and checks to see if 70% was properly returned. | ||
277 | |||
278 | // Test a sphere. | ||
279 | CheckllSetPrimitiveParams( | ||
280 | "test 1", // Prim test identification string | ||
281 | new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size | ||
282 | ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type | ||
283 | ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type | ||
284 | new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut | ||
285 | 0.80f, // Prim hollow | ||
286 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
287 | new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple | ||
288 | 0.80f); // Prim hollow check | ||
289 | |||
290 | // Test a prism. | ||
291 | CheckllSetPrimitiveParams( | ||
292 | "test 2", // Prim test identification string | ||
293 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
294 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
295 | ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type | ||
296 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
297 | 0.90f, // Prim hollow | ||
298 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist | ||
299 | new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper | ||
300 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
301 | 0.90f); // Prim hollow check | ||
302 | |||
303 | // Test a box. | ||
304 | CheckllSetPrimitiveParams( | ||
305 | "test 3", // Prim test identification string | ||
306 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
307 | ScriptBaseClass.PRIM_TYPE_BOX, // Prim type | ||
308 | ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type | ||
309 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
310 | 0.95f, // Prim hollow | ||
311 | new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist | ||
312 | new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper | ||
313 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
314 | 0.95f); // Prim hollow check | ||
315 | |||
316 | // Test a tube. | ||
317 | CheckllSetPrimitiveParams( | ||
318 | "test 4", // Prim test identification string | ||
319 | new LSL_Types.Vector3(4.2d, 4.2d, 4.2d), // Prim size | ||
320 | ScriptBaseClass.PRIM_TYPE_TUBE, // Prim type | ||
321 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
322 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
323 | 0.00f, // Prim hollow | ||
324 | new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist | ||
325 | new LSL_Types.Vector3(1.0d, 0.05d, 0.0d), // Prim hole size | ||
326 | // Expression for y selected to test precision problems during byte | ||
327 | // cast in SetPrimitiveShapeParams. | ||
328 | new LSL_Types.Vector3(0.0d, 0.35d + 0.1d, 0.0d), // Prim shear | ||
329 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut | ||
330 | // Expression for y selected to test precision problems during sbyte | ||
331 | // cast in SetPrimitiveShapeParams. | ||
332 | new LSL_Types.Vector3(-1.0d, 0.70d + 0.1d + 0.1d, 0.0d), // Prim taper | ||
333 | 1.11f, // Prim revolutions | ||
334 | 0.88f, // Prim radius | ||
335 | 0.95f, // Prim skew | ||
336 | 0.00f); // Prim hollow check | ||
337 | |||
338 | // Test a prism. | ||
339 | CheckllSetPrimitiveParams( | ||
340 | "test 5", // Prim test identification string | ||
341 | new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size | ||
342 | ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type | ||
343 | ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type | ||
344 | new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut | ||
345 | 0.95f, // Prim hollow | ||
346 | // Expression for x selected to test precision problems during sbyte | ||
347 | // cast in SetPrimitiveShapeBlockParams. | ||
348 | new LSL_Types.Vector3(0.7d + 0.2d, 0.0d, 0.0d), // Prim twist | ||
349 | // Expression for y selected to test precision problems during sbyte | ||
350 | // cast in SetPrimitiveShapeParams. | ||
351 | new LSL_Types.Vector3(2.0d, (1.3d + 0.1d), 0.0d), // Prim taper | ||
352 | new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear | ||
353 | 0.70f); // Prim hollow check | ||
354 | |||
355 | // Test a sculpted prim. | ||
356 | CheckllSetPrimitiveParams( | ||
357 | "test 6", // Prim test identification string | ||
358 | new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size | ||
359 | ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type | ||
360 | "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map | ||
361 | ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type | ||
362 | } | ||
363 | |||
364 | // Set prim params for a box, cylinder or prism and check results. | ||
365 | public void CheckllSetPrimitiveParams(string primTest, | ||
366 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
367 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, | ||
368 | float primHollowCheck) | ||
369 | { | ||
370 | // Set the prim params. | ||
371 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
372 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
373 | primCut, primHollow, primTwist, primTaper, primShear)); | ||
374 | |||
375 | // Get params for prim to validate settings. | ||
376 | LSL_Types.list primParams = | ||
377 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
378 | |||
379 | // Validate settings. | ||
380 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
381 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
382 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
383 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
384 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
385 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
386 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
387 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
388 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
389 | CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); | ||
390 | CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
391 | } | ||
392 | |||
393 | // Set prim params for a sphere and check results. | ||
394 | public void CheckllSetPrimitiveParams(string primTest, | ||
395 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
396 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, float primHollowCheck) | ||
397 | { | ||
398 | // Set the prim params. | ||
399 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
400 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
401 | primCut, primHollow, primTwist, primDimple)); | ||
402 | |||
403 | // Get params for prim to validate settings. | ||
404 | LSL_Types.list primParams = | ||
405 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
406 | |||
407 | // Validate settings. | ||
408 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
409 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
410 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
411 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
412 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
413 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
414 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
415 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
416 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
417 | CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); | ||
418 | } | ||
419 | |||
420 | // Set prim params for a torus, tube or ring and check results. | ||
421 | public void CheckllSetPrimitiveParams(string primTest, | ||
422 | LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, | ||
423 | float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, | ||
424 | LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, | ||
425 | float primRev, float primRadius, float primSkew, float primHollowCheck) | ||
426 | { | ||
427 | // Set the prim params. | ||
428 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
429 | ScriptBaseClass.PRIM_TYPE, primType, primHoleType, | ||
430 | primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut, | ||
431 | primTaper, primRev, primRadius, primSkew)); | ||
432 | |||
433 | // Get params for prim to validate settings. | ||
434 | LSL_Types.list primParams = | ||
435 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
436 | |||
437 | // Valdate settings. | ||
438 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
439 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
440 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
441 | Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), | ||
442 | "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); | ||
443 | CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); | ||
444 | Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, | ||
445 | "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); | ||
446 | CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); | ||
447 | CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); | ||
448 | CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear"); | ||
449 | CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut"); | ||
450 | CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper"); | ||
451 | Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY, | ||
452 | "TestllSetPrimitiveParams " + primTest + " prim revolutions fail"); | ||
453 | Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY, | ||
454 | "TestllSetPrimitiveParams " + primTest + " prim radius fail"); | ||
455 | Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY, | ||
456 | "TestllSetPrimitiveParams " + primTest + " prim skew fail"); | ||
457 | } | ||
458 | |||
459 | // Set prim params for a sculpted prim and check results. | ||
460 | public void CheckllSetPrimitiveParams(string primTest, | ||
461 | LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) | ||
462 | { | ||
463 | // Set the prim params. | ||
464 | m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, | ||
465 | ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); | ||
466 | |||
467 | // Get params for prim to validate settings. | ||
468 | LSL_Types.list primParams = | ||
469 | m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); | ||
470 | |||
471 | // Validate settings. | ||
472 | CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); | ||
473 | Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), | ||
474 | "TestllSetPrimitiveParams " + primTest + " prim type check fail"); | ||
475 | Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2), | ||
476 | "TestllSetPrimitiveParams " + primTest + " prim map check fail"); | ||
477 | Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3), | ||
478 | "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); | ||
479 | } | ||
480 | |||
481 | public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) | ||
482 | { | ||
483 | // Check each vector component against expected result. | ||
484 | Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY, | ||
485 | "TestllSetPrimitiveParams " + msg + " vector check fail on x component"); | ||
486 | Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY, | ||
487 | "TestllSetPrimitiveParams " + msg + " vector check fail on y component"); | ||
488 | Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY, | ||
489 | "TestllSetPrimitiveParams " + msg + " vector check fail on z component"); | ||
490 | } | ||
491 | |||
492 | [Test] | ||
493 | public void TestllVecNorm() | 257 | public void TestllVecNorm() |
494 | { | 258 | { |
495 | TestHelpers.InMethod(); | 259 | TestHelpers.InMethod(); |