Advertisement
Guest User

Untitled

a guest
May 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. func collide_face_with_point(face):
  2. var ins_point = insertion_point(face)
  3. if ins_point != null && (ins_point-actual_pos).length() < COLLISION_DISTANCE:
  4. if (face[1] - face[0]).cross(ins_point - face[0]).dot(face[3]) >= 0:
  5. if (face[0] - face[2]).cross(ins_point - face[2]).dot(face[3]) >= 0:
  6. if (face[2] - face[1]).cross(ins_point - face[1]).dot(face[3]) >= 0:
  7. collision_with_face(face)
  8. pass
  9.  
  10. func insertion_point(face):
  11. var n_dot_v = face[3].dot(velocity_vector)
  12. if n_dot_v == 0:
  13. return null
  14. return actual_pos - ((face[3].dot(actual_pos)-face[4])/face[3].dot(velocity_vector)*velocity_vector)
  15.  
  16. gdzie face od 0-2 to wierzchołki trójkąta 3 to normalna do płaszczyzny a 4 to alfa
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement