fix: remove X mirror, fix rotation float tolerance
UB mirrors both cell positions and player position within layer space, so relative offset is direct (mirrors cancel out). Removed X negation. Added float tolerance for rotation quaternion W component comparison (was using strict equality which fails on floating point values). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b067a148f3
commit
8d2e74397b
1 changed files with 8 additions and 5 deletions
|
|
@ -3858,8 +3858,10 @@ function updateRadarWindow(msg) {
|
||||||
const hasTiles = dungeonTileCanvases && Object.keys(dungeonTileCanvases).length > 0;
|
const hasTiles = dungeonTileCanvases && Object.keys(dungeonTileCanvases).length > 0;
|
||||||
|
|
||||||
// Normalize rotation value to radians (same as UB's DungeonCell.cs)
|
// Normalize rotation value to radians (same as UB's DungeonCell.cs)
|
||||||
|
// Raw value is quaternion W component: 1→180°, ~0.707→-90°, ~-0.707→90°, 0→0°
|
||||||
function cellRotation(rot) {
|
function cellRotation(rot) {
|
||||||
if (rot === 1) return Math.PI;
|
if (Math.abs(rot - 1) < 0.01) return Math.PI;
|
||||||
|
if (Math.abs(rot + 1) < 0.01) return Math.PI;
|
||||||
if (rot < -0.70 && rot > -0.8) return Math.PI / 2;
|
if (rot < -0.70 && rot > -0.8) return Math.PI / 2;
|
||||||
if (rot > 0.70 && rot < 0.8) return -Math.PI / 2;
|
if (rot > 0.70 && rot < 0.8) return -Math.PI / 2;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -3877,8 +3879,9 @@ function updateRadarWindow(msg) {
|
||||||
ctx.globalAlpha = isCurrentFloor ? 0.85 : 0.12;
|
ctx.globalAlpha = isCurrentFloor ? 0.85 : 0.12;
|
||||||
|
|
||||||
(level.cells || []).forEach(cell => {
|
(level.cells || []).forEach(cell => {
|
||||||
// UB mirrors X, Y flipped for north-up (AC Y+ = north, canvas Y+ = down)
|
// Direct relative position (UB mirrors both cell and player, cancels out)
|
||||||
const dx = -(cell.x - playerX) * scale;
|
// Y negated for north-up (AC Y+ = north, canvas Y+ = down)
|
||||||
|
const dx = (cell.x - playerX) * scale;
|
||||||
const dy = -(cell.y - playerY) * scale;
|
const dy = -(cell.y - playerY) * scale;
|
||||||
const tileCanvas = hasTiles ? dungeonTileCanvases[String(cell.env_id)] : null;
|
const tileCanvas = hasTiles ? dungeonTileCanvases[String(cell.env_id)] : null;
|
||||||
|
|
||||||
|
|
@ -3976,7 +3979,7 @@ function updateRadarWindow(msg) {
|
||||||
// Use raw physics coords in dungeons (X mirrored), EW/NS on surface
|
// Use raw physics coords in dungeons (X mirrored), EW/NS on surface
|
||||||
let dX, dY;
|
let dX, dY;
|
||||||
if (isDungeon && obj.raw_x !== undefined) {
|
if (isDungeon && obj.raw_x !== undefined) {
|
||||||
dX = -(obj.raw_x - playerX); // X mirrored
|
dX = (obj.raw_x - playerX);
|
||||||
dY = -(obj.raw_y - playerY); // Y flipped for north-up
|
dY = -(obj.raw_y - playerY); // Y flipped for north-up
|
||||||
} else {
|
} else {
|
||||||
dX = obj.ew - playerEW;
|
dX = obj.ew - playerEW;
|
||||||
|
|
@ -4039,7 +4042,7 @@ function updateRadarWindow(msg) {
|
||||||
const withDist = objects.map(obj => {
|
const withDist = objects.map(obj => {
|
||||||
let distMeters, dX, dY;
|
let distMeters, dX, dY;
|
||||||
if (isDungeon && obj.raw_x !== undefined) {
|
if (isDungeon && obj.raw_x !== undefined) {
|
||||||
dX = -(obj.raw_x - playerX);
|
dX = (obj.raw_x - playerX);
|
||||||
dY = -(obj.raw_y - playerY);
|
dY = -(obj.raw_y - playerY);
|
||||||
distMeters = Math.sqrt(dX * dX + dY * dY); // raw coords are ~meters
|
distMeters = Math.sqrt(dX * dX + dY * dY); // raw coords are ~meters
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue