mirror of
https://github.com/mwpenny/portal64-still-alive.git
synced 2024-10-19 22:27:36 -04:00
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:
parent
e85ac2fdf1
commit
d5a1c302b1
|
@ -402,8 +402,14 @@ int collisionSceneRaycastDoorways(struct CollisionScene* scene, struct Room* roo
|
|||
}
|
||||
|
||||
if (raycastQuadShape(&doorway->quad, ray, roomDistance, &hitTest) && hitTest.distance < roomDistance) {
|
||||
roomDistance = hitTest.distance;
|
||||
nextRoom = currentRoom == doorway->roomA ? doorway->roomB : doorway->roomA;
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,13 +22,11 @@ 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)
|
||||
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
|
||||
room_a, room_b = room_b, room_a
|
||||
end
|
||||
-- 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
|
||||
|
||||
table.insert(room_doorways[room_a + 1], doorway_index - 1)
|
||||
|
|
Loading…
Reference in a new issue