Skip to content

Commit

Permalink
Added Terrain to add entity menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
MStachowicz committed Mar 14, 2024
1 parent 1573ee4 commit 8deba66
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion source/UI/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ namespace UI
Component::Collider{});
}
}
if (ImGui::Button("Light"))
else if (ImGui::Button("Light"))
{
const auto& view_info = m_scene_system.get_current_scene_view_info();
auto cursor_ray = Utility::get_cursor_ray(m_input.cursor_position(), m_window.size(), view_info.m_view_position, view_info.m_projection, view_info.m_view);
Expand All @@ -583,6 +583,19 @@ namespace UI
Component::PointLight{intersection.value()});
}
}
else if (ImGui::Button("Terrain"))
{
const auto& view_info = m_scene_system.get_current_scene_view_info();
auto cursor_ray = Utility::get_cursor_ray(m_input.cursor_position(), m_window.size(), view_info.m_view_position, view_info.m_projection, view_info.m_view);
auto floor_plane = Geometry::Plane{glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)};

if (auto intersection = Geometry::get_intersection(cursor_ray, floor_plane))
{
m_scene_system.get_current_scene_entities().add_entity(
Component::Label{"Terrain"},
Component::Terrain{10, 10});
}
}

ImGui::EndMenu();
}
Expand Down

0 comments on commit 8deba66

Please sign in to comment.