3 ms·
Wouldn't a 'painter's algorithm'-style solution of: break all the shapes into boxes that can occupy only 1 space for height = 0 .. n: for <however
by fao_ 10y ago
Wouldn't a 'painter's algorithm'-style solution of:
break all the shapes into boxes that can occupy only 1 space
for height = 0 .. n:
for <however many boxes can be displayed in a column>
for <however many boxes can be displayed in a row>
draw box, step to next box (x+1, y+1)
solve these problems? I'm not sure how fast it would be in practice.
- munchbunny 10y agoThe way you would do this in practice would be: 1. Start with the abstraction that every shape is actually a group of one or more sub-shapes. (Well-understood and pretty much universally applied abstraction.) 2. Pre-process all of your geometry so that you won't get cycles of occlusion, which is the corner case the author mentioned. If you do have a cycle, then subdivide and group as mentioned in #1. 3. Use some fast but crude algorithm to preemptively reject non-visible shapes. 4. Apply painter's algorithm. to "probably visible" shapes.