summaryrefslogtreecommitdiff
path: root/modules/assimp
diff options
context:
space:
mode:
authorRevoluPowered <gordon@gordonite.tech>2019-09-05 22:22:03 +0100
committerRevoluPowered <gordon@gordonite.tech>2019-09-19 16:34:14 +0100
commitff8864e020acc4a7adcebede36c5709cdb7a1043 (patch)
treeed9fc2e87ff655dcfb30f23874721a03b04964c2 /modules/assimp
parenta1fcac640061c45e9dc55b1189e82aed3e2672fb (diff)
Fixed blend shapes disappearing
Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
Diffstat (limited to 'modules/assimp')
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index e5439fd132..4d053cb5d9 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -541,6 +541,25 @@ Ref<Mesh> EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(
mesh.instance();
bool has_uvs = false;
+ Map<String, uint32_t> morph_mesh_string_lookup;
+
+ for (int i = 0; i < p_surface_indices.size(); i++) {
+ const unsigned int mesh_idx = p_surface_indices[0];
+ const aiMesh *ai_mesh = state.assimp_scene->mMeshes[mesh_idx];
+ for (size_t j = 0; j < ai_mesh->mNumAnimMeshes; j++) {
+
+ String ai_anim_mesh_name = AssimpUtils::get_assimp_string(ai_mesh->mAnimMeshes[j]->mName);
+ if (!morph_mesh_string_lookup.has(ai_anim_mesh_name)) {
+ morph_mesh_string_lookup.insert(ai_anim_mesh_name, j);
+ mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED);
+ if (ai_anim_mesh_name.empty()) {
+ ai_anim_mesh_name = String("morph_") + itos(j);
+ }
+ mesh->add_blend_shape(ai_anim_mesh_name);
+ }
+ }
+ }
+
//
// Process Vertex Weights
//
@@ -789,16 +808,15 @@ Ref<Mesh> EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(
Array morphs;
morphs.resize(ai_mesh->mNumAnimMeshes);
Mesh::PrimitiveType primitive = Mesh::PRIMITIVE_TRIANGLES;
- Map<uint32_t, String> morph_mesh_idx_names;
+
for (size_t j = 0; j < ai_mesh->mNumAnimMeshes; j++) {
String ai_anim_mesh_name = AssimpUtils::get_assimp_string(ai_mesh->mAnimMeshes[j]->mName);
- mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED);
+
if (ai_anim_mesh_name.empty()) {
ai_anim_mesh_name = String("morph_") + itos(j);
}
- mesh->add_blend_shape(ai_anim_mesh_name);
- morph_mesh_idx_names.insert(j, ai_anim_mesh_name);
+
Array array_copy;
array_copy.resize(VisualServer::ARRAY_MAX);