fix(core): AC2D render split formula + triangle-aware Z sampling
Two fundamental terrain fixes based on the AC2D + holtburger deep dive: 1. Terrain split formula: replaced WorldBuilder's physics-path formula (214614067/1813693831) with AC2D's render-path formula (0x0CCAC033, 0x421BE3BD, 0x6C1AC587, 0x519B8F25). The two produce different splits for some cells. Since the render mesh uses this formula, the physics Z sampler must match it to avoid misalignment on slopes. 2. Triangle-aware Z: replaced bilinear interpolation in TerrainSurface with per-triangle barycentric interpolation. Each cell is split into two triangles (using the same AC2D formula). SampleZ determines which triangle the query point falls in, then interpolates within that triangle. This produces Z values that exactly match the visual terrain mesh — no more slope clipping. Removes the multi-point Z sampling hack from PlayerMovementController (no longer needed with exact triangle Z). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5cd776914a
commit
c5de445e5c
4 changed files with 116 additions and 72 deletions
|
|
@ -1419,7 +1419,10 @@ public sealed class GameWindow : IDisposable
|
|||
// surfaces for this landblock. Runs under _datLock (same lock as the
|
||||
// rest of ApplyLoadedTerrainLocked) so dat reads are safe.
|
||||
{
|
||||
var terrainSurface = new AcDream.Core.Physics.TerrainSurface(lb.Heightmap.Height, _heightTable);
|
||||
uint lbPhysX = (lb.LandblockId >> 24) & 0xFFu;
|
||||
uint lbPhysY = (lb.LandblockId >> 16) & 0xFFu;
|
||||
var terrainSurface = new AcDream.Core.Physics.TerrainSurface(
|
||||
lb.Heightmap.Height, _heightTable, lbPhysX, lbPhysY);
|
||||
|
||||
var cellSurfaces = new List<AcDream.Core.Physics.CellSurface>();
|
||||
var portalPlanes = new List<AcDream.Core.Physics.PortalPlane>();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue