From f72f7ce1f4af565f519b6f8536b7f448f578db48 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 23 Jun 2026 15:50:31 +0200 Subject: [PATCH] feat(envcell): CellHasTransparent predicate (shell-batching prep) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Rendering/Wb/EnvCellRenderer.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/AcDream.App/Rendering/Wb/EnvCellRenderer.cs b/src/AcDream.App/Rendering/Wb/EnvCellRenderer.cs index 1f4e4436..f7b13aa4 100644 --- a/src/AcDream.App/Rendering/Wb/EnvCellRenderer.cs +++ b/src/AcDream.App/Rendering/Wb/EnvCellRenderer.cs @@ -1053,6 +1053,29 @@ public sealed unsafe class EnvCellRenderer : IDisposable } } + /// + /// True if the cell's prepared snapshot has any transparent render batch. + /// The pview shell pass uses this to skip the (heavy per-frame) transparent + /// call for opaque-only cells — most cell geometry is + /// opaque walls/floors/ceilings, so this removes the bulk of the per-cell + /// transparent draws. Read-only; mirrors the [shell] probe's batch scan. + /// + public bool CellHasTransparent(uint cellId) + { + var snapshot = _activeSnapshot; + if (snapshot is null || !snapshot.BatchedByCell.TryGetValue(cellId, out var gfxDict)) + return false; + foreach (var (gfxObjId, transforms) in gfxDict) + { + if (transforms.Count == 0) continue; + var rd = _meshManager.TryGetRenderData(gfxObjId); + if (rd is null) continue; + foreach (var b in rd.Batches) + if (b.IsTransparent) return true; + } + return false; + } + // --------------------------------------------------------------------------- // GetCellLightSet (A7 Fix D D-2 helper) // Per-cell up-to-8 point lights, cached per frame. Camera-independent, like