Color legend method
Sorts items far to near by their depth, to paint overlapping overlays with depth testing off.
A static class. The drawing page shows it in context, with code.
Names are colored by what they are: a method; values and fields keep the plain color.
Methods
FarToNear() →
FarToNear(ReadOnlySpan<float> depths, Span<int> order) · Static. Fills order with the indices from 0 to its length − 1, sorted by depth from the largest, the farthest, to the smallest. Stable: items of equal depth keep their order. An insertion sort that allocates nothing and leaves depths as they are, quick for the tens to hundreds of items of an overlay.
| Parameter | Type | Description |
|---|---|---|
depths |
ReadOnlySpan<float> |
One depth per item, larger farther, such as the distance along the camera’s forward. At least as long as order. |
order |
Span<int> |
Filled with the indices in paint order. Its length is the number of items sorted. |