Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edge Case Issue - Caused by unsafe initilization of lowerIndex/upperIndex vars in QuickDecomp #15

Open
2chivi opened this issue Aug 17, 2020 · 1 comment

Comments

@2chivi
Copy link

2chivi commented Aug 17, 2020

Initializing lowerIndex at 0 is unsafe and causes some Edge Case miscalculations and bizarre artifacts. The 2nd code snippet shows where lowerIndex(0) could equal (upperIndex+1)%poly.length if upperIndex is poly.length-1. Even when lowerIndex was never actually calculated.

This code is from polygonQuickDecomp

                var upperInt = [0, 0], lowerInt = [0, 0], p = [0, 0]; // Points
                var upperDist = 0, lowerDist = 0, d = 0, closestDist = 0; // scalars
                var upperIndex = 0, lowerIndex = 0, closestIndex = 0;
if (lowerIndex === (upperIndex + 1) % polygon.length) {
@PraxTube
Copy link

Do you have an example where this is a problem? Also how would you handle this case?

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

No branches or pull requests

2 participants