From 8ed34af6f8a8ece92c2f122667eaf1af6d828278 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 11 Mar 2021 10:29:13 +0100 Subject: [PATCH] ImDrawList: clarified that PathArcTo()/PathArcToFast() cannot take radius < 0.0f. (#3491) + changed poor-man ceiling in _CalcCircleAutoSegmentCount() to use 0.999999f to reduce gaps Previously it sorts of accidentally worked but would lead to counter-clockwise paths which and have an effect on anti-aliasing. --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 1 + imgui_draw.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 1571e8bb4..9cbe13d8e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -42,6 +42,8 @@ Breaking Changes: bool closed = false ----> use ImDrawFlags_None, or 0 bool closed = true ----> use ImDrawFlags_Closed Difference may not be noticeable for most but zealous type-checking tools may report a need to change. +- ImDrawList: clarified that PathArcTo()/PathArcToFast() won't render with radius < 0.0f. Previously it sorts + of accidentally worked but would lead to counter-clockwise paths which and have an effect on anti-aliasing. - Style: renamed rarely used style.CircleSegmentMaxError (old default = 1.60f) to style.CircleTessellationMaxError (new default = 0.30f) as its meaning changed. (#3808) [@thedmd] - Win32+MinGW: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly diff --git a/imgui.cpp b/imgui.cpp index 4ae0e42e2..e6e8186b2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -376,6 +376,7 @@ CODE When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files. You can read releases logs https://github.com/ocornut/imgui/releases for more details. + - 2021/03/11 (1.82) - clarified that ImDrawList::PathArcTo(), ImDrawList::PathArcToFast() won't render with radius < 0.0f. Previously it sorts of accidentally worked but would generally lead to counter-clockwise paths and have an effect on anti-aliasing. - 2021/03/10 (1.82) - upgraded ImDrawList::AddPolyline() and PathStroke() "bool closed" parameter to "ImDrawFlags flags". The matching ImDrawFlags_Closed value is guaranteed to always stay == 1 in the future. - 2021/02/22 (1.82) - win32+mingw: Re-enabled IME functions by default even under MinGW. In July 2016, issue #738 had me incorrectly disable those default functions for MinGW. MinGW users should: either link with -limm32, either set their imconfig file with '#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS'. - 2021/02/17 (1.82) - renamed rarely used style.CircleSegmentMaxError (old default = 1.60f) to style.CircleTessellationMaxError (new default = 0.30f) as the meaning of the value changed. diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 7e18b4ba6..9a03b56c9 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -545,7 +545,7 @@ void ImDrawList::_OnChangedVtxOffset() int ImDrawList::_CalcCircleAutoSegmentCount(float radius) const { // Automatic segment count - const int radius_idx = (int)(radius + 0.999f); // ceil to never reduce accuracy + const int radius_idx = (int)(radius + 0.999999f); // ceil to never reduce accuracy if (radius_idx < IM_ARRAYSIZE(_Data->CircleSegmentCounts)) return _Data->CircleSegmentCounts[radius_idx]; // Use cached value else @@ -1026,9 +1026,10 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun } } +// 0: East, 3: South, 6: West, 9: North, 12: East void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12) { - if (radius == 0.0f) + if (radius <= 0.0f) { _Path.push_back(center); return; @@ -1052,7 +1053,7 @@ void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_ void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments) { - if (radius == 0.0f) + if (radius <= 0.0f) { _Path.push_back(center); return;