1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-11-23 02:38:53 -05:00

bbox overlap test to avoid disappearing lines when two ends end up outside culling area

This commit is contained in:
SergeyN 2020-05-14 01:52:47 +02:00
parent 9b098b816c
commit 17dba653a9

View File

@ -2093,32 +2093,27 @@ inline void RenderLineStrip(Transformer transformer, ImDrawList& DrawList, Gette
const int segments = count - 1;
ImVec2 p1 = transformer(getter(offset));
bool test1 = !cull || gp.BB_Grid.Contains(p1);
if (HasFlag(gp.CurrentPlot->Flags, ImPlotFlags_AntiAliased)) {
for (int i1 = i_start; i1 != i_end; i1 = i1 + 1 < count ? i1 + 1 : i1 + 1 - count)
{
for (int i1 = i_start; i1 != i_end; i1 = i1 + 1 < count ? i1 + 1 : i1 + 1 - count) {
ImVec2 p2 = transformer(getter(i1));
bool test2 = !cull || gp.BB_Grid.Contains(p2);
if (test1 | test2)
if (!cull || gp.BB_Grid.Overlaps(ImRect(ImMin(p1,p2), ImMax(p1,p2))))
RenderLineAA(DrawList, p1, p2, line_weight, col_line);
p1 = p2;
test1 = test2;
}
}
else {
const ImVec2 uv = DrawList._Data->TexUvWhitePixel;
DrawList.PrimReserve(segments * 6, segments * 4);
int segments_culled = 0;
for (int i1 = i_start; i1 != i_end; i1 = i1 + 1 < count ? i1 + 1 : i1 + 1 - count)
{
for (int i1 = i_start; i1 != i_end; i1 = i1 + 1 < count ? i1 + 1 : i1 + 1 - count) {
ImVec2 p2 = transformer(getter(i1));
bool test2 = !cull || gp.BB_Grid.Contains(p2);
if (test1 | test2)
if (!cull || gp.BB_Grid.Overlaps(ImRect(ImMin(p1, p2), ImMax(p1, p2))))
RenderLine(DrawList, p1, p2, line_weight, col_line, uv);
else
segments_culled++;
p1 = p2;
test1 = test2;
}
if (segments_culled > 0)
DrawList.PrimUnreserve(segments_culled * 6, segments_culled * 4);