From e154b4e4304d4eb99d8f6fba5d156eab451a49bf Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Thu, 31 Aug 2023 09:49:12 -0700 Subject: [PATCH] DacLinks: diagnose armature scaling, if more than 1% --- .../com/jme3/bullet/animation/DacLinks.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/MinieLibrary/src/main/java/com/jme3/bullet/animation/DacLinks.java b/MinieLibrary/src/main/java/com/jme3/bullet/animation/DacLinks.java index fdf6aa78b..547c47475 100644 --- a/MinieLibrary/src/main/java/com/jme3/bullet/animation/DacLinks.java +++ b/MinieLibrary/src/main/java/com/jme3/bullet/animation/DacLinks.java @@ -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 @@ -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. *