2
$\begingroup$

I'm experimenting with the bvhtree python module and am confused about the index attribute that's returned by find(). Assumption is that it's the vertex index but could be mistaken.

https://www.blender.org/api/blender_python_api_current/mathutils.bvhtree.html?highlight=bvhtree#module-mathutils.bvhtree

Also note that the documentation shows find_nearest() but the method is find() at the time of this writing

In the console with mathvis addon enabled, here's an example to test:

bv = bvhtree.BVHTree.FromObject(C.object, C.scene)
hit = bv.find(C.scene.cursor_location)[0]
index = C.active_object.data.vertices[bv.find(C.scene.cursor_location)[2]].co

enter image description here

but the hit and index don't match up as expected (would expect the vertex to be a little off but not across the shape). This is with a mesh object, no scale, no modifiers.

Supporting info is appreciated! Ideally I'd be able to get the vertex closest to a point with low overhead and easy syntax :)

$\endgroup$
1
  • 1
    $\begingroup$ For reference, I reported the discrepancy between find and find_nearest and the api has been corrected to match the documentation. From 2.77 BVHTree.find_nearest will need to be used. $\endgroup$
    – sambler
    Feb 8, 2016 at 2:15

1 Answer 1

1
$\begingroup$

It's the polygon (face) index.

It works like object/closest point on mesh . Not like kdtree, that gives vertex (vectors, points) relation

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .