101 } |
101 } |
102 } |
102 } |
103 |
103 |
104 std::optional<glm::vec2> geom::rayLineSegmentIntersection(const Ray<2>& ray, const LineSegment2D& line) |
104 std::optional<glm::vec2> geom::rayLineSegmentIntersection(const Ray<2>& ray, const LineSegment2D& line) |
105 { |
105 { |
106 std::optional<glm::vec2> result = lineLineIntersection(rayToLine(ray), lineFromPoints(line.points[0], line.points[1])); |
106 std::optional<glm::vec2> result = lineLineIntersection( |
|
107 rayToLine(ray), |
|
108 lineFromPoints(line.points[0], line.points[1])); |
107 if (result.has_value()) |
109 if (result.has_value()) |
108 { |
110 { |
109 const float d1 = glm::dot(*result - ray.anchor, ray.direction); |
111 const float d1 = glm::dot(*result - ray.anchor, ray.direction); |
110 if (d1 < 0) |
112 if (d1 < 0) |
111 { |
113 { |