vtkPropPicker in VTK 9.1 is now returning wrong world coordinates.

Hi Paulo, I meet the same problem as you reported!

In my situation, I added an extra renderer to the render window to do overlay drawing for annotation stuffs. After that, “vtkRenderer::GetZ” almost returns value 1.0 at every time. Then I digged into the issue by exporting z buffer as an image file, guess what? It’s the depth buffer of the annotation render layer! I found that multiple renderers are invoked one by one in the RendererCollections, so the second annotation renderer clear the depth buffer immediately which made vtkWorldPointPicker to catch the second layer depth buffer.

The way I handle this problem is by observing the vtkCommand::EndEvent to the main renderer, and invoke vtkWorldPointPicker in the callback when it is needed with the current mouse position as input, then cache the correct result. After this, an extra rendering invocation is need before fetching the cache.

By the way, I don’t think it’s an issue caused by VTK9.1 upgrade since I was using the older VTK8.2.0.

Hopes to help every one whom has being struggling in the same issue!