Fix crash when drawing 2d sprite with invalid atlas specified

This commit is contained in:
Wojtek Figat
2021-05-14 11:02:42 +02:00
parent f9b979f1c6
commit 42461f1b4a

View File

@@ -1544,7 +1544,7 @@ void Render2D::DrawTexture(TextureBase* t, const Rectangle& rect, const Color& c
void Render2D::DrawSprite(const SpriteHandle& spriteHandle, const Rectangle& rect, const Color& color)
{
RENDER2D_CHECK_RENDERING_STATE;
if (spriteHandle.Index == INVALID_INDEX || !spriteHandle.Atlas->GetTexture()->HasResidentMip())
if (spriteHandle.Index == INVALID_INDEX || !spriteHandle.Atlas || !spriteHandle.Atlas->GetTexture()->HasResidentMip())
return;
Sprite* sprite = &spriteHandle.Atlas->Sprites.At(spriteHandle.Index);
@@ -1571,7 +1571,7 @@ void Render2D::DrawTexturePoint(GPUTexture* t, const Rectangle& rect, const Colo
void Render2D::DrawSpritePoint(const SpriteHandle& spriteHandle, const Rectangle& rect, const Color& color)
{
RENDER2D_CHECK_RENDERING_STATE;
if (spriteHandle.Index == INVALID_INDEX || !spriteHandle.Atlas->GetTexture()->HasResidentMip())
if (spriteHandle.Index == INVALID_INDEX || !spriteHandle.Atlas || !spriteHandle.Atlas->GetTexture()->HasResidentMip())
return;
Sprite* sprite = &spriteHandle.Atlas->Sprites.At(spriteHandle.Index);