Repository navigation
Correct negative half-tie rounding in symmetric shadowcasting - #9
Merged
Merged
Conversation
HexDecimal
approved these changes
Oct 17, 2026
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port the rounding correction from libtcod/libtcod#204, as requested there.
The epsilon-scaled
roundfhelpers round negative half-ties in the wrong directions. At-0.5, the lower bound should round to0and the upper bound to-1; they currently return-1and0. Usefloorf(n + 0.5f)andceilf(n - 0.5f), matching the linked symmetric-shadowcasting reference.A public-API regression checks the complete visibility mask of a small corner layout in all four rotations and both wall-lighting modes. It fails 12 assertions before the correction and passes afterward.
The standalone library was also checked against an independent rational-slope reference on 576 visibility calls using libtcod's sample dungeon, including rotations, radius options and wall modes. This corrects 132 masks and 212 tile decisions, including 40 floor decisions. The 444 already-correct masks and 56 open-room controls across the existing algorithms remain byte-identical.
Validation: CMake shared-library build, the ordinary/symmetric native test selection (6 cases, 465 assertions), and applicable formatting hooks pass on Linux/GCC 13. Tests use Catch2 3.11.0 and GSL 4.0.0; the other platforms and fovtool are not exercised locally. Existing unrelated FOV regression cases are outside this validation. No API, allocation, radius convention or float-to-rational redesign is included.