Browse Source

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

UbitUmarov 5 years ago
parent
commit
cb1ebd1604

+ 16 - 16
BUILDING.md

@@ -1,11 +1,11 @@
 # Building on Windows
 
 Steps:
- * runprebuild.bat
- * Load OpenSim.sln into Visual Studio .NET and build the solution.
- * chdir bin 
- * copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
- * run OpenSim.exe
+* runprebuild.bat
+* Load OpenSim.sln into Visual Studio .NET and build the solution.
+* chdir bin 
+* copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
+* run OpenSim.exe
 
 # Building on Linux / Mac
 
@@ -16,17 +16,17 @@ Prereqs:
 *   See http://opensimulator.org/wiki/Dependencies for more information.
 
 From the distribution type:
- * ./runprebuild.sh
- * type msbuild or xbuild
- * cd bin 
- * copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
- * review and change those ini files according to your needs
- * windows: execute opensim.exe or opensim32.exe for small regions
- * linux: run ./opensim.sh
- * msbuild (xbuild) option switches
-   *  clean:  msbuild /target:clean
-   *  debug: (default) msbuild /property:Configuration=Debug
-   *  release: msbuild /property:Configuration=Release
+* ./runprebuild.sh
+* type msbuild or xbuild
+* cd bin 
+* copy OpenSim.ini.example to OpenSim.ini and other appropriate files in bin/config-include
+* review and change those ini files according to your needs
+* windows: execute opensim.exe or opensim32.exe for small regions
+* linux: run ./opensim.sh
+* msbuild (xbuild) option switches
+  *  clean:  msbuild /target:clean
+  *  debug: (default) msbuild /property:Configuration=Debug
+  *  release: msbuild /property:Configuration=Release
 
 # References
  

+ 98 - 0
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs

@@ -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;
+        }
+
     }
 }

+ 7 - 0
OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs

@@ -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);
     }
 }

+ 30 - 0
OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs

@@ -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);
+        }
     }
 }

+ 1 - 1
README.md

@@ -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.
 

+ 59 - 8
bin/ScriptSyntax.xml

@@ -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,6 +7204,8 @@
   <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>
@@ -7162,8 +7215,6 @@
   <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>
@@ -7173,6 +7224,8 @@
   <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>
@@ -7182,8 +7235,6 @@
   <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>
@@ -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>

+ 2 - 1
bin/config-include/osslEnable.ini

@@ -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