|
@@ -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
|