DrawList: AddCircle, AddCircleFilled: fixed large circles being under-tessellated (when above ~140 with default CircleTessellationMaxError).

This commit is contained in:
ocornut
2026-08-05 16:55:48 +02:00
parent 3741affa6d
commit 32b4600ca2
2 changed files with 10 additions and 4 deletions

View File

@@ -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,

View File

@@ -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