Skip to content

Commit

Permalink
fix #5057 (broken in d92b319; IsIdentity returns 0 when true)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtri committed Feb 5, 2016
1 parent a871b28 commit 151d7a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion rts/Rendering/Models/3DModel.h
Expand Up @@ -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);
}

Expand Down
28 changes: 15 additions & 13 deletions 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"
Expand Down Expand Up @@ -286,7 +285,8 @@ void CAssParser::LoadPieceTransformations(
const aiNode* pieceNode,
const LuaTable& pieceTable
) {
aiVector3D aiScaleVec, aiTransVec;
aiVector3D aiScaleVec;
aiVector3D aiTransVec;
aiQuaternion aiRotateQuat;

// process transforms
Expand Down Expand Up @@ -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);
Expand All @@ -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<float>(aiRotateQuat.GetMatrix()));
CMatrix44f bakedMatrix = aiMatrixToMatrix(aiMatrix4x4t<float>(aiRotateQuat.GetMatrix()));

if (piece == model->GetRootPiece()) {
const float3 xaxis = pieceTable.GetFloat3("xaxis", bakedMatrix.GetX());
Expand Down

0 comments on commit 151d7a2

Please sign in to comment.