summaryrefslogtreecommitdiffhomepage
path: root/editor
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-08-23 18:54:45 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-08-23 19:24:39 +0200
commitd5c8c9ba44d0225a942ae70006dc40e8cd22c244 (patch)
tree0577e69e071aef5660993264df8c2648d16bdf1d /editor
parentf5308a69ecb6404b02ca8cae1a49711dfceb2c33 (diff)
wip
Diffstat (limited to 'editor')
-rw-r--r--editor/CMakeLists.txt10
-rw-r--r--editor/app.hpp2
-rw-r--r--editor/draw.cpp1
-rw-r--r--editor/imgui.cpp72
4 files changed, 49 insertions, 36 deletions
diff --git a/editor/CMakeLists.txt b/editor/CMakeLists.txt
index 372d9cd8..41173308 100644
--- a/editor/CMakeLists.txt
+++ b/editor/CMakeLists.txt
@@ -30,8 +30,8 @@ target_link_libraries(${self} PRIVATE ${self}_o floormat-main floormat-serialize
install(TARGETS ${self} RUNTIME DESTINATION bin)
-if(NOT MSVC)
- target_precompile_headers(${self}_o REUSE_FROM floormat)
-else()
- target_precompile_headers(${self}_o PRIVATE ../src/precomp.hpp)
-endif()
+#if(NOT MSVC)
+# target_precompile_headers(${self}_o REUSE_FROM floormat)
+#else()
+# target_precompile_headers(${self}_o PRIVATE ../src/precomp.hpp)
+#endif()
diff --git a/editor/app.hpp b/editor/app.hpp
index e0168d68..d3eded11 100644
--- a/editor/app.hpp
+++ b/editor/app.hpp
@@ -115,6 +115,7 @@ private:
void draw_clickables();
void draw_light_info();
void draw_lightmap_test();
+ void do_lightmap_test();
void draw_editor_pane(float main_menu_height);
void draw_inspector();
@@ -170,7 +171,6 @@ private:
bool _render_clickables : 1 = false;
bool _render_vobjs : 1 = true;
bool _render_all_z_levels : 1 = true;
- bool _testing_light : 1 = false;
};
} // namespace floormat
diff --git a/editor/draw.cpp b/editor/draw.cpp
index aa8cc5f0..f54d6b49 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -182,6 +182,7 @@ void app::draw_collision_boxes()
void app::draw()
{
+ do_lightmap_test();
if (_render_bboxes)
draw_collision_boxes();
if (_editor.current_tile_editor() ||
diff --git a/editor/imgui.cpp b/editor/imgui.cpp
index ea76cc76..5bb0ad67 100644
--- a/editor/imgui.cpp
+++ b/editor/imgui.cpp
@@ -8,6 +8,7 @@
#include "main/clickable.hpp"
#include "imgui-raii.hpp"
#include "src/light.hpp"
+#include <Magnum/GL/Renderer.h>
namespace floormat {
@@ -95,6 +96,8 @@ float app::draw_main_menu()
void app::draw_ui()
{
+ GL::Renderer::enable(GL::Renderer::Feature::ScissorTest);
+
const auto dpi = M->dpi_scale().min();
[[maybe_unused]] const auto style_ = style_saver{};
auto& style = ImGui::GetStyle();
@@ -114,8 +117,7 @@ void app::draw_ui()
[[maybe_unused]] auto font = font_saver{ctx.FontSize*dpi};
- if (_tested_light)
- draw_lightmap_test();
+ draw_lightmap_test();
if (_editor.current_tile_editor() || _editor.current_scenery_editor() || _editor.current_vobj_editor())
draw_editor_pane(main_menu_height);
@@ -127,6 +129,8 @@ void app::draw_ui()
draw_z_level();
do_popup_menu();
ImGui::EndFrame();
+
+ GL::Renderer::disable(GL::Renderer::Feature::ScissorTest);
}
void app::draw_clickables()
@@ -202,25 +206,22 @@ void app::draw_light_info()
}
}
-void app::draw_lightmap_test()
+void app::do_lightmap_test()
{
- fm_debug_assert(_tested_light != 0);
+ if (!_tested_light)
+ return;
- constexpr auto preview_size = ImVec2{512, 512};
- ImGui::SetNextWindowSize(preview_size);
+ //GL::Renderer::setScissor({{}, M->window_size()}); // FIXME
+ GL::Renderer::disable(GL::Renderer::Feature::ScissorTest);
auto& w = M->world();
auto e_ = w.find_entity(_tested_light);
- auto b1 = push_style_var(ImGuiStyleVar_WindowPadding, {0, 0});
-
- constexpr auto flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar;
- bool is_open = true;
-
- if (e_ && ImGui::Begin("Lightmap", &is_open, flags))
+ if (e_)
{
+ auto& e = *e_;
fm_assert(e_->type() == entity_type::light);
- const auto& li = static_cast<const light&>(*e_);
+ const auto& li = static_cast<const light&>(e);
light_s L {
.center = Vector2(li.coord.local()) * TILE_SIZE2 + Vector2(li.offset),
.dist = li.max_distance,
@@ -228,25 +229,36 @@ void app::draw_lightmap_test()
.falloff = li.falloff,
};
auto& shader = M->lightmap_shader();
- if (!_testing_light || true)
- {
- _testing_light = true;
- shader.begin_occlusion();
- shader.add_chunk(Vector2{}, e_->chunk()); // todo add neighbors
- shader.end_occlusion();
- shader.bind();
- shader.add_light(L);
- M->bind();
- }
- else
- _testing_light = false;
- //constexpr auto img_size = 1 / Vector2(lightmap_shader::max_chunks);
- ImGui::Image(&shader.scratch_texture(), preview_size, {0, 0}, {1, 1});
+ auto ch = Vector2(e.coord.chunk());
+ shader.begin_occlusion();
+ shader.add_chunk(ch, e.chunk()); // todo add neighbors
+ shader.end_occlusion();
+ shader.bind();
+ shader.add_light(ch, L);
M->bind();
}
- else
- _testing_light = false;
- ImGui::End();
+}
+
+void app::draw_lightmap_test()
+{
+ if (!_tested_light)
+ return;
+
+ auto& shader = M->lightmap_shader();
+ bool is_open = true;
+ constexpr auto preview_size = ImVec2{512, 512};
+
+ ImGui::SetNextWindowSize(preview_size);
+
+ auto b1 = push_style_var(ImGuiStyleVar_WindowPadding, {0, 0});
+ constexpr auto flags = ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoScrollbar;
+
+ //constexpr auto img_size = 1 / Vector2(lightmap_shader::max_chunks);
+ if (ImGui::Begin("Lightmap", &is_open, flags))
+ {
+ ImGui::Image(&shader.scratch_texture(), preview_size, {0, 0}, {1, 1});
+ ImGui::End();
+ }
if (!is_open)
_tested_light = 0;
}