From e0690ba1948e2b6102001eddefdbaf2512bcdd66 Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Thu, 1 Feb 2024 23:37:27 +0000 Subject: [PATCH] style(transform): replace if by ternary operator Makes code more confusing --- engine/src/cubos/engine/transform/plugin.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/engine/src/cubos/engine/transform/plugin.cpp b/engine/src/cubos/engine/transform/plugin.cpp index 66f3a12a15..4d385e4a85 100644 --- a/engine/src/cubos/engine/transform/plugin.cpp +++ b/engine/src/cubos/engine/transform/plugin.cpp @@ -101,18 +101,9 @@ void cubos::engine::transformPlugin(Cubos& cubos) .call([](Query, const Position&, const Rotation&, const Scale&> query) { for (auto [localToWorld, localToParent, position, rotation, scale] : query) { - auto mat = glm::scale(glm::translate(localToWorld.mat, position.vec) * glm::toMat4(rotation.quat), - glm::vec3(scale.factor)); - - if (localToParent) - { - localToParent->mat = mat; - } - else - { - // No parent, so transform is relative to the world - localToWorld.mat = mat; - } + auto& mat = localToParent ? localToParent->mat : localToWorld.mat; + mat = glm::scale(glm::translate(glm::mat4(1.0F), position.vec) * glm::toMat4(rotation.quat), + glm::vec3(scale.factor)); } });