Errors in PhysicsSimulator.update

Jan 31, 2010 at 2:36 AM

Hello everyone.

In my application I have to smoothly resize bodies. I do this by removing the body and creating a new one slightly bigger.
Very frequently this cases crashes in the PhysicsSimulator update function. For example :

System.NullReferenceException: Object reference not set to an instance of an object.
   at FarseerGames.FarseerPhysics.PhysicsSimulator.ProcessAddedItems() in D:\Codearseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 634
   at FarseerGames.FarseerPhysics.PhysicsSimulator.Update(Single dt, Single dtReal) in D:\Code\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 378
   at FarseerGames.FarseerPhysics.PhysicsSimulator.Update(Single dt) in D:\Code\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 352

or

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at System.ThrowHelper.ThrowArgumentOutOfRangeException()
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at FarseerGames.FarseerPhysics.PhysicsSimulator.ProcessRemovedItems() in D:\Code\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 703
   at FarseerGames.FarseerPhysics.PhysicsSimulator.Update(Single dt, Single dtReal) in D:\Code\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 379
   at FarseerGames.FarseerPhysics.PhysicsSimulator.Update(Single dt) in D:\Code\Farseer.2.1.3XNA\Farseer Physics 2.1.3 XNA\PhysicsSimulator.cs:line 352

 

Is there a better way to resize bodies/Geoms ?

Is there a known problem about deleting and creating a lot of bodies ?

Thanks.