From 6ad23b4410b8f71a2919abad79ff6079ed93c06f Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 22 Dec 2023 21:44:03 -0800 Subject: [PATCH] Comments --- src/render/gpustate.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/render/gpustate.rs b/src/render/gpustate.rs index ad02067..7bd12ac 100644 --- a/src/render/gpustate.rs +++ b/src/render/gpustate.rs @@ -270,10 +270,8 @@ impl GPUState { let height = texture.height * s.scale; let width = height * texture.aspect; - // Sprite scale is relative to the sprite's defined height, - // so we apply both factors here - - // Don't compute matrices for sprites that are off the screen + // Don't draw (or compute matrices for) + // sprites that are off the screen if pos.x < clip_ne.x - width || pos.y > clip_ne.y + height || pos.x > clip_sw.x + width @@ -283,6 +281,12 @@ impl GPUState { continue; } + // Compute the values we need to draw + // scale: combines texture scale and zoom scale. + // screen_pos: position of this sprite in screen coordinates + // + // We can't use screen_pos to exclude off-screen sprites because + // it can't account for height and width. let scale = height / camera.zoom; let screen_pos: Point2 = pos / camera.zoom;