Bug in picking objects arranged as an assembly
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Quoting "Eran Guendelman" back in 2007, using VTK 5.0.3
I'm finding in my program that even when I call SetVisibility(0) and SetPickable(0) on vtkActors in my scene, the vtkPropPicker is incorrectly allowing them to be picked. I traced through the VTK code and believe I found the bug. Here's basically what's happening. Say my scene is:
A -> B -> C -> D
A: top level scene assembly B: an assembly which is a part of A (e.g. a model in the scene) C and D: vtkActors which are part of assembly B (e.g. bodies in my model)
So now suppose I hide body C (SetVisibility(0), and also SetPickable(0) for good measure although I don't think that's necessary under usual circumstances).
vtkPropPicker::Pick() calls vtkRenderer::PickRender() down the line, which does the following:
(1) Goes through all the top-level vtkProps in the scene. Namely A. It then adds A to a pickFrom list.
(2) A cullPicker (of type vtkPicker) is created to execute a pick against bounding boxes, to cull the bodies that will be rendered by the underlying DevicePickRender(). vtkPicker::Pick goes through each vtkProp in the pickFrom list (namely A), and goes through all paths of that prop (namely A->B->C and A->B->D). It omits any paths whose leaf node is not visible (so it omits A->B->C but intersects against A->B->D). In the situation where we do intersect D's bounding box, the top-level vtkProp is added to the vtkPicker's Prop3Ds list... i.e. A is added th the Prop3Ds list... NOT the leaf node D
(3) back in vtkRenderer::PickRender(), it fills PathArray with ALL of the paths of all of the vtkProps in the Prop3Ds list. i.e. it fills PathArray with all of the paths of A, which are A->B->C and A->B->D. (THIS IS ALREADY BAD NEWS BECAUSE A->B->C IS BACK UNDER CONSIDERATION)
(4) vtkOpenGLRenderer::DevicePickRender() is called, which calls vtkRenderer::PickGeometry(), which renders everything in the PathArray, and makes this comment: // We can render everything because if it was // not visible it would not have been put in the // list in the first place, and if it was allocated // no time (culled) it would have been removed from // the list
So there's an obvious problem here. When an intersection with D was found, the top-level vtkProp A was added to the Prop3Ds list... and then all of the paths of A were intersected against by the device pick render step. Ignoring the fact that A->B->C is supposed to be invisible and not pickable!
So is this a bug? And suggestions for getting around it? (Yes, I could make a flat scene graph and put C and D as top-level actors in the scene, but that's not a satisfactory solution).
Thanks.