MCPcopy Create free account
hub / github.com/brenocq/implot3d / RendererLineStripSkip

Class RendererLineStripSkip

implot3d_items.cpp:463–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461};
462
463template <class _Getter, class _GetterColor> struct RendererLineStripSkip : RendererBase {
464 RendererLineStripSkip(const _Getter& getter, const _GetterColor& col_getter, float weight)
465 : RendererBase(getter.Count - 1, 6, 4), Getter(getter), ColGetter(col_getter), HalfWeight(ImMax(1.0f, weight) * 0.5f) {
466 // Initialize the first point in plot coordinates
467 P1_plot = Getter(0);
468 }
469
470 void Init(ImDrawList3D& draw_list_3d) const { GetLineRenderProps(draw_list_3d, HalfWeight, UV0, UV1); }
471
472 IMPLOT3D_INLINE bool Render(ImDrawList3D& draw_list_3d, const ImPlot3DBox& cull_box, int prim) const {
473 // Get the next point in plot coordinates
474 ImPlot3DPoint P2_plot = Getter(prim + 1);
475 bool visible = false;
476
477 // Check for NaNs in P1_plot and P2_plot
478 if (!ImNan(P1_plot.x) && !ImNan(P1_plot.y) && !ImNan(P1_plot.z) && !ImNan(P2_plot.x) && !ImNan(P2_plot.y) && !ImNan(P2_plot.z)) {
479
480 // Clip the line segment to the culling box
481 ImPlot3DPoint P1_clipped, P2_clipped;
482 visible = cull_box.ClipLineSegment(P1_plot, P2_plot, P1_clipped, P2_clipped);
483
484 if (visible) {
485 // Convert clipped points to pixel coordinates
486 ImVec2 P1_screen = PlotToPixels(P1_clipped);
487 ImVec2 P2_screen = PlotToPixels(P2_clipped);
488 // Render the line segment
489 PrimLine(draw_list_3d, P1_screen, P2_screen, HalfWeight, ColGetter(prim), UV0, UV1, GetPointDepth((P1_plot + P2_plot) * 0.5));
490 }
491 }
492
493 // Update P1_plot if P2_plot is valid
494 if (!ImNan(P2_plot.x) && !ImNan(P2_plot.y) && !ImNan(P2_plot.z))
495 P1_plot = P2_plot;
496
497 return visible;
498 }
499
500 const _Getter& Getter;
501 const _GetterColor ColGetter;
502 mutable float HalfWeight;
503 mutable ImPlot3DPoint P1_plot;
504 mutable ImVec2 UV0;
505 mutable ImVec2 UV1;
506};
507
508template <class _Getter, class _GetterColor> struct RendererLineSegments : RendererBase {
509 RendererLineSegments(const _Getter& getter, const _GetterColor& col_getter, float weight)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected