From 4a2fc74e245bb948181db301b15246f915828fbc Mon Sep 17 00:00:00 2001 From: "OpenGenesis (MPL 2.0)" <153564363+opengenesislink@users.noreply.github.com> Date: Tue, 13 Oct 2026 21:18:13 +0200 Subject: [PATCH] feat: expose native oglGetRegionDimensions LSL function (#193) * feat(lsl): expose OGL region XYZ dimensions * feat(lsl): expose OGL region XYZ dimensions * feat(lsl): expose OGL region XYZ dimensions * test/docs: document and guard native OGL region dimensions * test/docs: document and guard native OGL region dimensions * test/docs: document and guard native OGL region dimensions * ci: verify native OGL region dimension registration --- .github/workflows/nexjast-ci.yml | 4 +++ .../Shared/Api/Implementation/LSL_Api.cs | 12 +++++++ .../Shared/Api/Interface/ILSL_Api.cs | 2 ++ .../Shared/Api/Runtime/LSL_Stub.cs | 6 ++++ doc/NexVerse/OGL_REGION_DIMENSIONS_LSL.md | 29 +++++++++++++++++ tools/ci/verify_ogl_region_dimensions.py | 31 +++++++++++++++++++ tools/lsl/ogl_region_dimensions_smoke.lsl | 18 +++++++++++ 7 files changed, 102 insertions(+) create mode 100644 doc/NexVerse/OGL_REGION_DIMENSIONS_LSL.md create mode 100644 tools/ci/verify_ogl_region_dimensions.py create mode 100644 tools/lsl/ogl_region_dimensions_smoke.lsl diff --git a/.github/workflows/nexjast-ci.yml b/.github/workflows/nexjast-ci.yml index 46976782..e862dd73 100644 --- a/.github/workflows/nexjast-ci.yml +++ b/.github/workflows/nexjast-ci.yml @@ -98,6 +98,10 @@ jobs: if-no-files-found: ignore retention-days: 30 + - name: Verify native OGL region dimensions LSL extension + shell: bash + run: python3 tools/ci/verify_ogl_region_dimensions.py + - name: Verify OSSL policy coverage shell: bash run: python3 tools/ci/verify_ossl_policy.py diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d0ac5b64..c82e66b7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6244,6 +6244,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0); } + /// + /// Returns the configured X, Y and Z dimensions of the current scene in metres. + /// OpenGenesisLINK extension; independent of the OSSL permission switch. + /// + public LSL_Vector oglGetRegionDimensions() + { + RegionInfo region = World.RegionInfo; + return new LSL_Vector((double)region.RegionSizeX, + (double)region.RegionSizeY, + (double)region.RegionSizeZ); + } + public LSL_String llGetEnv(LSL_String name) { string sname = name; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 11add3f6..22ac9092 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -205,6 +205,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces LSL_List llGetPrimitiveParams(LSL_List rules); LSL_Integer llGetRegionAgentCount(); LSL_Vector llGetRegionCorner(); + // OGL extension: actual scene dimensions including configured vertical extent. + LSL_Vector oglGetRegionDimensions(); LSL_Integer llGetRegionFlags(); LSL_Float llGetRegionFPS(); LSL_String llGetRegionName(); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 919c508b..cf981e2e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -933,6 +933,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase return m_LSL_Functions.llGetRegionCorner(); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public LSL_Vector oglGetRegionDimensions() + { + return m_LSL_Functions.oglGetRegionDimensions(); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public LSL_Integer llGetRegionFlags() { diff --git a/doc/NexVerse/OGL_REGION_DIMENSIONS_LSL.md b/doc/NexVerse/OGL_REGION_DIMENSIONS_LSL.md new file mode 100644 index 00000000..82086bab --- /dev/null +++ b/doc/NexVerse/OGL_REGION_DIMENSIONS_LSL.md @@ -0,0 +1,29 @@ +# Native OGL LSL: `oglGetRegionDimensions()` + +OpenGenesisLINK adds a parameterless LSL function: + +```lsl +vector dimensions = oglGetRegionDimensions(); +``` + +The function reads the **current simulator scene's configured dimensions**, in metres, and returns `` as an LSL vector. + +- `X`: configured horizontal width, e.g. 256 or 1024 metres. +- `Y`: configured horizontal length, e.g. 256 or 1024 metres. +- `Z`: `RegionInfo.RegionSizeZ`, the scene's configured vertical extent, commonly 4096 metres in the default simulator settings. + +For example, a 1024 × 1024 metre varregion with the default configured Z extent returns `<1024.0, 1024.0, 4096.0>`. The Z component **does not** mean terrain height at a position, the highest building, or the maximum altitude supported by every viewer or physics engine. Use `llGround()` for terrain height at an XY offset. + +The function belongs to the native LSL API and is therefore independent of the OSSL `AllowOSFunctions` switch and OSSL threat-level permissions. The existing `osGetRegionSize()` remains unchanged and continues to report Z = 0, preserving compatibility. + +This is an **OpenGenesisLINK extension**; unmodified Second Life and stock OpenSimulator do not support the function. Viewer-side highlighting/autocomplete may require separate updates, but server-side script compilation uses the registered API. + +## Test + +Run the structural regression check: + +```sh +python3 tools/ci/verify_ogl_region_dimensions.py +``` + +Load `tools/lsl/ogl_region_dimensions_smoke.lsl` into a prim and confirm that it reports the expected X/Y dimensions and a positive Z value on both a standard region and a configured varregion. The CI check verifies source registration and legacy behaviour; an in-world smoke test is required for runtime verification. diff --git a/tools/ci/verify_ogl_region_dimensions.py b/tools/ci/verify_ogl_region_dimensions.py new file mode 100644 index 00000000..ed1594fd --- /dev/null +++ b/tools/ci/verify_ogl_region_dimensions.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +"""Static regression guard for OpenGenesisLINK native region dimensions.""" +from pathlib import Path +import re + +root = Path(__file__).resolve().parents[2] +api = (root / "OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs").read_text(encoding="utf-8") +interface = (root / "OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs").read_text(encoding="utf-8") +stub = (root / "OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs").read_text(encoding="utf-8") +ossl = (root / "OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs").read_text(encoding="utf-8") +region_info = (root / "OpenSim/Framework/RegionInfo.cs").read_text(encoding="utf-8") + +signature = "LSL_Vector oglGetRegionDimensions()" +assert signature in interface, "missing native LSL API contract" +assert "public " + signature in api, "missing native implementation" +assert "public " + signature in stub, "missing script-facing wrapper" +assert "return m_LSL_Functions.oglGetRegionDimensions();" in stub +body = re.search(r"public LSL_Vector oglGetRegionDimensions\(\)\s*\{([^{}]*)\}", api) +assert body, "missing or unexpectedly changed function body" +for axis in ("X", "Y", "Z"): + assert f"region.RegionSize{axis}" in body.group(1), f"missing {axis} dimension" +assert "World.RegionInfo" in body.group(1), "dimension must use active scene, not a global constant" +assert "RegionSizeZ" in region_info, "configured scene Z dimension is unavailable" + +# This is a separate OGL LSL extension: no regression to legacy osGetRegionSize(). +old = re.search(r"public LSL_Vector osGetRegionSize\(\)\s*\{([^{}]*)\}", ossl) +assert old, "legacy OSSL function missing" +assert "0.0f" in old.group(1), "legacy osGetRegionSize Z behaviour changed" +assert "oglGetRegionDimensions" not in ossl, "OGL extension must stay outside OSSL gating" + +print("OGL region dimensions: LSL interface, wrapper, XYZ and legacy OSSL behaviour OK") diff --git a/tools/lsl/ogl_region_dimensions_smoke.lsl b/tools/lsl/ogl_region_dimensions_smoke.lsl new file mode 100644 index 00000000..59c79bbc --- /dev/null +++ b/tools/lsl/ogl_region_dimensions_smoke.lsl @@ -0,0 +1,18 @@ +// OpenGenesisLINK in-world smoke test +// Compile in the OGL simulator; stock Second Life/OpenSimulator does not offer ogl*. +default +{ + state_entry() + { + vector dimensions = oglGetRegionDimensions(); + llOwnerSay("Region: " + llGetRegionName() + + "\nX: " + (string)dimensions.x + " m" + + "\nY: " + (string)dimensions.y + " m" + + "\nZ: " + (string)dimensions.z + " m"); + + if (dimensions.x <= 0.0 || dimensions.y <= 0.0 || dimensions.z <= 0.0) + llOwnerSay("FAIL: invalid region dimensions"); + else + llOwnerSay("PASS: positive scene dimensions"); + } +}