ImDrawList: DIrect implementation of AddRect() (WIP) (fixup)

This commit is contained in:
thedmd 2024-09-16 01:07:03 +02:00
parent e8faa14773
commit 66a053ce64
1 changed files with 68 additions and 68 deletions

View File

@ -3426,7 +3426,7 @@ void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float th
// Note we don't render 1 pixels sized rectangles properly.
void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawFlags flags, float thickness)
{
if ((col & IM_COL32_A_MASK) == 0)
if ((col & IM_COL32_A_MASK) == 0 || thickness <= 0.0f) IM_UNLIKELY
return;
if (GImGui->IO.KeyCtrl || (flags & 0x80000000u))
@ -3472,8 +3472,8 @@ if (GImGui->IO.KeyCtrl || (flags & 0x80000000u))
if (rounding >= 0.5f)
{
flags = FixRectCornerFlags(flags);
rounding = ImMin(rounding, ImFabs(b.x - a.x - half_outer_thickness) * (((flags & ImDrawFlags_RoundCornersTop) == ImDrawFlags_RoundCornersTop) || ((flags & ImDrawFlags_RoundCornersBottom) == ImDrawFlags_RoundCornersBottom) ? 0.5f : 1.0f) - 1.0f);
rounding = ImMin(rounding, ImFabs(b.y - a.y - half_outer_thickness) * (((flags & ImDrawFlags_RoundCornersLeft) == ImDrawFlags_RoundCornersLeft) || ((flags & ImDrawFlags_RoundCornersRight) == ImDrawFlags_RoundCornersRight) ? 0.5f : 1.0f) - 1.0f);
rounding = ImMin(rounding, ImFabs(b.x - a.x) * (((flags & ImDrawFlags_RoundCornersTop) == ImDrawFlags_RoundCornersTop) || ((flags & ImDrawFlags_RoundCornersBottom) == ImDrawFlags_RoundCornersBottom) ? 0.5f : 1.0f) - 1.0f);
rounding = ImMin(rounding, ImFabs(b.y - a.y) * (((flags & ImDrawFlags_RoundCornersLeft) == ImDrawFlags_RoundCornersLeft) || ((flags & ImDrawFlags_RoundCornersRight) == ImDrawFlags_RoundCornersRight) ? 0.5f : 1.0f) - 1.0f);
}
if (rounding < 0.5f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone)
{
@ -3494,8 +3494,8 @@ if (GImGui->IO.KeyCtrl || (flags & 0x80000000u))
}
else
{
const int arc_step = ImMax(1, IM_DRAWLIST_ARCFAST_SAMPLE_MAX / _CalcCircleAutoSegmentCount(rounding));
const float arc_offset_correction = 0.207107f * _FringeScale; // sqrt(2)/4
const int arc_step = ImMax(1, IM_DRAWLIST_ARCFAST_SAMPLE_MAX / _CalcCircleAutoSegmentCount(rounding + half_outer_thickness));
const float arc_offset_correction = 0.207107f * _FringeScale; // sqrt(2)/2
#define IM_ADDRECT_EMIT_ARC(P, R, A_MIN, A_MAX) _PathArcToFastEx(P, R, (A_MIN) * IM_DRAWLIST_ARCFAST_SAMPLE_MAX / 12, (A_MAX) * IM_DRAWLIST_ARCFAST_SAMPLE_MAX / 12, arc_step)
#define IM_ADDRECT_EMIT_ROUNDED_PATH(AX, AY, BX, BY, ROUNDING) \