Skip to content

Commit

Permalink
Don't crash if images fail to load.
Browse files Browse the repository at this point in the history
  • Loading branch information
kring committed Nov 28, 2024
1 parent 6d5497d commit 7727407
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Source/CesiumRuntime/Private/CesiumGltfTextures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ SharedFuture<void> 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());
Expand Down
4 changes: 4 additions & 0 deletions Source/CesiumRuntime/Private/CesiumTextureUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ TUniquePtr<LoadedTextureResult> loadTextureFromModelAnyThreadPart(
};

CesiumGltf::Image& image = model.images[*optionalSourceIndex];
if (image.pAsset == nullptr) {
return nullptr;
}

const CesiumGltf::Sampler& sampler =
model.getSafe(model.samplers, texture.sampler);

Expand Down

0 comments on commit 7727407

Please sign in to comment.