Sun, 03 Jul 2022 21:47:44 +0300
Fix normal of the plane used to find cylinder height
src/layers/edittools.cpp | file | annotate | diff | comparison | revisions |
--- a/src/layers/edittools.cpp Sun Jul 03 20:18:34 2022 +0300 +++ b/src/layers/edittools.cpp Sun Jul 03 21:47:44 2022 +0300 @@ -268,13 +268,15 @@ return {}; } else { + const glm::vec3 cameravec = glm::normalize(this->renderer->cameraVector(this->localPosition)); + const glm::vec3 heightvec = glm::normalize(glm::vec3{gridMatrix[2]}); + const glm::vec3 normal = glm::cross(glm::cross(cameravec, heightvec), heightvec); const Plane plane{ - .normal = glm::normalize(this->renderer->cameraVector(this->localPosition)), + .normal = normal, .anchor = this->inputPolygon[0], }; const opt<glm::vec3> p = this->renderer->screenToModelCoordinates(this->localPosition, plane); if (p.has_value()) { - const glm::vec3 heightvec = glm::normalize(glm::vec3{gridMatrix[2]}); return std::round(glm::dot(*p - this->inputPolygon[0], heightvec)); } else {