Feat: Per-Index Color/Size Support with ImPlot3DSpec#182
Merged
Conversation
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per-Index Color/Size Support with ImPlot3DSpec
Closes #144
Summary
This PR introduces per-index color and size support across ImPlot3D plot types, just like implemented for ImPlot in epezent/implot#672. Users can now pass arrays of colors and sizes to apply a different color or size to each vertex, segment, or marker in their plots, enabling rich visualizations with color-coded spatial data.
It also overhauls
PlotMeshwith a new API matching the rest of the library, and adds per-index color support to meshes with a documented color indexing model.New Properties
Five new
ImPlot3DSpecproperties have been added:ImPlot3DProp_LineColorsImU32*ImPlot3DProp_FillColorsImU32*ImPlot3DProp_MarkerLineColorsImU32*ImPlot3DProp_MarkerFillColorsImU32*ImPlot3DProp_MarkerSizesfloat*Supported Plot Types
LineColorsFillColorsMarkerLineColorsMarkerFillColorsMarkerSizesPlotScatterPlotLinePlotTrianglePlotQuadPlotSurfacePlotMeshPlotMesh API Update
PlotMeshnow accepts separate coordinate arrays, consistent withPlotLine,PlotScatter, andPlotTriangle.Spec.OffsetandSpec.Strideapply to the vertex arrays only, not the index buffer. The oldImPlot3DPoint*overload is deprecated and will be removed in v1.0.Color array semantics for PlotMesh
FillColors/LineColorsidx_countFillColors[i] = vtx_colors[idxs[i]].MarkerFillColors/MarkerLineColorsvtx_countUsage
Implementation Details
GetterConstColor/GetterIdxColorfor colors,GetterConstSize/GetterIdxSizefor sizes. Lazy per-index fetching viaoperator()(int idx).GetterIdxColorapplies an optional alpha multiplier.RenderPrimitives/RenderPrimitives2/RenderPrimitives3: convenience wrappers that dispatch templated renderers, matching ImPlot's pattern.RenderColoredMarkers: dispatches on null checks ofMarkerSizes,MarkerFillColors,MarkerLineColorsto select const vs per-index getters, then calls the templatedRenderMarkers.RendererTriangleFill,RendererQuadFill): call the color getter per vertex index (3*prim+v,4*prim+v), enabling smooth GPU-interpolated color gradients across faces.PlotMeshEx: new internal helper taking separate vertex and triangle getters, used by both the new templatedPlotMeshoverload and the deprecatedImPlot3DPoint*fallback.GetterMeshTriangles: templated on three coordinate getters, replacing the oldImPlot3DPoint*-only struct.ImPlot3DPoint*overload still compiles (with a deprecation warning).FillAlphawhen applicable.