Beispiel #1
0
def raycast(p1, p2, actors, mode=RAYCAST_FIND_FIRST):
    ri = B2D.b2RayCastInput(p1=p1, p2=p2, maxFraction=1.0)
    ro = B2D.b2RayCastOutput()
    found = []
    for actor in actors:
        if actor.shape.RayCast(ro, ri, actor.transform, 0):
            if mode == RAYCAST_FIND_FIRST:
                ri.maxFraction = ro.fraction
            found.append(actor)
    if mode == RAYCAST_FIND_FIRST:
        return found[-1] if found else None
    return found