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.
This commit is contained in:
ocornut
2021-03-11 10:29:13 +01:00
parent a3ebd160cb
commit 8ed34af6f8
3 changed files with 7 additions and 3 deletions

View File

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