mirror of
https://github.com/blender/blender
synced 2026-11-22 03:45:13 +03:00
This commit bumps the `ios` branch from 5.0.0 alpha to 5.1.2 release. I merged v5.0-release first then v5.1-release. So it was a sequential merge. I'm just waiting to the approval of continuing development. The stuff that are missing (those are so close to implement): - #145484 iOS: Keyboard Input Support: https://projects.blender.org/blender/blender/pulls/145484 - #145702 iOS: Add clipboard Image: https://projects.blender.org/blender/blender/pulls/145702 - Fix QOS threading - Expose Downloads - UIScene Migration `make deps` needs to run two times. (still hacky....) OSL occurs racing conditions. Disclaimer: I used AI for searching in Documentation of Deps. So the implementation is by hand. **SACRED PINKY FINGER PROMISE** Pull Request: https://projects.blender.org/blender/blender/pulls/161073
34 lines
845 B
Python
34 lines
845 B
Python
import mathutils
|
|
|
|
# Create a KD-tree from a mesh.
|
|
from bpy import context
|
|
obj = context.object
|
|
|
|
mesh = obj.data
|
|
size = len(mesh.vertices)
|
|
kd = mathutils.kdtree.KDTree(size)
|
|
|
|
for i, v in enumerate(mesh.vertices):
|
|
kd.insert(v.co, i)
|
|
|
|
kd.balance()
|
|
|
|
|
|
# Find the closest point to the center.
|
|
co_find = (0.0, 0.0, 0.0)
|
|
co, index, dist = kd.find(co_find)
|
|
print("Close to center:", co, index, dist)
|
|
|
|
# 3D cursor relative to the object data.
|
|
co_find = obj.matrix_world.inverted() @ context.scene.cursor.location
|
|
|
|
# Find the closest 10 points to the 3D cursor.
|
|
print("Close 10 points")
|
|
for (co, index, dist) in kd.find_n(co_find, 10):
|
|
print(" ", co, index, dist)
|
|
|
|
|
|
# Find points within a radius of the 3D cursor.
|
|
print("Close points within 0.5 distance")
|
|
for (co, index, dist) in kd.find_range(co_find, 0.5):
|
|
print(" ", co, index, dist)
|