Skip to content

Commit

Permalink
ImDrawList: New AddPolyline() implementation (fixup)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedmd committed Sep 13, 2024
1 parent 8d6a28e commit 11bd1a2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2577,13 +2577,13 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
const int arc_count = (round_join ? points_count - (polyline.closed ? 0 : 1) : 0) + (!polyline.closed && round_cap ? 2 : 0);

#if defined(IMGUI_ENABLE_SSE)
#define IM_POLYLINE_TMP_BUFFER_ROUND_UP(count, size) (((count) * (size) + sizeof(__m128) - 1) / sizeof(ImVec2))
#define IM_POLYLINE_TEMP_BUFFER_ROUND_UP(count, size) (((count) * (size) + sizeof(__m128) - 1) / sizeof(ImVec2))
#else
#define IM_POLYLINE_TMP_BUFFER_ROUND_UP(count, size) (count)
#define IM_POLYLINE_TEMP_BUFFER_ROUND_UP(count, size) (count)
#endif

const int normal_count = IM_POLYLINE_TMP_BUFFER_ROUND_UP(points_count, sizeof(ImVec2));
const int segment_length_sqr_count = IM_POLYLINE_TMP_BUFFER_ROUND_UP(points_count + 1, sizeof(float));
const int normal_count = IM_POLYLINE_TEMP_BUFFER_ROUND_UP(points_count, sizeof(ImVec2));
const int segment_length_sqr_count = IM_POLYLINE_TEMP_BUFFER_ROUND_UP(points_count + 1, sizeof(float));

this->_Data->TempBuffer.reserve_discard(normal_count + segment_length_sqr_count + arc_count * sizeof(ImDrawListPolylineArc) / 3); // 'count' normals and 'count + 1 + 1 (to round up)' segment lengths
ImVec2* normals = this->_Data->TempBuffer.Data;
Expand Down

0 comments on commit 11bd1a2

Please sign in to comment.