Efficient way to retrieve user data when picking points?



I need to select a polyline or mesh with custom user data, pick a point from a set of construction points and retrieve some user data from these. This data is exactly the index of the picked point in an array contained in the user data.

I found a naive way to do this: I pick a point and then I loop over the user data array to find another point with exactly the same (x,y,z) coordinates, and take its index.

It works but I’d rather avoid comparing double values and dealing with machine precision. Does somebody have a better idea on the way to do it?

Thanks a lot,

(Dale Fugier) #2

Hi Pablo,

Did my reply to your other posted question help with this?

– Dale


Mmm not exactly. The deep question is: how to, from a selection of a 3d point, retrieve some more data that was associated to this point?

I got an idea: add point objects to the scene with attached user data (in my case its respective index in my array), restrict the selection to these and retrieve it.

I’ll tell you if it works.



The idea worked! I add some point objects with custom user data, apply a geometry filter and delete the objects when the command is done.