acdream/src/AcDream.App/Rendering/OrbitCamera.cs
Erik d4b5c71e66 fix(render): re-land near plane 0.1m (retail Render::znear) — #110 resolved, closes the §4 corner see-through; close #105/#110
The 137b4f2 payload, re-landed now that #110 is resolved: the missing-indoor-
textures correlation was the pre-existing #105 staged-texture-flush drop
(fixed in c787201), not a near-plane mechanism. znear=0.1 merely raised #105's
trigger probability — a closer near plane makes close-up geometry newly
visible, inflating per-frame prepare/upload pressure indoors and growing the
never-flushed tail. Exactly the handoff's only-credible-link hypothesis,
verified instead of assumed.

Retail: Render::SetFOVRad sets znear=0.1 flat (decomp :342173, initializer
:1101867). 0.1 < the 0.3m camera-collision sphere, so a wall the collided eye
presses against no longer falls inside the near plane — the §4 corner
see-through-wall closes.

Verification on the 0.1 arm (the arm that struck 2-of-3 on 2026-06-10):
nearplane-reland-1.log — [tex-flush] after=0 on all 45 lines, 68,291 [shell]
lines with zero zh>0 batches, all four dat tripwires silent, no [wb-error].
ISSUES.md: #105 + #110 moved to Recently closed with root cause + evidence.
Pending user re-gate: corner press (wall stays solid) + distance scan for
z-shimmer (none expected; retail ships 0.1 with D24).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-10 12:14:00 +02:00

29 lines
1,006 B
C#

using System.Numerics;
namespace AcDream.App.Rendering;
public sealed class OrbitCamera : ICamera
{
public Vector3 Target { get; set; } = new(96, 96, 0); // center of a 192x192 landblock
public float Distance { get; set; } = 300f;
public float Yaw { get; set; } = MathF.PI / 4f;
public float Pitch { get; set; } = MathF.PI / 6f;
public float FovY { get; set; } = MathF.PI / 3f;
public float Aspect { get; set; } = 16f / 9f;
public Matrix4x4 View
{
get
{
var eye = Target + new Vector3(
Distance * MathF.Cos(Pitch) * MathF.Cos(Yaw),
Distance * MathF.Cos(Pitch) * MathF.Sin(Yaw),
Distance * MathF.Sin(Pitch));
return Matrix4x4.CreateLookAt(eye, Target, Vector3.UnitZ);
}
}
// Near plane 0.1 m = retail Render::znear (see RetailChaseCamera.Projection).
public Matrix4x4 Projection
=> Matrix4x4.CreatePerspectiveFieldOfView(FovY, Aspect, 0.1f, 5000f);
}