Skip to content

vtkRenderedArea picker off by one error

When picking using the vtkRenderedAreaPicker, it would set CurrentPickedId to 1, in order to not set the associated color to black ( eg: the background where nothing is present). However, the CurrentPickedId is incremented just before tranversing the first object, making it equal to 2, which is already a mistake. Further down the call path, we get the picked value and subtract 1 (to get an ID of 1) but the pick buffer color has IDs of 0 (the background) and 2 (the object).

When you have 2 objects and you pick one, you run into a situation where the currently picked item is 1, the list of currently picked items are 2s.

The fix is simple. When starting picking, set the CurrentPickedId to 0. When traversing the first object, it gets set to 1. When you get the currently picked object, don't subtract 1 (as I think it was a bad patch anyway at some point), and in the color buffer, you have IDs of 1s. Everything is now consistent.

Merge request reports