Closed dazerdude closed 3 years ago
Thanks! That resolved the issue of unbalanced OnCollision-OnSeparation events I had.
I guess, solution has low performance and unnecessary gc work. Is it better to check in 'for' cycle about list sync?
Yeah. This definitely isn't as performant as it could be. It does unnecessary allocations and cpu work. It worked for my use case though, and I didn't really want to mess around too much with code I didn't understand that well. The better solution would be to either correct the iteration variable when destroy occurs, or keep a local list of destroyed objects and remove them after the loop completes.
This should have been resolved after I switched to using a linked list for contacts. Could you please check if it works?
Unfortunately I don't think I can repro this anymore. My code is extremely different from where it was when I wrote this PR.
No problems. Thanks for the PR and everything.
ContactManager.Collide would skip contacts while iterating if Destroy was called. When destroy was called the list was downsized, but i was still incremented. I fixed this by copying the list at the beginning of the iteration.