Fix portal indicator HUD not working through multiple doorways

* Doorway normals now always point toward room A. This was intended
  and code was written for it, but typos prevented it from working.
* Consistent doorway directions allowed resurrection of previous
  collisionSceneRaycastDoorways() implementation
This commit is contained in:
Matt Penny 2024-08-20 17:37:29 -04:00
parent e85ac2fdf1
commit d5a1c302b1
2 changed files with 12 additions and 8 deletions

View file

@ -402,8 +402,14 @@ int collisionSceneRaycastDoorways(struct CollisionScene* scene, struct Room* roo
}
if (raycastQuadShape(&doorway->quad, ray, roomDistance, &hitTest) && hitTest.distance < roomDistance) {
// Check that the doorway wasn't hit from the wrong side
int expectedRoom = vector3Dot(&doorway->quad.plane.normal, &hitTest.normal) < 0.0f ? doorway->roomA : doorway->roomB;
int otherRoom = currentRoom == doorway->roomA ? doorway->roomB : doorway->roomA;
if (expectedRoom == otherRoom) {
nextRoom = otherRoom;
roomDistance = hitTest.distance;
nextRoom = currentRoom == doorway->roomA ? doorway->roomB : doorway->roomA;
}
}
}

View file

@ -22,14 +22,12 @@ for doorway_index, doorway in pairs(sk_scene.nodes_for_type('@doorway')) do
local room_a = room_export.node_nearest_room_index(doorway.node, nil)
local room_b, room_b_bb = room_export.node_nearest_room_index(doorway.node, room_a)
if room_b_block then
local room_b_center = room_b_bb:lerp(0.5)
-- check if the doorway is facing room A
if (room_b_center - quad.corner):dot(quad.plane.normal > 0) then
-- Check if the doorway is facing room A
if (room_b_center - quad.corner):dot(quad.plane.normal) > 0 then
room_a, room_b = room_b, room_a
end
end
table.insert(room_doorways[room_a + 1], doorway_index - 1)
table.insert(room_doorways[room_b + 1], doorway_index - 1)