Thu, 27 Feb 2020 14:38:48 +0200
fixed testing of whether screenToModelCoordinates's result value is behind the camera
src/gl/partrenderer.cpp | file | annotate | diff | comparison | revisions |
--- a/src/gl/partrenderer.cpp Thu Feb 27 12:23:42 2020 +0200 +++ b/src/gl/partrenderer.cpp Thu Feb 27 14:38:48 2020 +0200 @@ -300,11 +300,11 @@ auto p2 = this->unproject({point.x(), point.y(), 1}); geom::Line line = geom::lineFromPoints(p1, p2); std::optional<glm::vec3> result; - // If the dot product between the line direction and plane normal is negative, the point - // of intersection lies behind the camera. - if (glm::dot(line.direction, plane.normal) > 0) + result = geom::linePlaneIntersection(line, plane, 0.01f); + // If the point lies behind the camera, do not return a result. + if (result.has_value() and glm::dot(line.direction, *result - p1) < 0) { - result = geom::linePlaneIntersection(line, plane, 0.01); + result.reset(); } return result; }