mirror of
https://github.com/DragonMinded/bemaniutils.git
synced 2026-08-19 00:36:51 -05:00
Fix clipping entirely off screen perspective quads.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user