From 1a8d3c777a3ff368df1e1f4486b537afe0483b99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Fri, 8 Jan 2021 13:28:54 +0100 Subject: [PATCH] Contruct Transform like glTF --- lavos/include/lavos/component/transform_component.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lavos/include/lavos/component/transform_component.h b/lavos/include/lavos/component/transform_component.h index db508a1..b7e8c17 100644 --- a/lavos/include/lavos/component/transform_component.h +++ b/lavos/include/lavos/component/transform_component.h @@ -22,7 +22,9 @@ class TransformComp: public Component glm::mat4 GetMatrix() { - return glm::scale(glm::translate(glm::mat4(1.0f), translation), scale) * glm::toMat4(rotation); + return glm::translate(glm::mat4(1.0f), translation) + * glm::toMat4(rotation) + * glm::scale(glm::mat4(1.0f), scale); } glm::mat4 GetMatrixWorld() @@ -30,11 +32,10 @@ class TransformComp: public Component glm::mat4 m = GetMatrix(); Node *parent = GetNode()->GetParent(); - if(parent == nullptr) + if(!parent) return m; - TransformComp *parent_transform = parent->GetTransformComp(); - if(parent_transform == nullptr) + if(!parent_transform) return m; return parent_transform->GetMatrixWorld() * m; -- 2.45.2