Graphics/Sprite: Fix #138

This commit is contained in:
Jérôme Leclercq 2017-10-26 15:33:30 +02:00
parent 9daadb73bc
commit bf82a34fc4
1 changed files with 5 additions and 4 deletions

View File

@ -282,9 +282,6 @@ namespace Nz
*/
inline void Sprite::SetTexture(std::size_t skinIndex, TextureRef texture, bool resizeSprite)
{
if (resizeSprite && texture && texture->IsValid())
SetSize(Vector2f(Vector2ui(texture->GetSize())));
const MaterialRef& material = GetMaterial(skinIndex);
if (material->GetReferenceCount() > 1)
@ -292,10 +289,14 @@ namespace Nz
MaterialRef newMat = Material::New(*material); // Copy
newMat->SetDiffuseMap(std::move(texture));
SetMaterial(skinIndex, std::move(newMat));
SetMaterial(skinIndex, std::move(newMat), resizeSprite);
}
else
{
material->SetDiffuseMap(std::move(texture));
if (resizeSprite && texture && texture->IsValid())
SetSize(Vector2f(Vector2ui(texture->GetSize())));
}
}
/*!