Picking order

Am I right in thinking the picking results returned are not in the order of how the geoms are in relation to the view?

indeed with firther investigation the order is not in the order of the ray.


private void orderResults(PickRenderResult[] results) {
        for (int i = 0; i < results.length - 1; i++)
            for (int j = 0; j < results.length - 1 - i; j++) {
                if (results[j].getZMin() > results[j + 1].getZMin()) {
                    swap(j, j + 1, results);
                }
            }
    }

    private void swap(int index, int otherIndex, PickRenderResult[] results) {
        PickRenderResult tmp = results[index];
        results[index] = results[otherIndex];
        results[otherIndex] = tmp;
    }

is how I did it

I had the same problem, when I tested it, the results were not in order every time, so what I did was, everytime pick occured, found the result element with the smallest Z min value, this solved the problem, but still the picking is kind off slow if you have a lot of geometry in the view, a little bit of speedup is gained if you reduce number of pickable shapes.

Hi,

The order of picking results returned is not guaranteed to be always the same. Picking results are stored in the result list on the rendering order, which depends on the rendering atom sort modes, rendering pass, etc., so even can be different on every frame rendered.

You have to use Z values to check which result you need.

As of performance, it depends on number of pickable shapes (don’t set pickable to true until you really want shape to be pickable), graphic card driver you use, and built-in Xith3D culling mechanisms. There are several ways on how to improve picking performance, so if you want to dig into this, let me know and I’ll try to explain some points (OK, this will require modification of Xith3D).

Yuri

Yuri,
could you please further explain how to improve picking performance? The way it looks right now, it seems that we will require a lot of pickable objects in the system we are building, so picking performance with a large number of pickable objects is critical.

Thank you,
Sergey.