You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Fix MeshInstance3D::get_active_material() error on empty mesh or empty surfaces
FixesMeshInstance3D::get_active_material() error on empty mesh or empty surfaces.
This commit is contained in:
@@ -380,19 +380,19 @@ Ref<Material> MeshInstance3D::get_active_material(int p_surface) const {
|
|||||||
return mat_override;
|
return mat_override;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ref<Mesh> m = get_mesh();
|
||||||
|
if (m.is_null() || m->get_surface_count() == 0) {
|
||||||
|
return Ref<Material>();
|
||||||
|
}
|
||||||
|
|
||||||
Ref<Material> surface_material = get_surface_override_material(p_surface);
|
Ref<Material> surface_material = get_surface_override_material(p_surface);
|
||||||
if (surface_material.is_valid()) {
|
if (surface_material.is_valid()) {
|
||||||
return surface_material;
|
return surface_material;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<Mesh> m = get_mesh();
|
|
||||||
if (m.is_valid()) {
|
|
||||||
return m->surface_get_material(p_surface);
|
return m->surface_get_material(p_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ref<Material>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MeshInstance3D::_mesh_changed() {
|
void MeshInstance3D::_mesh_changed() {
|
||||||
ERR_FAIL_COND(mesh.is_null());
|
ERR_FAIL_COND(mesh.is_null());
|
||||||
const int surface_count = mesh->get_surface_count();
|
const int surface_count = mesh->get_surface_count();
|
||||||
|
|||||||
Reference in New Issue
Block a user