world_interior_names: keep points on a rotated room face inside

A point exactly on a room face can land 3e-16 m outside after the inverse
rotation (review on #3813: +90 degrees about X, scale XY 1.5 / Z -2), and
the exact-zero test dropped it. Room containment now allows 1e-6 m. The
full levels.rpf v1.0.2.1 counts are unchanged (215 stored, 484 conjugated).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mast3rL
2026-11-22 18:46:07 -05:00
parent fcfed3996b
commit d90c1acf0e
2 changed files with 13 additions and 1 deletions

View File

@ -211,6 +211,17 @@ class ResolveTest(unittest.TestCase):
self.assertEqual(rows[KEY_A]["outside_box_m_conjugate"], [0.0, 0.5])
self.assertEqual(s["positions_in_a_room_box"], {"stored": 1, "conjugate": 1})
def test_room_face_after_rotation_counts(self):
# Review case on fcfed39: +90 degrees about X stored as float32, scale XY 1.5 and Z -2. The room's upper
# world Z face is 30.75; the inverse rotation puts a point on it at local Y 0.7500000000000003.
q = struct.unpack("<4f", struct.pack("<4f", S, 0.0, 0.0, S))
d = {"name": HA, "keys": {}, "bb_min": [1.0, -2.0, 0.0], "bb_max": [4.0, 1.0, 3.0],
"rooms": [[J("a"), [2.0, -1.0, 0.5], [3.0, 0.5, 2.0], 0]]}
p = {"archetype": HA, "position": [10.0, 20.0, 30.0], "rotation": list(q), "scale_xy": 1.5, "scale_z": -2.0}
for z, hits in ((30.749, 1), (30.75, 1), (30.751, 0)):
s, _ = T.resolve({KEY_A: [[13.75, 22.5, z]]}, {0: ([d], [p])})
self.assertEqual(s["positions_in_a_room_box"]["stored"], hits, z)
def test_scaled_box_negative_and_missing_scale(self):
lo, hi = [-1.0, -2.0, 0.0], [3.0, 2.0, 4.0]
self.assertEqual(T._scaled(lo, hi, {"scale_xy": -2.0, "scale_z": 0.5}), ([-6.0, -4.0, 0.0], [2.0, 4.0, 2.0]))

View File

@ -57,6 +57,7 @@ LIMBO = joaat("limbo")
ROOM_KEY = 0xA261E0A9 # a room's hash member that holds an interior key's joaat
OVERLAP = 64 << 20 # a worker reads this far past its window so a resource that straddles the edge is whole
THRESHOLDS = (0, 1, 2, 5, 10, 25, 100)
ROOM_EPS = 1e-6 # metres; a point on a room face stays inside despite the rounding of the inverse rotation
def _vec3(b, base, member):
@ -289,7 +290,7 @@ def resolve(names, found, duplicate_keys=0):
for q in positions:
locs = [(_local(q, p["position"], r), p) for p, r in placed]
out.append(min(_outside(v, *_scaled(lo, hi, p)) for v, p in locs))
if any(rn != LIMBO and rlo and rhi and _outside(v, *_scaled(rlo, rhi, p)) == 0.0
if any(rn != LIMBO and rlo and rhi and _outside(v, *_scaled(rlo, rhi, p)) <= ROOM_EPS
for v, p in locs for rn, rlo, rhi, _ in d["rooms"]):
summary["positions_in_a_room_box"][tag] += 1
row["outside_box_m_" + tag] = [round(x, 3) for x in out]