Skip to content

Commit b9ab0e4

Browse files
committed
Fix handling missing skins using ufbx importer
Previously, _asset_parse_skins() would mess with the order of skin indices. However, the rest of the code expected these to match to ufbx skin indices. To fix this, retain the original skin indices in FBXState::original_skin_indices.
1 parent 03e6fbb commit b9ab0e4

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

modules/fbx/fbx_document.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -693,10 +693,7 @@ Error FBXDocument::_parse_meshes(Ref<FBXState> p_state) {
693693

694694
// Find the first imported skin deformer
695695
for (ufbx_skin_deformer *fbx_skin : fbx_mesh->skin_deformers) {
696-
if (!p_state->skin_indices.has(fbx_skin->typed_id)) {
697-
continue;
698-
}
699-
GLTFSkinIndex skin_i = p_state->skin_indices[fbx_skin->typed_id];
696+
GLTFSkinIndex skin_i = p_state->original_skin_indices[fbx_skin->typed_id];
700697
if (skin_i < 0) {
701698
continue;
702699
}
@@ -2341,7 +2338,7 @@ Error FBXDocument::_parse_skins(Ref<FBXState> p_state) {
23412338
HashMap<GLTFNodeIndex, bool> joint_mapping;
23422339

23432340
for (const ufbx_skin_deformer *fbx_skin : fbx_scene->skin_deformers) {
2344-
if (fbx_skin->clusters.count == 0) {
2341+
if (fbx_skin->clusters.count == 0 || fbx_skin->weights.count == 0) {
23452342
p_state->skin_indices.push_back(-1);
23462343
continue;
23472344
}
@@ -2387,8 +2384,9 @@ Error FBXDocument::_parse_skins(Ref<FBXState> p_state) {
23872384
}
23882385
}
23892386
}
2387+
p_state->original_skin_indices = p_state->skin_indices.duplicate();
23902388
Error err = SkinTool::_asset_parse_skins(
2391-
p_state->skin_indices.duplicate(),
2389+
p_state->original_skin_indices,
23922390
p_state->skins.duplicate(),
23932391
p_state->nodes.duplicate(),
23942392
p_state->skin_indices,

modules/fbx/fbx_state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class FBXState : public GLTFState {
5353
HashMap<Pair<uint64_t, uint64_t>, GLTFTextureIndex, PairHash<uint64_t, uint64_t>> albedo_transparency_textures;
5454

5555
Vector<GLTFSkinIndex> skin_indices;
56+
Vector<GLTFSkinIndex> original_skin_indices;
5657
HashMap<ObjectID, GLTFSkeletonIndex> skeleton3d_to_fbx_skeleton;
5758
HashMap<ObjectID, HashMap<ObjectID, GLTFSkinIndex>> skin_and_skeleton3d_to_fbx_skin;
5859
HashSet<String> unique_mesh_names; // Not in GLTFState because GLTFState prefixes mesh names with the scene name (or _)

0 commit comments

Comments
 (0)