Merge pull request #412 from opengenesislink/feat/g1-mesh-land-impact-engine

feat(g1): opt-in mesh land impact for parcels, quota checks and viewer CAPS
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-11-08 17:38:23 +01:00
commit 78a2fb3cfa
22 files changed
+705 -17

No files matched your search

@@ -0,0 +1,50 @@
name: OGL G1 Mesh Land Impact
on:
pull_request:
paths:
- 'OpenSim/Region/CoreModules/World/Land/**'
- 'OpenSim/Region/CoreModules/OpenSim.Region.CoreModules.csproj'
- 'OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs'
- 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs'
- 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs'
- 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs'
- 'OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs'
- 'OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs'
- 'OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs'
- 'OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs'
- 'bin/OpenSim*.ini*'
- 'tools/ci/OglMeshLandImpactRegression/**'
- 'tools/ci/verify_ogl_mesh_land_impact.py'
- '.github/workflows/ogl-mesh-land-impact.yml'
push:
branches: [main]
paths:
- 'OpenSim/Region/CoreModules/World/Land/**'
- 'OpenSim/Region/CoreModules/OpenSim.Region.CoreModules.csproj'
- 'OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs'
- 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs'
- 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs'
- 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs'
- 'OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs'
- 'OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs'
- 'OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs'
- 'OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs'
- 'bin/OpenSim*.ini*'
- 'tools/ci/OglMeshLandImpactRegression/**'
- 'tools/ci/verify_ogl_mesh_land_impact.py'
- '.github/workflows/ogl-mesh-land-impact.yml'
permissions:
contents: read
jobs:
land-impact-gate:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Validate mesh land impact module wiring
run: python3 tools/ci/verify_ogl_mesh_land_impact.py
- name: Regression test linked mesh land-impact arithmetic
run: dotnet run --configuration Release --project tools/ci/OglMeshLandImpactRegression/OglMeshLandImpactRegression.csproj
@@ -276,7 +276,12 @@ namespace OpenSim.Region.ClientStack.Linden
// Required for linking
grp.RootPart.ClearUpdateSchedule();
if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
// Legacy UploadObject CAPS creates mesh instances one at
// a time. At minimum, never undercharge a costly instance
// as a flat single prim while the LI policy is enabled.
int landImpact = m_scene.RequestModuleInterface<IPrimCountModule>()
?.GetObjectLandImpact(grp) ?? 1;
if (m_scene.Permissions.CanRezObject(landImpact, avatar.UUID, pos))
{
m_scene.AddSceneObject(grp);
grp.AbsolutePosition = obj.Position;
@@ -1010,8 +1010,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
}
else
{
IPrimCountModule landImpactModule =
m_Scene.RequestModuleInterface<IPrimCountModule>();
foreach (SceneObjectGroup g in objlist)
primcount += g.PrimCount;
primcount += landImpactModule?.GetObjectLandImpact(g) ?? g.PrimCount;
}
if (!m_Scene.Permissions.CanRezObject(primcount, remoteClient.AgentId, pos) && !attachment)
@@ -1172,7 +1174,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
SceneObjectGroup g = objlist[i];
if (!m_Scene.Permissions.CanRezObject(
g.PrimCount, remoteClient.AgentId, pos + veclist[i])
m_Scene.RequestModuleInterface<IPrimCountModule>()
?.GetObjectLandImpact(g) ?? g.PrimCount,
remoteClient.AgentId, pos + veclist[i])
&& !isAttachment)
{
// The client operates in no fail mode. It will
@@ -413,6 +413,8 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="World\Land\PrimCountModule.cs">
<Compile Include="World\Land\OglMeshLandImpactMath.cs" />
<Compile Include="World\Land\OglMeshLandImpactCalculator.cs" />
<SubType>Code</SubType>
</Compile>
<Compile Include="World\Land\LandChannel.cs">
@@ -1751,7 +1751,9 @@ namespace OpenSim.Region.CoreModules.World.Land
}
try
{
primCount[obj.OwnerID] += obj.PrimCount;
primCount[obj.OwnerID] +=
m_scene.RequestModuleInterface<IPrimCountModule>()?.GetObjectLandImpact(obj)
?? obj.PrimCount;
}
catch (KeyNotFoundException)
{
@@ -1786,7 +1788,9 @@ namespace OpenSim.Region.CoreModules.World.Land
{
ownersAndCount.Add(obj.OwnerID, 0);
}
ownersAndCount[obj.OwnerID] += obj.PrimCount;
ownersAndCount[obj.OwnerID] +=
m_scene.RequestModuleInterface<IPrimCountModule>()?.GetObjectLandImpact(obj)
?? obj.PrimCount;
}
}
catch (InvalidOperationException)
@@ -0,0 +1,264 @@
// SPDX-License-Identifier: BSD-3-Clause
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.CoreModules.World.Land
{
/// <summary>
/// Optional, region-scoped mesh land-impact estimator. Reads the same
/// compressed LOD lengths as the model upload cost calculator. Does not
/// alter linkset part counts, script link numbers, or persisted assets.
/// </summary>
internal sealed class OglMeshLandImpactCalculator
{
private const int MaxCachedMeshAssets = 8192;
private const int MaxMeshBytesToInspect = 64 * 1024 * 1024;
private const int MaxConvexBytesToDecode = 128 * 1024;
private const int MaxDecodedConvexBytes = 256 * 1024;
private readonly Scene m_scene;
private readonly Dictionary<UUID, MeshMetrics> m_cache = new();
private readonly object m_cacheLock = new();
internal OglMeshLandImpactCalculator(Scene scene)
{
m_scene = scene ?? throw new ArgumentNullException(nameof(scene));
}
internal int GetLandImpact(SceneObjectGroup group)
{
GetWeights(group, out bool containsMesh, out double streaming,
out double physics, out double server);
return OglMeshLandImpactMath.LandImpact(
group?.PrimCount ?? 0, containsMesh, streaming, physics, server);
}
internal void GetWeights(SceneObjectGroup group, out bool containsMesh,
out double streaming, out double physics, out double server)
{
containsMesh = false;
streaming = physics = server = 0;
if (group is null || group.IsDeleted || group.IsAttachment)
return;
SceneObjectPart[] parts = group.Parts;
if (parts is null || parts.Length == 0)
return;
// The legacy primitive accounting remains unchanged when no mesh
// is present in a linkset.
foreach (SceneObjectPart part in parts)
{
if (IsMesh(part))
{
containsMesh = true;
break;
}
}
if (!containsMesh)
{
streaming = physics = server = parts.Length;
return;
}
server = OglMeshLandImpactMath.ServerWeight(
parts.Length, group.ScriptCount(), group.UsesPhysics);
foreach (SceneObjectPart part in parts)
{
if (part is null || !IsMesh(part))
{
// Classic prims in a mixed linkset retain conservative cost.
streaming += 1.0;
physics += 1.0;
continue;
}
MeshMetrics metrics = GetMeshMetrics(part.Shape.SculptTexture);
if (!metrics.Valid)
{
// Unknown, unavailable, oversize, or malformed mesh assets
// never gain an automatic land quota discount.
streaming += 1.0;
physics += 1.0;
continue;
}
double streamingWeight = OglMeshLandImpactMath.StreamingWeight(
metrics.High, metrics.Medium, metrics.Low, metrics.Lowest,
part.Scale.LengthSquared());
streaming += double.IsFinite(streamingWeight)
? Math.Max(0.01, streamingWeight) : 1.0;
if (part.PhysicsShapeType == (byte)PhysShapeType.none)
continue;
if (part.PhysicsShapeType == (byte)PhysShapeType.convex)
{
// Same per-vertex convex weighting as the existing mesh
// uploader, with actual physics actor weight as a floor.
double hull = metrics.ConvexVertices > 0
? 0.04 * (metrics.ConvexVertices + 1) : 1.0;
physics += Math.Max(hull, SafePhysicsCost(part));
}
else
{
// Prim physics can use a detailed triangle collision
// shape. Never give it the low convex-hull discount.
physics += Math.Max(1.0, SafePhysicsCost(part));
}
}
}
internal static bool IsMesh(SceneObjectPart part)
{
return part?.Shape is not null &&
part.Shape.SculptType == (byte)SculptType.Mesh &&
part.Shape.SculptTexture.IsNotZero();
}
private static double SafePhysicsCost(SceneObjectPart part)
{
float cost = part.PhysicsCost;
return float.IsFinite(cost) && cost >= 0 ? cost : 1.0;
}
private MeshMetrics GetMeshMetrics(UUID assetId)
{
if (assetId.IsZero())
return default;
lock (m_cacheLock)
{
if (m_cache.TryGetValue(assetId, out MeshMetrics cached))
return cached;
}
MeshMetrics metrics = default;
try
{
AssetBase asset = m_scene.AssetService?.Get(assetId.ToString());
if (asset?.Data is byte[] data &&
data.Length > 0 && data.Length <= MaxMeshBytesToInspect)
metrics = ParseMesh(data);
}
catch (Exception) // Unavailable asset or malformed LLSD: fail closed.
{
metrics = default;
}
lock (m_cacheLock)
{
if (m_cache.Count >= MaxCachedMeshAssets)
m_cache.Clear();
m_cache[assetId] = metrics;
}
return metrics;
}
private static MeshMetrics ParseMesh(byte[] data)
{
using MemoryStream stream = new(data, writable: false);
if (OSDParser.DeserializeLLSDBinary(stream) is not OSDMap root)
return default;
long payloadOffset = stream.Position;
if (!TryReadSection(root, "high_lod", payloadOffset, data.Length,
out int high, out _, out _))
return default;
int medium = ReadOptionalSection(root, "medium_lod", payloadOffset, data.Length);
int low = ReadOptionalSection(root, "low_lod", payloadOffset, data.Length);
int lowest = ReadOptionalSection(root, "lowest_lod", payloadOffset, data.Length);
int vertices = ReadConvexVertices(root, payloadOffset, data);
return new MeshMetrics(true, high, medium, low, lowest, vertices);
}
private static int ReadOptionalSection(OSDMap root, string name,
long baseOffset, int dataLength)
{
return TryReadSection(root, name, baseOffset, dataLength,
out int size, out _, out _) ? size : 0;
}
private static bool TryReadSection(OSDMap root, string name,
long baseOffset, int dataLength, out int size,
out int offset, out int absoluteOffset)
{
size = offset = absoluteOffset = 0;
if (!root.TryGetValue(name, out OSD section) || section is not OSDMap map ||
!map.TryGetValue("offset", out OSD offsetValue) ||
!map.TryGetValue("size", out OSD sizeValue))
return false;
offset = offsetValue.AsInteger();
size = sizeValue.AsInteger();
long absolute = baseOffset + offset;
if (offset < 0 || size <= 0 || absolute < 0 ||
absolute + size > dataLength)
return false;
absoluteOffset = (int)absolute;
return true;
}
private static int ReadConvexVertices(OSDMap root, long baseOffset, byte[] data)
{
if (!TryReadSection(root, "physics_convex", baseOffset, data.Length,
out int size, out _, out int absoluteOffset) ||
size > MaxConvexBytesToDecode)
return 0;
try
{
using MemoryStream compressed = new(data, absoluteOffset, size, writable: false);
using ZLibStream zlib = new(compressed, CompressionMode.Decompress);
using MemoryStream decompressed = new();
byte[] buffer = new byte[4096];
int read;
while ((read = zlib.Read(buffer, 0, buffer.Length)) > 0)
{
if (decompressed.Length + read > MaxDecodedConvexBytes)
return 0;
decompressed.Write(buffer, 0, read);
}
decompressed.Position = 0;
if (OSDParser.DeserializeLLSDBinary(decompressed) is OSDMap convex &&
convex.TryGetValue("BoundingVerts", out OSD verts))
{
byte[] dataVerts = verts.AsBinary();
if (dataVerts is not null && dataVerts.Length >= 6 &&
dataVerts.Length % 6 == 0)
return dataVerts.Length / 6;
}
}
catch (Exception)
{
// Missing/invalid convex hull means a conservative physics
// cost, not a truncated or unvalidated cheap collision shape.
}
return 0;
}
private readonly struct MeshMetrics
{
internal readonly bool Valid;
internal readonly int High;
internal readonly int Medium;
internal readonly int Low;
internal readonly int Lowest;
internal readonly int ConvexVertices;
internal MeshMetrics(bool valid, int high, int medium,
int low, int lowest, int convexVertices)
{
Valid = valid;
High = high;
Medium = medium;
Low = low;
Lowest = lowest;
ConvexVertices = convexVertices;
}
}
}
}
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: BSD-3-Clause
using System;
namespace OpenSim.Region.CoreModules.World.Land
{
/// <summary>
/// Pure, deterministic land-impact arithmetic. The inputs are costs for
/// the ENTIRE linked object, not rounded per-part costs.
/// </summary>
public static class OglMeshLandImpactMath
{
public static double ServerWeight(int partCount, int scriptCount, bool physical)
{
if (partCount <= 0)
return 0;
if (physical)
return partCount;
double weight = 0.5 * partCount;
if (scriptCount > 1)
weight += 0.25 * (scriptCount - 1);
return Math.Min(partCount, weight);
}
public static int LandImpact(int partCount, bool containsMesh,
double streaming, double physics, double server)
{
if (partCount <= 0)
return 0;
if (!containsMesh)
return partCount;
// Missing / malformed cost inputs cannot grant a discount.
if (!double.IsFinite(streaming) || !double.IsFinite(physics) ||
!double.IsFinite(server) || streaming < 0 || physics < 0 || server < 0)
return partCount;
double highest = Math.Max(streaming, Math.Max(physics, server));
if (highest >= int.MaxValue)
return int.MaxValue;
return Math.Max(1, (int)Math.Ceiling(highest));
}
/// <summary>
/// Mirrors the four-LOD weighted download model used by the built-in
/// model uploader (MeshCost.cs), from compressed per-LOD byte lengths.
/// </summary>
public static double StreamingWeight(int high, int medium, int low,
int lowest, double squaredDiameter)
{
if (high <= 0 || !double.IsFinite(squaredDiameter) || squaredDiameter <= 0)
return double.NaN;
medium = medium > 0 ? medium : high;
low = low > 0 ? low : medium;
lowest = lowest > 0 ? lowest : low;
double ah = Math.Min(262144.0, squaredDiameter * 17.36);
double am = Math.Min(262144.0, squaredDiameter * 277.78);
double al = Math.Min(262144.0, squaredDiameter * 1111.11);
double ae = 262144.0;
double wh = Math.Max(1.0, ah);
double wm = Math.Max(1.0, am - ah);
double wl = Math.Max(1.0, al - am);
double we = Math.Max(1.0, ae - al);
double totalArea = wh + wm + wl + we;
double h = Math.Max(16, high - 384);
double m = Math.Max(16, medium - 384);
double l = Math.Max(16, low - 384);
double e = Math.Max(16, lowest - 384);
return 0.004 * (h * wh + m * wm + l * wl + e * we) / totalArea;
}
}
}
@@ -56,6 +56,8 @@ namespace OpenSim.Region.CoreModules.World.Land
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_Scene;
private bool m_meshLandImpactEnabled;
private OglMeshLandImpactCalculator m_meshLandImpact;
private Dictionary<UUID, PrimCounts> m_PrimCounts =
new Dictionary<UUID, PrimCounts>();
private Dictionary<UUID, UUID> m_OwnerMap =
@@ -83,11 +85,17 @@ namespace OpenSim.Region.CoreModules.World.Land
public void Initialise(IConfigSource source)
{
// Off by default in OpenSimDefaults.ini; opt in per simulator
// after confirming production parcel quotas and viewer behavior.
m_meshLandImpactEnabled =
source?.Configs["OGLMeshLandImpact"]?.GetBoolean("Enabled", false) ?? false;
}
public void AddRegion(Scene scene)
{
m_Scene = scene;
m_meshLandImpact = m_meshLandImpactEnabled
? new OglMeshLandImpactCalculator(scene) : null;
m_Scene.RegisterModuleInterface<IPrimCountModule>(this);
@@ -114,6 +122,38 @@ namespace OpenSim.Region.CoreModules.World.Land
get { return "PrimCountModule"; }
}
public bool MeshLandImpactEnabled => m_meshLandImpactEnabled;
public int GetObjectLandImpact(SceneObjectGroup group)
{
if (group is null)
return 0;
if (!m_meshLandImpactEnabled || m_meshLandImpact is null)
return group.PrimCount;
return m_meshLandImpact.GetLandImpact(group);
}
public void GetObjectLandImpactWeights(SceneObjectGroup group,
out float streaming, out float physics, out float server)
{
if (group is null)
{
streaming = physics = server = 0;
return;
}
if (!m_meshLandImpactEnabled || m_meshLandImpact is null)
{
streaming = physics = server = group.PrimCount;
return;
}
m_meshLandImpact.GetWeights(group, out _, out double sw,
out double pw, out double vw);
streaming = (float)Math.Min(float.MaxValue, sw);
physics = (float)Math.Min(float.MaxValue, pw);
server = (float)Math.Min(float.MaxValue, vw);
}
private void OnParcelPrimCountAdd(SceneObjectGroup obj)
{
// If we're tainted already, don't bother to add. The next
@@ -205,7 +245,9 @@ namespace OpenSim.Region.CoreModules.World.Land
if (m_ParcelCounts.TryGetValue(landData.GlobalID, out parcelCounts))
{
UUID landOwner = landData.OwnerID;
int partCount = obj.GetPartCount();
// Land/parcel limits use linkset LI, not raw mesh part count.
// LSL and the editable linkset structure still use PrimCount.
int partCount = GetObjectLandImpact(obj);
m_SimwideCounts[landOwner] += partCount;
if (parcelCounts.Users.ContainsKey(obj.OwnerID))
@@ -37,5 +37,14 @@ namespace OpenSim.Region.Framework.Interfaces
void TaintPrimCount();
IPrimCounts GetPrimCounts(UUID parcelID);
// Quota cost for a full linked object (does not alter PrimCount or LSL).
int GetObjectLandImpact(OpenSim.Region.Framework.Scenes.SceneObjectGroup group);
// Accurate aggregate costs for viewer GetObjectCost/selected weights.
bool MeshLandImpactEnabled { get; }
void GetObjectLandImpactWeights(
OpenSim.Region.Framework.Scenes.SceneObjectGroup group,
out float streaming, out float physics, out float server);
}
}
@@ -2696,10 +2696,15 @@ namespace OpenSim.Region.Framework.Scenes
return null;
int totalPrims = 0;
long totalLandImpact = 0;
IPrimCountModule primCountModule = RequestModuleInterface<IPrimCountModule>();
foreach (SceneObjectGroup group in objlist)
totalPrims += group.PrimCount;
{
totalPrims += group.PrimCount; // Actual linkset/rez placement geometry.
totalLandImpact += primCountModule?.GetObjectLandImpact(group) ?? group.PrimCount;
}
if (!Permissions.CanRezObject(totalPrims, newowner, pos))
if (!Permissions.CanRezObject((int)Math.Min(int.MaxValue, totalLandImpact), newowner, pos))
return null;
if (!Permissions.BypassPermissions())
@@ -253,6 +253,12 @@ namespace OpenSim.Region.Framework.Scenes
}
m_hasGroupChanged = value;
// Resizes, physics changes and script changes can change mesh
// costs. Recalculate lazily on the next land quota query.
if (value && m_scene is not null &&
m_scene.RequestModuleInterface<IPrimCountModule>()?.MeshLandImpactEnabled == true)
m_scene.EventManager.TriggerParcelPrimCountTainted();
//m_log.DebugFormat(
// "[SCENE OBJECT GROUP]: HasGroupChanged set to {0} for {1} {2}", m_hasGroupChanged, Name, LocalId);
}
@@ -1826,6 +1832,22 @@ namespace OpenSim.Region.Framework.Scenes
public void GetResourcesCosts(SceneObjectPart apart,
out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost)
{
// Mesh LI is calculated for the complete linked object. Report
// the exact rounded quota cost through the viewer ObjectCost CAPS.
IPrimCountModule landImpactModule =
m_scene?.RequestModuleInterface<IPrimCountModule>();
if (landImpactModule?.MeshLandImpactEnabled == true)
{
landImpactModule.GetObjectLandImpactWeights(this,
out _, out float physicsWeight, out _);
linksetResCost = landImpactModule.GetObjectLandImpact(this);
linksetPhysCost = physicsWeight;
int count = Math.Max(1, PrimCount);
partCost = apart is null ? 0 : linksetResCost / count;
partPhysCost = apart is null ? 0 : physicsWeight / count;
return;
}
// this information may need to be cached
float cost;
@@ -1883,6 +1905,15 @@ namespace OpenSim.Region.Framework.Scenes
public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost)
{
IPrimCountModule landImpactModule =
m_scene?.RequestModuleInterface<IPrimCountModule>();
if (landImpactModule?.MeshLandImpactEnabled == true)
{
landImpactModule.GetObjectLandImpactWeights(this,
out StreamCost, out PhysCost, out SimulCost);
return;
}
SceneObjectPart p;
SceneObjectPart[] parts = m_parts.GetArray();
@@ -1092,6 +1092,11 @@ namespace OpenSim.Region.Framework.Scenes
set
{
m_shape = value;
// A mesh/sculpt/prim shape switch can change LI even when
// the number of linked parts remains constant.
if (ParentGroup?.Scene is Scene scene &&
scene.RequestModuleInterface<IPrimCountModule>()?.MeshLandImpactEnabled == true)
scene.EventManager.TriggerParcelPrimCountTainted();
}
}
@@ -1107,6 +1112,12 @@ namespace OpenSim.Region.Framework.Scenes
{
Vector3 oldscale = m_shape.Scale;
m_shape.Scale = value;
// Streaming LI depends on the physical size. The old
// PrimCount-only path did not need a recount on scaling.
if ((value - oldscale).LengthSquared() > 0.000001f &&
ParentGroup?.Scene is Scene scene &&
scene.RequestModuleInterface<IPrimCountModule>()?.MeshLandImpactEnabled == true)
scene.EventManager.TriggerParcelPrimCountTainted();
if (ParentGroup is not null && ((value - oldscale).LengthSquared() >1.0f))
ParentGroup.InvalidBoundsRadius();
PhysicsActor actor = PhysActor;
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules
Vector3 objectPosition = sog.AbsolutePosition;
ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo);
string response = DoCommonChecks(GetLandImpact(sog), sp.UUID, lo);
if (response != null)
{
@@ -159,7 +159,7 @@ namespace OpenSim.Region.OptionalModules
return true;
}
int objectCount = sog.PrimCount;
int objectCount = GetLandImpact(sog);
// TODO: Add Special Case here for temporary prims
@@ -182,7 +182,7 @@ namespace OpenSim.Region.OptionalModules
if (newParcel == null)
return true;
int objectCount = sog.PrimCount;
int objectCount = GetLandImpact(sog);
// TODO: Add Special Case here for temporary prims
@@ -194,6 +194,12 @@ namespace OpenSim.Region.OptionalModules
return true;
}
private int GetLandImpact(SceneObjectGroup objectGroup)
{
return m_scene.RequestModuleInterface<IPrimCountModule>()
?.GetObjectLandImpact(objectGroup) ?? objectGroup.PrimCount;
}
private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
{
string response = null;
@@ -761,11 +761,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
return;
}
int totalPrims = 0;
int totalImpact = 0;
IPrimCountModule landImpactModule = m_scene.RequestModuleInterface<IPrimCountModule>();
foreach (SceneObjectGroup group in objlist)
totalPrims += group.PrimCount;
totalImpact += landImpactModule?.GetObjectLandImpact(group) ?? group.PrimCount;
if (! m_scene.Permissions.CanRezObject(totalPrims, item.OwnerID, pos))
if (! m_scene.Permissions.CanRezObject(totalImpact, item.OwnerID, pos))
{
GenerateRuntimeError("Not allowed to create the object");
return;
+2 -1
View File
@@ -63,7 +63,8 @@
PublicPort = "80"
PrivURL = ${Const|BaseURL}
PrivatePort = "8003"
[OGLMeshLandImpact]
Enabled = true
[Startup]
; OGL 0.9.3.13: Live-Profil, Opt-in fuer erweiterte Regionssicht.
; 1024 m MaxDrawDistance / 768 m MaxRegionsViewDistance als Preset;
+3 -1
View File
@@ -52,6 +52,8 @@
PrivURL = ${Const|BaseURL}
PrivatePort = "8003"
[OGLMeshLandImpact]
Enabled = false
[Startup]
; OGL 0.9.3.13: erweiterte Sicht auf mehr als das bisherige 3x3-Raster.
; Opt-in: angepasste Defaults MaxDrawDistance=1024 und
@@ -152,7 +154,7 @@
SubjectTemplate = "Offline-IM Nachricht von {SENDER}"
RelaySigningKey = "${Environment|NEXVERSE_IM_RELAY_SIGNING_KEY}"
ReplyLifetimeDays = 5
SMTPHost = "mail.nexvortex.de"
SMTPHost = "web01.nexvortex.de"
SMTPPort = 587
UseStartTls = true
UseSslOnConnect = false
+9
View File
@@ -59,6 +59,15 @@
MaximumArchiveMiB = 20480
MigrationStorageId = ""
; OpenGenesisLINK G1 Mesh Land Impact (per-simulator).
; Classic prim linksets keep their original counts. Mesh linksets use
; the maximum of LOD streaming, convex physics and server weights.
; The number of editable linked parts and LSL link numbers never change.
; This is an OGL approximation of Second Life LI, not the proprietary
; Linden Lab implementation. Staging validation is recommended.
[OGLMeshLandImpact]
Enabled = false
[Startup]
; Console prompt
; Certain special characters can be used to customize the prompt
@@ -0,0 +1,83 @@
# OpenGenesisLINK G1 – Mesh Land Impact (opt-in)
## Zweck
OpenSimulator zaehlt bei Landlimits standardmaessig jedes verlinkte Objektteil
als ein Prim. In Second Life ist die **Land Impact (LI)**-Quota fuer Mesh-Objekte
separat von der Anzahl der editierbaren Teile. Dieses Feature fuehrt eine
**eigene, abschaltbare OGL-Annaeherung** ein; es ist kein identischer
Linden-Lab-Land-Impact-Algorithmus.
## Verhalten
- Ohne Mesh im Linkset: klassischer PrimCount unveraendert.
- Bei Mesh im Linkset: **max(download/streaming, physics, server)** wird
berechnet und fuer das gesamte Linkset **einmal aufgerundet**, mindestens 1.
- Download-Kosten: dieselbe gewichtete LOD-Kompressionsgroessen-Formel wie
der vorhandene Mesh-Upload-Kostenrechner (`MeshCost.cs`), inkl. Objektgroesse.
- Physik: vorhandener Convex-Hull-Vertex-Faktor (0,04 pro Vertex) und
die groesseren vorhandenen PhysicsActor-Kosten; `PhysicsShapeType = Prim`
hat konservativ mindestens 1 pro Teil.
- Servergewicht: statische nichtphysische Linksets mit 0 Skripten
**0,5 pro Teil**, Skriptzuschlaege, physische Linksets mindestens 1 pro Teil.
- Komplexe Meshes, groessere Objekte, aufwendige Physik oder Skripte
koennen **mehr** LI kosten als vorher.
- Beispielsweise koennen 10 kleine, optimierte und ungeskriptete Mesh-Teile
5 LI kosten; das ist **kein garantierter 50-%-Rabatt**.
- Fehlende, unlesbare, uebergrosse oder ungueltige Mesh-Assets erhalten
keinen Rabatt. Die Asset-Header werden begrenzt und pro Region gecacht.
- Die physische Anzahl der Teile (`SceneObjectGroup.PrimCount`),
`llGetNumberOfPrims`, `llGetLinkNumber`, die Linkset-Bearbeitung und
alle gespeicherten Objekte bleiben unveraendert.
## Konfiguration
```ini
[OGLMeshLandImpact]
Enabled = true
```
- `bin/OpenSimDefaults.ini`: **false** (sicherer genereller Default).
- `bin/OpenSim.ini.example`: **false** fuer neue/nicht getestete Grids.
- `bin/OpenSim.ini`: **true** fuer die Stadt-NexVerse-Quellkonfiguration.
- Aktive Betreiber-INI wird beim Deployment nicht ohne Weiteres
automatisch ersetzt: Einstellung der produktiven `OpenSim.ini`
kontrollieren und Simulator neu starten.
## Abrechnungs-Integration
`PrimCountModule` verwendet LI fuer Parzellen, Eigentuer-/Benutzer-Kontingente
und simweite Kapazitaeten. `LandObject` meldet den passenden LI in der
Eigentuemeranzeige. `PrimLimitsModule` prueft beim Duplizieren und
Parzellenwechsel dieselbe Belastung. Normale Inventar- und
JsonStore-Rezpfade verwenden die neue Zahl fuer die Berechtigungspruefung.
GetObjectCost- und ResourceCostSelected-CAPS liefern die berechneten
Linkset-Kosten, ohne die echten Linknummern zu veraendern.
## Grenzen und Rollout
1. **Nicht identisch mit Second Life**: Die Download- und
Convex-Physik-Faktoren basieren auf den bestehenden OpenGenesisLINK-
Uploader-Daten, nicht auf einem exakten proprietaeren SL-Modell.
2. Ein ueber mehrere Mesh-Teile direkt aus dem Viewer angelegtes Objekt
wird in manchen alten UploadObject-CAPS-Pfaden schon pro einzelnem
Teil geprueft; ein Folgeaudit dieser Legacy-Verkettung ist sinnvoll.
3. Tests vor Aktivierung: Inventar-Rez, Hochladen, Drag-Drop, Copy,
Script-Rez, Link/Delink, Skalierung, Skript hinzufuegen/entfernen,
physisch/nichtphysisch, Objekt mit fehlendem Mesh-Asset, Parzellen-
und Regionslimit sowie Viewer-Mehr-Info-Dialog.
4. Vor Aktivierung Primbudget und Landnutzung sichern. Die Umstellung
kann bestehende Mesh-Bauten neu bewerten.
5. Im Fehlerfall `Enabled = false` setzen und Simulator neu starten:
danach gilt die bisherige Primzahl pro Linkset.
6. Kein Aendern von OAR/IAR-Archiven, persistenten Regionobjekten oder
LSL-/Viewer-Protokollen.
## Tests
`dotnet run --configuration Release --project tools/ci/OglMeshLandImpactRegression/OglMeshLandImpactRegression.csproj`
und `python3 tools/ci/verify_ogl_mesh_land_impact.py`, plus G1 .NET10
Linux/Windows/ARM64 sowie NexVerse-Integrations-CI.
Bei hohen echten Mesh-Asset-Komplexitaeten werden abschliessende
Inworld-Vergleiche gegen Second Life separat benoetigt.
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Exe</OutputType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Include="../../../OpenSim/Region/CoreModules/World/Land/OglMeshLandImpactMath.cs" Link="OglMeshLandImpactMath.cs"/>
</ItemGroup>
</Project>
@@ -0,0 +1,24 @@
using OpenSim.Region.CoreModules.World.Land;
static void Check(bool success, string what)
{
if (!success) throw new InvalidOperationException("Mesh LI regression failed: " + what);
}
Check(OglMeshLandImpactMath.LandImpact(10, false, 0, 0, 5) == 10, "classic 10-prims count 10");
Check(OglMeshLandImpactMath.ServerWeight(10, 0, false) == 5, "10 static mesh parts have server weight 5");
Check(OglMeshLandImpactMath.LandImpact(10, true, 2, 3, 5) == 5, "10 optimized mesh parts have 5 LI");
Check(OglMeshLandImpactMath.LandImpact(1, true, 0.05, 0.10, 0.5) == 1, "single mesh at least one LI");
Check(OglMeshLandImpactMath.LandImpact(3, true, 0.3, 0.6, 1.5) == 2, "round linked object only once");
Check(OglMeshLandImpactMath.LandImpact(10, true, 15.1, 1, 5) == 16, "high download cost raises impact");
Check(OglMeshLandImpactMath.LandImpact(10, true, 0.1, 20, 5) == 20, "complex physics raises impact");
Check(OglMeshLandImpactMath.ServerWeight(10, 0, true) == 10, "physical no static discount");
Check(OglMeshLandImpactMath.ServerWeight(10, 5, false) == 6, "script cost contributes");
Check(OglMeshLandImpactMath.ServerWeight(10, 300, false) == 10, "script weight bounded at parts");
Check(OglMeshLandImpactMath.LandImpact(10, true, double.NaN, 0, 5) == 10, "invalid weights fail closed");
Check(OglMeshLandImpactMath.LandImpact(10, true, -1, 0, 5) == 10, "negative weights fail closed");
Check(OglMeshLandImpactMath.LandImpact(0, true, 1, 1, 1) == 0, "empty object");
Check(OglMeshLandImpactMath.StreamingWeight(400, 300, 200, 100, 3) > 0, "valid mesh LOD streaming");
Check(OglMeshLandImpactMath.StreamingWeight(80000, 50000, 20000, 10000, 12) >
OglMeshLandImpactMath.StreamingWeight(800, 500, 200, 100, 12), "large LOD costs more");
Check(double.IsNaN(OglMeshLandImpactMath.StreamingWeight(0, 0, 0, 0, 1)), "invalid LOD fails closed");
Console.WriteLine("OpenGenesisLINK G1 mesh land impact arithmetic: PASS");
+1 -1
View File
@@ -33,7 +33,7 @@ for path in ("bin/OpenSim.ini", "bin/OpenSim.ini.example"):
"Enabled = true",
'RelayDomain = "im.stadt-nexverse.de"',
'SubjectTemplate = "Offline-IM Nachricht von {SENDER}"',
'SMTPHost = "mail.nexvortex.de"',
'SMTPHost = "web01.nexvortex.de"',
"SMTPPort = 587",
"UseStartTls = true",
'SMTPUsername = "relay@im.stadt-nexverse.de"',
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""Guard linked object land impact wiring without changing LSL link part counts."""
from pathlib import Path
root = Path(__file__).resolve().parents[2]
def read(p): return (root / p).read_text(encoding="utf-8")
core = read("OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs")
engine = read("OpenSim/Region/CoreModules/World/Land/OglMeshLandImpactCalculator.cs")
math = read("OpenSim/Region/CoreModules/World/Land/OglMeshLandImpactMath.cs")
interface = read("OpenSim/Region/Framework/Interfaces/IPrimCountModule.cs")
group = read("OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs")
land = read("OpenSim/Region/CoreModules/World/Land/LandObject.cs")
limits = read("OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs")
coreproj = read("OpenSim/Region/CoreModules/OpenSim.Region.CoreModules.csproj")
assert 'GetBoolean("Enabled", false)' in core
assert "int partCount = GetObjectLandImpact(obj);" in core
assert "GetObjectLandImpact(SceneObjectGroup group)" in core
assert "GetObjectLandImpactWeights" in core and "GetObjectLandImpactWeights" in interface
assert "MeshLandImpactEnabled" in core and "MeshLandImpactEnabled" in interface
assert "OglMeshLandImpactCalculator.cs" in coreproj
assert "OglMeshLandImpactMath.cs" in coreproj
assert "MaxCachedMeshAssets = 8192" in engine
assert "MaxMeshBytesToInspect = 64 * 1024 * 1024" in engine
assert "physics_convex" in engine and "BoundingVerts" in engine
assert "streaming += 1.0" in engine and "physics += 1.0" in engine
assert "OglMeshLandImpactMath.StreamingWeight" in engine
assert "OglMeshLandImpactMath.ServerWeight" in engine
assert "Math.Ceiling(highest)" in math
assert "GetObjectLandImpact(obj)" in land
assert "GetLandImpact(sog)" in limits
assert "m_scene?.RequestModuleInterface<IPrimCountModule>()" in group
assert "TriggerParcelPrimCountTainted" in group
assert "TriggerParcelPrimCountTainted" in read("OpenSim/Region/Framework/Scenes/SceneObjectPart.cs")
assert "GetObjectLandImpact(group)" in read("OpenSim/Region/Framework/Scenes/Scene.Inventory.cs")
assert "GetObjectLandImpact(g)" in read("OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs")
assert "GetObjectLandImpact(grp)" in read("OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs")
assert "GetObjectLandImpact(group)" in read("OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs")
for file, enabled in [
("bin/OpenSimDefaults.ini", "false"),
("bin/OpenSim.ini.example", "false"),
("bin/OpenSim.ini", "true"),
]:
cfg = read(file)
section = cfg.split("[OGLMeshLandImpact]", 1)[1].split("[", 1)[0]
assert f"Enabled = {enabled}" in section, f"{file}: unexpected mesh LI switch"
assert "get { return m_parts.Count; }" in group, "LSL/linkset part counting changed"
assert "GetPartCount()" in group, "Actual edit/physics linkset part count changed"
print("OpenGenesisLINK G1 Mesh Land Impact core configuration and integration: PASS")