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

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