Fix get_active_material when a material is directly set on the mesh
Makes MeshInstance3D::get_active_material consistent with the logic in the rendering system. Fixes #38108
This commit is contained in:
parent
088c2a0870
commit
72ee09082c
1 changed files with 12 additions and 9 deletions
|
@ -307,19 +307,22 @@ Ref<Material> MeshInstance3D::get_surface_material(int p_surface) const {
|
||||||
|
|
||||||
Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
|
Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
|
||||||
|
|
||||||
if (get_material_override() != Ref<Material>()) {
|
Ref<Material> material_override = get_material_override();
|
||||||
return get_material_override();
|
if (material_override.is_valid()) {
|
||||||
} else if (p_surface < materials.size()) {
|
return material_override;
|
||||||
return materials[p_surface];
|
}
|
||||||
} else {
|
|
||||||
Ref<Mesh> mesh = get_mesh();
|
|
||||||
|
|
||||||
if (mesh.is_null() || p_surface >= mesh->get_surface_count()) {
|
Ref<Material> surface_material = get_surface_material(p_surface);
|
||||||
return Ref<Material>();
|
if (surface_material.is_valid()) {
|
||||||
}
|
return surface_material;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Mesh> mesh = get_mesh();
|
||||||
|
if (mesh.is_valid()) {
|
||||||
return mesh->surface_get_material(p_surface);
|
return mesh->surface_get_material(p_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Ref<Material>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshInstance3D::_mesh_changed() {
|
void MeshInstance3D::_mesh_changed() {
|
||||||
|
|
Loading…
Reference in a new issue