SortVisualsByDepth
ceramic.SortVisualsByDepth (Class)
Simplified high-performance stable merge sort for Visual arrays based on depth only.
SortVisualsByDepth provides a streamlined sorting algorithm that orders visuals
purely by their depth property, ignoring other rendering criteria like texture
or blending mode. This makes it faster than SortVisuals when you only need
depth-based ordering.
Key characteristics:
- Sorts by depth only (higher depth values render on top)
- Stable sort: preserves relative order of visuals with equal depth
- Same optimizations as SortVisuals (inlining, unsafe access, insertion sort for small arrays)
- Faster than full SortVisuals when texture batching is not a concern
Use cases:
- UI elements where depth is the primary ordering criterion
- Debug visualizations
- Scenarios where draw call batching is less important than simplicity
Example usage:
var visuals:Array<Visual> = [...];
SortVisualsByDepth.sort(visuals);
See: ceramic.SortVisuals For complete rendering order sorting, ceramic.Visual.depth For the depth property
Static Members
Sorts an array of Visual objects in place by depth value only.
This is a simplified version of SortVisuals.sort() that only considers
the depth property. Visuals with higher depth values will be sorted
after (rendered on top of) visuals with lower depth values.
The sort is stable, preserving the relative order of visuals with
equal depth values. This operation modifies the array in place.
Name |
Type |
Description |
a |
Array<Visual> |
The array of visuals to sort by depth. Modified in place. If null, behavior is undefined. |
Private Members
Compares two visuals by depth only.
Name |
Type |
Description |
a |
Visual |
First visual to compare |
b |
Visual |
Second visual to compare |
Returns |
Description |
Int |
-1 if a has lower depth, 1 if a has higher depth, 0 if equal |