From c0c7e6a0de94c450275775d8a94582f7a6457871 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Fri, 12 Mar 2021 14:48:38 +0100 Subject: [PATCH] trim uvIndices to fix import of Cheetah3D generated fbx files --- code/AssetLib/FBX/FBXMeshGeometry.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp index 0a5074fb4..fd8a0ff98 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.cpp +++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp @@ -508,11 +508,17 @@ void ResolveVertexDataArray(std::vector& data_out, const Scope& source, std::vector uvIndices; ParseVectorDataArray(uvIndices,GetRequiredElement(source,indexDataElementName)); - // if (uvIndices.size() != vertex_count) { - // FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ") - // << uvIndices.size() << ", expected " << vertex_count); - // return; - // } + if (uvIndices.size() > vertex_count) { + FBXImporter::LogWarn(Formatter::format("trimming length of input array for ByPolygonVertex mapping: ") + << uvIndices.size() << ", expected " << vertex_count); + uvIndices.resize(vertex_count); + } + + if (uvIndices.size() != vertex_count) { + FBXImporter::LogError(Formatter::format("length of input data unexpected for ByPolygonVertex mapping: ") + << uvIndices.size() << ", expected " << vertex_count); + return; + } data_out.resize(vertex_count);