def getNearestVertexToPoly(object, poly, point):
""" Returns the nearest vertext to a poligon.
:param poly: The poligon if wich vertex you want to check.
:type poly: |KX_PolyProxy|
:param point: The point to check, in world coordinates.
:type point: |Vector|
"""
if not type(point) is Vector: point = Vector(point)
mesh = poly.getMesh()
min = None
f = None
for i in range(poly.getNumVertex()):
v = mesh.getVertex(0, poly.getVertexIndex(i))
r = vectorFrom2Points(v.XYZ, point - object.worldPosition).length
if not min or r < min:
min = r
f = v
return f
评论列表
文章目录