I keep doing this over and over again, capturing vertices within a radius form a center (test) point, therefore I think it would be of immense value to have a Mesh.GetVerticesWithinRadius() function based on an optimized internal RTree thingy or whatever is the fastest thinkable. Something like this
var stay_optimized = true; int neighbor_indices = mesh.GetVerticesWithinRadius(center, radius, stay_optimized); // alternative name int neighbor_indices = mesh.CaptureVerticesInSphere(center, radius, stay_optimized);
The option “stay_optimized” is to tell the Mesh to keep any additional optimized internal data structures (RTree etc) for additional calls (like in a loop etc).
Calling the method with the parameter stay_optimized = false could free the internal optimization structure (if it causes the Mesh class consume more memory).
I know I can extract the Vertices list and build a RTree from it (and then do my thing with the tree), but since I so often perform such “CaptureVerticesInSphere” kindof operations in different contexts and in multiple script components, I keep thinking it really should be supported by the optimized Mesh class itself.
And while at it, why not also a GetFacesWithinRadius command:
var stay_optimized = true; var include_corners = true; // if false, inclusion based on face centers is good enough int face_indices = mesh.GetFacesWithinRadius(center, radius, include_corners , stay_optimized);
And why not also a GetEdgesWithinRadius command:
var stay_optimized = true; Line edges = mesh.GetEdgesWithinRadius(center, radius, stay_optimized);
Wow, that would make life so much easier. I mean, provide a center point and a radius and… like so: