Add ability to remove walls
This commit is contained in:
parent
0b830d0e8d
commit
cc42b4ea87
2 changed files with 356 additions and 966 deletions
1278
Data/sandbox-log.txt
1278
Data/sandbox-log.txt
File diff suppressed because it is too large
Load diff
|
@ -353,15 +353,35 @@ void Editor::UpdateModeNormal()
|
||||||
if (info.wall)
|
if (info.wall)
|
||||||
{
|
{
|
||||||
// Remove a 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)
|
else if (info.sector)
|
||||||
{
|
{
|
||||||
// Remove a sector. We'll want to remove any portals first
|
// Remove a sector. We'll want to remove any portals first
|
||||||
for (const auto& sp : sandbox->map.sectors)
|
for (const auto& sp: sandbox->map.sectors)
|
||||||
{
|
{
|
||||||
if (sp.get() == info.sector)
|
if (sp.get() == info.sector)
|
||||||
continue;
|
continue;
|
||||||
for (auto& l : sp->walls)
|
for (auto& l: sp->walls)
|
||||||
{
|
{
|
||||||
if (l.portal == info.sector)
|
if (l.portal == info.sector)
|
||||||
{
|
{
|
||||||
|
@ -370,15 +390,18 @@ void Editor::UpdateModeNormal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sandbox->map.sectors.erase(std::remove_if(
|
sandbox->map.sectors.erase(
|
||||||
sandbox->map.sectors.begin(),
|
std::remove_if(
|
||||||
sandbox->map.sectors.end(),
|
sandbox->map.sectors.begin(),
|
||||||
[&](const auto& sp) { return sp.get() == info.sector; }
|
sandbox->map.sectors.end(),
|
||||||
), sandbox->map.sectors.end());
|
[&](const auto& sp) { return sp.get() == info.sector; }
|
||||||
|
),
|
||||||
RebuildMap();
|
sandbox->map.sectors.end()
|
||||||
kp3d::editor_hovered_batch.clear();
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RebuildMap();
|
||||||
|
kp3d::editor_hovered_batch.clear();
|
||||||
}
|
}
|
||||||
catch (std::bad_any_cast& e)
|
catch (std::bad_any_cast& e)
|
||||||
{
|
{
|
||||||
|
@ -456,7 +479,6 @@ void Editor::UpdateModeNormal()
|
||||||
wall_update.walls_to_update.emplace(&wall, WP_END);
|
wall_update.walls_to_update.emplace(&wall, WP_END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue