summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-03-25 22:47:16 +0100
committerGitHub <noreply@github.com>2022-03-25 22:47:16 +0100
commit6fce38d1da7f11ec7fd4cf75a981e890673e2479 (patch)
treef7e6510d4608fce1f1aedafc93a724459ec03348 /modules
parentd3064400c574ac2c784dfae1680ea88eaed71ab7 (diff)
parent5e6d4baa48b0104f1f0778d098aa145b8ce368a8 (diff)
Merge pull request #59489 from adamscott/add-gltf-dae-fbx-blend-shape-mask-array-format-enforcers
Add GLTF, DAE and FBX importers enforcement for blend shape mask array
Diffstat (limited to 'modules')
-rw-r--r--modules/fbx/data/fbx_mesh_data.cpp11
-rw-r--r--modules/gltf/gltf_document.cpp7
2 files changed, 18 insertions, 0 deletions
diff --git a/modules/fbx/data/fbx_mesh_data.cpp b/modules/fbx/data/fbx_mesh_data.cpp
index 643a74f83e..1d59851778 100644
--- a/modules/fbx/data/fbx_mesh_data.cpp
+++ b/modules/fbx/data/fbx_mesh_data.cpp
@@ -371,6 +371,17 @@ ImporterMeshInstance3D *FBXMeshData::create_fbx_mesh(const ImportState &state, c
Array mesh_array = surface->surface_tool->commit_to_arrays();
Array blend_shapes = surface->morphs;
+ // Enforce blend shape mask array format
+ for (int i = 0; i < blend_shapes.size(); i++) {
+ Array bsdata = blend_shapes[i];
+
+ for (int j = 0; j < Mesh::ARRAY_MAX; j++) {
+ if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << j))) {
+ bsdata[j] = Variant();
+ }
+ }
+ }
+
if (surface->material.is_valid()) {
mesh->add_surface(Mesh::PRIMITIVE_TRIANGLES, mesh_array, blend_shapes, Dictionary(), surface->material, surface->material->get_name());
} else {
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index c70081a620..a8211569eb 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -2907,6 +2907,13 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
}
array_copy = blend_surface_tool->commit_to_arrays();
+ // Enforce blend shape mask array format
+ for (int l = 0; l < Mesh::ARRAY_MAX; l++) {
+ if (!(Mesh::ARRAY_FORMAT_BLEND_SHAPE_MASK & (1 << l))) {
+ array_copy[l] = Variant();
+ }
+ }
+
morphs.push_back(array_copy);
}
}