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

Polygon-polygon minimum translation vector appears invalid #7

Open
Slaktus opened this issue Sep 10, 2019 · 4 comments
Open

Polygon-polygon minimum translation vector appears invalid #7

Slaktus opened this issue Sep 10, 2019 · 4 comments

Comments

@Slaktus
Copy link

Slaktus commented Sep 10, 2019

Calling IntersectMTV with two rotated polygons leads to strange behaviour:

  • MTV is not normalized
  • MTV orientation may be incorrect depending on the orientation of the collision
  • Depending on orientation of intersection, the MTV only gets calculated if poly2 completely contains poly1, or at least it appears the center point of poly1 must be contained by poly2

https://imgur.com/a/CSnDjWi

Let me know what more information you need, if any. I'm using a modified version of 4ed1885 adapted to use Unity.Mathematics types and math functions. I'm also avoiding allocations by reusing cached objects rather than constructing new ones, but other than that, the code should be the same.

@Slaktus
Copy link
Author

Slaktus commented Sep 10, 2019

Better animation showing problem more clearly:
https://imgur.com/a/WSQGNmb

The cyan line is the unnormalized minimum translation vector not multiplied by the magnitude.

@Tjstretchalot
Copy link
Owner

Thank you for the detailed report! It's surprising that this is happening with triangles and rectangles. Would it be possible to dump the location of each polygon (the vertices + offset is enough) at a moment you know you have the wrong result?

@Slaktus
Copy link
Author

Slaktus commented Sep 12, 2019

Hey,

Sorry, but I've already rewritten the function, so that'll be a bit of a hassle.

If there's no error on your side, then the bugs might have been introduced by some over-optimistic optimization on my end.

@Tjstretchalot
Copy link
Owner

I'll leave this up in the hope that I will have an opportunity at some point to test some polygons by eyeballing reasonable numbers for what was in the video.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants