utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:UPBGE-CommunityAddon 作者: elmeunick9 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号