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
This commit is contained in:
1 parent
6947586fed
commit
4a2fc74e24
7 files changed
+102
No files matched your search
@@ -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
|
||||
|
||||
@@ -6244,6 +6244,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the configured X, Y and Z dimensions of the current scene in metres.
|
||||
/// OpenGenesisLINK extension; independent of the OSSL permission switch.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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 `<X, Y, Z>` 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.
|
||||
@@ -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")
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user