diff --git a/engine/src/gizmos/types/cut_cone.hpp b/engine/src/gizmos/types/cut_cone.hpp index a3125e69b..37d94eb3d 100644 --- a/engine/src/gizmos/types/cut_cone.hpp +++ b/engine/src/gizmos/types/cut_cone.hpp @@ -47,19 +47,36 @@ namespace cubos::engine glm::vec3 n = glm::normalize(mPointB - mPointA); glm::vec3 p; - if (n[0] != n[1]) + + if (n[0] != 0 && n[1] != 0) { - p = {n[1], -n[0], n[2]}; + p = {-n[1], n[0], 0}; } - else if (n[0] != n[2]) + else if (n[0] == 0 && n[1] != 0) { - p = {-n[2], n[1], n[0]}; + if (n[2] != 0) + { + p = {1, 0, -n[1] / n[2]}; + } + else + { + p = {1, 0, 0}; + } } else { - p = {n[0], -n[2], n[1]}; + if (n[2] != 0) + { + p = {0, 1, -n[1] / n[2]}; + } + else + { + p = {0, 1, 0}; + } } + p = glm::normalize(p); + glm::vec3 pA = p * mRadiusA; for (int i = 0; i < GizmosRenderer::CutConeVertsPerBase; i++) diff --git a/engine/src/gizmos/types/ring.hpp b/engine/src/gizmos/types/ring.hpp index 1416db063..c79ff9065 100644 --- a/engine/src/gizmos/types/ring.hpp +++ b/engine/src/gizmos/types/ring.hpp @@ -47,19 +47,35 @@ namespace cubos::engine glm::vec3 n = glm::normalize(mPointB - mPointA); glm::vec3 p; - if (n[0] != n[1]) + if (n[0] != 0 && n[1] != 0) { - p = {n[1], -n[0], n[2]}; + p = {-n[1], n[0], 0}; } - else if (n[0] != n[2]) + else if (n[0] == 0 && n[1] != 0) { - p = {-n[2], n[1], n[0]}; + if (n[2] != 0) + { + p = {1, 0, -n[1] / n[2]}; + } + else + { + p = {1, 0, 0}; + } } else { - p = {n[0], -n[2], n[1]}; + if (n[2] != 0) + { + p = {0, 1, -n[1] / n[2]}; + } + else + { + p = {0, 1, 0}; + } } + p = glm::normalize(p); + glm::vec3 pA = p * mRadiusOuter; glm::vec3 pB = p * mRadiusInner;