feat(physics #145): Slice 1 — Position/Frame types + LandDefs.GetBlockOffset (0x0043e630)
Introduces the two value types (Frame, Position) that represent retail's cell-relative position pair (acclient.h:30647/30658). Types are unused by consumers yet — zero behavior change. Also ports LandDefs::get_block_offset (pc:69189, @0x0043e630): world-meter offset between two named landblock ids, the ONLY cross-cell translation primitive in retail physics. Conformance tests: same-landblock→Zero, south-neighbour→(0,-192,0) (the exact #145 cascade cell), east-neighbour→(+192,0,0), diagonal→(+192,+192,0). 4/4 pass; full Core suite 1522 passed / 0 failed. DatFrame alias added to 4 files that had using DatReaderWriter.Types + using AcDream.Core.Physics in scope simultaneously. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ed32db70d7
commit
438bb681a5
8 changed files with 115 additions and 18 deletions
|
|
@ -141,6 +141,34 @@ public static class LandDefs
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <c>LandDefs::get_block_offset</c> (pc:69189, @0x0043e630): world-meter offset
|
||||
/// from <paramref name="source"/>'s landblock origin to <paramref name="dest"/>'s.
|
||||
/// ZeroVector when both ids share a landblock (high words equal). The decomp's
|
||||
/// <c>block_byte<<3</c> converts to lcoord (cell) units and the literal
|
||||
/// <c>·24 m/cell</c> then nets to <c>(Δlandblock)·192 m</c> per axis. The
|
||||
/// degenerate <c>arg==0</c> fallbacks are ported verbatim (dest==0 → raw source
|
||||
/// id; source==0 → 0 lcoord). The ONLY cross-cell translation in retail physics:
|
||||
/// a delta of two NAMED cell ids, never an accumulation against a moving center.
|
||||
/// </summary>
|
||||
public static Vector3 GetBlockOffset(uint source, uint dest)
|
||||
{
|
||||
uint srcBlock = source >> 16;
|
||||
uint dstBlock = dest >> 16;
|
||||
if (srcBlock == dstBlock)
|
||||
return Vector3.Zero;
|
||||
|
||||
int srcLx, srcLy;
|
||||
if (source == 0u) { srcLx = 0; srcLy = 0; }
|
||||
else { srcLx = (int)((source >> 21) & 0x7f8u); srcLy = (int)((srcBlock & 0xFFu) << 3); }
|
||||
|
||||
int dstLx, dstLy;
|
||||
if (dest == 0u) { dstLx = (int)source; dstLy = (int)source; } // retail degenerate guard
|
||||
else { dstLx = (int)((dest >> 21) & 0x7f8u); dstLy = (int)((dstBlock & 0xFFu) << 3); }
|
||||
|
||||
return new Vector3((dstLx - srcLx) * CellLength, (dstLy - srcLy) * CellLength, 0f);
|
||||
}
|
||||
|
||||
// Retail cell_in_range: landcell, envcell, or the block sentinel.
|
||||
private static bool CellLowInRange(uint low)
|
||||
=> low is (>= 1u and <= 0x40u) or (>= 0x100u and <= 0xFFFDu) or 0xFFFFu;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue