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

Class RendererLineStrip

implot3d_items.cpp:425–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

423};
424
425template <class _Getter, class _GetterColor> struct RendererLineStrip : RendererBase {
426 RendererLineStrip(const _Getter& getter, const _GetterColor& col_getter, float weight)
427 : RendererBase(getter.Count - 1, 6, 4), Getter(getter), ColGetter(col_getter), HalfWeight(ImMax(1.0f, weight) * 0.5f) {
428 // Initialize the first point in plot coordinates
429 P1_plot = Getter(0);
430 }
431
432 void Init(ImDrawList3D& draw_list_3d) const { GetLineRenderProps(draw_list_3d, HalfWeight, UV0, UV1); }
433
434 IMPLOT3D_INLINE bool Render(ImDrawList3D& draw_list_3d, const ImPlot3DBox& cull_box, int prim) const {
435 ImPlot3DPoint P2_plot = Getter(prim + 1);
436
437 // Clip the line segment to the culling box using Liang-Barsky algorithm
438 ImPlot3DPoint P1_clipped, P2_clipped;
439 bool visible = cull_box.ClipLineSegment(P1_plot, P2_plot, P1_clipped, P2_clipped);
440
441 if (visible) {
442 // Convert clipped points to pixel coordinates
443 ImVec2 P1_screen = PlotToPixels(P1_clipped);
444 ImVec2 P2_screen = PlotToPixels(P2_clipped);
445 // Render the line segment
446 PrimLine(draw_list_3d, P1_screen, P2_screen, HalfWeight, ColGetter(prim), UV0, UV1, GetPointDepth((P1_plot + P2_plot) * 0.5));
447 }
448
449 // Update for next segment
450 P1_plot = P2_plot;
451
452 return visible;
453 }
454
455 const _Getter& Getter;
456 const _GetterColor ColGetter;
457 mutable float HalfWeight;
458 mutable ImPlot3DPoint P1_plot;
459 mutable ImVec2 UV0;
460 mutable ImVec2 UV1;
461};
462
463template <class _Getter, class _GetterColor> struct RendererLineStripSkip : RendererBase {
464 RendererLineStripSkip(const _Getter& getter, const _GetterColor& col_getter, float weight)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected