Skip to content

Commit

Permalink
DacLinks: diagnose armature scaling, if more than 1%
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Aug 31, 2023
1 parent 2edc7b0 commit e154b4e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MinieLibrary/src/main/java/com/jme3/bullet/animation/DacLinks.java
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,8 @@ protected void createSpatialData(Spatial spatial) {
spatial.addControlAt(composerIndex, preComposer);
}
}

checkForArmatureScaling();
/*
* Find the target meshes and choose the transform spatial.
* Don't invoke getTargets() here, since the SkinningControl or
Expand Down Expand Up @@ -1432,6 +1434,24 @@ private void addJoints(PhysicsLink parentLink) {
}
}

/**
* Check the bind transforms for evidence of armature scaling, something
* DynamicAnimControl doesn't handle well. TODO handle it better
*/
private void checkForArmatureScaling() {
float maxScale = 1f;
float minScale = 1f;
for (Transform t : bindTransforms) {
Vector3f scale = t.getScale(); // alias
maxScale = MyMath.max(maxScale, scale.x, scale.y, scale.z);
minScale = MyMath.min(minScale, scale.x, scale.y, scale.z);
}
if (minScale < 0.99f || maxScale > 1.01f) {
logger3.warning("Armature scaling detected: minScale="
+ minScale + " maxScale=" + maxScale);
}
}

/**
* Enumerate immediate child BoneLinks of the specified bone/torso link.
*
Expand Down

0 comments on commit e154b4e

Please sign in to comment.