From 1abce92887922eeee0fefdff1d7d17ea278a339e Mon Sep 17 00:00:00 2001 From: Matthew Hayden Date: Thu, 21 Mar 2024 18:00:43 +0000 Subject: [PATCH] Decode matrices in column-major order. --- src/Text/GLTF/Loader/Internal/Decoders.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Text/GLTF/Loader/Internal/Decoders.hs b/src/Text/GLTF/Loader/Internal/Decoders.hs index 09b779d..22babb9 100644 --- a/src/Text/GLTF/Loader/Internal/Decoders.hs +++ b/src/Text/GLTF/Loader/Internal/Decoders.hs @@ -90,12 +90,17 @@ getMat3 getter = -- | 4x4 Matrix binary decoder getMat4 :: Get a -> Get (Vector (M44 a)) getMat4 getter = - getVector - $ V4 - <$> (V4 <$> getter <*> getter <*> getter <*> getter) - <*> (V4 <$> getter <*> getter <*> getter <*> getter) - <*> (V4 <$> getter <*> getter <*> getter <*> getter) - <*> (V4 <$> getter <*> getter <*> getter <*> getter) + getVector $ do { + m11 <- getter; m12 <- getter; m13 <- getter; m14 <- getter; + m21 <- getter; m22 <- getter; m23 <- getter; m24 <- getter; + m31 <- getter; m32 <- getter; m33 <- getter; m34 <- getter; + m41 <- getter; m42 <- getter; m43 <- getter; m44 <- getter; + return $ V4 + (V4 m11 m21 m31 m41) + (V4 m12 m22 m32 m42) + (V4 m13 m23 m33 m43) + (V4 m14 m24 m34 m44) + } -- | Byte binary decoder getByte :: Get Int8