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;