Add ability to remove walls

This commit is contained in:
KP 2024-07-31 00:33:14 -05:00
parent 0b830d0e8d
commit cc42b4ea87
2 changed files with 356 additions and 966 deletions

File diff suppressed because it is too large Load diff

View file

@ -353,6 +353,26 @@ void Editor::UpdateModeNormal()
if (info.wall)
{
// Remove a wall
// This is kinda risky, might wanna pop open a warning or make a backup or something LOL
for (const auto& sp : sandbox->map.sectors)
{
for (int i = 0; i < sp->walls.size(); i++)
{
Wall& wall = sp->walls[i];
Wall& neighbor = sp->walls[(i - 1) % sp->walls.size()];
if (&wall == info.wall)
neighbor.end = wall.end;
}
}
info.sector->walls.erase(
std::remove_if(
info.sector->walls.begin(),
info.sector->walls.end(),
[&](const auto& sp) { return &sp == info.wall; }
),
info.sector->walls.end()
);
}
else if (info.sector)
{
@ -370,16 +390,19 @@ void Editor::UpdateModeNormal()
}
}
}
sandbox->map.sectors.erase(std::remove_if(
sandbox->map.sectors.erase(
std::remove_if(
sandbox->map.sectors.begin(),
sandbox->map.sectors.end(),
[&](const auto& sp) { return sp.get() == info.sector; }
), sandbox->map.sectors.end());
),
sandbox->map.sectors.end()
);
}
RebuildMap();
kp3d::editor_hovered_batch.clear();
}
}
catch (std::bad_any_cast& e)
{
KP3D_LOG_ERROR("Bad any cast: {}", e.what());
@ -456,7 +479,6 @@ void Editor::UpdateModeNormal()
wall_update.walls_to_update.emplace(&wall, WP_END);
}
}
}
}
else