From dd893ac4f558505a528f64164ce6dd177e56002b Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 9 Apr 2015 21:43:42 +0100 Subject: [PATCH 1/2] Warning fix. --- imgui.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 678c4f07a..3a968207b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7861,7 +7861,6 @@ void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, floa r = ImMin(r, fabsf(b.x-a.x) * ( ((rounding_corners&(1|2))==(1|2)) || ((rounding_corners&(4|8))==(4|8)) ? 0.5f : 1.0f )); r = ImMin(r, fabsf(b.y-a.y) * ( ((rounding_corners&(1|8))==(1|8)) || ((rounding_corners&(2|4))==(2|4)) ? 0.5f : 1.0f )); - const ImVec2 uv = GImGui->FontTexUvWhitePixel; if (r == 0.0f || rounding_corners == 0) { // Use triangle so we can merge more draw calls together (at the cost of extra vertices) From a48130b6828ef75ca0f5d9b9790fe3dbfac54d65 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 9 Apr 2015 22:49:18 +0100 Subject: [PATCH 2/2] ImDrawList: Minor optimisation. --- imgui.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 3a968207b..fe12074dd 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7762,11 +7762,14 @@ void ImDrawList::PrimQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, con void ImDrawList::PrimLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness) { const float inv_length = 1.0f / sqrtf(ImLengthSqr(b - a)); - const ImVec2 hn = (b - a) * (thickness * 0.5f * inv_length);// half normalized - const ImVec2 hp0 = ImVec2(+hn.y, -hn.x); // half perpendiculars + user offset - const ImVec2 hp1 = ImVec2(-hn.y, +hn.x); + const float dx = (b.x - a.x) * (thickness * 0.5f * inv_length); // line direction, halved + const float dy = (b.y - a.y) * (thickness * 0.5f * inv_length); // line direction, halved - PrimQuad(a + hp0, b + hp0, b + hp1, a + hp1, col); + const ImVec2 pa(a.x + dy, a.y - dx); + const ImVec2 pb(b.x + dy, b.y - dx); + const ImVec2 pc(b.x - dy, b.y + dx); + const ImVec2 pd(a.x - dy, a.y + dx); + PrimQuad(pa, pb, pc, pd, col); } void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness)