Fix ImporterMesh bone weight handling during lightmap unwrap
(cherry picked from commit 145503765a
)
This commit is contained in:
parent
4f04d3191e
commit
08bc3570ae
|
@ -1237,6 +1237,7 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
|
||||||
for (int i = 0; i < lightmap_surfaces.size(); i++) {
|
for (int i = 0; i < lightmap_surfaces.size(); i++) {
|
||||||
Ref<SurfaceTool> st;
|
Ref<SurfaceTool> st;
|
||||||
st.instantiate();
|
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->begin(Mesh::PRIMITIVE_TRIANGLES);
|
||||||
st->set_material(lightmap_surfaces[i].material);
|
st->set_material(lightmap_surfaces[i].material);
|
||||||
st->set_meta("name", lightmap_surfaces[i].name);
|
st->set_meta("name", lightmap_surfaces[i].name);
|
||||||
|
@ -1304,7 +1305,15 @@ Error ImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_transform,
|
||||||
Ref<SurfaceTool> &tool = surfaces_tools[i];
|
Ref<SurfaceTool> &tool = surfaces_tools[i];
|
||||||
tool->index();
|
tool->index();
|
||||||
Array arrays = tool->commit_to_arrays();
|
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));
|
set_lightmap_size_hint(Size2(size_x, size_y));
|
||||||
|
|
Loading…
Reference in New Issue