diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-21 14:25:03 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-09-21 14:25:03 +0200 |
commit | 44ea5f94707b718335cea619207c06ce836d611f (patch) | |
tree | 4f3d525bca4e2cf4ed380c1750e5ba7e0059a6b8 | |
parent | 1094239f56c8706c14e494bd5ced0462bead6e2b (diff) | |
parent | 145503765ad37591042eedcf52c504609c95a1d2 (diff) | |
download | redot-engine-44ea5f94707b718335cea619207c06ce836d611f.tar.gz |
Merge pull request #81854 from bitsawer/fix_importer_mesh_bones
Fix ImporterMesh bone weight handling during lightmap unwrap
-rw-r--r-- | scene/resources/importer_mesh.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scene/resources/importer_mesh.cpp b/scene/resources/importer_mesh.cpp index 8768cd7c2a..f479ae1e1b 100644 --- a/scene/resources/importer_mesh.cpp +++ b/scene/resources/importer_mesh.cpp @@ -1233,6 +1233,7 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, for (int i = 0; i < lightmap_surfaces.size(); i++) { Ref<SurfaceTool> st; st.instantiate(); + st->set_skin_weight_count((lightmap_surfaces[i].format & Mesh::ARRAY_FLAG_USE_8_BONE_WEIGHTS) ? SurfaceTool::SKIN_8_WEIGHTS : SurfaceTool::SKIN_4_WEIGHTS); st->begin(Mesh::PRIMITIVE_TRIANGLES); st->set_material(lightmap_surfaces[i].material); st->set_meta("name", lightmap_surfaces[i].name); @@ -1300,7 +1301,15 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform, Ref<SurfaceTool> &tool = surfaces_tools[i]; tool->index(); Array arrays = tool->commit_to_arrays(); - add_surface(tool->get_primitive_type(), arrays, Array(), Dictionary(), tool->get_material(), tool->get_meta("name"), lightmap_surfaces[i].format); + + uint64_t format = lightmap_surfaces[i].format; + if (tool->get_skin_weight_count() == SurfaceTool::SKIN_8_WEIGHTS) { + format |= RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS; + } else { + format &= ~RS::ARRAY_FLAG_USE_8_BONE_WEIGHTS; + } + + add_surface(tool->get_primitive_type(), arrays, Array(), Dictionary(), tool->get_material(), tool->get_meta("name"), format); } set_lightmap_size_hint(Size2(size_x, size_y)); |