From 7727407a62f8cc35455f6e98feac956e8ec4a3aa Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 28 Nov 2024 19:30:21 +1100 Subject: [PATCH] Don't crash if images fail to load. --- Source/CesiumRuntime/Private/CesiumGltfTextures.cpp | 2 +- Source/CesiumRuntime/Private/CesiumTextureUtility.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp b/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp index d0787ccc6..2e563a987 100644 --- a/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp +++ b/Source/CesiumRuntime/Private/CesiumGltfTextures.cpp @@ -238,7 +238,7 @@ SharedFuture createTextureInLoadThread( CesiumGltf::Image* pImage = CesiumGltf::Model::getSafe(&gltf.images, pTexture->source); - if (pImage == nullptr) + if (pImage == nullptr || pImage->pAsset == nullptr) return asyncSystem.createResolvedFuture().share(); check(pTexture->source >= 0 && pTexture->source < imageNeedsMipmaps.size()); diff --git a/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp b/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp index 4522422c1..aa6899e33 100644 --- a/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp +++ b/Source/CesiumRuntime/Private/CesiumTextureUtility.cpp @@ -179,6 +179,10 @@ TUniquePtr loadTextureFromModelAnyThreadPart( }; CesiumGltf::Image& image = model.images[*optionalSourceIndex]; + if (image.pAsset == nullptr) { + return nullptr; + } + const CesiumGltf::Sampler& sampler = model.getSafe(model.samplers, texture.sampler);