-
Notifications
You must be signed in to change notification settings - Fork 350
Handle matrix + silhouette updates better #555
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
Handle matrix + silhouette updates better #555
Conversation
@@ -104,7 +104,7 @@ class SVGSkin extends Skin { | |||
return mip; | |||
} | |||
|
|||
updateSilhouette (scale = 1) { | |||
updateSilhouette (scale = [100, 100]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😳
(fortunately, this didn't break anything--all call sites specified a scale explicitly)
b68056b
to
f2c87cb
Compare
f2c87cb
to
2b129d8
Compare
2b129d8
to
9e80f1c
Compare
da15dbc
to
e7b1504
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Resolves
Resolves (part of) #545
Resolves #546
Resolves scratchfoundation/scratch-gui#5647
Proposed Changes
This PR makes the following changes:
updateCPURenderAttributes
method toDrawable
RenderWebGL._touchingBounds
toRenderWebGL.isTouchingColor
andRenderWebGL.isTouchingDrawables
Drawable.isTouching
,Skin.isTouchingNearest
, andSkin.isTouchingLinear
explaining that those functions' callers are responsible for updating the silhouette + matrixRenderWebGL._getConvexHullPointsForDrawable
Reason for Changes
Add
updateCPURenderAttributes
method toDrawable
RenderWebGL
that called bothDrawable.updateMatrix
andDrawable.skin.updateSilhouette
, and none that called just one or the other. Some checked whether the drawable's skin existed, others did not. I've consolidated calls toDrawable.updateMatrix
andDrawable.skin.updateSilhouette
into a single utility method, for conciseness and consistency.updateCPURenderAttributes
does not multiply the drawable's scale by the screen-space scaling ratio, since CPU rendering always occurs at the "native" stage size.Move CPU render attribute update fromRenderWebGL._touchingBounds
toRenderWebGL.isTouchingColor
andRenderWebGL.isTouchingDrawables
Moved to another PR_touchingBounds
doesn't actually require the passed drawable's matrix or silhouette to be up-to-date. However,isTouchingColor
andisTouchingDrawables
relied on it updating those. For clarity (and to prevent things from breaking if a future coder decided to "optimize"_touchingBounds
), these calls have been moved (in the form of calls to the newupdateCPURenderAttributes
function) to the places that actually require the drawable's matrix and silhouette to be updated.Add documentation notes to
Drawable.isTouching
,Skin.isTouchingNearest
, andSkin.isTouchingLinear
explaining that those functions' callers are responsible for updating the silhouette + matrixUpdate CPU render attributes inRenderWebGL._getConvexHullPointsForDrawable
This appears to be what was causing the issue in Revert "Merge pull request #394 from paulkaplan/defer-silhouette-upda… #398.Done in a previous PR_getConvexHullPointsForDrawable
calls methods which require the drawable's matrix + silhouette to be up-to-date, but previously did not update them.I have tested this manually and confirmed that it does not regress #543.