aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMicheil Merlin2011-08-12 21:09:01 -0500
committerJustin Clark-Casey (justincc)2011-08-13 15:34:08 +0100
commitb80dfb6572438cb583e95884c0f607342f0c88d4 (patch)
tree2d54624869cbbd630c7c622b8b2f91510b44fc57
parentFix a problem in the Flotsam asset cache where assets were being put into the... (diff)
downloadopensim-SC_OLD-b80dfb6572438cb583e95884c0f607342f0c88d4.zip
opensim-SC_OLD-b80dfb6572438cb583e95884c0f607342f0c88d4.tar.gz
opensim-SC_OLD-b80dfb6572438cb583e95884c0f607342f0c88d4.tar.bz2
opensim-SC_OLD-b80dfb6572438cb583e95884c0f607342f0c88d4.tar.xz
llGetPrimitiveParams fix prim hollow/hole shape value
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs175
-rw-r--r--prebuild.xml1
3 files changed, 179 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8a281d4..c84afee 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7650,7 +7650,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7650 case ScriptBaseClass.PRIM_TYPE_BOX: 7650 case ScriptBaseClass.PRIM_TYPE_BOX:
7651 case ScriptBaseClass.PRIM_TYPE_CYLINDER: 7651 case ScriptBaseClass.PRIM_TYPE_CYLINDER:
7652 case ScriptBaseClass.PRIM_TYPE_PRISM: 7652 case ScriptBaseClass.PRIM_TYPE_PRISM:
7653 res.Add(new LSL_Integer(Shape.ProfileCurve)); 7653 res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
7654 res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); 7654 res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
7655 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); 7655 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
7656 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); 7656 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@@ -7659,7 +7659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7659 break; 7659 break;
7660 7660
7661 case ScriptBaseClass.PRIM_TYPE_SPHERE: 7661 case ScriptBaseClass.PRIM_TYPE_SPHERE:
7662 res.Add(new LSL_Integer(Shape.ProfileCurve)); 7662 res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
7663 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); 7663 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
7664 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); 7664 res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0));
7665 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); 7665 res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
@@ -7675,7 +7675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7675 case ScriptBaseClass.PRIM_TYPE_TUBE: 7675 case ScriptBaseClass.PRIM_TYPE_TUBE:
7676 case ScriptBaseClass.PRIM_TYPE_TORUS: 7676 case ScriptBaseClass.PRIM_TYPE_TORUS:
7677 // holeshape 7677 // holeshape
7678 res.Add(new LSL_Integer(Shape.ProfileCurve)); 7678 res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble.
7679 7679
7680 // cut 7680 // cut
7681 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); 7681 res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index 3f37ec7..623c82d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -27,11 +27,13 @@
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenSim.Framework;
30using OpenSim.Tests.Common; 31using OpenSim.Tests.Common;
31using OpenSim.Region.ScriptEngine.Shared; 32using OpenSim.Region.ScriptEngine.Shared;
32using OpenSim.Region.Framework.Scenes; 33using OpenSim.Region.Framework.Scenes;
33using Nini.Config; 34using Nini.Config;
34using OpenSim.Region.ScriptEngine.Shared.Api; 35using OpenSim.Region.ScriptEngine.Shared.Api;
36using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
35using OpenMetaverse; 37using OpenMetaverse;
36using System; 38using System;
37using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
@@ -47,6 +49,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
47 49
48 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; 50 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
49 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d; 51 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
52 private const double FLOAT_ACCURACY = 0.00005d;
50 private LSL_Api m_lslApi; 53 private LSL_Api m_lslApi;
51 54
52 [SetUp] 55 [SetUp]
@@ -166,6 +169,178 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
166 } 169 }
167 170
168 [Test] 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 // Test a sphere.
186 CheckllSetPrimitiveParams(
187 "test 1", // Prim test identification string
188 new LSL_Types.Vector3(6.0d, 9.9d, 9.9d), // Prim size
189 ScriptBaseClass.PRIM_TYPE_SPHERE, // Prim type
190 ScriptBaseClass.PRIM_HOLE_DEFAULT, // Prim hole type
191 new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut
192 0.80d, // Prim hollow
193 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
194 new LSL_Types.Vector3(0.32d, 0.76d, 0.0d)); // Prim dimple
195
196 // Test a prism.
197 CheckllSetPrimitiveParams(
198 "test 2", // Prim test identification string
199 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
200 ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type
201 ScriptBaseClass.PRIM_HOLE_CIRCLE, // Prim hole type
202 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
203 0.90d, // Prim hollow
204 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist
205 new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper
206 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear
207
208 // Test a box.
209 CheckllSetPrimitiveParams(
210 "test 3", // Prim test identification string
211 new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size
212 ScriptBaseClass.PRIM_TYPE_BOX, // Prim type
213 ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type
214 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut
215 0.90d, // Prim hollow
216 new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist
217 new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper
218 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear
219
220 // Test a tube.
221 CheckllSetPrimitiveParams(
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.00d, // Prim hollow
228 new LSL_Types.Vector3(1.0d, -1.0d, 0.0d), // Prim twist
229 new LSL_Types.Vector3(1.0d, 0.5d, 0.0d), // Prim hole size
230 new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear
231 new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim profile cut
232 new LSL_Types.Vector3(-1.0d, 1.0d, 0.0d), // Prim taper
233 1.0d, // Prim revolutions
234 1.0d, // Prim radius
235 0.0d); // Prim skew
236 }
237
238 // Set prim params for a box, cylinder or prism and check results.
239 public void CheckllSetPrimitiveParams(string primTest,
240 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
241 double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear)
242 {
243 // Set the prim params.
244 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
245 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
246 primCut, primHollow, primTwist, primTaper, primShear));
247
248 // Get params for prim to validate settings.
249 LSL_Types.list primParams =
250 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
251
252 // Validate settings.
253 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
254 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
255 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
256 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
257 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
258 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
259 Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
260 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
261 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
262 CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper");
263 CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
264 }
265
266 // Set prim params for a sphere and check results.
267 public void CheckllSetPrimitiveParams(string primTest,
268 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
269 double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple)
270 {
271 // Set the prim params.
272 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
273 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
274 primCut, primHollow, primTwist, primDimple));
275
276 // Get params for prim to validate settings.
277 LSL_Types.list primParams =
278 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
279
280 // Validate settings.
281 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
282 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
283 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
284 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
285 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
286 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
287 Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
288 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
289 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
290 CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple");
291 }
292
293 // Set prim params for a torus, tube or ring and check results.
294 public void CheckllSetPrimitiveParams(string primTest,
295 LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
296 double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
297 LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
298 double primRev, double primRadius, double primSkew)
299 {
300 // Set the prim params.
301 m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
302 ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
303 primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
304 primTaper, primRev, primRadius, primSkew));
305
306 // Get params for prim to validate settings.
307 LSL_Types.list primParams =
308 m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));
309
310 // Valdate settings.
311 CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
312 Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
313 "TestllSetPrimitiveParams " + primTest + " prim type check fail");
314 Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
315 "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
316 CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
317 Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
318 "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
319 CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
320 CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size");
321 CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
322 CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut");
323 CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper");
324 Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY,
325 "TestllSetPrimitiveParams " + primTest + " prim revolution fail");
326 Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY,
327 "TestllSetPrimitiveParams " + primTest + " prim radius fail");
328 Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY,
329 "TestllSetPrimitiveParams " + primTest + " prim skew fail");
330 }
331
332 public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg)
333 {
334 // Check each vector component against expected result.
335 Assert.AreEqual(vecCheck.x, vecReturned.x, VECTOR_COMPONENT_ACCURACY,
336 "TestllSetPrimitiveParams " + msg + " vector check fail on x component");
337 Assert.AreEqual(vecCheck.y, vecReturned.y, VECTOR_COMPONENT_ACCURACY,
338 "TestllSetPrimitiveParams " + msg + " vector check fail on y component");
339 Assert.AreEqual(vecCheck.z, vecReturned.z, VECTOR_COMPONENT_ACCURACY,
340 "TestllSetPrimitiveParams " + msg + " vector check fail on z component");
341 }
342
343 [Test]
169 // llVecNorm test. 344 // llVecNorm test.
170 public void TestllVecNorm() 345 public void TestllVecNorm()
171 { 346 {
diff --git a/prebuild.xml b/prebuild.xml
index 411ceb0..b56c5b5 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -3146,6 +3146,7 @@
3146 <Reference name="OpenSim.Region.OptionalModules"/> 3146 <Reference name="OpenSim.Region.OptionalModules"/>
3147 <Reference name="OpenSim.Region.ScriptEngine.Shared"/> 3147 <Reference name="OpenSim.Region.ScriptEngine.Shared"/>
3148 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/> 3148 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
3149 <Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/>
3149 <Reference name="OpenSim.Region.ScriptEngine.XEngine"/> 3150 <Reference name="OpenSim.Region.ScriptEngine.XEngine"/>
3150 <Reference name="OpenSim.Services.Interfaces"/> 3151 <Reference name="OpenSim.Services.Interfaces"/>
3151 <Reference name="OpenSim.Tests.Common"/> 3152 <Reference name="OpenSim.Tests.Common"/>