Mostly I'm just trying to work out what the best approach would be for my game. I hope this isn't too offtopic here, but given that your approach seems to be quite close to what I'm looking for, I hope this is the right thread 😉
Some stuff in my game will be unbreakable. Obviously this is pretty straightforward. Other stuff needs to be breakable, but depending on its physical properties and the effects that happen to/near it, the breaking up of the bodies would need to appear in a variety of different ways. Some things might shatter, like glass in an explosion; some things might sag and melt (like going from a solid shape to something like in your code with loose joints that eventually give way under the weight of the bodes); some things might get sliced in clean lines; some things might get pieces chipped off like someone taking a chisel to soft stone.
One question (and I think it might be one for another thread) is how you go about breaking these entities up into smaller bodies. I guess the question I'm interested in here is how do I get a number of bodies to "stick together" in such a way that they seem solid, even if pieces are removed? My current thinking is that I should go with your approach of stitching lots of bodies together with joints, so that the joints can be tested for stresses above a certain threshold, and break if that threshold is exceeded, but the joints in your sample code stretch and sag under gravity or small forces, and I want some kind of joint that holds solidly up until the time it hits breaking point.
Some stuff in my game will be unbreakable. Obviously this is pretty straightforward. Other stuff needs to be breakable, but depending on its physical properties and the effects that happen to/near it, the breaking up of the bodies would need to appear in a variety of different ways. Some things might shatter, like glass in an explosion; some things might sag and melt (like going from a solid shape to something like in your code with loose joints that eventually give way under the weight of the bodes); some things might get sliced in clean lines; some things might get pieces chipped off like someone taking a chisel to soft stone.
One question (and I think it might be one for another thread) is how you go about breaking these entities up into smaller bodies. I guess the question I'm interested in here is how do I get a number of bodies to "stick together" in such a way that they seem solid, even if pieces are removed? My current thinking is that I should go with your approach of stitching lots of bodies together with joints, so that the joints can be tested for stresses above a certain threshold, and break if that threshold is exceeded, but the joints in your sample code stretch and sag under gravity or small forces, and I want some kind of joint that holds solidly up until the time it hits breaking point.