From 7949ba771b149d355fcdce721e59afcca998015f Mon Sep 17 00:00:00 2001 From: Andrea Catania Date: Sat, 28 Jul 2018 20:32:28 +0200 Subject: SoftBody add MeshInstance Material correctly --- scene/3d/soft_body.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scene/3d/soft_body.cpp b/scene/3d/soft_body.cpp index 9655152c49..4ab7013707 100644 --- a/scene/3d/soft_body.cpp +++ b/scene/3d/soft_body.cpp @@ -453,6 +453,9 @@ void SoftBody::become_mesh_owner() { if (!mesh_owner) { mesh_owner = true; + Vector > copy_materials; + copy_materials.append_array(materials); + ERR_FAIL_COND(!mesh->get_surface_count()); // Get current mesh array and create new mesh array with necessary flag for softbody @@ -466,11 +469,10 @@ void SoftBody::become_mesh_owner() { Ref soft_mesh; soft_mesh.instance(); soft_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, surface_arrays, surface_blend_arrays, surface_format); + soft_mesh->surface_set_material(0, mesh->surface_get_material(0)); set_mesh(soft_mesh); - Vector > copy_materials; - copy_materials.append_array(materials); for (int i = copy_materials.size() - 1; 0 <= i; --i) { set_surface_material(i, copy_materials[i]); } -- cgit v1.2.3