From 7e70c6dad1922e29be48dd876bfe49515befe7bc Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Thu, 5 Aug 2021 17:35:32 +0000 Subject: [PATCH] Fix clipping entirely off screen perspective quads. --- bemani/format/afp/blend/perspective.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bemani/format/afp/blend/perspective.py b/bemani/format/afp/blend/perspective.py index 8cbebd9..27a668b 100644 --- a/bemani/format/afp/blend/perspective.py +++ b/bemani/format/afp/blend/perspective.py @@ -51,19 +51,24 @@ def perspective_calculate( 1 / distance, ) + # Clip out anything that is completely off screen. + if minz is None or maxz is None: + raise Exception("Logic error!") + # Calculate the maximum range of update this texture can possibly reside in. minx = max(int(min(p.x for p in xy)), 0) maxx = min(int(max(p.x for p in xy)) + 1, imgwidth) miny = max(int(min(p.y for p in xy)), 0) maxy = min(int(max(p.y for p in xy)) + 1, imgheight) - if minz is None or maxz is None: - raise Exception("Logic error!") - if minz <= 0.0 and maxz <= 0.0: # This is entirely behind the camera, clip it. return (None, minx, miny, maxx, maxy) + if minx >= imgwidth or maxx < 0 or miny >= imgheight or maxy < 0: + # This is entirely off screen, clip it. + return (None, minx, miny, maxx, maxy) + if minz < 0.0 and maxz > 0.0: # This clips through the camera, default to drawing the whole image. minx = 0