add osApproxEquals for float, vector and rotation, note that default margin is 1e-6 to match strings rounding

0.9.1.0-post-fixes
UbitUmarov 2018-11-20 18:12:18 +00:00
parent c4a0e574c8
commit cb1ebd1604
7 changed files with 220 additions and 33 deletions

View File

@ -5305,5 +5305,103 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return ((string)src).Replace(oldvalue, newvalue);
}
public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b)
{
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
return 1;
}
public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b, LSL_Float margin)
{
double e = Math.Abs(margin);
if (a > b + e || a < b - e)
return 0;
return 1;
}
public LSL_Integer osApproxEquals(LSL_Vector va, LSL_Vector vb)
{
double a = va.x;
double b = vb.x;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
a = va.y;
b = vb.y;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
a = va.z;
b = vb.z;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
return 1;
}
public LSL_Integer osApproxEquals(LSL_Vector va, LSL_Vector vb, LSL_Float margin)
{
double e = Math.Abs(margin);
double a = va.x;
double b = vb.x;
if (a > b + e || a < b - e)
return 0;
a = va.y;
b = vb.y;
if (a > b + e || a < b - e)
return 0;
a = va.z;
b = vb.z;
if (a > b + e || a < b - e)
return 0;
return 1;
}
public LSL_Integer osApproxEquals(LSL_Rotation ra, LSL_Rotation rb)
{
double a = ra.x;
double b = rb.x;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
a = ra.y;
b = rb.y;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
a = ra.z;
b = rb.z;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
a = ra.s;
b = rb.s;
if (a > b + 1.0e-6 || a < b - 1.0e-6)
return 0;
return 1;
}
public LSL_Integer osApproxEquals(LSL_Rotation ra, LSL_Rotation rb, LSL_Float margin)
{
double e = Math.Abs(margin);
double a = ra.x;
double b = rb.x;
if (a > b + e || a < b - e)
return 0;
a = ra.y;
b = rb.y;
if (a > b + e || a < b - e)
return 0;
a = ra.z;
b = rb.z;
if (a > b + e || a < b - e)
return 0;
a = ra.s;
b = rb.s;
if (a > b + e || a < b - e)
return 0;
return 1;
}
}
}

View File

@ -540,5 +540,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Integer osStringLastIndexOf(LSL_String src, LSL_String value, LSL_Integer start, LSL_Integer count, LSL_Integer ignorecase);
LSL_String osStringRemove(LSL_String src, LSL_Integer start, LSL_Integer count);
LSL_String osStringReplace(LSL_String src, LSL_String oldvalue, LSL_String newvalue);
LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b);
LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b, LSL_Float margin);
LSL_Integer osApproxEquals(vector va, vector vb);
LSL_Integer osApproxEquals(vector va, vector vb, LSL_Float margin);
LSL_Integer osApproxEquals(rotation ra, rotation rb);
LSL_Integer osApproxEquals(rotation ra, rotation rb, LSL_Float margin);
}
}

View File

@ -1337,5 +1337,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osStringReplace(src, oldvalue, newvalue);
}
public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b)
{
return m_OSSL_Functions.osApproxEquals(a, b);
}
public LSL_Integer osApproxEquals(LSL_Float a, LSL_Float b, LSL_Float margin)
{
return m_OSSL_Functions.osApproxEquals(a, b, margin);
}
public LSL_Integer osApproxEquals(vector va, vector vb)
{
return m_OSSL_Functions.osApproxEquals(va, vb);
}
public LSL_Integer osApproxEquals(vector va, vector vb, LSL_Float margin)
{
return m_OSSL_Functions.osApproxEquals(va, vb, margin);
}
public LSL_Integer osApproxEquals(rotation ra, rotation rb)
{
return m_OSSL_Functions.osApproxEquals(ra, rb);
}
public LSL_Integer osApproxEquals(rotation ra, rotation rb, LSL_Float margin)
{
return m_OSSL_Functions.osApproxEquals(ra, rb, margin);
}
}
}

View File

@ -32,7 +32,7 @@ Now see the "Configuring OpenSim" section
# Running OpenSim on Linux
You will need Mono >= 2.10.8.1 upt to version 0.9.0.1 and mono > 5.0 on others. On some Linux distributions you
You will need Mono >= 2.10.8.1 up to version 0.9.0.1 and mono > 5.0 on others. On some Linux distributions you
may need to install additional packages. See http://opensimulator.org/wiki/Dependencies
for more information.

View File

