diff --git a/psemek b/psemek index 4e9a551..4890761 160000 --- a/psemek +++ b/psemek @@ -1 +1 @@ -Subproject commit 4e9a551452952c95f98dc1ed96645d8208ec1649 +Subproject commit 4890761b0ae5de23bbd4f28faefd41de423f6512 diff --git a/source/application.cpp b/source/application.cpp index fdbbab7..ce9588f 100644 --- a/source/application.cpp +++ b/source/application.cpp @@ -9,10 +9,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -225,7 +225,7 @@ namespace gmtk return std::nullopt; } - geom::vector const neighbours[4] + math::vector const neighbours[4] { {1, 0}, {0, 1}, @@ -236,15 +236,15 @@ namespace gmtk struct location { int level; - geom::point coords; + math::point coords; - geom::point center() const + math::point center() const { float s = std::pow(3.f, -level); return {(coords[0] + 0.5f) * s, (coords[1] + 0.5f) * s}; } - geom::box bbox(float extra = 0.f) const + math::box bbox(float extra = 0.f) const { float s = std::pow(3.f, -level); return {{{(coords[0] - extra) * s, (coords[0] + 1.f + extra) * s}, {(coords[1] - extra) * s, (coords[1] + 1.f + extra) * s}}}; @@ -270,7 +270,7 @@ namespace gmtk return {level, {coords[0], coords[1] + 1}}; } - location moved(geom::vector const & delta) const + location moved(math::vector const & delta) const { return {level, coords + delta}; } @@ -282,7 +282,7 @@ namespace gmtk location up() const { - return {level - 1, {geom::idiv(coords[0], 3), geom::idiv(coords[1], 3)}}; + return {level - 1, {math::idiv(coords[0], 3), math::idiv(coords[1], 3)}}; } friend bool operator == (location const & x, location const & y) = default; @@ -371,12 +371,12 @@ namespace gmtk float state = 0.f; }; - geom::point position(ecs::container & world, item const & i) + math::point position(ecs::container & world, item const & i) { if (i.target) { auto end = world.get(i.target).get().location; - return geom::lerp(i.start.center(), end.center(), i.state); + return math::lerp(i.start.center(), end.center(), i.state); } else return i.start.center(); @@ -387,7 +387,7 @@ namespace gmtk if (i.target) { auto end = world.get(i.target).get().location; - return 3.f * std::pow(3.f, -geom::lerp(i.start.level, end.level, i.state)); + return 3.f * std::pow(3.f, -math::lerp(i.start.level, end.level, i.state)); } else return 3.f * std::pow(3.f, -i.start.level); @@ -406,10 +406,10 @@ namespace gmtk int s = std::pow(3, l.level - tile.level); - geom::interval xrange{tile.coords[0] * s, (tile.coords[0] + 1) * s - 1}; - geom::interval yrange{tile.coords[1] * s, (tile.coords[1] + 1) * s - 1}; + math::interval xrange{tile.coords[0] * s, (tile.coords[0] + 1) * s - 1}; + math::interval yrange{tile.coords[1] * s, (tile.coords[1] + 1) * s - 1}; - return geom::contains(xrange, l.coords[0]) && geom::contains(yrange, l.coords[1]); + return math::contains(xrange, l.coords[0]) && math::contains(yrange, l.coords[1]); } struct lab @@ -967,7 +967,7 @@ namespace gmtk return result; } - void draw_grid(geom::box const & box, float view_level, gfx::painter & painter, bool solid = false) + void draw_grid(math::box const & box, float view_level, gfx::painter & painter, bool solid = false) { float const grid_width = 0.025f * std::min(box[0].length() / 3.f, std::pow(3.f, -1.f - view_level)); @@ -999,7 +999,7 @@ namespace gmtk } } - void draw_item(resource_type const & type, geom::point const & pos, float scale, gfx::painter & painter, bool selected = false, int opacity = 255) + void draw_item(resource_type const & type, math::point const & pos, float scale, gfx::painter & painter, bool selected = false, int opacity = 255) { auto color = color_of(type); gfx::color_rgba bcolor = selected ? gfx::white : gfx::black; @@ -1015,9 +1015,9 @@ namespace gmtk break; case shape_type::square: { - auto box = geom::expand(geom::box::singleton(pos), 0.075f * scale); + auto box = math::expand(math::box::singleton(pos), 0.075f * scale); painter.rect(box, bcolor); - box = geom::shrink(box, 0.025f * scale); + box = math::shrink(box, 0.025f * scale); painter.rect(box, color); } break; @@ -1029,9 +1029,9 @@ namespace gmtk auto c = (i == 0) ? bcolor : color; for (int j = 0; j < 6; ++j) { - float a = geom::rad(j * 60.f); - float b = geom::rad((j + 1) * 60.f); - painter.triangle(pos, pos + geom::direction(a) * r, pos + geom::direction(b) * r, c); + float a = math::rad(j * 60.f); + float b = math::rad((j + 1) * 60.f); + painter.triangle(pos, pos + math::direction(a) * r, pos + math::direction(b) * r, c); } } } @@ -1041,19 +1041,19 @@ namespace gmtk float animation_factor(float animate) { - static geom::gradient const g + static math::gradient const g { std::pair{0.5f, 0.f}, - geom::easing_type::cubic, + math::easing_type::cubic, std::pair{0.875f, 1.f}, - geom::easing_type::cubic, + math::easing_type::cubic, std::pair{1.f, 0.f}, }; return g(animate); } - void draw_structure(geom::box const & bbox, transformer const & t, gfx::painter & painter) + void draw_structure(math::box const & bbox, transformer const & t, gfx::painter & painter) { switch (t.type) { @@ -1061,7 +1061,7 @@ namespace gmtk { float an = animation_factor(t.animate); - auto box = geom::shrink(bbox, bbox[0].length() * 0.2f); + auto box = math::shrink(bbox, bbox[0].length() * 0.2f); float r1 = std::sqrt(2.f) * (2.f + 2.f * an) / 16.f * box[0].length(); float r2 = std::sqrt(2.f) * (4.f + 2.f * an) / 16.f * box[0].length(); @@ -1069,9 +1069,9 @@ namespace gmtk float s = bbox[0].length() * 0.025f; float t = 0.6f * s; - box = geom::expand(box, an * box[0].length() * 0.125f); + box = math::expand(box, an * box[0].length() * 0.125f); - geom::point points[] + math::point points[] { box.corner(0.f, 0.75f), box.corner(0.f, 0.25f), @@ -1083,7 +1083,7 @@ namespace gmtk box.corner(0.25f, 1.f), }; - static geom::triangle const triangles[] + static math::triangle const triangles[] { {0, 1, 2}, {0, 2, 3}, @@ -1099,14 +1099,14 @@ namespace gmtk if (i == 1) { - points[0] += geom::vector{ s, -t}; - points[1] += geom::vector{ s, t}; - points[2] += geom::vector{ t, s}; - points[3] += geom::vector{-t, s}; - points[4] += geom::vector{-s, t}; - points[5] += geom::vector{-s, -t}; - points[6] += geom::vector{-t, -s}; - points[7] += geom::vector{ t, -s}; + points[0] += math::vector{ s, -t}; + points[1] += math::vector{ s, t}; + points[2] += math::vector{ t, s}; + points[3] += math::vector{-t, s}; + points[4] += math::vector{-s, t}; + points[5] += math::vector{-s, -t}; + points[6] += math::vector{-t, -s}; + points[7] += math::vector{ t, -s}; } for (auto const & t : triangles) @@ -1123,21 +1123,21 @@ namespace gmtk for (int i = 0; i < 4; ++i) { - auto d = geom::direction(geom::rad(45.f + 90.f * i)); + auto d = math::direction(math::rad(45.f + 90.f * i)); painter.line(c + d * r1, c + d * r2, s, gfx::black, true); } } break; case transformer_type::reshaper: { - auto box = geom::shrink(bbox, bbox[0].length() * 0.2f); + auto box = math::shrink(bbox, bbox[0].length() * 0.2f); float s = bbox[0].length() * 0.025f; // for (int k = 0; k < 2; ++k) for (int k = 1; k < 2; ++k) { - geom::point points[] + math::point points[] { box.corner(0.f, 1.f), box.corner(0.f, 0.75f), @@ -1147,7 +1147,7 @@ namespace gmtk box.corner(1.f, 1.f), }; - static geom::triangle const triangles[] + static math::triangle const triangles[] { {0, 1, 2}, {0, 2, 3}, @@ -1163,12 +1163,12 @@ namespace gmtk if (i == 1) { - points[0] += geom::vector{s, -s}; - points[1] += geom::vector{s, 0.6f * s}; - points[2] += geom::vector{0.6f * s, s}; - points[3] += geom::vector{- 0.6f * s, s}; - points[4] += geom::vector{-s, 0.6f * s}; - points[5] += geom::vector{-s, -s}; + points[0] += math::vector{s, -s}; + points[1] += math::vector{s, 0.6f * s}; + points[2] += math::vector{0.6f * s, s}; + points[3] += math::vector{- 0.6f * s, s}; + points[4] += math::vector{-s, 0.6f * s}; + points[5] += math::vector{-s, -s}; } for (int j = 0; j < 2; ++j) @@ -1198,9 +1198,9 @@ namespace gmtk if (k == 0) { - p0 = c + geom::ort(p0 - c); - p1 = c + geom::ort(p1 - c); - p2 = c + geom::ort(p2 - c); + p0 = c + math::ort(p0 - c); + p1 = c + math::ort(p1 - c); + p2 = c + math::ort(p2 - c); } painter.triangle(p0, p1, p2, color); @@ -1219,24 +1219,24 @@ namespace gmtk auto c = bbox.center(); - static geom::gradient const g + static math::gradient const g { std::pair{0.5f, 1.f}, - geom::easing_type::cubic, + math::easing_type::cubic, std::pair{1.f, 0.f}, }; - float offset = - g(t.animate) * geom::pi / 3.f; + float offset = - g(t.animate) * math::pi / 3.f; int n = 6; for (int i = 0; i < n; ++i) { - float a = (i * 2.f * geom::pi) / n + offset; - float b = ((i + 1) * 2.f * geom::pi) / n + offset; + float a = (i * 2.f * math::pi) / n + offset; + float b = ((i + 1) * 2.f * math::pi) / n + offset; - auto da = geom::direction(a); - auto db = geom::direction(b); + auto da = math::direction(a); + auto db = math::direction(b); painter.triangle(c + da * r2, c + db * r2, c + da * r1, gfx::white); painter.triangle(c + db * r2, c + da * r1, c + db * r1, gfx::white); @@ -1244,11 +1244,11 @@ namespace gmtk for (int i = 0; i < n; ++i) { - float a = (i * 2.f * geom::pi) / n + offset; - float b = ((i + 1) * 2.f * geom::pi) / n + offset; + float a = (i * 2.f * math::pi) / n + offset; + float b = ((i + 1) * 2.f * math::pi) / n + offset; - auto da = geom::direction(a); - auto db = geom::direction(b); + auto da = math::direction(a); + auto db = math::direction(b); painter.line(c + da * r1, c + db * r1, s, gfx::black, false); painter.line(c + da * r2, c + db * r2, s, gfx::black, false); @@ -1261,10 +1261,10 @@ namespace gmtk } } - void draw_structure(geom::box const & bbox, crossing const &, gfx::painter & painter) + void draw_structure(math::box const & bbox, crossing const &, gfx::painter & painter) { - auto wbox = geom::shrink(bbox, bbox[0].length() * 0.1f); - auto sbox = geom::shrink(bbox, bbox[0].length() * 0.3f); + auto wbox = math::shrink(bbox, bbox[0].length() * 0.1f); + auto sbox = math::shrink(bbox, bbox[0].length() * 0.3f); gfx::color_rgba color{64, 64, 64, 255}; @@ -1272,7 +1272,7 @@ namespace gmtk painter.rect({sbox[0], wbox[1]}, color); } - void draw_card(geom::box const & bbox, card_type type, gfx::painter & painter, float animation = 0.f) + void draw_card(math::box const & bbox, card_type type, gfx::painter & painter, float animation = 0.f) { switch (type) { @@ -1347,11 +1347,11 @@ namespace gmtk { auto q = map.world->get(b).get().location; - geom::vector d = q.center() - vertex.location.center(); + math::vector d = q.center() - vertex.location.center(); auto c = vertex.location.center() + d / 2.f; - auto n = geom::ort(d); + auto n = math::ort(d); float s = 1.f / 6.f; @@ -1367,7 +1367,7 @@ namespace gmtk map.world->apply([&](vertex const & v, source const & s) { - geom::vector shift{0.f, 0.f}; + math::vector shift{0.f, 0.f}; if (v.location.coords[0] < 0) shift = {1.f, 0.f}; else if (v.location.coords[0] >= 3) @@ -1385,15 +1385,15 @@ namespace gmtk map.world->apply([&](vertex const & v, transformer const & t) { auto box = v.location.bbox(); - // box = geom::expand(box, 0.125f * animation_factor(t.animate) * box[0].length()); + // box = math::expand(box, 0.125f * animation_factor(t.animate) * box[0].length()); draw_structure(box, t, painter); }); map.world->apply([&](vertex const & v, lab const & l) { - geom::vector shift{1.f, -1.f}; + math::vector shift{1.f, -1.f}; - shift[0] *= v.location.bbox()[0].length() * geom::sqr(std::sin(l.animate_error * geom::pi)) * std::sin(l.animate_error * geom::pi * 5.f) / 12.f; + shift[0] *= v.location.bbox()[0].length() * math::sqr(std::sin(l.animate_error * math::pi)) * std::sin(l.animate_error * math::pi * 5.f) / 12.f; shift[1] *= v.location.bbox()[0].length() * animation_factor(l.animate) / 12.f; painter.rect(shift + v.location.bbox(-0.2f), {0, 0, 0, 255}); @@ -1408,7 +1408,7 @@ namespace gmtk int opacity = std::round(255 * (1.f - std::abs(i + map.stage_animation))); if (map.stage + i >= 1 && map.stage + i < std::size(stages)) - draw_item(stages[map.stage + i].type, pen + geom::vector{(i + map.stage_animation) * 40.f * ui_scale, 0.f}, 1.f, painter, false, opacity); + draw_item(stages[map.stage + i].type, pen + math::vector{(i + map.stage_animation) * 40.f * ui_scale, 0.f}, 1.f, painter, false, opacity); if (i == 0) { @@ -1426,7 +1426,7 @@ namespace gmtk }); } - void draw_selection(geom::box const & b, gfx::painter & painter, gfx::color_rgba const & color, bool solid = false) + void draw_selection(math::box const & b, gfx::painter & painter, gfx::color_rgba const & color, bool solid = false) { float w = b[0].length() * 0.05f; @@ -2094,12 +2094,12 @@ namespace gmtk auto from = view_transition_->old.bbox(1.f / 3.f); auto to = view_stack_.back().bbox(1.f / 3.f); - float t = geom::smoothstep(view_transition_->timer * 2.f); + float t = math::smoothstep(view_transition_->timer * 2.f); - view_box_[0].min = geom::lerp(from[0].min, to[0].min, t); - view_box_[0].max = geom::lerp(from[0].max, to[0].max, t); - view_box_[1].min = geom::lerp(from[1].min, to[1].min, t); - view_box_[1].max = geom::lerp(from[1].max, to[1].max, t); + view_box_[0].min = math::lerp(from[0].min, to[0].min, t); + view_box_[0].max = math::lerp(from[0].max, to[0].max, t); + view_box_[1].min = math::lerp(from[1].min, to[1].min, t); + view_box_[1].max = math::lerp(from[1].max, to[1].max, t); view_transition_->timer += frame_dt; if (view_transition_->timer >= 0.5f) @@ -2110,7 +2110,7 @@ namespace gmtk view_box_ = view_stack_.back().bbox(1.f / 3.f); } - view_box_[0] = geom::expand(view_box_[0], (view_box_[1].length() * aspect_ratio - view_box_[0].length()) / 2.f); + view_box_[0] = math::expand(view_box_[0], (view_box_[1].length() * aspect_ratio - view_box_[0].length()) / 2.f); update_selected(); @@ -2154,8 +2154,8 @@ namespace gmtk if (view_transition_) { - float t = geom::smoothstep(view_transition_->timer * 2.f); - view_level = geom::lerp(view_transition_->old.level, view_stack_.back().level, t); + float t = math::smoothstep(view_transition_->timer * 2.f); + view_level = math::lerp(view_transition_->old.level, view_stack_.back().level, t); } draw_grids(map_, view_level, painter_); @@ -2235,9 +2235,9 @@ namespace gmtk if (!in_menu()) { float w = (view_box_[0].length() - view_box_[1].length()) / 2.f; - geom::vector t{view_box_[1].length() / 5.f, 0.f}; - geom::vector d{w, 0.f}; - geom::vector n{w + t[0], 0.f}; + math::vector t{view_box_[1].length() / 5.f, 0.f}; + math::vector d{w, 0.f}; + math::vector n{w + t[0], 0.f}; auto p00 = view_box_.corner(0, 0); auto p01 = view_box_.corner(0, 1); @@ -2301,13 +2301,13 @@ namespace gmtk float const scale = std::pow(3.f, -1.f - view_level); float const step = 1.5f * scale / 9.f; - geom::point pen = view_box_.corner(0, 1) + geom::vector{9.f, -60.f} * ui_scale + geom::vector{step, - 3.f * step} / 2.f; + math::point pen = view_box_.corner(0, 1) + math::vector{9.f, -60.f} * ui_scale + math::vector{step, - 3.f * step} / 2.f; for (auto const & recipe : recipies.at(*shown_recipies)) { int i = 0; for (auto type : recipe.inputs) { - draw_item(type, pen + geom::vector{i * step, 0.f}, scale, painter_); + draw_item(type, pen + math::vector{i * step, 0.f}, scale, painter_); ++i; } @@ -2317,14 +2317,14 @@ namespace gmtk float t = 0.25f * std::sqrt(0.75f); painter_.triangle( - pen + geom::vector{(i - t) * step, -s * step}, - pen + geom::vector{(i - t) * step, s * step}, - pen + geom::vector{(i + t) * step, 0.f}, + pen + math::vector{(i - t) * step, -s * step}, + pen + math::vector{(i - t) * step, s * step}, + pen + math::vector{(i + t) * step, 0.f}, {192, 192, 192, 255} ); i = 4; - draw_item(recipe.output, pen + geom::vector{i * step, 0.f}, scale, painter_); + draw_item(recipe.output, pen + math::vector{i * step, 0.f}, scale, painter_); pen[1] -= step; } @@ -2336,7 +2336,7 @@ namespace gmtk { float const step = 0.5f * std::pow(3.f, - 1.f - view_level); - geom::point pen = view_box_.corner(1, 1) - geom::vector{step, step} / 2.f; + math::point pen = view_box_.corner(1, 1) - math::vector{step, step} / 2.f; if (map_.cards.size() > 1) for (auto type : card_type_values()) @@ -2344,12 +2344,12 @@ namespace gmtk if (!map_.cards.contains(type)) continue; - geom::box box{{{pen[0] - step, pen[0]}, {pen[1] - step, pen[1]}}}; + math::box box{{{pen[0] - step, pen[0]}, {pen[1] - step, pen[1]}}}; box[0] -= step * card_animation_[type].shift / 2.f; float animation = card_animation_[type].phase; - if (geom::contains(box, mouse_world_)) + if (math::contains(box, mouse_world_)) { selected_card_ = type; if (old_selected_card != type) @@ -2365,7 +2365,7 @@ namespace gmtk draw_card(box, type, painter_, 1.f - animation); if (map_.cards.at(type) < 1000) - painter_.text(box.center() - geom::vector{step, 0.f}, std::to_string(map_.cards.at(type)), {.scale = {ui_scale, -ui_scale}, .c = gfx::black}); + painter_.text(box.center() - math::vector{step, 0.f}, std::to_string(map_.cards.at(type)), {.scale = {ui_scale, -ui_scale}, .c = gfx::black}); pen[1] -= step; } @@ -2441,7 +2441,7 @@ namespace gmtk } { - geom::point pen = view_box_.corner(0, 1) + geom::vector{9.f, -12.f} * ui_scale; + math::point pen = view_box_.corner(0, 1) + math::vector{9.f, -12.f} * ui_scale; gfx::painter::text_options opts{.scale = {ui_scale, -ui_scale}, .x = gfx::painter::x_align::left, .y = gfx::painter::y_align::top, .c = gfx::black}; @@ -2474,7 +2474,7 @@ namespace gmtk if (!in_start_menu_) { - geom::point pen = view_box_.corner(0, 0) + geom::vector{9.f, 12.f} * ui_scale; + math::point pen = view_box_.corner(0, 0) + math::vector{9.f, 12.f} * ui_scale; gfx::color_rgba c{127, 127, 127, 255}; @@ -2483,7 +2483,7 @@ namespace gmtk .scale = {ui_scale, -ui_scale}, .x = gfx::painter::x_align::left, .y = gfx::painter::y_align::bottom, .c = c }; - painter_.text(pen + geom::vector{0.f, 16.f * ui_scale}, util::to_string("Level ", map_.stage, "/", std::size(stages) - 1), opts); + painter_.text(pen + math::vector{0.f, 16.f * ui_scale}, util::to_string("Level ", map_.stage, "/", std::size(stages) - 1), opts); painter_.text(pen, is_sandbox_mode_ ? "Sandbox" : is_challenge_mode_ ? "Challenge" : "Campaign", opts); } @@ -2500,11 +2500,11 @@ namespace gmtk float total_height = button_height * menu_buttons_.size() + button_spacing * (menu_buttons_.size() - 1.f); - auto pen = view_box_.center() + geom::vector{-button_width, total_height} / 2.f; + auto pen = view_box_.center() + math::vector{-button_width, total_height} / 2.f; for (int i = 0; i < menu_buttons_.size(); ++i) { - geom::box box; + math::box box; box[0] = {pen[0], pen[0] + button_width}; box[1] = {pen[1] - button_height, pen[1]}; @@ -2515,9 +2515,9 @@ namespace gmtk if (active) { - box = geom::expand(box, menu_buttons_[i].selected_state * 4.f * ui_scale); + box = math::expand(box, menu_buttons_[i].selected_state * 4.f * ui_scale); - if (geom::contains(box, mouse_world_)) + if (math::contains(box, mouse_world_)) { selected_button_ = i; if (old_selected_button != i) @@ -2533,7 +2533,7 @@ namespace gmtk text_color = {0, 0, 0, 255}; } - painter_.rect(geom::expand(box, ui_scale * 2.5f), text_color); + painter_.rect(math::expand(box, ui_scale * 2.5f), text_color); painter_.rect(box, bg_color); painter_.text(box.center(), menu_buttons_[i].text, {.scale = {ui_scale * 2.f, - ui_scale * 2.f}, .c = text_color}); @@ -2543,7 +2543,7 @@ namespace gmtk } } - painter_.render(geom::orthographic_camera{view_box_}.transform()); + painter_.render(math::orthographic_camera{view_box_}.transform()); } private: @@ -2695,9 +2695,9 @@ namespace gmtk util::clock<> clock_; float time_speed_ = 1.f; - geom::vector screen_size_{1, 1}; - geom::point mouse_{0, 0}; - geom::point mouse_world_{0, 0}; + math::vector screen_size_{1, 1}; + math::point mouse_{0, 0}; + math::point mouse_world_{0, 0}; bool item_killing_spree_ = false; gfx::painter painter_; @@ -2712,7 +2712,7 @@ namespace gmtk std::vector view_stack_; - geom::box view_box_; + math::box view_box_; std::optional selected_; std::optional belt_start_; @@ -2743,11 +2743,11 @@ namespace gmtk if (!in_menu() && !view_transition_) { - if (geom::contains(geom::shrink(view_box_[0], (view_box_[0].length() - view_box_[1].length()) / 2.f), mouse_world_[0])) + if (math::contains(math::shrink(view_box_[0], (view_box_[0].length() - view_box_[1].length()) / 2.f), mouse_world_[0])) map_.world->apply([&](ecs::handle entity, item const & i) { - auto box = geom::expand(geom::box::singleton(position(*map_.world, i)), scale(*map_.world, i) / 9.f); - if (geom::contains(box, mouse_world_)) + auto box = math::expand(math::box::singleton(position(*map_.world, i)), scale(*map_.world, i) / 9.f); + if (math::contains(box, mouse_world_)) selected_item_ = entity; }); @@ -2775,14 +2775,14 @@ namespace gmtk location p{1 + l.level, {std::floor(m[0]), std::floor(m[1])}}; - geom::interval xrange{3 * l.coords[0], 3 * l.coords[0] + 2}; - geom::interval yrange{3 * l.coords[1], 3 * l.coords[1] + 2}; - auto xwrange = geom::expand(xrange, 1); - auto ywrange = geom::expand(yrange, 1); + math::interval xrange{3 * l.coords[0], 3 * l.coords[0] + 2}; + math::interval yrange{3 * l.coords[1], 3 * l.coords[1] + 2}; + auto xwrange = math::expand(xrange, 1); + auto ywrange = math::expand(yrange, 1); - if (geom::contains(xrange, p.coords[0]) && geom::contains(yrange, p.coords[1])) + if (math::contains(xrange, p.coords[0]) && math::contains(yrange, p.coords[1])) selected_ = p; - else if (view_stack_.size() > 1 && within_grid(p) && ((geom::contains(xwrange, p.coords[0]) && geom::contains(yrange, p.coords[1])) || (geom::contains(xrange, p.coords[0]) && geom::contains(ywrange, p.coords[1])))) + else if (view_stack_.size() > 1 && within_grid(p) && ((math::contains(xwrange, p.coords[0]) && math::contains(yrange, p.coords[1])) || (math::contains(xrange, p.coords[0]) && math::contains(ywrange, p.coords[1])))) { selected_ = p; while (selected_->level > 0)