Measuring overlap of meshes

I’m working on a human character animation control system built using Panda3D for the games/graphics side of things, and I’m trying to figure out if there’s a way to implement a restriction that’d stop the character from moving an arm through the chest or thigh etc.

The two direct ways I could think of doing this included a physics-based one where the outer layer of the character model becomes a surface that can’t be -

The other was to come up with a way to detect if there’s overlap between parts of the character mesh/measure how much overlap there are.

Could someone please point me to whether there’s already a method in Panda3D to do that? Or perhaps point me to which points in the API might allow me to find out if there’s overlap between specified parts of the mesh geometry using readings on the positions etc?

Hmm… Offhand, two main options occur to me:

  • First, you could use Panda’s built-in collision system to detect collisions, then respond to those collisions appropriately.
  • Second, you could use the Bullet physics engine, for which Panda has a set of bindings, and which includes potentialy-useful features like hinges. This could then prevent intersections, potentially.

Thanks, I started giving it a try with Bullet this week, I’m trying to create cylinders for the arms etc of the character and attaching them to the joint. But when I try to configure the solids like in the following code, at initialization, the positions gets set to the parent joint position.

But when I rotate the parent of the joint, all that is normal, but the cylinder is still in the original position per the debug wireframe drawings. ANd, I tried printing a self.r_elbow.getPos(), and that node is moving per usual and everything.

Am I missing something on the bullet physics bits, or is this something to do with my joint nodes etc?

shape = BulletCapsuleShape(0.7, 1.5, ZUp)
cylinder = BulletRigidBodyNode('Cylinder')
cylinder.addShape(shape)
self.right_arm_np = render_node.attachNewNode(cylinder)
self.right_arm_np.node().setMass(0.0)
self.right_arm_np.reparentTo(self.r_elbow)
world_node.attach(self.right_arm_np.node())

A different approach is needed here, you don’t need to attach physical bodies to the bone until you need it. That is, this is done at the moment when the character died.