void IkSolver::applyAllConstraints(const Bone *parent, const Bone &b) { if ((parent == 0) && (b.primaryJointIdx >= 0)) applyConstraints(b, b.joints[b.primaryJointIdx]); else if (parent != 0) applyConstraints(b, *b.findJointWith(*parent)); for (int i = 0; i < (int)b.joints.size(); ++i) { const Bone::Connection &c = b.joints[i]; if (c.to != parent) applyAllConstraints(&b, *c.to); } }
void IkSolver::updateBoneTransforms(const Bone *parent, const Bone &b, const mat4d &base) const { const BoneState &bs = boneStates[b.id]; if (parent == 0) bs.boneToWorld = base * mat4d(bs.rot); else { const Bone::Connection &c = *b.findJointWith(*parent); bs.boneToWorld = base * mat4d(bs.rot) * vmath::translation_matrix(-c.pos); } for (int i = 0; i < (int)b.joints.size(); ++i) { const Bone::Connection &c = b.joints[i]; Bone &bn = *c.to; if (&bn != parent) updateBoneTransforms(&b, bn, bs.boneToWorld * vmath::translation_matrix(c.pos)); } }