Skip to content

Commit

Permalink
Fix for room<=>door connection assert for complex floorplan office bu…
Browse files Browse the repository at this point in the history
…ildings where a door ends at a wall separating two rooms
  • Loading branch information
fegennari committed Apr 1, 2024
1 parent 1cf0275 commit 52d6e16
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/building_floorplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,15 @@ void building_interior_t::assign_door_conn_rooms(unsigned start_ds_ix) {
for (unsigned r = rooms_start; r < rooms_end; ++r) {
if (rooms[r].contains_pt(test_pt)) {ds_room_ix = r; break;}
}
assert(ds_room_ix >= 0); // adj room must be found
if (ds_room_ix == -1) { // adj room not found
// can only happen with complex floorplan buildings where a wall ends exactly at a doorway so that neither room contains the point
test_pt[!d->dim] = d->d[!d->dim][0]; // choose edge of door rather than center

for (unsigned r = rooms_start; r < rooms_end; ++r) {
if (rooms[r].contains_pt(test_pt)) {ds_room_ix = r; break;}
}
assert(ds_room_ix >= 0);
}
d->conn_room[s] = ds_room_ix;
} // for s
assert(d->conn_room[0] != d->conn_room[1]); // can't be connected to the same room on both sides
Expand Down

0 comments on commit 52d6e16

Please sign in to comment.