AdamsLair / duality

a 2D Game Development Framework
https://adamslair.github.io/duality
MIT License
1.41k stars 286 forks source link

NullReferenceException in FarseerDuality when spliting up a Shape with the CuttingTools #401

Open ChristianGreiner opened 8 years ago

ChristianGreiner commented 8 years ago

I tried to split up a shape of a Rigidbody with the "CuttingToools" from Farseer. As soon as I split it up, I've got this NullReferenceException:

[Edit] Error:   An error occurred: NullReferenceException: Object reference not set to an instance of an object.
CallStack:
   at FarseerPhysics.Dynamics.World.ProcessRemovedBodies() in c:\Stuff\svn\Projects\AdamsLair.FarseerDuality\Dynamics\World.cs:line 610
   at FarseerPhysics.Dynamics.World.ProcessChanges() in c:\Stuff\svn\Projects\AdamsLair.FarseerDuality\Dynamics\World.cs:line 411
   at FarseerPhysics.Dynamics.World.Step(Single dt) in c:\Stuff\svn\Projects\AdamsLair.FarseerDuality\Dynamics\World.cs:line 639
   at Duality.Resources.Scene.<Update>b__8() in c:\projects\duality\Duality\Resources\Scene.cs:line 473
   at Duality.DualityApp.EditorGuard(Action action) in c:\projects\duality\Duality\DualityApp.cs:line 983

My code:

if (keyboard.KeyHit(Key.B))
{
    var world = Scene.PhysicsWorld;
    CuttingTools.Cut(world, mousePosition.Xy, Vector2.Zero, 2f);
}
ilexp commented 8 years ago

Using non-exposed Farseer API directly is currently not supported in Duality - when possible, try to stick to what you can do using Duality RigidBodies and Shapes directly.

However, it won't hurt to investigate this. Keeping it open, but low-prio for now.