Finish Gizmos
This commit is contained in:
parent
0c52643b11
commit
491d7d3094
3 changed files with 209 additions and 2215 deletions
2378
Data/sandbox-log.txt
2378
Data/sandbox-log.txt
File diff suppressed because it is too large
Load diff
|
@ -108,6 +108,11 @@ void Editor::RenderStem(kp3d::Vec3 position)
|
|||
Renderer3D::DrawBillboard(m_stem, {position.x, position.y + size.y * 0.5f, position.z}, size);
|
||||
}
|
||||
|
||||
void Editor::RebuildMap()
|
||||
{
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
}
|
||||
|
||||
void Editor::UpdateModeBuild()
|
||||
{
|
||||
if (sandbox->IsMouseButtonDown(kp3d::MOUSE_BUTTON_LEFT))
|
||||
|
@ -138,7 +143,7 @@ void Editor::UpdateModeBuild()
|
|||
}
|
||||
|
||||
sandbox->map.sectors.push_back(s);
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
|
||||
points.clear();
|
||||
}
|
||||
|
@ -190,7 +195,7 @@ void Editor::UpdateModeBuild()
|
|||
}
|
||||
|
||||
sandbox->map.sectors.push_back(s);
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
points.clear();
|
||||
has_start_pos = false;
|
||||
}
|
||||
|
@ -324,16 +329,32 @@ void Editor::UpdateModeNormal()
|
|||
(info.sector->floor.base_height + info.sector->ceiling.base_height) * 0.5f,
|
||||
-info.wall->start.y};
|
||||
wall_update.main_wall = info.wall;
|
||||
wall_update.walls_to_update.emplace(&neighbor, WP_END);
|
||||
//wall_update.walls_to_update.emplace(&neighbor, WP_END);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const auto& sp: sandbox->map.sectors)
|
||||
{
|
||||
if (sp.get() == info.sector)
|
||||
continue;
|
||||
//if (sp.get() == info.sector)
|
||||
// continue;
|
||||
for (int i = 0; i < sp->walls.size(); i++)
|
||||
{
|
||||
const float E = 4.0f / 128.0f;
|
||||
Wall& wall = sp->walls[i];
|
||||
Wall& neighbor_l = sp->walls[(i - 1) % sp->walls.size()];
|
||||
Wall& neighbor_r = sp->walls[(i + 1) % sp->walls.size()];
|
||||
if (FloatCmp(wall.start.x, wall_update.main_wall->start.x, E) &&
|
||||
FloatCmp(wall.start.y, wall_update.main_wall->start.y, E))
|
||||
{
|
||||
wall_update.walls_to_update.emplace(&wall, WP_START);
|
||||
// wall_update.walls_to_update.emplace(&neighbor_l, WP_END);
|
||||
}
|
||||
else if (FloatCmp(wall.end.x, wall_update.main_wall->start.x, E) &&
|
||||
FloatCmp(wall.end.y, wall_update.main_wall->start.y, E))
|
||||
{
|
||||
wall_update.walls_to_update.emplace(&wall, WP_END);
|
||||
// wall_update.walls_to_update.emplace(&neighbor_r, WP_START);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -383,6 +404,8 @@ void Editor::RenderModeNormal()
|
|||
nullptr
|
||||
);
|
||||
editing_gizmo = v;
|
||||
if (v)
|
||||
kp3d::editor_hovered_batch.clear();
|
||||
|
||||
float translation[3];
|
||||
float rotation[3];
|
||||
|
@ -413,7 +436,7 @@ void Editor::RenderModeNormal()
|
|||
|
||||
if (v)
|
||||
{
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +523,7 @@ void Editor::RenderUI()
|
|||
changed |= ImGui::InputFloat("Ceiling height", &info.sector->ceiling.base_height);
|
||||
changed |= ImGui::Checkbox("Inverted", &info.sector->inverted);
|
||||
if (changed)
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
ImGui::SeparatorText("Materials");
|
||||
RenderUIMaterialSelect("Floor", MAT_FLOOR_TEX, &info.sector->floor.material);
|
||||
RenderUIMaterialSelect("Ceiling", MAT_CEILING_TEX, &info.sector->ceiling.material);
|
||||
|
@ -699,14 +722,14 @@ void Editor::RenderUIMaterialModal()
|
|||
m_materials_to_update.clear();
|
||||
ImGui::CloseCurrentPopup();
|
||||
should_show_material_modal = false;
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
}
|
||||
|
||||
if (should_close)
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
should_show_material_modal = false;
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
}
|
||||
|
||||
if (should_update_texture)
|
||||
|
@ -716,7 +739,7 @@ void Editor::RenderUIMaterialModal()
|
|||
m_materials_to_update.clear();
|
||||
ImGui::CloseCurrentPopup();
|
||||
should_show_material_modal = false;
|
||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
||||
RebuildMap();
|
||||
}
|
||||
|
||||
ImGui::EndPopup();
|
||||
|
@ -738,7 +761,7 @@ void Editor::OnScrollWheel(const kp3d::ScrollWheelEvent* e)
|
|||
if (info.flat)
|
||||
{
|
||||
info.flat->base_height += factor;
|
||||
sandbox->map.Rebuild(GEN_NORMALS);
|
||||
RebuildMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
void Update();
|
||||
void RenderMap();
|
||||
void RenderStem(kp3d::Vec3 position);
|
||||
void RebuildMap();
|
||||
|
||||
void UpdateModeBuild();
|
||||
void RenderModeBuild();
|
||||
|
|
Loading…
Reference in a new issue