New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[sprite] don't set default rect before the user provided one #1725
Conversation
Can you provide an example that explains the use case here? Also have you seen the code in SFML/src/SFML/Graphics/Sprite.cpp Lines 66 to 68 in 4cbb34d
|
Also have you seen the code in setTexture? yes, this is why I did this. Exapmple is simple Before sprite would create internal rectangle based on texture size, set texture, and then create new internal rectangle based on |
Ah okay, that seems to make sense to me then. Somehow had a hard time understanding the purpose. 😄 @LaurentGomila any reason why we didn't do it this way from the beginning? |
I don't really remember. Just a guess: the |
@eXpl0it3r @LaurentGomila Potential problem seems to be when the user want to set rect to before: SFML/src/SFML/Graphics/Sprite.cpp Line 78 in 4cbb34d
I'm not sure if there are any legitimate usages for setting rect to all 0 but it's something I didn't thought of yesterday. edit: SFML/src/SFML/Graphics/Sprite.cpp Line 61 in 91fb6b6
to m_texture = &texture;
|
Small Optimisation. Using second constructor with user provided rextureRect we first create the default one(by setTexture method) and then overwrite it with the user provided one. With this change we simply first set user provided textureRect and then set the texture which prevents unnecesary creating the default one.
Please review.
Cheers.