@@ -1486,6 +1486,18 @@ class RenderWebGL extends EventEmitter {
1486
1486
return bounds ;
1487
1487
}
1488
1488
1489
+ _unsnappedTouchingBounds ( drawableID ) {
1490
+ // _touchingBounds with the snapToint call removed.
1491
+ const drawable = this . _allDrawables [ drawableID ] ;
1492
+ if ( ! drawable . skin || ! drawable . skin . getTexture ( [ 100 , 100 ] ) ) return null ;
1493
+ const bounds = drawable . getFastBounds ( ) ;
1494
+ bounds . clamp ( this . _xLeft , this . _xRight , this . _yBottom , this . _yTop ) ;
1495
+ if ( bounds . width === 0 || bounds . height === 0 ) {
1496
+ return null ;
1497
+ }
1498
+ return bounds ;
1499
+ }
1500
+
1489
1501
/**
1490
1502
* Filter a list of candidates for a touching query into only those that
1491
1503
* could possibly intersect the given bounds.
@@ -1737,7 +1749,8 @@ class RenderWebGL extends EventEmitter {
1737
1749
return ;
1738
1750
}
1739
1751
1740
- const bounds = this . _touchingBounds ( stampID ) ;
1752
+ // tw: snapping occurs later
1753
+ const bounds = this . _unsnappedTouchingBounds ( stampID ) ;
1741
1754
if ( ! bounds ) {
1742
1755
return ;
1743
1756
}
@@ -1750,13 +1763,21 @@ class RenderWebGL extends EventEmitter {
1750
1763
twgl . bindFramebufferInfo ( gl , skin . _framebuffer ) ;
1751
1764
1752
1765
// Limit size of viewport to the bounds around the stamp Drawable and create the projection matrix for the draw.
1753
- gl . viewport (
1754
- // tw: account for renderQuality
1755
- ( ( this . _nativeSize [ 0 ] * 0.5 ) + bounds . left ) * skin . renderQuality ,
1756
- ( ( this . _nativeSize [ 1 ] * 0.5 ) - bounds . top ) * skin . renderQuality ,
1757
- bounds . width * skin . renderQuality ,
1758
- bounds . height * skin . renderQuality
1759
- ) ;
1766
+ // tw: scale for high quality render
1767
+ if ( ! this . useHighQualityRender ) {
1768
+ bounds . snapToInt ( ) ;
1769
+ }
1770
+ let x = ( this . _nativeSize [ 0 ] * 0.5 ) + bounds . left ;
1771
+ let y = ( this . _nativeSize [ 1 ] * 0.5 ) - bounds . top ;
1772
+ let width = bounds . width ;
1773
+ let height = bounds . height ;
1774
+ if ( this . useHighQualityRender ) {
1775
+ x = Math . floor ( x * skin . renderQuality ) ;
1776
+ y = Math . floor ( y * skin . renderQuality ) ;
1777
+ width = Math . ceil ( width * skin . renderQuality ) ;
1778
+ height = Math . ceil ( height * skin . renderQuality ) ;
1779
+ }
1780
+ gl . viewport ( x , y , width , height ) ;
1760
1781
const projection = twgl . m4 . ortho ( bounds . left , bounds . right , bounds . top , bounds . bottom , - 1 , 1 ) ;
1761
1782
1762
1783
// Draw the stamped sprite onto the PenSkin's framebuffer.
0 commit comments