The idea of this patch is to draw the elements used to snap with flat colors (for indices 32UI) in a occult framebuffer. And use the glReadPixel to find the nearest element.
The snap to faces continues to use raycast, so this mode is not affected by the patch.
The main purpose of using OpenGL is to be able to occlude the elements not seen through the Z-Buffer.
Other benefits include:
- Simplify the code;
- enable multiple elements to snap efficiently and correctly (snap to faces, edges and vertices at the same time);
I tried using the Gawain API and GPU to create Batchs, but I was very limited to using builtin shaders and matrices. also, meshes for the snap-in edit-mode must ignore the sealed or hidden elements.
I also could not use the GPU_frambuffer API because it only works with floats (which is incompatible with glReadPixel for uints).
Since Blender 2.8 is still going to take a long time to get released, I don't find it problematic to apply this patch for now (I'll have time to edit and fix bugs - if the users find one).
Note: The Macro: DRAW_FRAMEBUFFER_ON_SCREEN s enabled. This causes you to see a drawing that should not exist (used for Debug). Something like: