From a00b87891997fb947fc1eb0f91d3ad1d34505364 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 17 Aug 2017 01:26:08 +0800 Subject: [PATCH] Use transposed matrix everywhere --- lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp | 18 ++---------------- lib/irrlicht/source/Irrlicht/CSkinnedMesh.h | 3 --- sources.cmake | 2 +- src/graphics/sp_mesh_loader.cpp | 2 +- src/graphics/sp_mesh_loader.hpp | 2 +- src/graphics/stk_mesh_loader.cpp | 1 - 6 files changed, 5 insertions(+), 23 deletions(-) diff --git a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp index 79a925523..b4fcf2b64 100644 --- a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp +++ b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.cpp @@ -21,7 +21,7 @@ namespace scene CSkinnedMesh::CSkinnedMesh() : SkinningBuffers(0), AnimationFrames(0.f), FramesPerSecond(25.f), LastAnimatedFrame(-1), SkinnedLastFrame(false), - InterpolationMode(EIM_LINEAR), TransposedMatrix(false), + InterpolationMode(EIM_LINEAR), HasAnimation(false), PreparedForSkinning(false), AnimateNormals(true), HardwareSkinning(false), m_total_joints(0), m_current_joint(0) @@ -92,13 +92,6 @@ IMesh* CSkinnedMesh::getMesh(s32 frame, s32 detailLevel, s32 startFrameLoop, s32 } -//! For loader usage. -void CSkinnedMesh::setTransposedMatrix(bool val) -{ - TransposedMatrix = val; -} - - //-------------------------------------------------------------------------- // Keyframe Animation //-------------------------------------------------------------------------- @@ -190,14 +183,7 @@ void CSkinnedMesh::buildAllLocalAnimatedMatrices() // IRR_TEST_BROKEN_QUATERNION_USE: TODO - switched to getMatrix_transposed instead of getMatrix for downward compatibility. // Not tested so far if this was correct or wrong before quaternion fix! - if (TransposedMatrix) - { - joint->Animatedrotation.getMatrix_transposed(joint->LocalAnimatedMatrix); - } - else - { - joint->LocalAnimatedMatrix=joint->Animatedrotation.getMatrix(); - } + joint->Animatedrotation.getMatrix_transposed(joint->LocalAnimatedMatrix); // --- joint->LocalAnimatedMatrix *= joint->Animatedrotation.getMatrix() --- f32 *m1 = joint->LocalAnimatedMatrix.pointer(); diff --git a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h index e104f747c..0dd936f0d 100644 --- a/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h +++ b/lib/irrlicht/source/Irrlicht/CSkinnedMesh.h @@ -155,8 +155,6 @@ namespace scene virtual void updateBoundingBox(void); - void setTransposedMatrix(bool); - //! Recovers the joints from the mesh void recoverJointsFromMesh(core::array &jointChildSceneNodes); @@ -225,7 +223,6 @@ private: E_INTERPOLATION_MODE InterpolationMode:8; - bool TransposedMatrix; bool HasAnimation; bool PreparedForSkinning; bool AnimateNormals; diff --git a/sources.cmake b/sources.cmake index ddc029d4f..d4f28ae4d 100644 --- a/sources.cmake +++ b/sources.cmake @@ -1,4 +1,4 @@ -# Modify this file to change the last-modified date when you add/remove a file. +# Modify this file to change the last-modified date when you add/remove a file. # This will then trigger a new cmake run automatically. file(GLOB_RECURSE STK_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.hpp") file(GLOB_RECURSE STK_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*.cpp") diff --git a/src/graphics/sp_mesh_loader.cpp b/src/graphics/sp_mesh_loader.cpp index f897d3820..fd1bd48ea 100644 --- a/src/graphics/sp_mesh_loader.cpp +++ b/src/graphics/sp_mesh_loader.cpp @@ -544,7 +544,7 @@ void SPMeshLoader::LocRotScale::read(irr::io::IReadFile* spm) float tmp[10]; spm->read(&tmp, 40); m_loc = core::vector3df(tmp[0], tmp[1], tmp[2]); - m_rot = core::quaternion(tmp[3], tmp[4], tmp[5], tmp[6]); + m_rot = core::quaternion(-tmp[3], -tmp[4], -tmp[5], tmp[6]); m_rot.normalize(); m_scale = core::vector3df(tmp[7], tmp[8], tmp[9]); } // LocRotScale::read diff --git a/src/graphics/sp_mesh_loader.hpp b/src/graphics/sp_mesh_loader.hpp index b63a517ca..5333339be 100644 --- a/src/graphics/sp_mesh_loader.hpp +++ b/src/graphics/sp_mesh_loader.hpp @@ -326,7 +326,7 @@ private: core::matrix4 lm, sm, rm; lm.setTranslation(m_loc); sm.setScale(m_scale); - m_rot.getMatrix(rm); + m_rot.getMatrix_transposed(rm); return lm * rm * sm; } // -------------------------------------------------------------------- diff --git a/src/graphics/stk_mesh_loader.cpp b/src/graphics/stk_mesh_loader.cpp index 7cdd4f5c2..a11dca346 100644 --- a/src/graphics/stk_mesh_loader.cpp +++ b/src/graphics/stk_mesh_loader.cpp @@ -41,7 +41,6 @@ scene::IAnimatedMesh* STKMeshLoader::createMesh(io::IReadFile* f) B3DFile = f; AnimatedMesh = new scene::CSkinnedMesh(); - AnimatedMesh->setTransposedMatrix(true); ShowWarning = true; // If true a warning is issued if too many textures are used VerticesStart=0;