Merge pull request #64554 from nongvantinh/material_are_not_applied

This commit is contained in:
Rémi Verschelde 2022-08-30 19:28:05 +02:00 committed by GitHub
commit 2932593519
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,8 +115,8 @@ void MeshInstance3D::set_mesh(const Ref<Mesh> &p_mesh) {
if (mesh.is_valid()) { if (mesh.is_valid()) {
mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed)); mesh->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &MeshInstance3D::_mesh_changed));
_mesh_changed();
set_base(mesh->get_rid()); set_base(mesh->get_rid());
_mesh_changed();
} else { } else {
blend_shape_tracks.clear(); blend_shape_tracks.clear();
blend_shape_properties.clear(); blend_shape_properties.clear();
@ -380,6 +380,13 @@ void MeshInstance3D::_mesh_changed() {
} }
} }
int surface_count = mesh->get_surface_count();
for (int surface_index = 0; surface_index < surface_count; ++surface_index) {
if (surface_override_materials[surface_index].is_valid()) {
RS::get_singleton()->instance_set_surface_override_material(get_instance(), surface_index, surface_override_materials[surface_index]->get_rid());
}
}
update_gizmos(); update_gizmos();
} }