Skip to content

Commit

Permalink
Check for rays being inside first
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Jun 11, 2024
1 parent 2a54fe3 commit 6a2e11c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/collisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,12 +769,12 @@ def trace_ray(self, start: Vec | FrozenVec, delta: Vec | FrozenVec) -> Hit | Non
best_hit: Hit | None = None
inside = True
for plane in self.planes:
# Check if the start point is inside the plane.
if Vec.dot(start, plane.normal) < plane.distance:
inside = False
dot = Vec.dot(plane.normal, direction)
# If perpendicular or facing in the same direction, the ray can't trace into it.
if dot <= 0.0:
# Check if the start point is inside the plane.
if Vec.dot(start, plane.normal) < plane.distance:
inside = False
continue
t = (plane.distance - Vec.dot(start, plane.normal)) / dot
if not (0.0 <= t <= max_dist) or (best_hit is not None and t > best_hit.distance):
Expand Down

0 comments on commit 6a2e11c

Please sign in to comment.