Skip to content

fix: resolve PolyBool T-Junction crash in BayazitDecomposer#36

Open
bomlinux92-byte wants to merge 1 commit into
Henry00IS:masterfrom
bomlinux92-byte:fix-t-junction-crash
Open

fix: resolve PolyBool T-Junction crash in BayazitDecomposer#36
bomlinux92-byte wants to merge 1 commit into
Henry00IS:masterfrom
bomlinux92-byte:fix-t-junction-crash

Conversation

@bomlinux92-byte
Copy link
Copy Markdown

Summary

Fix for [BOUNTY 0] PolyBool can cause an editor crash on T-Junctions — Issue #17

The bug: When two shapes look like a B (two loops connected by an infinitely thin point), Boolean operations mistakenly merge them at the singularity, causing a stack overflow crash in BayazitDecomposer.

Fix

Added a preprocessing step in BayazitDecomposer.ConvexPartition that detects self-touching singularities before the recursive Bayazit partitioner runs:

  • non-adjacent coincident vertices: detects when a vertex that is not part of an adjacent edge coincides with another vertex
  • T-junction style vertex-on-edge touches: detects when a vertex lies exactly on a non-adjacent edge

When a singularity is found, the polygon is split into two valid CCW polygons and each side is partitioned independently. This prevents the recursive Bayazit algorithm from hitting the stack overflow case.

Changes

  • Scripts/ShapeEditor/Decomposition/Bayazit/BayazitDecomposer.cs — +168 lines
  • Added FindSingularities() method to detect self-touching polygon regions
  • Added SplitAtSingularity() method to split polygons at singular vertices/edges
  • Added IsSelfTouching() helper to identify problematic polygon configurations

Validation

  • git diff --check passes
  • Code compiles as a Unity package

Closes #17

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.

[50$ Bounty] PolyBool can cause an editor crash on T-Junctions

1 participant