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

Remove calls to updateDrawableSkinIdRotationCenter #2314

Merged

Conversation

adroitwhiz
Copy link
Contributor

@adroitwhiz adroitwhiz commented Jan 30, 2020

Proposed Changes

This PR removes calls to Renderer.updateDrawableSkinIdRotationCenter, replacing them with calls to Renderer.updateDrawableSkinId.

It also fixes loadBitmap_ to properly set bitmap costumes' rotation centers.

Reason for Changes

Everywhere in the current codebase, updating a drawable's rotation center should do nothing.

It appears to be a vestige of the time when rotation centers belonged to Drawables and not Skins (the code to update drawables' rotation centers was added Oct 9, 2016, Skins were introduced Dec 28, 2016).

Fixing a long-standing bug with vector costumes in scratch-render (see scratchfoundation/scratch-render#550 for a detailed writeup) involves changes to the way vector costumes' rotation centers are set; notably, changing the rotation center requires re-loading the SVG. Supporting the ability to set a skin's rotation center after it is created makes the required scratch-render fix much harder to implement.

Furthermore, since the functionality to set a Drawable's rotation center is currently effectively unused, changing the parts of scratch-render that involve rotation centers could break it unknowingly, causing future headaches if others try to use the API.

Finally, as I mentioned earlier, rotation centers now belong to Skins (which correspond to costumes), so it doesn't make sense to consider them a "Drawable property".

There was one case in which updating a costume's rotation center actually did something: when first loading a bitmap, the costume rotation center was not divided by 2. The call to updateDrawableSkinIdRotationCenter when setting a target's costume, which did properly set the rotation center for bitmap costumes, hid this oversight.

@adroitwhiz adroitwhiz requested review from rschamp and fsih January 30, 2020 05:13
@adroitwhiz adroitwhiz force-pushed the dont-update-rotation-center branch from 53437b8 to a434bc5 Compare January 30, 2020 05:53
@adroitwhiz
Copy link
Contributor Author

Make sure you test this after merging scratchfoundation/scratch-render#561 -- there are some existing rotation-center-related issues in the codebase that may interfere with testing.

src/import/load-costume.js Outdated Show resolved Hide resolved
Copy link
Contributor

@cwillisf cwillisf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me... assigned to @fsih pending testing

Copy link
Contributor

@fsih fsih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants