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);
|
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()
|
void Editor::UpdateModeBuild()
|
||||||
{
|
{
|
||||||
if (sandbox->IsMouseButtonDown(kp3d::MOUSE_BUTTON_LEFT))
|
if (sandbox->IsMouseButtonDown(kp3d::MOUSE_BUTTON_LEFT))
|
||||||
|
@ -138,7 +143,7 @@ void Editor::UpdateModeBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
sandbox->map.sectors.push_back(s);
|
sandbox->map.sectors.push_back(s);
|
||||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
RebuildMap();
|
||||||
|
|
||||||
points.clear();
|
points.clear();
|
||||||
}
|
}
|
||||||
|
@ -190,7 +195,7 @@ void Editor::UpdateModeBuild()
|
||||||
}
|
}
|
||||||
|
|
||||||
sandbox->map.sectors.push_back(s);
|
sandbox->map.sectors.push_back(s);
|
||||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
RebuildMap();
|
||||||
points.clear();
|
points.clear();
|
||||||
has_start_pos = false;
|
has_start_pos = false;
|
||||||
}
|
}
|
||||||
|
@ -324,16 +329,32 @@ void Editor::UpdateModeNormal()
|
||||||
(info.sector->floor.base_height + info.sector->ceiling.base_height) * 0.5f,
|
(info.sector->floor.base_height + info.sector->ceiling.base_height) * 0.5f,
|
||||||
-info.wall->start.y};
|
-info.wall->start.y};
|
||||||
wall_update.main_wall = info.wall;
|
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)
|
for (const auto& sp: sandbox->map.sectors)
|
||||||
{
|
{
|
||||||
if (sp.get() == info.sector)
|
//if (sp.get() == info.sector)
|
||||||
continue;
|
// continue;
|
||||||
for (int i = 0; i < sp->walls.size(); i++)
|
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
|
nullptr
|
||||||
);
|
);
|
||||||
editing_gizmo = v;
|
editing_gizmo = v;
|
||||||
|
if (v)
|
||||||
|
kp3d::editor_hovered_batch.clear();
|
||||||
|
|
||||||
float translation[3];
|
float translation[3];
|
||||||
float rotation[3];
|
float rotation[3];
|
||||||
|
@ -413,7 +436,7 @@ void Editor::RenderModeNormal()
|
||||||
|
|
||||||
if (v)
|
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::InputFloat("Ceiling height", &info.sector->ceiling.base_height);
|
||||||
changed |= ImGui::Checkbox("Inverted", &info.sector->inverted);
|
changed |= ImGui::Checkbox("Inverted", &info.sector->inverted);
|
||||||
if (changed)
|
if (changed)
|
||||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
RebuildMap();
|
||||||
ImGui::SeparatorText("Materials");
|
ImGui::SeparatorText("Materials");
|
||||||
RenderUIMaterialSelect("Floor", MAT_FLOOR_TEX, &info.sector->floor.material);
|
RenderUIMaterialSelect("Floor", MAT_FLOOR_TEX, &info.sector->floor.material);
|
||||||
RenderUIMaterialSelect("Ceiling", MAT_CEILING_TEX, &info.sector->ceiling.material);
|
RenderUIMaterialSelect("Ceiling", MAT_CEILING_TEX, &info.sector->ceiling.material);
|
||||||
|
@ -699,14 +722,14 @@ void Editor::RenderUIMaterialModal()
|
||||||
m_materials_to_update.clear();
|
m_materials_to_update.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
should_show_material_modal = false;
|
should_show_material_modal = false;
|
||||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
RebuildMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_close)
|
if (should_close)
|
||||||
{
|
{
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
should_show_material_modal = false;
|
should_show_material_modal = false;
|
||||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
RebuildMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (should_update_texture)
|
if (should_update_texture)
|
||||||
|
@ -716,7 +739,7 @@ void Editor::RenderUIMaterialModal()
|
||||||
m_materials_to_update.clear();
|
m_materials_to_update.clear();
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
should_show_material_modal = false;
|
should_show_material_modal = false;
|
||||||
sandbox->map.Rebuild(kp3d::GEN_NORMALS);
|
RebuildMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
|
@ -738,7 +761,7 @@ void Editor::OnScrollWheel(const kp3d::ScrollWheelEvent* e)
|
||||||
if (info.flat)
|
if (info.flat)
|
||||||
{
|
{
|
||||||
info.flat->base_height += factor;
|
info.flat->base_height += factor;
|
||||||
sandbox->map.Rebuild(GEN_NORMALS);
|
RebuildMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public:
|
||||||
void Update();
|
void Update();
|
||||||
void RenderMap();
|
void RenderMap();
|
||||||
void RenderStem(kp3d::Vec3 position);
|
void RenderStem(kp3d::Vec3 position);
|
||||||
|
void RebuildMap();
|
||||||
|
|
||||||
void UpdateModeBuild();
|
void UpdateModeBuild();
|
||||||
void RenderModeBuild();
|
void RenderModeBuild();
|
||||||
|
|
Loading…
Reference in a new issue