Skip to content
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

bugfix for dirty sprite when using a source rect #899

Merged
merged 2 commits into from Mar 20, 2019

Conversation

Projects
None yet
4 participants
@dr0id
Copy link
Contributor

dr0id commented Mar 11, 2019

fixes the bug reported by Inigo González inigoini@gmail.com:

[pygame] BUG: sprite refresh when using source_rect

from 2019.03.10

_spr_rect_clip = _spr_rect.clip
for idx in _spr_rect.collidelistall(_update):
# clip
clip = _spr_rect_clip(_update[idx])
_surf_blit(spr.image,
clip,
(clip[0] - _spr_rect[0],
clip[1] - _spr_rect[1],
(clip[0] - _spr_rect[0] + spr.source_rect[0],

This comment has been minimized.

Copy link
@charlesej

charlesej Mar 11, 2019

Contributor

The default value for source_rect is None, so this will crash when a source_rect is not used.

This comment has been minimized.

Copy link
@dr0id

dr0id Mar 11, 2019

Author Contributor

Thanks for the review and feedback.

You are right, the source_rect can be None. I have considered it now in the second commit.

About the different sizes... it does not make much sense because its the source area of the blit method (not sure what will happen if you have a bigger source rect...... for a smaller source rect I guess you only the that part).

I still wonder if the clipping will work in all cases.

@@ -1099,17 +1099,14 @@ def draw(self, surface, bgd=None):
if spr._visible:
# sprite not dirty; blit only the intersecting part
_spr_rect = spr.rect
if spr.source_rect is not None:

This comment has been minimized.

Copy link
@charlesej

charlesej Mar 11, 2019

Contributor

I think a DirtySprite's rect and source_rect can be different sizes so this code is probably still required to ensure the proper image is drawn.

This comment has been minimized.

Copy link
@charlesej

charlesej Mar 11, 2019

Contributor

My understanding is that source_rect is used to get the correct image. If you look above at lines 1063-1067 you will see that a similar thing is being done there.

@dlon

This comment has been minimized.

Copy link
Member

dlon commented Mar 18, 2019

The test in #900 still seems to fail

@charlesej

This comment has been minimized.

Copy link
Contributor

charlesej commented Mar 19, 2019

The test is still failing because this update is removing code (lines 1102-1104 in the original code) that is unrelated to fixing this issue. The removal of those lines breaks current usage and is inconsistent with other parts of the code (lines 1063-1067: source_rect usage).

The originator did a good job of fixing the original issue, but making an unrelated functionality breaking change (granted this is a minor one) would be best done via a separate update. It would also be useful to include some related tests and update the documentation stating that this functionality has been changed and may break existing code.

@illume illume merged commit b9229c9 into pygame:master Mar 20, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@illume

This comment has been minimized.

Copy link
Member

illume commented Mar 20, 2019

Continuing this PR in a pygame repo branch so we can all collaborate more easily...
#919

@dlon dlon referenced this pull request Mar 23, 2019

Closed

1.9.5 release notes. #561

4 of 4 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.