aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2018-11-20 18:12:18 +0000
committerUbitUmarov2018-11-20 18:12:18 +0000
commitcb1ebd1604315226e67012cc202c8845d05ddce4 (patch)
tree33357f246e1b804d5dd5c0df66f4c04464ffe3a3 /OpenSim
parentmantis 8410: llwhisper, llSay and llShout emit from the source prim not root (diff)
downloadopensim-SC-cb1ebd1604315226e67012cc202c8845d05ddce4.zip
opensim-SC-cb1ebd1604315226e67012cc202c8845d05ddce4.tar.gz
opensim-SC-cb1ebd1604315226e67012cc202c8845d05ddce4.tar.bz2
opensim-SC-cb1ebd1604315226e67012cc202c8845d05ddce4.tar.xz
add osApproxEquals for float, vector and rotation, note that default margin is 1e-6 to match strings rounding
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs98
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs30
3 files changed, 135 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index f0177db..7b56b90 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -5305,5 +5305,103 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5305 5305
5306 return ((string)src).Replace(oldvalue, newvalue); 5306 return ((string)src).Replace(oldvalue, newvalue);
5307 } 5307 }
5308
5309 public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b)
5310 {
5311 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5312 return 0;
5313 return 1;
5314 }
5315
5316 public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b, LSL_Float margin)
5317 {
5318 double e = Math.Abs(margin);
5319 if (a > b + e || a < b - e)
5320 return 0;
5321 return 1;
5322 }
5323
5324 public LSL_Integer osApproxEquals(LSL_Vector va, LSL_Vector vb)
5325 {
5326 double a = va.x;
5327 double b = vb.x;
5328 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5329 return 0;
5330 a = va.y;
5331 b = vb.y;
5332 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5333 return 0;
5334 a = va.z;
5335 b = vb.z;
5336 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5337 return 0;
5338
5339 return 1;
5340 }
5341
5342 public LSL_Integer osApproxEquals(LSL_Vector va, LSL_Vector vb, LSL_Float margin)
5343 {
5344 double e = Math.Abs(margin);
5345 double a = va.x;
5346 double b = vb.x;
5347 if (a > b + e || a < b - e)
5348 return 0;
5349 a = va.y;
5350 b = vb.y;
5351 if (a > b + e || a < b - e)
5352 return 0;
5353 a = va.z;
5354 b = vb.z;
5355 if (a > b + e || a < b - e)
5356 return 0;
5357
5358 return 1;
5359 }
5360
5361 public LSL_Integer osApproxEquals(LSL_Rotation ra, LSL_Rotation rb)
5362 {
5363 double a = ra.x;
5364 double b = rb.x;
5365 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5366 return 0;
5367 a = ra.y;
5368 b = rb.y;
5369 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5370 return 0;
5371 a = ra.z;
5372 b = rb.z;
5373 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5374 return 0;
5375 a = ra.s;
5376 b = rb.s;
5377 if (a > b + 1.0e-6 || a < b - 1.0e-6)
5378 return 0;
5379
5380 return 1;
5381 }
5382
5383 public LSL_Integer osApproxEquals(LSL_Rotation ra, LSL_Rotation rb, LSL_Float margin)
5384 {
5385 double e = Math.Abs(margin);
5386 double a = ra.x;
5387 double b = rb.x;
5388 if (a > b + e || a < b - e)
5389 return 0;
5390 a = ra.y;
5391 b = rb.y;
5392 if (a > b + e || a < b - e)
5393 return 0;
5394 a = ra.z;
5395 b = rb.z;
5396 if (a > b + e || a < b - e)
5397 return 0;
5398 a = ra.s;
5399 b = rb.s;
5400 if (a > b + e || a < b - e)
5401 return 0;
5402
5403 return 1;
5404 }
5405
5308 } 5406 }
5309} \ No newline at end of file 5407} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 2ab1fff..5bb7670 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -540,5 +540,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
540 LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer start, LSL_Integer count, LSL_Integer ignorecase); 540 LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer start, LSL_Integer count, LSL_Integer ignorecase);
541 LSL_String osStringRemove(LSL_String src, LSL_Integer start, LSL_Integer count); 541 LSL_String osStringRemove(LSL_String src, LSL_Integer start, LSL_Integer count);
542 LSL_String osStringReplace(LSL_String src, LSL_String oldvalue, LSL_String newvalue); 542 LSL_String osStringReplace(LSL_String src, LSL_String oldvalue, LSL_String newvalue);
543
544 LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b);
545 LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b, LSL_Float margin);
546 LSL_Integer osApproxEquals(vector va, vector vb);
547 LSL_Integer osApproxEquals(vector va, vector vb, LSL_Float margin);
548 LSL_Integer osApproxEquals(rotation ra, rotation rb);
549 LSL_Integer osApproxEquals(rotation ra, rotation rb, LSL_Float margin);
543 } 550 }
544} 551}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 1c003a0..29ada83 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -1337,5 +1337,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1337 { 1337 {
1338 return m_OSSL_Functions.osStringReplace(src, oldvalue, newvalue); 1338 return m_OSSL_Functions.osStringReplace(src, oldvalue, newvalue);
1339 } 1339 }
1340
1341 public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b)
1342 {
1343 return m_OSSL_Functions.osApproxEquals(a, b);
1344 }
1345
1346 public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b, LSL_Float margin)
1347 {
1348 return m_OSSL_Functions.osApproxEquals(a, b, margin);
1349 }
1350
1351 public LSL_Integer osApproxEquals(vector va, vector vb)
1352 {
1353 return m_OSSL_Functions.osApproxEquals(va, vb);
1354 }
1355
1356 public LSL_Integer osApproxEquals(vector va, vector vb, LSL_Float margin)
1357 {
1358 return m_OSSL_Functions.osApproxEquals(va, vb, margin);
1359 }
1360
1361 public LSL_Integer osApproxEquals(rotation ra, rotation rb)
1362 {
1363 return m_OSSL_Functions.osApproxEquals(ra, rb);
1364 }
1365
1366 public LSL_Integer osApproxEquals(rotation ra, rotation rb, LSL_Float margin)
1367 {
1368 return m_OSSL_Functions.osApproxEquals(ra, rb, margin);
1369 }
1340 } 1370 }
1341} 1371}