Add ability to remove sectors
This commit is contained in:
parent
e5a7498ef3
commit
0b830d0e8d
2 changed files with 997 additions and 980 deletions
1935
Data/sandbox-log.txt
1935
Data/sandbox-log.txt
File diff suppressed because it is too large
Load diff
|
@ -347,6 +347,44 @@ void Editor::UpdateModeNormal()
|
||||||
// Wall/sector remove
|
// Wall/sector remove
|
||||||
if (sandbox->IsKeyDown(kp3d::KEY_DELETE))
|
if (sandbox->IsKeyDown(kp3d::KEY_DELETE))
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const auto& info = std::any_cast<kp3d::BatchSectorInfo>(kp3d::editor_hovered_batch[0]->userdata);
|
||||||
|
if (info.wall)
|
||||||
|
{
|
||||||
|
// Remove a wall
|
||||||
|
}
|
||||||
|
else if (info.sector)
|
||||||
|
{
|
||||||
|
// Remove a sector. We'll want to remove any portals first
|
||||||
|
for (const auto& sp : sandbox->map.sectors)
|
||||||
|
{
|
||||||
|
if (sp.get() == info.sector)
|
||||||
|
continue;
|
||||||
|
for (auto& l : sp->walls)
|
||||||
|
{
|
||||||
|
if (l.portal == info.sector)
|
||||||
|
{
|
||||||
|
l.portal = nullptr;
|
||||||
|
l.materials[TEX_FRONT] = l.materials[TEX_UPPER];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
|
||||||
|
RebuildMap();
|
||||||
|
kp3d::editor_hovered_batch.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (std::bad_any_cast& e)
|
||||||
|
{
|
||||||
|
KP3D_LOG_ERROR("Bad any cast: {}", e.what());
|
||||||
|
kp3d::editor_hovered_batch.clear();
|
||||||
|
}
|
||||||
sandbox->KeyReset(kp3d::KEY_DELETE);
|
sandbox->KeyReset(kp3d::KEY_DELETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +392,10 @@ void Editor::UpdateModeNormal()
|
||||||
if (sandbox->IsMouseButtonDown(kp3d::MOUSE_BUTTON_MIDDLE))
|
if (sandbox->IsMouseButtonDown(kp3d::MOUSE_BUTTON_MIDDLE))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editing_gizmo)
|
if (editing_gizmo)
|
||||||
|
|
Loading…
Reference in a new issue