acdream/src/AcDream.App/Rendering/RetailParticleGeometryClassifier.cs
Erik b26f84cc69 fix(ui): restore radar, retail wield switching, and protection meshes
Late-bind radar snapshots to the canonical LiveEntityRuntime maps so the retained radar survives bootstrap and session replacement instead of capturing empty sentinels.

Route paperdoll drops through the retail AutoWield blocker transaction. Move conflicting held weapons, shields, explicit jewelry destinations, and mismatched ammo to the backpack one authoritative confirmation at a time; preserve compatible arrows when switching to melee.

Render mode-1 and no-degrade particle GfxObjs as their authored modern-pipeline meshes, retain Always2D billboards, interleave both paths back-to-front, balance emitter mesh ownership, and fail safely on corrupt DAT material metadata. This restores the closed apex on Armor Self/protection effects.

Retain Studio fixture controller lifetimes, add installed-DAT and adversarial regression coverage, synchronize retail research/divergence bookkeeping, and pass all three review tracks plus the full Release suite.

Co-Authored-By: Codex <noreply@openai.com>
2026-07-14 20:52:45 +02:00

60 lines
1.9 KiB
C#

using System;
using AcDream.Core.Meshing;
using DatReaderWriter.DBObjs;
namespace AcDream.App.Rendering;
/// <summary>
/// Retail particle geometry selection from <c>CPhysicsPart::Always2D</c>
/// (named retail 0x0050D8A0). A GfxObj with no degrade entry, or whose first
/// degrade has mode 1, is drawn as its authored 3D mesh. Every other first
/// degrade mode uses the camera-facing 2D presentation.
/// </summary>
public static class RetailParticleGeometryClassifier
{
public static RetailParticleGeometryKind Classify(uint? firstDegradeMode)
=> firstDegradeMode is uint mode && mode != 1u
? RetailParticleGeometryKind.Billboard
: RetailParticleGeometryKind.FullMesh;
}
public enum RetailParticleGeometryKind
{
FullMesh,
Billboard,
}
/// <summary>
/// Resolves authored particle-surface blending without allowing one malformed
/// Surface entry to abort the render frame. The fallback remains the batch's
/// already-decoded additive bit; it never fabricates geometry or a material.
/// </summary>
internal static class RetailParticleBlendResolver
{
public static TranslucencyKind Resolve(
uint surfaceId,
bool batchIsAdditive,
Func<uint, Surface?>? loadSurface,
Action<string>? diagnostic = null)
{
TranslucencyKind fallback = batchIsAdditive
? TranslucencyKind.Additive
: TranslucencyKind.AlphaBlend;
if (surfaceId == 0 || loadSurface is null)
return fallback;
try
{
Surface? surface = loadSurface(surfaceId);
return surface is null
? fallback
: TranslucencyKindExtensions.FromSurfaceType(surface.Type);
}
catch (Exception ex)
{
diagnostic?.Invoke(
$"[particle-material] Failed to decode Surface 0x{surfaceId:X8}: {ex.Message}");
return fallback;
}
}
}