phase(N.4): WbMeshAdapter stub + IWbMeshAdapter interface

Stub adapter that validates constructor args and exposes the public
shape (IncrementRefCount / DecrementRefCount / GetRenderData / Dispose).
Real ObjectMeshManager init is deferred to Task 9 — for now methods
no-op so call sites can wire the adapter without behavioral effect.

IWbMeshAdapter interface enables mocking in subsequent tasks
(LandblockSpawnAdapter tests in Task 11 need it).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-05-08 13:18:50 +02:00
parent ed73fc5040
commit 1030c69b3c
3 changed files with 131 additions and 0 deletions

View file

@ -0,0 +1,12 @@
namespace AcDream.App.Rendering.Wb;
/// <summary>
/// Mockable interface over <see cref="WbMeshAdapter"/> so adapters that
/// drive ref-count lifecycle (e.g. LandblockSpawnAdapter, EntitySpawnAdapter)
/// can be unit-tested without a real WB pipeline behind them.
/// </summary>
public interface IWbMeshAdapter
{
void IncrementRefCount(ulong id);
void DecrementRefCount(ulong id);
}

View file

@ -0,0 +1,72 @@
using System;
using DatReaderWriter;
using Microsoft.Extensions.Logging;
using Silk.NET.OpenGL;
namespace AcDream.App.Rendering.Wb;
/// <summary>
/// Single seam between acdream and WB's render pipeline. Owns the
/// <c>ObjectMeshManager</c> instance (when fully initialized) and exposes
/// a stable acdream-shaped API so the rest of the renderer doesn't need
/// to know about WB's types directly.
///
/// <para>
/// <b>Phase N.4 staging:</b> currently a stub. Real <c>ObjectMeshManager</c>
/// + <c>OpenGLGraphicsDevice</c> initialization is added in Task 9 once
/// the dat-reader adapter (Task 6) lands. Until then, methods no-op so
/// call sites can wire the adapter without behavioral effect when the
/// <see cref="WbFoundationFlag.IsEnabled"/> flag is on.
/// </para>
/// </summary>
public sealed class WbMeshAdapter : IDisposable, IWbMeshAdapter
{
// _meshManager and _graphicsDevice will be wired in Task 9 once
// WbDatReaderAdapter (Task 6) lands. For now, both are null and all
// methods no-op.
// private ObjectMeshManager? _meshManager;
// private OpenGLGraphicsDevice? _graphicsDevice;
private bool _disposed;
public WbMeshAdapter(GL gl, DatCollection dats, ILogger<WbMeshAdapter> logger)
{
ArgumentNullException.ThrowIfNull(gl);
ArgumentNullException.ThrowIfNull(dats);
ArgumentNullException.ThrowIfNull(logger);
// TODO(N.4 Task 9): construct OpenGLGraphicsDevice and ObjectMeshManager
// once WbDatReaderAdapter (Task 6) is available to bridge our DatCollection
// to WB's IDatReaderWriter.
}
private WbMeshAdapter()
{
// Uninitialized constructor — only for tests / for cases where the
// flag is off and the caller wants a Dispose-safe no-op instance.
}
/// <summary>Test/init helper — produces a Dispose-safe instance with no
/// underlying mesh manager. Public methods are all no-ops.</summary>
public static WbMeshAdapter CreateUninitialized() => new();
/// <summary>Returns null until Task 9 wires up the real mesh manager.</summary>
public object? GetRenderData(ulong id) => null;
public void IncrementRefCount(ulong id)
{
// No-op until Task 9.
}
public void DecrementRefCount(ulong id)
{
// No-op until Task 9.
}
public void Dispose()
{
if (_disposed) return;
_disposed = true;
// _meshManager?.Dispose();
// _graphicsDevice?.Dispose();
}
}