Hello,
I'm completely new to Box2D, so bear with me if there's something I'm not quite getting. 🙂
I'm trying to build an editor type program in which the user could create shapes, and then choose to merge them dynamically, with a "weld joint." I'd like to make the joint have complete rigidity, so as I understand the way to do this is to destroy one of the bodies and add its shapes to the other body. I'd also like to preserve any other types of joints already attached to either of the bodies, so just recreating the shapes in the one body from their b2ShapeDefs is not quite enough.
My idea at this point is to write a function
which would attach all the shapes and joints from b2 onto b1, destroy b2, and return a pointer to b1. This may be a decent amount of work, as I'd need to preserve the rotations of all the shapes in b2, and recreate b2ShapeDefs for them so that I can create new shapes attached to b1.
So basically I'm just wondering if anyone has attempted something like this already, if anyone has ideas on a better design, or if there's some way in Box2D to do this already that I'm missing. Thanks!
I'm completely new to Box2D, so bear with me if there's something I'm not quite getting. 🙂
I'm trying to build an editor type program in which the user could create shapes, and then choose to merge them dynamically, with a "weld joint." I'd like to make the joint have complete rigidity, so as I understand the way to do this is to destroy one of the bodies and add its shapes to the other body. I'd also like to preserve any other types of joints already attached to either of the bodies, so just recreating the shapes in the one body from their b2ShapeDefs is not quite enough.
My idea at this point is to write a function
Code:
b2Body *b2World::MergeBodies(b2Body *b1, b2Body *b2);
which would attach all the shapes and joints from b2 onto b1, destroy b2, and return a pointer to b1. This may be a decent amount of work, as I'd need to preserve the rotations of all the shapes in b2, and recreate b2ShapeDefs for them so that I can create new shapes attached to b1.
So basically I'm just wondering if anyone has attempted something like this already, if anyone has ideas on a better design, or if there's some way in Box2D to do this already that I'm missing. Thanks!