Fix crash in StaticModel::GetMaterial when model is not loaded or has invalid entries count

This commit is contained in:
Wojtek Figat
2024-03-12 13:05:02 +01:00
parent 8f2bc17a94
commit e12919da98

View File

@@ -553,13 +553,11 @@ const Span<MaterialSlot> StaticModel::GetMaterialSlots() const
MaterialBase* StaticModel::GetMaterial(int32 entryIndex)
{
if (Model)
Model->WaitForLoaded();
else
if (!Model || Model->WaitForLoaded())
return nullptr;
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
MaterialBase* material = Entries[entryIndex].Material.Get();
if (!material)
if (!material && entryIndex < Model->MaterialSlots.Count())
{
material = Model->MaterialSlots[entryIndex].Material.Get();
if (!material)