behdad / box2d

Automatically exported from code.google.com/p/box2d
2 stars 12 forks source link

Fixture singly linked list problem #123

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a body with multiple 3+ fixtures (i used polygon shapes with line 
fixtures)
2. Delete the #2 fixture, the #3 should disappear from the debug draw and 
an Assert (cannot remove fixture not attached to body) will occur if I try 
destroy #3
3. Crash! in Body() DestroyFixture()

What is the expected output? What do you see instead?
Fixture should be removed w/o any problems, I strange behavior and assert.

What version of the product are you using? On what operating system?
Box2DX for XNA, the Xbox version

Please provide any additional information below.

The problem is the singly list isn't fixing the "hole" when a fixture is 
destroy, I replaced the code with this.

            // Remove the fixture from this body's singly linked list.
            Debug.Assert(_fixtureCount > 0);
            Fixture node = _fixtureList;
            bool found = false;
            Fixture prev = _fixtureList;
            while (node != null)
            {
                if (node == fixture)
                {
                    if (node != _fixtureList)
                    {
                        prev._next = fixture._next;
                    }
                    else
                    {
                        _fixtureList = fixture._next;
                    }
                    found = true;
                    break;
                }

                prev = node;
                node = node._next;
            }

Great engine btw! very stable.

Original issue reported on code.google.com by FreeDebr...@gmail.com on 25 Apr 2010 at 4:39

GoogleCodeExporter commented 9 years ago
I just wanted to update this bug report with my post regarding a similar (the 
same?) problem.  This is for Box2d 
that is bundled with cosos2d for iphone.  See post for details on version 
number.

http://www.box2d.org/forum/viewtopic.php?f=4&t=4886

Original comment by Tralorni...@gmail.com on 28 Apr 2010 at 6:31

GoogleCodeExporter commented 9 years ago
The joint and fixture lists on a body are now updated as a body is being 
destroyed (for the SayGoodbye events).

Original comment by erinca...@gmail.com on 16 Aug 2010 at 5:43