소스 검색

tests: Add unit test for CollisionRay into CollisionBox

Closes #613
Jerome 6 년 전
부모
커밋
66ea0471a0
1개의 변경된 파일17개의 추가작업 그리고 0개의 파일을 삭제
  1. 17 0
      tests/collide/test_into_box.py

+ 17 - 0
tests/collide/test_into_box.py

@@ -26,3 +26,20 @@ def test_plane_into_box():
 
 
     entry = make_collision(plane, box)[0]
     entry = make_collision(plane, box)[0]
     assert entry is None
     assert entry is None
+
+
+def test_ray_into_box():
+    ray = CollisionRay(1, 1, 1, 0, 1, 0)
+    box = CollisionBox((0, 0, 0), 3, 3, 5)
+    entry = make_collision(ray, box)[0]
+    assert entry is not None
+    assert entry.get_from() == ray
+    assert entry.get_into() == box
+
+    # Colliding just on the edge
+    entry, np_from, np_into = make_collision(CollisionRay(3, 3, 0, 1, -1, 0), box)
+    assert entry.get_surface_point(np_from) == Point3(3, 3, 0)
+
+    # No collision
+    entry = make_collision(CollisionRay(0, 0, 100, 1, 0, 0), box)[0]
+    assert entry is None