VelcroPhysics icon indicating copy to clipboard operation
VelcroPhysics copied to clipboard

TextureConverter.DetectVertices() throws InvalidOperationException on blank textures

Open harrisse opened this issue 8 years ago • 1 comments

In TextureConverter:274 there's a possible InvalidOperationException when accessing polygonEntrance.Value. This will only occur when GetTopMostVertex returns null which will only occur when the texture is blank. As an example of where this might occur in the wild is with programmatically generated textures, or in my case, a texture atlas with the occasional blank tile.

My vote for a resolution is for the method to either return null, or return new List<Vertices>() or throw new Exception("Your texture is blank.") (or some message like that).

EDIT: After further testing, it looks like this method may also throw when there are one pixel wide polygons. I can reproduce consistently with some textures but not with others containing 1 pixel polygons. Will update when I figure out the pattern.

harrisse avatar Feb 10 '18 06:02 harrisse

This user appears to have encountered the same issue: http://community.monogame.net/t/farseer-physics-texture-to-body-problem/6942

harrisse avatar Feb 10 '18 22:02 harrisse