diff options
-rw-r--r-- | editor/app.hpp | 1 | ||||
-rw-r--r-- | editor/imgui-editors.cpp | 12 | ||||
-rw-r--r-- | src/chunk-walls.cpp | 43 |
3 files changed, 19 insertions, 37 deletions
diff --git a/editor/app.hpp b/editor/app.hpp index 0d056558..8c8a522f 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -127,7 +127,6 @@ private: void draw_inspector(); static void entity_inspector_name(char* buf, size_t len, object_id id); bool check_inspector_exists(const popup_target& p); - void draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas); void draw_editor_scenery_pane(scenery_editor& ed); void draw_editor_vobj_pane(vobj_editor& ed); void set_cursor_from_imgui(); diff --git a/editor/imgui-editors.cpp b/editor/imgui-editors.cpp index 95e51667..8ba6aece 100644 --- a/editor/imgui-editors.cpp +++ b/editor/imgui-editors.cpp @@ -35,13 +35,10 @@ StringView scenery_type_to_string(const vobj_& vobj) { return vobj.name; } std::shared_ptr<anim_atlas> get_atlas(const vobj_& vobj) { return vobj.factory->atlas(); } StringView scenery_name(StringView, const vobj_& vobj) { return vobj.descr; } -} // namespace - -void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas) +void draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const std::shared_ptr<tile_atlas>& atlas, Vector2 dpi) { const auto b = push_id("tile-pane"); - const auto dpi = M->dpi_scale(); constexpr Color4 color_perm_selected{1, 1, 1, .7f}, color_selected{1, 0.843f, 0, .8f}, color_hover{0, .8f, 1, .7f}; @@ -108,9 +105,8 @@ void app::draw_editor_tile_pane_atlas(tile_editor& ed, StringView name, const st do_caption(); } - template<typename T> -static void impl_draw_editor_scenery_pane(T& ed, Vector2 dpi) +void impl_draw_editor_scenery_pane(T& ed, Vector2 dpi) { const auto b1 = push_id("scenery-pane"); @@ -192,6 +188,8 @@ static void impl_draw_editor_scenery_pane(T& ed, Vector2 dpi) template void impl_draw_editor_scenery_pane(scenery_editor&, Vector2); template void impl_draw_editor_scenery_pane(vobj_editor&, Vector2); +} // namespace + void app::draw_editor_scenery_pane(scenery_editor& ed) { impl_draw_editor_scenery_pane<scenery_editor>(ed, M->dpi_scale()); @@ -243,7 +241,7 @@ void app::draw_editor_pane(float main_menu_height) { if (ed) for (const auto& [k, v] : *ed) - draw_editor_tile_pane_atlas(*ed, k, v); + draw_editor_tile_pane_atlas(*ed, k, v, dpi); else if (sc) draw_editor_scenery_pane(*sc); else if (vo) diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp index aaba1201..8133f798 100644 --- a/src/chunk-walls.cpp +++ b/src/chunk-walls.cpp @@ -33,32 +33,6 @@ namespace { using Wall::Group_; using Wall::Direction_; -// ----------------------- - -constexpr Quads::quad get_corner(Direction_ D, Group_ G, float depth) -{ - CORRADE_ASSUME(D < Direction_::COUNT); - CORRADE_ASSUME(G < Group_::COUNT); - constexpr Vector2 half_tile = TILE_SIZE2*.5f; - constexpr float X = half_tile.x(), Y = half_tile.y(), Z = TILE_SIZE.z(); - const bool is_west = D == Wall::Direction_::W; - - if (!is_west) - return {{ - {-X, -Y, 0 }, - {-X, -Y, Z }, - {-X - depth, -Y, 0 }, - {-X - depth, -Y, Z }, - }}; - else - return {{ - {-X, -Y - depth, 0 }, - {-X, -Y - depth, Z }, - {-X, -Y, 0 }, - {-X, -Y, Z }, - }}; -} - constexpr Quads::quad get_quad(Direction_ D, Group_ G, float depth) { CORRADE_ASSUME(D < Direction_::COUNT); @@ -126,14 +100,25 @@ constexpr Quads::quad get_quad(Direction_ D, Group_ G, float depth) }}; } case corner: - return get_corner(D, G, depth); + if (!is_west) + return {{ + {-X, -Y, 0 }, + {-X, -Y, Z }, + {-X - depth, -Y, 0 }, + {-X - depth, -Y, Z }, + }}; + else + return {{ + {-X, -Y - depth, 0 }, + {-X, -Y - depth, Z }, + {-X, -Y, 0 }, + {-X, -Y, Z }, + }}; } std::unreachable(); fm_abort("invalid wall_atlas group '%d'", (int)G); } -// ----------------------- - Array<Quads::indexes> make_indexes_() { auto array = Array<Quads::indexes>{NoInit, chunk::max_wall_quad_count }; |