Skip to content

Commit

Permalink
style(transform): replace if by ternary operator
Browse files Browse the repository at this point in the history
Makes code more confusing
  • Loading branch information
RiscadoA committed Feb 2, 2024
1 parent 43e126b commit 96877c3
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions engine/src/cubos/engine/transform/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,9 @@ void cubos::engine::transformPlugin(Cubos& cubos)
.call([](Query<LocalToWorld&, Opt<LocalToParent&>, 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));
}
});

Expand Down

0 comments on commit 96877c3

Please sign in to comment.