New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLTF Importer: Build a list of the actual vertices so it works well with shared attribute lists #5003
GLTF Importer: Build a list of the actual vertices so it works well with shared attribute lists #5003
Conversation
…ith shared attribute lists
ASSIMP_LOG_WARN("Positions of target ", i, " in mesh \"", mesh.name, "\" does not match the vertex count"); | ||
} else { | ||
aiVector3D *positionDiff = nullptr; | ||
target.position[0]->ExtractData(positionDiff); | ||
target.position[0]->ExtractData(positionDiff, vertexRemappingTable); | ||
for (unsigned int vertexId = 0; vertexId < aim->mNumVertices; vertexId++) { | ||
aiAnimMesh.mVertices[vertexId] += positionDiff[vertexId]; | ||
} | ||
delete[] positionDiff; | ||
} | ||
} | ||
if (needNormals) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to revisit whether the following block still uses the correct indexing of normals/tangets for animated parts
@@ -380,7 +380,7 @@ TEST_F(utglTF2ImportExport, importglTF2PrimitiveModeLines) { | |||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/glTF-Asset-Generator/Mesh_PrimitiveMode/Mesh_PrimitiveMode_08.gltf", aiProcess_ValidateDataStructure); | |||
EXPECT_NE(nullptr, scene); | |||
EXPECT_EQ(scene->mMeshes[0]->mNumVertices, 4u); | |||
std::array<unsigned int, 5> l1 = { { 0u, 3u, 2u, 1u, 0u } }; | |||
std::array<unsigned int, 5> l1 = { { 0u, 1u, 2u, 3u, 0u } }; | |||
EXPECT_EQ(scene->mMeshes[0]->mFaces[0].mNumIndices, 2u); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extracting the used vertices changes the order of vertices and thus the index buffer
@kimkulling , what do you think about this improvements? |
I have started to take a look on it. Stay tuned :-). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So when identitying the indices are the same this fix will just reuse them to save memory allocation. Great idea! Thanks a lot for your investigations and the PR as well! I really appreciate this!
Merged, thanks a lot for your contribution. |
This PR addresses this bug:
Out-of-memory for some gltf exported with "Sketchup glTF Exporter by Centaur"
It shows that the memory consumption during import for said customer model now goes down from >800GM (->out-of-memory) to <700MB, so more than 1000x !
In my opinion this change makes sense, but I wanted to ask if this looks like a good approach to the problem for you as well.
Of course this needs more testing with other assets,