I am doing a lot of voxel game development and I am optimizing the light engine. The idea is, that I can check if light can enter a block or not.
To break down the question to the minimal, here it is:
I got a set of quads. Now I need to check if the target quad is completely (i.e. no light can shine through) covered by the set.
Examples:
[(0.0, 0.0, 1.0, 1.0)]->true[(0.0, 0.0, 1.0, 0.5)]->false[(0.0, 0.0, 1.0, 0.5),(0.0, 0.5, 1.0, 1.0)]->true
How do I solve it? Performance is not the biggest concern here, the data is pre calculated.
I tried calculating the surface area and adding them together, but that has the flaw of floating point error and even more important: What if quads are overlapping? Then that breaks.
I also tried iterating and checking if it exceeds the bounding box, like quad.min.x < targetMinX || quad.min.x > targetMaxX || … but that fails in some cases.