by snprbob86 · 14y ago · 0 comments
Example: Games often bubble sort world objects by depth. There is a small performance gain to be had by drawing closer objects first, so that you can depth-cull expensive pixels behind them. Game engines can run several iterations of bubble sort, but stop before sorting the set completely, since the z-buffer will ensure correctness. Over the span of several frames, the incremental bubble sort will achieve a total sort, but the incremental approach bounds cost more tightly. Since the depth of objects only changes relatively when you look around, it's usually a pretty good approximation of "perfect" behavior.
This of course assumes that the swap won't mess up the processing algorithm.
It also is an optimization, so best left for later stages of development.
Anyway, thanks for showing this example - it gives me another trick to try for a couple projects I'm working on. :)