-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Update: See #18 (comment)
As you know, TurboWarp is all about speeding up Scratch projects, so when I saw a function, isTouchingDrawables, with this comment...
scratch-render/src/RenderWebGL.js
Lines 1274 to 1275 in dd5d399
| // This is an EXTREMELY brute force collision detector, but it is | |
| // still faster than asking the GPU to give us the pixels. |
...I saw potential for improvement.
If I'm understanding the code right, Scratch checks for collisions between every single pixel to be sure that the sprites appear to be precisely touching each other. This can slow things down a lot when overused.
Instead of colliding individual pixels, combining groups of pixels to form rectangles, as shown in the video below, would reduce the number of regions that need to be accounted for, increasing performance in the long run.
optimized.touching.detector.webm
Some projects may see performance improvements of over 10x or even 50x in circumstances that would normally cause lag spikes.