diff --git a/include/omath/hud/hud_renderer_interface.hpp b/include/omath/hud/hud_renderer_interface.hpp index 117cb7d..8d62532 100644 --- a/include/omath/hud/hud_renderer_interface.hpp +++ b/include/omath/hud/hud_renderer_interface.hpp @@ -18,8 +18,7 @@ namespace omath::hud virtual void add_polyline(const std::span>& vertexes, const Color& color, float thickness) = 0; - virtual void add_filled_polyline(const std::span>& vertexes, const Color& color, - float thickness) = 0; + virtual void add_filled_polyline(const std::span>& vertexes, const Color& color) = 0; virtual void add_rectangle(const Vector2& min, const Vector2& max, const Color& color) = 0; diff --git a/include/omath/hud/renderer_realizations/imgui_renderer.hpp b/include/omath/hud/renderer_realizations/imgui_renderer.hpp index cd4dbbe..5645de2 100644 --- a/include/omath/hud/renderer_realizations/imgui_renderer.hpp +++ b/include/omath/hud/renderer_realizations/imgui_renderer.hpp @@ -14,7 +14,7 @@ namespace omath::hud void add_line(const Vector2& line_start, const Vector2& line_end, const Color& color, float thickness) override; void add_polyline(const std::span>& vertexes, const Color& color, float thickness) override; - void add_filled_polyline(const std::span>& vertexes, const Color& color, float thickness) override; + void add_filled_polyline(const std::span>& vertexes, const Color& color) override; void add_rectangle(const Vector2& min, const Vector2& max, const Color& color) override; void add_filled_rectangle(const Vector2& min, const Vector2& max, const Color& color) override; void add_text(const Vector2& position, const Color& color, const std::string_view& text) override; diff --git a/source/hud/entity_overlay.cpp b/source/hud/entity_overlay.cpp index 7049508..073fffd 100644 --- a/source/hud/entity_overlay.cpp +++ b/source/hud/entity_overlay.cpp @@ -10,7 +10,9 @@ namespace omath::hud const auto points = m_canvas.as_array(); m_renderer->add_polyline({points.data(), points.size()}, box_color, thickness); - m_renderer->add_filled_polyline({points.data(), points.size()}, fill_color, thickness); + + if (fill_color.value().w > 0.f) + m_renderer->add_filled_polyline({points.data(), points.size()}, fill_color); } void EntityOverlay::add_cornered_2d_box(const Color& box_color, const Color& fill_color, const float corner_ratio_len, const float thickness) const @@ -173,11 +175,11 @@ namespace omath::hud } void EntityOverlay::add_centered_bottom_label(const Color& color, const float offset, const bool outlined, - const std::string_view& text) + const std::string_view& text) { const auto text_size = m_renderer->calc_text_size(text); - const auto box_center_x = m_canvas.bottom_left_corner.x - + (m_canvas.bottom_right_corner.x - m_canvas.bottom_left_corner.x) / 2.f; + const auto box_center_x = + m_canvas.bottom_left_corner.x + (m_canvas.bottom_right_corner.x - m_canvas.bottom_left_corner.x) / 2.f; const auto pos = Vector2{box_center_x - text_size.x / 2.f, m_text_cursor_bottom.y + offset}; if (outlined) @@ -192,8 +194,8 @@ namespace omath::hud const std::string_view& text) { const auto text_size = m_renderer->calc_text_size(text); - const auto box_center_x = m_canvas.top_left_corner.x - + (m_canvas.top_right_corner.x - m_canvas.top_left_corner.x) / 2.f; + const auto box_center_x = + m_canvas.top_left_corner.x + (m_canvas.top_right_corner.x - m_canvas.top_left_corner.x) / 2.f; m_text_cursor_top.y -= text_size.y; const auto pos = Vector2{box_center_x - text_size.x / 2.f, m_text_cursor_top.y - offset}; diff --git a/source/hud/renderer_realizations/imgui_renderer.cpp b/source/hud/renderer_realizations/imgui_renderer.cpp index ac5cadd..5d397d4 100644 --- a/source/hud/renderer_realizations/imgui_renderer.cpp +++ b/source/hud/renderer_realizations/imgui_renderer.cpp @@ -25,12 +25,10 @@ namespace omath::hud ImDrawFlags_Closed, thickness); } - void ImguiHudRenderer::add_filled_polyline(const std::span>& vertexes, const Color& color, - const float thickness) + void ImguiHudRenderer::add_filled_polyline(const std::span>& vertexes, const Color& color) { - ImGui::GetBackgroundDrawList()->AddPolyline(reinterpret_cast(vertexes.data()), - static_cast(vertexes.size()), color.to_im_color(), - ImDrawFlags_Closed, thickness); + ImGui::GetBackgroundDrawList()->AddConvexPolyFilled(reinterpret_cast(vertexes.data()), + static_cast(vertexes.size()), color.to_im_color()); } void ImguiHudRenderer::add_rectangle(const Vector2& min, const Vector2& max, const Color& color)