Checked @Evgeni_Popov’s changes over the current proposed fix. Looks great! we’re finally properly updating our linked transforms off of skeleton.returnToRest()
I noticed that it broke the latest iteration of the playground, however but it appeard to be caused by some of our logic we use to scale our skeleton debug meshes (@L332-336):
if(bone.getParent()){
let distanceFromParent = BABYLON.Vector3.Distance(bone.getParent().getPosition(BABYLON.Space.WORLD, this.mesh), bone.getPosition(BABYLON.Space.WORLD, this.mesh))
let factor = (distanceFromParent/(longestBoneLength*this.options.displayOptions.sphereFactor))
scale*=factor
}
resulted in the meshes being far too large, since we’re using the posed mesh absolute positions…
changing this logic to instead use the local bindPose offset gave us a better result:
if(bone.getParent()){
let restPosePosition = new BABYLON.Vector3();
bone.getParent().getRestPose().decompose(null, null, restPosePosition);
let distanceFromParent = restPosePosition.length();
let factor = (distanceFromParent/(longestBoneLength*this.options.displayOptions.sphereFactor))
scale*=factor
}
https://playground.babylonjs.com/#ZJIBBU#38
Ok! I think that settles it! I’ll update the PR with the additions. Thanks again!