From 151d7a20565a541fdf4c30b4c501633959aa1626 Mon Sep 17 00:00:00 2001 From: rtri Date: Fri, 5 Feb 2016 18:49:45 +0100 Subject: [PATCH] fix #5057 (broken in d92b3196; IsIdentity returns 0 when true) --- rts/Rendering/Models/3DModel.h | 2 +- rts/Rendering/Models/AssParser.cpp | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/rts/Rendering/Models/3DModel.h b/rts/Rendering/Models/3DModel.h index f1b15db6135..20101d493ca 100644 --- a/rts/Rendering/Models/3DModel.h +++ b/rts/Rendering/Models/3DModel.h @@ -155,7 +155,7 @@ struct S3DModelPiece { void SetModelMatrix(const CMatrix44f& m) { // assimp only bakedRotMatrix = m; - hasIdentityRot = m.IsIdentity(); + hasIdentityRot = (m.IsIdentity() == 0); assert(m.IsOrthoNormal() == 0); } diff --git a/rts/Rendering/Models/AssParser.cpp b/rts/Rendering/Models/AssParser.cpp index 81332eedca5..026c54ef3c5 100644 --- a/rts/Rendering/Models/AssParser.cpp +++ b/rts/Rendering/Models/AssParser.cpp @@ -1,7 +1,6 @@ /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ #include "AssParser.h" - #include "3DModel.h" #include "3DModelLog.h" #include "AssIO.h" @@ -286,7 +285,8 @@ void CAssParser::LoadPieceTransformations( const aiNode* pieceNode, const LuaTable& pieceTable ) { - aiVector3D aiScaleVec, aiTransVec; + aiVector3D aiScaleVec; + aiVector3D aiTransVec; aiQuaternion aiRotateQuat; // process transforms @@ -316,7 +316,7 @@ void CAssParser::LoadPieceTransformations( // together with the (baked) aiRotateQuad they determine the // model's pose *before* any animations execute // - // float3 rotAngles = pieceTable.GetFloat3("rotate", aiQuaternionToRadianAngles(aiRotateQuat) * RADTODEG); + // float3 pieceRotAngles = pieceTable.GetFloat3("rotate", aiQuaternionToRadianAngles(aiRotateQuat) * RADTODEG); float3 pieceRotAngles = pieceTable.GetFloat3("rotate", ZeroVector); pieceRotAngles.x = pieceTable.GetFloat("rotatex", pieceRotAngles.x); @@ -340,20 +340,22 @@ void CAssParser::LoadPieceTransformations( ); // NOTE: - // at least collada (.dae) files generated by Blender represent - // a coordinate-system that differs from the "standard" formats - // (3DO, S3O, ...) for which existing tools at least have prior - // knowledge of Spring's expectations --> let the user override - // the ROOT rotational transform and the rotation-axis mapping - // used by animation scripts (but re-modelling/re-exporting is - // always preferred!) even though AssImp should convert models - // to its own system which matches that of Spring + // at least collada (.dae) files generated by Blender are stored + // in a coordinate-system that differs from the standard formats + // (3DO, S3O, ...) for which existing tools have prior knowledge + // of Spring's convention, but AssImp's internal system happens + // to match our own so we need no explicit conversion + // + // we allow overriding the (baked) ROOT rotational transform and + // the rotation-axis mapping used by animation scripts because it + // can be a benefit to create models wrt. a different orientation + // than that of the 3D editor (but re-modelling / re-exporting is + // always preferred!) // // .dae : x=Rgt, y=-Fwd, z= Up, as=(-1, -1, 1), am=AXIS_XZY (if Z_UP) // .dae : x=Rgt, y=-Fwd, z= Up, as=(-1, -1, 1), am=AXIS_XZY (if Y_UP) [!?] // .blend: ???? - CMatrix44f bakedMatrix; - bakedMatrix = aiMatrixToMatrix(aiMatrix4x4t(aiRotateQuat.GetMatrix())); + CMatrix44f bakedMatrix = aiMatrixToMatrix(aiMatrix4x4t(aiRotateQuat.GetMatrix())); if (piece == model->GetRootPiece()) { const float3 xaxis = pieceTable.GetFloat3("xaxis", bakedMatrix.GetX());