I posted a question up on stackexchange a while ago but never got an answer. I was hoping someone here might be able to shed some light on what’s going on. Bear with me, it’s code-related
Basically I’m noticing two different selection behaviors. The ‘select (de)select all’ tool will select an object while clicking up to 20 pixels off the actual object. So clicking on empty space <= 20 pixels away from the object will still select the object.
Border select on the other hand will very precisely select what’s surrounded by the marquee. So dragging the marquee up to the edge of an object will not select it until the object is actually inside the border, and it is exactly or very close to exactly pixel accurate.
So I thought maybe I could force more accurate single-click selections by invoking a single pixel border select through python, like this:
bpy.ops.view3d.select_border(gesture_mode=3, xmin=x, xmax=x, ymin=y, ymax=y)
But that gave me the same sloppy results as regular ‘select (de)select all’
A 2x2 pixel border like this, however:
bpy.ops.view3d.select_border(gesture_mode=3, xmin=x, xmax=x+1, ymin=y, ymax=y+1)
Gave me very accurate selections! But since it’s actually border selecting, executing this on overlapping objects would make multiple selections with a single click, which isn’t really what I’m after.
So I checked the source code for VIEW3D_OT_select to see if I could figure out what’s going on and saw this:
prop = RNA_def_int_vector(ot->srna, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Mouse location", INT_MIN, INT_MAX);
The location property takes a single pixel coordinate as it’s argument.
So what, if anything, is here that would cause this inaccuracy when a single pixel is given for selection targeting? Does the Integer 2 after “location” have anything to do with it? I couldn’t figure out what that value does. Furthermore, what is the benefit of this behavior? Why does selection work this way instead of only selecting what the user has actually clicked on?
I’m desperately trying to understand this. Thanks for any help!