From 32b4600ca2f42784290c1aa0f15b0548d9037004 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 5 Aug 2026 16:55:48 +0200 Subject: [PATCH] DrawList: AddCircle, AddCircleFilled: fixed large circles being under-tessellated (when above ~140 with default CircleTessellationMaxError). --- docs/CHANGELOG.txt | 2 ++ imgui_draw.cpp | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 26ef30838..29bcda07b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -198,6 +198,8 @@ Other Changes: - AddRectFilled(): non-integer coordinates will now display anti-aliased edges. Previously, non-integer coordinates rendered with aliased edges snapped by the rasterizer. (#6971) + - AddCircle, AddCircleFilled: fixed large circles being under-tessellated + (when above ~140 with default CircleTessellationMaxError). - Improved debug-build performance in various locations. - Improved minor mismatches when overlapping strokes and filled shapes. For example, when using inside strokes, diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 05bd5e829..ec193c71b 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2714,7 +2714,7 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu return; } - if (num_segments <= 0) + if (num_segments <= 0 && outer_radius <= _Data->ArcFastRadiusCutoff) { // Use arc with automatic segment count const int a_step = IM_DRAWLIST_ARCFAST_SAMPLE_MAX / _CalcCircleAutoSegmentCount(outer_radius); // Use outer_radius for segment count to be consistent with rounded rect. @@ -2723,7 +2723,9 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu } else { - // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) + // Explicit segment count or above fast arc cutoff (still clamp to avoid drawing insanely tessellated shapes) + if (num_segments <= 0) + num_segments = _CalcCircleAutoSegmentCount(outer_radius); num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); // Because we are filling a closed shape we remove 1 from the count of segments/points @@ -2756,7 +2758,7 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, radius = _FringeScale * 0.5f; } - if (num_segments <= 0) + if (num_segments <= 0 && radius <= _Data->ArcFastRadiusCutoff) { // Use arc with automatic segment count _PathArcToFastEx(center, radius, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0); @@ -2764,7 +2766,9 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, } else { - // Explicit segment count (still clamp to avoid drawing insanely tessellated shapes) + // Explicit segment count or above cutoff (still clamp to avoid drawing insanely tessellated shapes) + if (num_segments <= 0) + num_segments = _CalcCircleAutoSegmentCount(radius); num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX); // Because we are filling a closed shape we remove 1 from the count of segments/points