From 692240f60d38c293265ee148dbe6373437b4aa17 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Fri, 24 Aug 2012 16:19:43 +0200 Subject: [PATCH] sf::Sprite::setTexture(..., false) resets the texture rect only if it hasn't been set before --- src/SFML/Graphics/Sprite.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/SFML/Graphics/Sprite.cpp b/src/SFML/Graphics/Sprite.cpp index 71b72a9b6..e590a1379 100644 --- a/src/SFML/Graphics/Sprite.cpp +++ b/src/SFML/Graphics/Sprite.cpp @@ -36,7 +36,7 @@ namespace sf //////////////////////////////////////////////////////////// Sprite::Sprite() : m_texture (NULL), -m_textureRect(0, 0, 0, 0) +m_textureRect() { } @@ -44,7 +44,7 @@ m_textureRect(0, 0, 0, 0) //////////////////////////////////////////////////////////// Sprite::Sprite(const Texture& texture) : m_texture (NULL), -m_textureRect(0, 0, 0, 0) +m_textureRect() { setTexture(texture); } @@ -53,7 +53,7 @@ m_textureRect(0, 0, 0, 0) //////////////////////////////////////////////////////////// Sprite::Sprite(const Texture& texture, const IntRect& rectangle) : m_texture (NULL), -m_textureRect(0, 0, 0, 0) +m_textureRect() { setTexture(texture); setTextureRect(rectangle); @@ -63,8 +63,8 @@ m_textureRect(0, 0, 0, 0) //////////////////////////////////////////////////////////// void Sprite::setTexture(const Texture& texture, bool resetRect) { - // Recompute the texture area if requested, or if there was no valid texture before - if (resetRect || !m_texture) + // Recompute the texture area if requested, or if there was no valid texture & rect before + if (resetRect || (!m_texture && (m_textureRect == sf::IntRect()))) setTextureRect(IntRect(0, 0, texture.getSize().x, texture.getSize().y)); // Assign the new texture