Skip to content

Conversation

@Bigfoot71
Copy link
Contributor

Fixes the buffer overrun issue reported here: #5326 (comment)

After investigating the problem, the most reasonable approach seems to be using exclusive tests for the X/Y planes during clipping while keeping inclusive tests for Z.

The current clipping implementation is based on multiple rewrites of the approach originally described in this blog:
https://fabiensanglard.net/polygon_codec/

Our original implementation followed the same conditional logic as in the blog post, but this behavior might also be related to the projection [NDC -> screen] convention we follow (and which didn't seem to be a problem anyway in the context of the blog post), so clipping with exclusive X/Y borders seems more consistent in our case, while keeping Z inclusive avoids losing fragments.

For reference, here are the original papers that describes the logic:

@raysan5 raysan5 merged commit 4ff296b into raysan5:master Nov 8, 2025
16 checks passed
@raysan5
Copy link
Owner

raysan5 commented Nov 8, 2025

@Bigfoot71 thanks for the review and the detailed explanation and references!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants