Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. # Returns the three vertices of the given triangle in CCW order
  2. GetVertices(t)
  3. # Returns the three triangles adjacent to this one.
  4. # Ordered so that GetAdjacentTriangles(t)[i] shares entries i and i+1 of GetVertices(t).
  5. # An entry may be None if the edge is on the boundary of the navmesh.
  6. GetAdjacentTriangles(t)
  7.  
  8. def LineOfSight(s1,t1,s2,t2):
  9. d = s2 - s1 # Direction from s1 to s2
  10. n = (-d.y, d.x) # Normal to line s1-s2.
  11. ns = Dot(n, s1)
  12. while t1 != t2:
  13. dp = [Dot(n, v) for v in navmesh.GetVertices(t1)]
  14. for i in xrange(3):
  15. if dp[i] < 0 and dp[(i+1)%3] >= 0: break
  16. # We should cross the edge between vertices i and i+1.
  17. t1 = navmesh.GetAdjacentTriangles(t1)[i]
  18. if t1 is None: return False # We stepped off the NavMesh
  19. return True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement