BayazitDecomposer.ConvexPartition exception in WP8

Nov 24, 2012 at 2:52 AM
Edited Nov 24, 2012 at 3:37 AM

Hello, 

I was told by a user that one of my wp7 games crashes on wp8 so I did a little digging and found that BayazitDecomposer.ConvexPartition throws the exception:

System.ArgumentOutOfRangeException

 

In the output in visual studio 2012 I see this when launching the game page:

A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.ni.dll

This causes all of my objects to not have collision so its a really big problem for the game.

The weird thing is that this only happens on real WP8 devices but not the emulator.

Anyone know why this happens?  What can I do to fix this?

 

EDIT:

Found this in stacktrace

StackTrace = "   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)\r\n   at System.Collections.Generic.List`1.get_Item(Int32 index)\r\n   at FarseerPhysics.Common.Decomposition.BayazitDecomposer.At(Int32 i, Ve...

Coordinator
Nov 24, 2012 at 11:31 PM

The BayazitDecomposer, just like all the other triangulation algorithms are all unsafe to use in live environments. They will crash on certain inputs and Bayazit is one of the more unstable algorithms since it is built by a single man for his school project, and not in a published and peer reviewed paper.

I would recommend you switch to the earclip algorithm. If the vertices you input comes from the users, make sure to clean them up and test if they are simple polygons. Those checks are not made by default for performance reasons.