Update: Me and @Sebastian Parborg (zeddb) is experimenting with an alternate algorithm using embree. This specific revision can be put on hold.
This patch contains change for doing intersection in multiple threads in line art.
At the moment, it's split into 8 (for example) threads like this in the image frame:
(x,y range -1 to 1) -1 0 1 +-----------+-----------+ 1 | thread 1 | thread 2 | +-----------+-----------+ | thread 3 | thread 4 | +-----------+-----------+ 0 | thread 5 | thread 6 | +-----------+-----------+ | thread 7 | thread 8 | +-----------+-----------+ -1
This naturally handles intersection only when they are visible in the frame, so if you zoom in on a portion of the model, only intersections in that part is getting calculated. However the problem with this method is that if your model largely stays inside one of the tiles, only one thread is effectively producing anything.
We may need better tile splitting method for threading. Now on an average model, this tiled method uses about 50% less time in calculating the intersections, but with 8 threads we should do better, however with the spatial locking in place I'm not sure how much speed up we could eventually gain.