If two bodies are touching each other, resting on top of each other, and I destroy one of them, I don't get an EndContact() call. I think it might have something to do with the call getting stuck in Alchemy-land when b2ContactManager destroys a contact (?). Or I could be doing something wrong.
Thanks for any help.
- Doug
Are you destroying from any contact call? Because the world is locked at that point, and you shouldn't delete bodies.
-P
No, the destroy is done inside a key press listener. Looking deeper into both the C++ and ActionScript, it looks like the world's b2ContactManager class in C++ land has no way of being assigned a b2ContactListener from ActionScript land, so the call just doesn't get made in the first place, or gets made to a b2ContactListener only in C++ land. Could be way off though too 🙂
How are you destroying your body? Are you just removing it from the stage if you're using WCK? is "reportEndContact" definitely true? I'm 99% certain the problem is not something off in alchemy land.
I use the Alchemy port directly, so in this case I'm just calling b2World::DestroyBody(), which eventually calls lib.b2World_DestroyBody(m_world._ptr, _ptr). In the C++ version of Box2D, this invokes the world's b2ContactManager to make an EndContact() call to its m_contactListener class.
I think everything works fine in Alchemy land, but the call just isn't getting out to my b2ContactListener implementation in ActionScript.
All the report flags are set to true, so normal "EndContacts" get fired, i.e. if I pull the first body off the other body instead of destroying it.
Ok, the latest commit to github should fix this problem. Turns out I didn't even need to release everything there, because I was already doing it in the destruction listener. Of course, alchemy happily marched along as if nothing was wrong.
Sorry I doubted you! I was thinking that if this bug were true, it would wreak havoc on all my other projects.
Yea it's actually odd that I haven't ran into this before either. Your fix does the trick for me though.
As usual, you're very quick to address issues. I appreciate it.
I solved it by saving all contacts in an associated object and manually removing them when the fixture is destroyed. Not great but it works! I tried changing the fixture without destroying it but box2d didn't seem to only kindof like that. It works but not very well.