Fix model material access with empty entries
Allow model instance material APIs to fall back to asset material slots when instance entries have not been initialized yet. Lazily initialize entries before writing material overrides so imported prefab StaticModel instances can call GetMaterial and SetMaterial without assertion failures.\n\nFixes #3801.
This commit is contained in:
@@ -1317,8 +1317,8 @@ MaterialBase* AnimatedModel::GetMaterial(int32 entryIndex)
|
||||
SkinnedModel->WaitForLoaded();
|
||||
else
|
||||
return nullptr;
|
||||
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
|
||||
MaterialBase* material = Entries[entryIndex].Material.Get();
|
||||
CHECK_RETURN(entryIndex >= 0 && entryIndex < SkinnedModel->MaterialSlots.Count(), nullptr);
|
||||
MaterialBase* material = entryIndex < Entries.Count() ? Entries[entryIndex].Material.Get() : nullptr;
|
||||
if (!material)
|
||||
{
|
||||
material = SkinnedModel->MaterialSlots[entryIndex].Material.Get();
|
||||
|
||||
Reference in New Issue
Block a user