It shouldn't be too hard to allow shapes to be added/removed. There's one API problem though. Users don't create shapes directly, so they don't have any direct handle to the shapes.
Would it be better to have a utility function that merges two bodies? Another function could split a single body.
Yeah, I was worried a bit about that API issue. The thing is, though, users may not be holding refs to the shapes, but they at least have access - that's how drawing gets done. It might be slightly inconvenient, but this is sort of advanced functionality, so a bit of work is not a terrible idea; the only real problem is that it's difficult to know which shape in the array matches up with which original created shape since the shapes themselves don't have user data. It's mildly unfortunate that there's no great way to allow users to hold on to shapes after they are created, but if you want to allow reuse of the shapes during body creation, which I think is pretty important, there's not much choice there.
Regardless of your decision on that front, having merge and split utilities would be great. Any thoughts on how the split method would be used? What's the best way to specify a partition? We still have the "which shape is which" problem, though. Thoughts?
That sounds like a good approach.
Any particular reason for passing a pointer to be filled in the ExtractDef functions instead of just returning a copy?
Shape definitions are not stored in the original form. There is some optimization that happens and some of the data lives in the broad-phase. So extractedDef != originalDef. So the user passes a pointer to a temporary shape definition that is then filled by the extraction code.
That's cool with me. I can live with that.
Thanks guys for the diggs and support 🙂
That digg thing was crazy, I'm just happy that it didn't happen directly to my site. It would have been down for a long time.