Cherry-Pick: Fix "Match Corners" not correctly updating cells when erasing (godotengine/godot#112145) - #1460
Conversation
…ult in all neighbors updating correctly (cherry picked from commit b2a4bda3b0d1fdd9707ca4053c6bb1300a29f7bd)
Covers the "Match Corners" erase bug fixed in the previous commit: a square cell's corners are shared with all eight surrounding cells, so erasing a cell has to reconsider the four orthogonal neighbors too, not only the four diagonal ones reachable through a corner peering bit. The test builds a tile set per terrain mode with one tile for every combination of that mode's peering bits, fills a 5x5 block, then erases the center cell the way the editor's eraser does and checks which cells terrain_fill_pattern() hands back. Diagonals are only required in the modes that have corner bits. Before the fix the "corners" subcase fails on all four orthogonal neighbors; "corners and sides" and "sides" pass either way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: Redot-Engine/redot-engine/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. WalkthroughTerrain fill now includes existing neighboring cells when it builds the modifiable-cell set. New tests erase the center of a filled area across three terrain modes and check the affected cells. ChangesTerrain Fill
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change addresses incomplete neighbor updates when erasing corner-matched terrain. No actionable merge-blocking risk is established; merge after normal checks pass. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #1292
Cherry-pick of godotengine/godot#112145 (upstream commit
b2a4bda3b0d1fdd9707ca4053c6bb1300a29f7bdby @IphStich, merged 2025-10-29), plus a regression test.TileMapLayer::terrain_fill_pattern()— the path the terrains eraser uses — collected the cells it may rewrite by walking only the neighbors reachable through a valid peering bit of the terrain set:With Match Corners the only valid bits are the four corners, so for a square grid that neighborhood is just the four diagonal cells. But a square cell's corner points are each shared by four cells, so the four orthogonal neighbors share corners with the erased cell as well — they get new constraints and are then never updated, which is the stale tiles reported in #1292. Match Corners and Sides has side bits too, so all eight neighbors end up in the list and the bug does not show there, exactly as the issue describes.
Upstream's fix walks every existing neighbor instead, like
terrain_fill_connect()(the painting path) already did:Cells whose constraints did not change keep their pattern, so Match Sides is unaffected.
Testing
Adds
tests/scene/test_tile_map_layer.h(there were no TileMapLayer tests). It builds a tile set per terrain mode with one tile for every combination of that mode's peering bits, fills a 5x5 block, erases the center cell the way the eraser does, and checks which cellsterrain_fill_pattern()returns.masterthecornerssubcase fails on exactly the four orthogonal neighbors;corners and sidesandsidespass.pre-commit run -aclean.Also tested by hand in the editor with the MRP attached to #1292 (Match Corners, square 60x60 tiles), erasing cells with patched and unpatched builds of the same commit side by side.
Summary by CodeRabbit