From bffc7b9f23f26751bb0324307c794d1da09c56f6 Mon Sep 17 00:00:00 2001 From: Mark Date: Fri, 29 Dec 2023 17:54:51 -0800 Subject: [PATCH] Fixed hiding rotated sprites --- src/render/gpustate.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/render/gpustate.rs b/src/render/gpustate.rs index 9fa132e..7a16edc 100644 --- a/src/render/gpustate.rs +++ b/src/render/gpustate.rs @@ -220,14 +220,17 @@ impl GPUState { // Game dimensions of this sprite post-scale. // Don't divide by 2, we use this later. let height = s.size / s.pos.z; - let width = height * texture.aspect; + + // Width or height, whichever is larger + // Accounts for sprite rotation. + let m = height * texture.aspect.max(1.0); // 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 - || pos.y < clip_sw.y - height + if pos.x < clip_ne.x - m + || pos.y > clip_ne.y + m + || pos.x > clip_sw.x + m + || pos.y < clip_sw.y - m { return; }