@ -1,4 +1,4 @@
9e55237f-19be-984f-6bdc-a8fd07eb2447
0acc12d6-3dc9-9574-7bd6-d298c045f046
<llsd><map><key>llsd-lsl-syntax-version</key><integer>2</integer>
<key>controls</key>
<map>
@ -6058,6 +6058,57 @@
<map><key>b</key><map><key>type</key><string>vector</string></map></map>
</array>
</map>
<key>osApproxEquals</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>va</key><map><key>type</key><string>vector</string></map></map>
<map><key>vb</key><map><key>type</key><string>vector</string></map></map>
<map><key>margin</key><map><key>type</key><string>float</string></map></map>
</array>
</map>
<key>osApproxEquals</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>va</key><map><key>type</key><string>vector</string></map></map>
<map><key>vb</key><map><key>type</key><string>vector</string></map></map>
</array>
</map>
<key>osApproxEquals</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>a</key><map><key>type</key><string>float</string></map></map>
<map><key>b</key><map><key>type</key><string>float</string></map></map>
<map><key>margin</key><map><key>type</key><string>float</string></map></map>
</array>
</map>
<key>osApproxEquals</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>a</key><map><key>type</key><string>float</string></map></map>
<map><key>b</key><map><key>type</key><string>float</string></map></map>
</array>
</map>
<key>osApproxEquals</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>ra</key><map><key>type</key><string>rotation</string></map></map>
<map><key>rb</key><map><key>type</key><string>rotation</string></map></map>
<map><key>margin</key><map><key>type</key><string>float</string></map></map>
</array>
</map>
<key>osApproxEquals</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>ra</key><map><key>type</key><string>rotation</string></map></map>
<map><key>rb</key><map><key>type</key><string>rotation</string></map></map>
</array>
</map>
<key>osAvatarName2Key</key>
<map>
<key>return</key><string>string</string>
@ -6795,13 +6846,13 @@
<key>osRegionNotice</key>
<map>
<key>arguments</key><array>
<map><key>agentID</key><map><key>type</key><string>key</string></map></map>
<map><key>msg</key><map><key>type</key><string>string</string></map></map>
</array>
</map>
<key>osRegionNotice</key>
<map>
<key>arguments</key><array>
<map><key>agentID</key><map><key>type</key><string>key</string></map></map>
<map><key>msg</key><map><key>type</key><string>string</string></map></map>
</array>
</map>
@ -6810,6 +6861,7 @@
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>seconds</key><map><key>type</key><string>float</string></map></map>
<map><key>msg</key><map><key>type</key><string>string</string></map></map>
</array>
</map>
<key>osRegionRestart</key>
@ -6817,7 +6869,6 @@
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>seconds</key><map><key>type</key><string>float</string></map></map>
<map><key>msg</key><map><key>type</key><string>string</string></map></map>
</array>
</map>
<key>osReplaceString</key>
@ -7153,21 +7204,12 @@
<key>arguments</key><array>
<map><key>src</key><map><key>type</key><string>string</string></map></map>
<map><key>value</key><map><key>type</key><string>string</string></map></map>
<map><key>start</key><map><key>type</key><string>integer</string></map></map>
<map><key>count</key><map><key>type</key><string>integer</string></map></map>
<map><key>ignorecase</key><map><key>type</key><string>integer</string></map></map>
</array>
</map>
<key>osStringIndexOf</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>src</key><map><key>type</key><string>string</string></map></map>
<map><key>value</key><map><key>type</key><string>string</string></map></map>
<map><key>start</key><map><key>type</key><string>integer</string></map></map>
<map><key>count</key><map><key>type</key><string>integer</string></map></map>
<map><key>ignorecase</key><map><key>type</key><string>integer</string></map></map>
</array>
</map>
<key>osStringLastIndexOf</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
@ -7187,6 +7229,15 @@
<map><key>ignorecase</key><map><key>type</key><string>integer</string></map></map>
</array>
</map>
<key>osStringLastIndexOf</key>
<map>
<key>return</key><string>integer</string>
<key>arguments</key><array>
<map><key>src</key><map><key>type</key><string>string</string></map></map>
<map><key>value</key><map><key>type</key><string>string</string></map></map>
<map><key>ignorecase</key><map><key>type</key><string>integer</string></map></map>
</array>
</map>
<key>osStringRemove</key>
<map>
<key>return</key><string>string</string>
@ -7249,7 +7300,6 @@
<map>
<key>arguments</key><array>
<map><key>agent</key><map><key>type</key><string>string</string></map></map>
<map><key>regionName</key><map><key>type</key><string>string</string></map></map>
<map><key>position</key><map><key>type</key><string>vector</string></map></map>
<map><key>lookat</key><map><key>type</key><string>vector</string></map></map>
</array>
@ -7258,6 +7308,7 @@
<map>
<key>arguments</key><array>
<map><key>agent</key><map><key>type</key><string>string</string></map></map>
<map><key>regionName</key><map><key>type</key><string>string</string></map></map>
<map><key>position</key><map><key>type</key><string>vector</string></map></map>
<map><key>lookat</key><map><key>type</key><string>vector</string></map></map>
</array>

View File

@ -127,8 +127,8 @@
Allow_osDie = ${OSSL|osslParcelOG}ESTATE_MANAGER,ESTATE_OWNER
; ThreatLevel Moderate
Allow_osDropAttachment = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Allow_osDetectedCountry = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Allow_osDropAttachment = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Allow_osDropAttachmentAt = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Allow_osGetAgentCountry = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
Allow_osGetGridCustom = ${OSSL|osslParcelO}ESTATE_MANAGER,ESTATE_OWNER
@ -228,6 +228,7 @@
; available functions out of Threat level control (for reference only)
; Allow_osAdjustSoundVolume = true
; Allow_osAngleBetween = true
; Allow_osApproxEquals = true
; Allow_osCheckODE = true
; Allow_osClearInertia = true
; Allow_osCollisionSound = true