From f04573984a51974eb8d52e34f077b9add1a7a7ef Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 Jan 2020 20:41:37 +0100 Subject: [PATCH 1/4] Update glTF2Importer.cpp Remove dead code --- code/glTF2/glTF2Importer.cpp | 65 ++++++++---------------------------- 1 file changed, 13 insertions(+), 52 deletions(-) diff --git a/code/glTF2/glTF2Importer.cpp b/code/glTF2/glTF2Importer.cpp index d607d27a5..edee9c8e6 100644 --- a/code/glTF2/glTF2Importer.cpp +++ b/code/glTF2/glTF2Importer.cpp @@ -139,45 +139,6 @@ static aiTextureMapMode ConvertWrappingMode(SamplerWrap gltfWrapMode) { } } -/*static void CopyValue(const glTF2::vec3& v, aiColor3D& out) -{ - out.r = v[0]; out.g = v[1]; out.b = v[2]; -} - - -static void CopyValue(const glTF2::vec4& v, aiColor4D& out) -{ - out.r = v[0]; out.g = v[1]; out.b = v[2]; out.a = v[3]; -}*/ - -/*static void CopyValue(const glTF2::vec4& v, aiColor3D& out) -{ - out.r = v[0]; out.g = v[1]; out.b = v[2]; -}*/ - -/*static void CopyValue(const glTF2::vec3& v, aiColor4D& out) -{ - out.r = v[0]; out.g = v[1]; out.b = v[2]; out.a = 1.0; -} - -static void CopyValue(const glTF2::vec3& v, aiVector3D& out) -{ - out.x = v[0]; out.y = v[1]; out.z = v[2]; -} - -static void CopyValue(const glTF2::vec4& v, aiQuaternion& out) -{ - out.x = v[0]; out.y = v[1]; out.z = v[2]; out.w = v[3]; -}*/ - -/*static void CopyValue(const glTF2::mat4& v, aiMatrix4x4& o) -{ - o.a1 = v[ 0]; o.b1 = v[ 1]; o.c1 = v[ 2]; o.d1 = v[ 3]; - o.a2 = v[ 4]; o.b2 = v[ 5]; o.c2 = v[ 6]; o.d2 = v[ 7]; - o.a3 = v[ 8]; o.b3 = v[ 9]; o.c3 = v[10]; o.d3 = v[11]; - o.a4 = v[12]; o.b4 = v[13]; o.c4 = v[14]; o.d4 = v[15]; -}*/ - inline void SetMaterialColorProperty(Asset & /*r*/, vec4 &prop, aiMaterial *mat, const char *pKey, unsigned int type, unsigned int idx) { aiColor4D col; CopyValue(prop, col); @@ -512,7 +473,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { } } - aiFace *faces = 0; + aiFace *faces = nullptr; size_t nFaces = 0; if (prim.indices) { @@ -674,13 +635,13 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { } } - if (faces) { + if (nullptr != faces) { aim->mFaces = faces; aim->mNumFaces = static_cast(nFaces); ai_assert(CheckValidFacesIndices(faces, static_cast(nFaces), aim->mNumVertices)); } - if (prim.material) { + if (nullptr != prim.material) { aim->mMaterialIndex = prim.material.GetIndex(); } else { aim->mMaterialIndex = mScene->mNumMaterials - 1; @@ -981,7 +942,9 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & } void glTF2Importer::ImportNodes(glTF2::Asset &r) { - if (!r.scene) return; + if (!r.scene) { + return; + } std::vector> rootNodes = r.scene->nodes; @@ -1292,7 +1255,9 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) { if (!img.mimeType.empty()) { const char *ext = strchr(img.mimeType.c_str(), '/') + 1; if (ext) { - if (strcmp(ext, "jpeg") == 0) ext = "jpg"; + if (strcmp(ext, "jpeg") == 0) { + ext = "jpg"; + } size_t len = strlen(ext); if (len <= 3) { @@ -1308,19 +1273,15 @@ void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) { const bool hasVersion = !a.asset.version.empty(); const bool hasGenerator = !a.asset.generator.empty(); const bool hasCopyright = !a.asset.copyright.empty(); - if (hasVersion || hasGenerator || hasCopyright) - { + if (hasVersion || hasGenerator || hasCopyright) { mScene->mMetaData = new aiMetadata; - if (hasVersion) - { + if (hasVersion) { mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version)); } - if (hasGenerator) - { + if (hasGenerator) { mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator)); } - if (hasCopyright) - { + if (hasCopyright) { mScene->mMetaData->Add(AI_METADATA_SOURCE_COPYRIGHT, aiString(a.asset.copyright)); } } From 9b8f2970c86ae982799872e286f315484da3eb49 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 Jan 2020 21:22:41 +0100 Subject: [PATCH 2/4] Update glTF2Importer.cpp - fix compiler error: invalid == operator - Fix compiler warning: conversion from double to ai_real --- code/glTF2/glTF2Importer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/glTF2/glTF2Importer.cpp b/code/glTF2/glTF2Importer.cpp index edee9c8e6..250c790b1 100644 --- a/code/glTF2/glTF2Importer.cpp +++ b/code/glTF2/glTF2Importer.cpp @@ -179,8 +179,8 @@ inline void SetMaterialTextureProperty(std::vector &embeddedTexIdxs, Asset // coordinate of the actual meshes during import. const ai_real rcos(cos(-transform.mRotation)); const ai_real rsin(sin(-transform.mRotation)); - transform.mTranslation.x = (0.5 * transform.mScaling.x) * (-rcos + rsin + 1) + prop.TextureTransformExt_t.offset[0]; - transform.mTranslation.y = ((0.5 * transform.mScaling.y) * (rsin + rcos - 1)) + 1 - transform.mScaling.y - prop.TextureTransformExt_t.offset[1];; + transform.mTranslation.x = (static_cast( 0.5 ) * transform.mScaling.x) * (-rcos + rsin + 1) + prop.TextureTransformExt_t.offset[0]; + transform.mTranslation.y = ((static_cast( 0.5 ) * transform.mScaling.y) * (rsin + rcos - 1)) + 1 - transform.mScaling.y - prop.TextureTransformExt_t.offset[1];; mat->AddProperty(&transform, 1, _AI_MATKEY_UVTRANSFORM_BASE, texType, texSlot); } @@ -641,7 +641,7 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { ai_assert(CheckValidFacesIndices(faces, static_cast(nFaces), aim->mNumVertices)); } - if (nullptr != prim.material) { + if (prim.material) { aim->mMaterialIndex = prim.material.GetIndex(); } else { aim->mMaterialIndex = mScene->mNumMaterials - 1; From 37210372a8259ef7e82ad5210dfb117669989413 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 Jan 2020 21:26:37 +0100 Subject: [PATCH 3/4] Update VertexTriangleAdjacency.cpp closes https://github.com/assimp/assimp/issues/2806: calculate corret number of vertices. --- code/Common/VertexTriangleAdjacency.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/Common/VertexTriangleAdjacency.cpp b/code/Common/VertexTriangleAdjacency.cpp index 7cfd1a350..83558f697 100644 --- a/code/Common/VertexTriangleAdjacency.cpp +++ b/code/Common/VertexTriangleAdjacency.cpp @@ -58,7 +58,7 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces, { // compute the number of referenced vertices if it wasn't specified by the caller const aiFace* const pcFaceEnd = pcFaces + iNumFaces; - if (!iNumVertices) { + if (0 == iNumVertices) { for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace) { ai_assert( nullptr != pcFace ); ai_assert(3 == pcFace->mNumIndices); @@ -68,7 +68,7 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces, } } - mNumVertices = iNumVertices; + mNumVertices = iNumVertices + 1; unsigned int* pi; From 7b7100a94b2274f80be4c79759b118dd504d0695 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 8 Jan 2020 14:20:56 +0200 Subject: [PATCH 4/4] Revert 3_bananas.amf.7z to working version Was broken by a8a1ca9894a38164f3111f57fddb887b3549ea60. Partially revert that commit. Closes #2857 --- test/models-nonbsd/AMF/3_bananas.amf.7z | Bin 7652204 -> 7652329 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/test/models-nonbsd/AMF/3_bananas.amf.7z b/test/models-nonbsd/AMF/3_bananas.amf.7z index 9d035c5925798d4b67923125a2e93e60efae0c9b..c2b6785a3804e3636d2876b7297ebb934a721a7f 100644 GIT binary patch delta 1268 zcmWlYe^Aq99LH}AVN6E44Tf&YZ#K5vz$E!O;+L44{FIRn84Yj@1OnEn$FJhdb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