From e53d4735b0ca5fd879168a135129e42887a74511 Mon Sep 17 00:00:00 2001 From: awefers Date: Mon, 27 Nov 2017 11:30:18 -0500 Subject: [PATCH] Fix transform matrices multiplication order per glTF2.0 spec Closes #1568 --- code/glTF2Importer.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index 297f2bc72..7e7483484 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -515,7 +515,13 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector& CopyValue(node.translation.value, trans); aiMatrix4x4 t; aiMatrix4x4::Translation(trans, t); - matrix = t * matrix; + matrix = matrix * t; + } + + if (node.rotation.isPresent) { + aiQuaternion rot; + CopyValue(node.rotation.value, rot); + matrix = matrix * aiMatrix4x4(rot.GetMatrix()); } if (node.scale.isPresent) { @@ -523,14 +529,7 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector& CopyValue(node.scale.value, scal); aiMatrix4x4 s; aiMatrix4x4::Scaling(scal, s); - matrix = s * matrix; - } - - - if (node.rotation.isPresent) { - aiQuaternion rot; - CopyValue(node.rotation.value, rot); - matrix = aiMatrix4x4(rot.GetMatrix()) * matrix; + matrix = matrix * s; } }