Skip to content

Commit

Permalink
library: comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 19, 2024
1 parent e1db2e3 commit fd85ea4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public BoneMapping getForSource(String sourceBoneName) {
public SkeletonMapping inverse() {
SkeletonMapping result = new SkeletonMapping();
for (BoneMapping boneMapping : mappings.values()) {
Quaternion twist = boneMapping.getTwist();
Quaternion twist = boneMapping.getTwist(); // alias
Quaternion inverseTwist = twist.inverse();
String targetName = boneMapping.getTargetName();
String sourceName = boneMapping.getSourceName();
Expand Down Expand Up @@ -300,7 +300,7 @@ public SkeletonMapping clone() throws CloneNotSupportedException {
super.clone();
SkeletonMapping result = new SkeletonMapping();
for (BoneMapping boneMapping : mappings.values()) {
Quaternion twist = boneMapping.getTwist();
Quaternion twist = boneMapping.getTwist(); // alias
twist = twist.clone();
String targetName = boneMapping.getTargetName();
String sourceName = boneMapping.getSourceName();
Expand Down
16 changes: 9 additions & 7 deletions WesLibrary/src/main/java/jme3utilities/wes/Pose.java
Original file line number Diff line number Diff line change
Expand Up @@ -1114,19 +1114,20 @@ private void retargetBones(
assert map != null;

int targetIndex = skeleton.getBoneIndex(bone);
Transform userTransform = transforms.get(targetIndex);
Transform userTransform = transforms.get(targetIndex); // alias
userTransform.loadIdentity();

String targetName = bone.getName();
BoneMapping boneMapping = map.get(targetName);
BoneMapping boneMapping = map.get(targetName); // alias
if (boneMapping != null) {
// Calculate the orientation of the source bone in model space.
String sourceName = boneMapping.getSourceName();
int sourceIndex = sourcePose.findBone(sourceName);
Quaternion mo = sourcePose.modelOrientation(sourceIndex, null);

// Set the orientation of the target bone in user space:
Quaternion userRotation = userForModel(targetIndex, mo, null);
Quaternion twist = boneMapping.getTwist();
Quaternion twist = boneMapping.getTwist(); // alias
Quaternion rot = userTransform.getRotation(); // alias
userRotation.mult(twist, rot);
MyQuaternion.normalizeLocal(rot);
Expand All @@ -1153,20 +1154,21 @@ private void retargetJoints(
assert map != null;

int targetIndex = joint.getId();
Transform userTransform = transforms.get(targetIndex);
Transform userTransform = transforms.get(targetIndex); // alias
userTransform.loadIdentity();

String targetName = joint.getName();
BoneMapping boneMapping = map.get(targetName);
BoneMapping boneMapping = map.get(targetName); // alias
if (boneMapping != null) {
// Calculate the orientation of the source joint in model space.
String sourceName = boneMapping.getSourceName();
int sourceIndex = sourcePose.findBone(sourceName);
Quaternion mo = sourcePose.modelOrientation(sourceIndex, null);

// Set the orientation of the target joint in user space:
Quaternion userRotation = userForModel(targetIndex, mo, null);
Quaternion twist = boneMapping.getTwist();
Quaternion rot = userTransform.getRotation();
Quaternion twist = boneMapping.getTwist(); // alias
Quaternion rot = userTransform.getRotation(); // alias
userRotation.mult(twist, rot);
MyQuaternion.normalizeLocal(rot);
}
Expand Down

0 comments on commit fd85ea4

Please sign in to comment.