using System.Collections.Generic;
namespace AcDream.Core.Rendering.Wb;
///
/// Computes WorldBuilder's content identity for an EnvCell shell.
/// Equal environment, cell-structure, and ordered surface tuples share one
/// prepared geometry payload even when they occur under different cell IDs.
///
public static class EnvCellGeometryIdentity
{
///
/// Source: WorldBuilder EnvCellRenderManager.GetEnvCellGeomId,
/// lines 94-103. Bit 33 separates content identities from per-cell IDs,
/// whose synthetic geometry requests use bit 32.
///
public static ulong Compute(
uint environmentId,
ushort cellStructure,
IReadOnlyList surfaces)
{
long hash = 17;
hash = unchecked(hash * 31 + environmentId);
hash = unchecked(hash * 31 + cellStructure);
for (int i = 0; i < surfaces.Count; i++)
hash = unchecked(hash * 31 + surfaces[i]);
return (ulong)hash | 0x2_0000_0000UL;
}
}