@@ -942,12 +942,7 @@ void ImDrawList::_SelectLineTexture(float screen_thickness, ImVec2* out_uv0, ImV
942942 }
943943}
944944
945- static inline ImDrawFlags _GetStrokePos (ImDrawFlags flags, ImDrawFlags default_stroke_pos)
946- {
947- if (flags & ImDrawFlags_StrokeMask_)
948- return (flags & ImDrawFlags_StrokeMask_);
949- return default_stroke_pos;
950- }
945+ #define _GetStrokePos (_FLAGS, _DEFAULT_STROKE_POS ) (((_FLAGS) & ImDrawFlags_StrokeMask_) ? ((_FLAGS) & ImDrawFlags_StrokeMask_) : _DEFAULT_STROKE_POS)
951946
952947IM_MSVC_RUNTIME_CHECKS_RESTORE
953948
@@ -1058,7 +1053,6 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
10581053 }
10591054
10601055 const float half_aa = _FringeScale * 0 .5f ; // Used for end caps, does not use "fringe" since end cap AA is not using the texture.
1061- const float half_thickness = thickness * 0 .5f ;
10621056 const bool use_aa_ends = (flags & (ImDrawFlags_AALines | ImDrawFlags_AALineEnds)) == (ImDrawFlags_AALines | ImDrawFlags_AALineEnds);
10631057
10641058 const int first_vtx_offset = (int )(_VtxWritePtr - VtxBuffer.Data );
@@ -1084,8 +1078,8 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
10841078 dir.y = -n1.x ;
10851079 if (flags & ImDrawFlags_CapSquare)
10861080 {
1087- p1.x -= dir.x * half_thickness ;
1088- p1.y -= dir.y * half_thickness ;
1081+ p1.x -= dir.x * thickness * 0 . 5f ;
1082+ p1.y -= dir.y * thickness * 0 . 5f ;
10891083 }
10901084
10911085 if (!use_aa_ends)
@@ -1251,7 +1245,6 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
12511245 // Connect prev to next
12521246 IM_APPEND_TRI (base_idx + 0 , base_idx + 2 , base_idx + 3 );
12531247 IM_APPEND_TRI (base_idx + 0 , base_idx + 3 , base_idx + 1 );
1254-
12551248 base_idx = next_base_idx;
12561249 }
12571250
@@ -1270,8 +1263,8 @@ void ImDrawList::_AddPolyline(const ImVec2* points, const int points_count, ImU3
12701263 dir.y = -n1.x ;
12711264 if (flags & ImDrawFlags_CapSquare)
12721265 {
1273- p1.x += dir.x * half_thickness ;
1274- p1.y += dir.y * half_thickness ;
1266+ p1.x += dir.x * thickness * 0 . 5f ;
1267+ p1.y += dir.y * thickness * 0 . 5f ;
12751268 }
12761269
12771270 if (!use_aa_ends)
@@ -1900,13 +1893,12 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t
19001893 thickness0 = _CalculateCenterBiasedOffset (thickness) + fringe * 0 .5f ;
19011894 else if (stroke_pos == ImDrawFlags_StrokeInside)
19021895 thickness0 = fringe * 0 .5f ;
1903- float thickness1 = (thickness + fringe) - thickness0;
1896+ const float thickness1 = (thickness + fringe) - thickness0;
19041897
1905- const float ratio = thickness0 / (thickness0 + thickness1); // The points using uv2 are placed on the path, calculate the position from stroke offets .
1898+ const float ratio = thickness0 / (thickness0 + thickness1); // The points using uv2 are placed on the path, calculate the position from stroke offsets .
19061899 const ImVec2 uv2 (uv0.x + (uv1.x - uv0.x ) * ratio, uv0.y );
19071900
19081901 const float half_aa = _FringeScale * 0 .5f ; // Used for end caps, does not use "fringe" since end cap AA is not using the texture.
1909- const float half_thickness = thickness * 0 .5f ;
19101902 const bool use_aa_ends = (flags & (ImDrawFlags_AALines | ImDrawFlags_AALineEnds)) == (ImDrawFlags_AALines | ImDrawFlags_AALineEnds);
19111903
19121904 if (!use_aa_ends)
@@ -1922,6 +1914,7 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t
19221914 float p2_y = p2.y ;
19231915 if (flags & ImDrawFlags_CapSquare)
19241916 {
1917+ const float half_thickness = thickness * 0 .5f ;
19251918 p1_x -= dir_x * half_thickness;
19261919 p1_y -= dir_y * half_thickness;
19271920 p2_x += dir_x * half_thickness;
@@ -1934,7 +1927,6 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t
19341927 base_idx = (int )_VtxCurrentIdx;
19351928 IM_APPEND_VTX (p1_x - norm_x * thickness0, p1_y - norm_y * thickness0, uv0, col);
19361929 IM_APPEND_VTX (p1_x + norm_x * thickness1, p1_y + norm_y * thickness1, uv1, col);
1937-
19381930 IM_APPEND_VTX (p2_x - norm_x * thickness0, p2_y - norm_y * thickness0, uv0, col);
19391931 IM_APPEND_VTX (p2_x + norm_x * thickness1, p2_y + norm_y * thickness1, uv1, col);
19401932
@@ -1972,7 +1964,6 @@ void ImDrawList::_AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float t
19721964 next_base_idx = (int )_VtxCurrentIdx;
19731965 IM_APPEND_VTX (pa_x - norm_x * thickness0, pa_y - norm_y * thickness0, uv0, col);
19741966 IM_APPEND_VTX (pa_x + norm_x * thickness1, pa_y + norm_y * thickness1, uv1, col);
1975-
19761967 IM_APPEND_VTX (pb_x - norm_x * thickness0, pb_y - norm_y * thickness0, uv0, col_trans);
19771968 IM_APPEND_VTX (pb_x + norm_x * thickness1, pb_y + norm_y * thickness1, uv1, col_trans);
19781969
0 commit comments