Fix crash if texture is missing

#942
This commit is contained in:
Wojtek Figat
2023-02-17 16:19:10 +01:00
parent aa1a0ea4a2
commit 5dc63da4bf
3 changed files with 4 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ void Lightmap::EnsureSize(int32 size)
#if COMPILE_WITH_ASSETS_IMPORTER
Guid id = Guid::New();
LOG(Info, "Cannot load lightmap {0} ({1}:{2}). Creating new one.", id, _index, textureIndex);
LOG(Info, "Cannot load lightmap ({1}:{2}). Creating new one with ID={0}.", id, _index, textureIndex);
String assetPath;
_manager->GetCachedLightmapPath(&assetPath, _index, textureIndex);

View File

@@ -48,7 +48,7 @@ public:
/// Gets attached texture objects
/// </summary>
/// <param name="lightmaps">Lightmaps textures array</param>
void GetTextures(GPUTexture* lightmaps[]) const
void GetTextures(GPUTexture* lightmaps[3]) const
{
lightmaps[0] = _textures[0] ? _textures[0]->GetTexture() : nullptr;
lightmaps[1] = _textures[1] ? _textures[1]->GetTexture() : nullptr;
@@ -59,7 +59,7 @@ public:
/// Gets attached texture objects
/// </summary>
/// <param name="lightmaps">Lightmaps textures array</param>
void GetTextures(Texture* lightmaps[]) const
void GetTextures(Texture* lightmaps[3]) const
{
lightmaps[0] = _textures[0].Get();
lightmaps[1] = _textures[1].Get();

View File

@@ -152,7 +152,7 @@ void ShadowsOfMordor::Builder::updateLightmaps()
{
auto texture = textures[textureIndex];
GPUDevice::Instance->Locker.Unlock();
if (texture->WaitForLoaded())
if (!texture || texture->WaitForLoaded())
{
LOG(Error, "Lightmap load failed.");
return;