diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-06-10 10:57:53 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-06-10 10:57:53 +0200 |
commit | 411b53fd96b3e43960fcd1bf4bfeefe4c5e2f164 (patch) | |
tree | b56da1aee8a89e0582b81bf85098c06f837fc6ed /editor | |
parent | bb70c67f77fbd3a8d1af5d73bad27acf1b986fc6 (diff) |
wip
Diffstat (limited to 'editor')
-rw-r--r-- | editor/app.cpp | 1 | ||||
-rw-r--r-- | editor/app.hpp | 4 | ||||
-rw-r--r-- | editor/imgui.cpp | 42 |
3 files changed, 47 insertions, 0 deletions
diff --git a/editor/app.cpp b/editor/app.cpp index f988f230..fa1c9b76 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -78,6 +78,7 @@ void app::reset_world(struct world&& w_) _editor.on_release(); _editor.clear_selection(); kill_popups(true); + _tested_light = 0; clear_keys(); const auto pixel = cursor.pixel; diff --git a/editor/app.hpp b/editor/app.hpp index b739d34c..37cdcccf 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -114,6 +114,8 @@ private: void draw_collision_boxes(); void draw_clickables(); void draw_light_info(); + void draw_lightmap_test(); + void draw_editor_pane(float main_menu_height); void draw_inspector(); bool check_inspector_exists(const popup_target& p); @@ -159,6 +161,8 @@ private: cursor_state cursor; popup_target _popup_target; + object_id _tested_light = 0; + int8_t _z_level = 0; bool _pending_popup : 1 = false; diff --git a/editor/imgui.cpp b/editor/imgui.cpp index df75501a..5b02d134 100644 --- a/editor/imgui.cpp +++ b/editor/imgui.cpp @@ -4,6 +4,7 @@ #include "src/world.hpp" #include "src/anim-atlas.hpp" #include "shaders/shader.hpp" +#include "shaders/lightmap.hpp" #include "main/clickable.hpp" #include "imgui-raii.hpp" #include "src/light.hpp" @@ -109,6 +110,8 @@ void app::draw_ui() draw_clickables(); if (_render_vobjs) draw_light_info(); + if (_tested_light) + draw_lightmap_test(); const float main_menu_height = draw_main_menu(); [[maybe_unused]] auto font = font_saver{ctx.FontSize*dpi}; @@ -197,6 +200,41 @@ void app::draw_light_info() } } +void app::draw_lightmap_test() +{ + fm_debug_assert(_tested_light != 0); + + ImGui::SetNextWindowSize({1024, 1024}); + + auto& w = M->world(); + auto L = w.find_entity(_tested_light); + + constexpr auto flags = + ImGuiWindowFlags_NoTitleBar | + ImGuiWindowFlags_NoResize | + ImGuiWindowFlags_NoMove | + ImGuiWindowFlags_NoScrollbar; + + if (L && ImGui::Begin("Lightmap", nullptr, flags)) + { + fm_assert(L->type() == entity_type::light); + auto& shader = M->lightmap_shader(); + light_s light { + .center = {8 * 64, 8 * 64}, + .dist = 4, + .color = {255, 255, 255}, + .falloff = light_falloff::linear, + }; + shader.begin({0, 0}, light); + shader.end(); + M->bind(); + ImGui::Image(&shader.texture(), {1024, 1024}); + ImGui::End(); + } + else + _tested_light = 0; +} + static constexpr auto SCENERY_POPUP_NAME = "##scenery-popup"_s; bool app::check_inspector_exists(const popup_target& p) @@ -244,6 +282,10 @@ void app::do_popup_menu() if (bool b_ins = !check_inspector_exists(_popup_target); ImGui::MenuItem("Inspect", nullptr, !b_ins, b_ins)) inspectors.push_back(std::exchange(_popup_target, {})); + if (bool b_testing = e.id == _tested_light; + e.type() == entity_type::light) + if (ImGui::MenuItem("Test", nullptr, b_testing)) + _tested_light = e.id; ImGui::SeparatorText("Modify"); if (auto next_rot = e.atlas->next_rotation_from(e.r); ImGui::MenuItem("Rotate", nullptr, false, next_rot != e.r && e.can_rotate(next_rot))) |