Fix crash in StaticModel::GetMaterial when model is not loaded or has invalid entries count
This commit is contained in:
@@ -553,13 +553,11 @@ const Span<MaterialSlot> StaticModel::GetMaterialSlots() const
|
|||||||
|
|
||||||
MaterialBase* StaticModel::GetMaterial(int32 entryIndex)
|
MaterialBase* StaticModel::GetMaterial(int32 entryIndex)
|
||||||
{
|
{
|
||||||
if (Model)
|
if (!Model || Model->WaitForLoaded())
|
||||||
Model->WaitForLoaded();
|
|
||||||
else
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
|
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
|
||||||
MaterialBase* material = Entries[entryIndex].Material.Get();
|
MaterialBase* material = Entries[entryIndex].Material.Get();
|
||||||
if (!material)
|
if (!material && entryIndex < Model->MaterialSlots.Count())
|
||||||
{
|
{
|
||||||
material = Model->MaterialSlots[entryIndex].Material.Get();
|
material = Model->MaterialSlots[entryIndex].Material.Get();
|
||||||
if (!material)
|
if (!material)
|
||||||
|
|||||||
Reference in New Issue
Block a user