spine-runtimes/todos/done/2025-01-21-10-06-07-cpp-clipping-broken.md
Mario Zechner c7af1a3438 [cpp] Fix C++ clipping triangle skipping and control flow bugs
- Remove erroneous i+=3 increment in SkeletonClipping.cpp that caused triangle skipping
- Add missing continue statement to match Java reference implementation behavior
- Portal animation now renders correctly with proper triangular clipping
2025-07-22 02:09:01 +02:00

21 lines
1.6 KiB
Markdown

# C++ Clipping Appears Broken
**Status:** Done
**Agent PID:** 7713
## Original Todo
c++ clipping appears broken, try with portal animation in spine-glfw
## Description
Fix critical bugs in the C++ clipping implementation that cause triangles to be skipped during clipping operations. The analysis reveals that the C++ port of the Java reference implementation has several bugs, most notably an erroneous loop increment that causes incomplete triangle processing during clipping.
## Implementation Plan
- [x] Fix triangle skipping bug: Remove line 249 `i += 3;` from spine-cpp/src/spine/SkeletonClipping.cpp in clipTriangles method (keep `index += 3; break;` only)
- [x] Analyze Java labeled continue statements: Compare spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SkeletonClipping.java lines 414-430 with C++ lines 322-336 to determine correct control flow
- [x] Fix polygon clipping control flow: Modify spine-cpp/src/spine/SkeletonClipping.cpp lines 322-336 to properly handle intersection cases (replace missing continue logic with appropriate break/goto)
- [x] Build spine-cpp: Run `cd spine-cpp && cmake -B build && cmake --build build` to verify compilation
- [x] Enable portal test: Uncomment line 90 in spine-glfw/example/main.cpp: `animationState.setAnimation(0, "portal", true);` (already enabled)
- [x] Build spine-glfw: Run `cd spine-glfw && cmake -B build && cmake --build build` to compile test
- [x] User test: Run spine-glfw example and verify portal animation shows correct triangular clipping (no missing/skipped triangles)
## Notes
[Implementation notes]