Rendering and picking nodes on top with correct depth support #546
Description
To render nodes on top one could use SoAnnotation
. This node however disables use of the depth buffer so nodes are rendered using rendering order, not depth order which is not always desirable. To circumvent that problem it is possible to simply split rendering into two (or more) steps separated by clearing of the depth buffer either by splitting the graph into two separate roots, or accumulating nodes into proper path lists and then dispatching the rendering action to them separately.
This works well for rendering, however SoPickAction
s are not aware of such "steps" or "layers" and return incorrect order of picked points. Using SoPickStyle::SHAPE_ON_TOP
results in objects being on top, which is problematic when there are multiple objects overlapping "on top" as they considered in rendering order.
My proposal is to add additional priority
property into SoPickStyle
node and SoPickStyleElement
. Elements would then be sorted first by their priorities (higher priority means that objects should be picked first), and then by the distance from camera. For compatibility, objects with SHAPE_ON_TOP
would be considered as having highest possible priority with distance set to 0 (like it is now). This should would add only one more comparison to the sorting, which should not be problem in terms of performance.
Once agreed that it is ok, I can implement such feature. If wanted layered rendering could be implemented directly into Coin3D however because depth buffer would have to be cleared between each layer it could result in potentially changed behavior for code that relies on having proper depth buffer after dispatching the action rendering action.