From c0326523ac243622f211644a74e11d10c5142420 Mon Sep 17 00:00:00 2001 From: Erik Date: Thu, 21 May 2026 16:50:05 +0200 Subject: [PATCH] =?UTF-8?q?fix(O-T4):=20address=20spec-review=20findings?= =?UTF-8?q?=20=E2=80=94=20InstanceData=20+=20using=20cleanups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four fixes from T4 spec review: 1. Extracted InstanceData.cs (14-line struct) verbatim to src/AcDream.App/Rendering/Wb/InstanceData.cs (per O-D1). 2. ObjectMeshManager.cs: replaced `using Chorizite.OpenGLSDLBackend.Lib;` with `using AcDream.Core.Rendering.Wb;` (TextureHelpers comes from our T2 Core extraction; InstanceData comes from new T4 cleanup). 3. EmbeddedResourceReader.GetEmbeddedResource promoted from `internal` to `public` per O-D9 intent (the type promotion only changed the class signature in T3; this finishes the spec). 4. OpenGLGraphicsDevice.cs: removed stale T3 interim comment at lines 142-145 — T4 resolved the ParticleBatcher construction via post-ctor assignment in WbMeshAdapter.cs:78. Build green; tests green (1147 passing, 8 pre-existing failures baseline maintained). Spec: docs/superpowers/specs/2026-05-21-phase-o-dat-path-unification-design.md Co-Authored-By: Claude Opus 4.7 (1M context) --- .../Rendering/Wb/EmbeddedResourceReader.cs | 2 +- src/AcDream.App/Rendering/Wb/InstanceData.cs | 15 +++++++++++++++ src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs | 2 +- .../Rendering/Wb/OpenGLGraphicsDevice.cs | 7 +++---- 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 src/AcDream.App/Rendering/Wb/InstanceData.cs diff --git a/src/AcDream.App/Rendering/Wb/EmbeddedResourceReader.cs b/src/AcDream.App/Rendering/Wb/EmbeddedResourceReader.cs index 24e2ff6..bc10f69 100644 --- a/src/AcDream.App/Rendering/Wb/EmbeddedResourceReader.cs +++ b/src/AcDream.App/Rendering/Wb/EmbeddedResourceReader.cs @@ -16,7 +16,7 @@ namespace AcDream.App.Rendering.Wb { /// (lower-case, wb_ prefix to distinguish WB-origin shaders from acdream's own) /// public static class EmbeddedResourceReader { - internal static string GetEmbeddedResource(string filename) { + public static string GetEmbeddedResource(string filename) { // Convert "Shaders.Particle.vert" → "wb_particle.vert" // Strip leading "Shaders." then lowercase and prefix with wb_ string leafName; diff --git a/src/AcDream.App/Rendering/Wb/InstanceData.cs b/src/AcDream.App/Rendering/Wb/InstanceData.cs new file mode 100644 index 0000000..bf911ec --- /dev/null +++ b/src/AcDream.App/Rendering/Wb/InstanceData.cs @@ -0,0 +1,15 @@ +using System.Numerics; +using System.Runtime.InteropServices; + +namespace AcDream.App.Rendering.Wb { + [StructLayout(LayoutKind.Sequential, Pack = 16)] + public struct InstanceData { + public const uint INSTANCE_FLAG_DISQUALIFIED = 1u; + + public Matrix4x4 Transform; // 64 bytes + public uint CellId; // 4 bytes + public uint Flags; // 4 bytes + private uint _pad1; // 4 bytes + private uint _pad2; // 4 bytes -> total 80 bytes + } +} diff --git a/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs b/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs index 8a6dda1..d2e1f4c 100644 --- a/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs +++ b/src/AcDream.App/Rendering/Wb/ObjectMeshManager.cs @@ -16,7 +16,7 @@ using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using WorldBuilder.Shared.Services; -using Chorizite.OpenGLSDLBackend.Lib; +using AcDream.Core.Rendering.Wb; using PixelFormat = Silk.NET.OpenGL.PixelFormat; using BoundingBox = Chorizite.Core.Lib.BoundingBox; using BCnEncoder.Decoder; diff --git a/src/AcDream.App/Rendering/Wb/OpenGLGraphicsDevice.cs b/src/AcDream.App/Rendering/Wb/OpenGLGraphicsDevice.cs index 02f20b7..79f8e0c 100644 --- a/src/AcDream.App/Rendering/Wb/OpenGLGraphicsDevice.cs +++ b/src/AcDream.App/Rendering/Wb/OpenGLGraphicsDevice.cs @@ -139,10 +139,9 @@ namespace AcDream.App.Rendering.Wb { InitializeSharedDebugResources(); - // T3 interim: ParticleBatcher (Chorizite.OpenGLSDLBackend.Lib.ParticleBatcher) is a T4 type - // (Particle batcher + emitter extraction is in T4). It expects the WB-original - // OpenGLGraphicsDevice type; we cannot pass `this` until T4 extracts it alongside us. - // The property is set to null! here; T4 will restore the real construction. + // ParticleBatcher is constructed post-ctor by WbMeshAdapter (WbMeshAdapter.cs:78) + // after the adapter has wired up all dependencies. The null! here is overridden + // immediately after construction; it is not observable as null at runtime. ParticleBatcher = null!; }