1
0
Fork 0
mirror of https://github.com/gwm17/implot.git synced 2024-10-09 23:57:26 -04: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

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