Skip to content

Commit 32b4600

Browse files
committed
DrawList: AddCircle, AddCircleFilled: fixed large circles being under-tessellated (when above ~140 with default CircleTessellationMaxError).
1 parent 3741aff commit 32b4600

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

docs/CHANGELOG.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ Other Changes:
198198
- AddRectFilled(): non-integer coordinates will now display anti-aliased edges.
199199
Previously, non-integer coordinates rendered with aliased edges snapped by the
200200
rasterizer. (#6971)
201+
- AddCircle, AddCircleFilled: fixed large circles being under-tessellated
202+
(when above ~140 with default CircleTessellationMaxError).
201203
- Improved debug-build performance in various locations.
202204
- Improved minor mismatches when overlapping strokes and filled shapes.
203205
For example, when using inside strokes,

imgui_draw.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,7 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu
27142714
return;
27152715
}
27162716

2717-
if (num_segments <= 0)
2717+
if (num_segments <= 0 && outer_radius <= _Data->ArcFastRadiusCutoff)
27182718
{
27192719
// Use arc with automatic segment count
27202720
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
27232723
}
27242724
else
27252725
{
2726-
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
2726+
// Explicit segment count or above fast arc cutoff (still clamp to avoid drawing insanely tessellated shapes)
2727+
if (num_segments <= 0)
2728+
num_segments = _CalcCircleAutoSegmentCount(outer_radius);
27272729
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
27282730

27292731
// Because we are filling a closed shape we remove 1 from the count of segments/points
@@ -2756,15 +2758,17 @@ void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col,
27562758
radius = _FringeScale * 0.5f;
27572759
}
27582760

2759-
if (num_segments <= 0)
2761+
if (num_segments <= 0 && radius <= _Data->ArcFastRadiusCutoff)
27602762
{
27612763
// Use arc with automatic segment count
27622764
_PathArcToFastEx(center, radius, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0);
27632765
_Path.Size--;
27642766
}
27652767
else
27662768
{
2767-
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
2769+
// Explicit segment count or above cutoff (still clamp to avoid drawing insanely tessellated shapes)
2770+
if (num_segments <= 0)
2771+
num_segments = _CalcCircleAutoSegmentCount(radius);
27682772
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
27692773

27702774
// Because we are filling a closed shape we remove 1 from the count of segments/points

0 commit comments

Comments
 (0)