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

Class RendererLineSegments

implot3d_items.cpp:508–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

506};
507
508template <class _Getter, class _GetterColor> struct RendererLineSegments : RendererBase {
509 RendererLineSegments(const _Getter& getter, const _GetterColor& col_getter, float weight)
510 : RendererBase(getter.Count / 2, 6, 4), Getter(getter), ColGetter(col_getter), HalfWeight(ImMax(1.0f, weight) * 0.5f) {}
511
512 void Init(ImDrawList3D& draw_list_3d) const { GetLineRenderProps(draw_list_3d, HalfWeight, UV0, UV1); }
513
514 IMPLOT3D_INLINE bool Render(ImDrawList3D& draw_list_3d, const ImPlot3DBox& cull_box, int prim) const {
515 // Get the segment's endpoints in plot coordinates
516 ImPlot3DPoint P1_plot = Getter(prim * 2 + 0);
517 ImPlot3DPoint P2_plot = Getter(prim * 2 + 1);
518
519 // Check for NaNs in P1_plot and P2_plot
520 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)) {
521
522 // Clip the line segment to the culling box
523 ImPlot3DPoint P1_clipped, P2_clipped;
524 bool visible = cull_box.ClipLineSegment(P1_plot, P2_plot, P1_clipped, P2_clipped);
525
526 if (visible) {
527 // Convert clipped points to pixel coordinates
528 ImVec2 P1_screen = PlotToPixels(P1_clipped);
529 ImVec2 P2_screen = PlotToPixels(P2_clipped);
530 // Render the line segment
531 PrimLine(draw_list_3d, P1_screen, P2_screen, HalfWeight, ColGetter(prim), UV0, UV1, GetPointDepth((P1_plot + P2_plot) * 0.5));
532 }
533 return visible;
534 }
535
536 return false;
537 }
538
539 const _Getter& Getter;
540 const _GetterColor ColGetter;
541 mutable float HalfWeight;
542 mutable ImVec2 UV0;
543 mutable ImVec2 UV1;
544};
545
546template <class _Getter, class _GetterColor> struct RendererTriangleFill : RendererBase {
547 RendererTriangleFill(const _Getter& getter, const _GetterColor& col_getter)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected