Unnecessary updateSkin() call?

In version 1.0, BoneTransform has a code that avoid unnecessary update

using 'oldFrame' variable



    public void setCurrentFrame(int frame) {
        if (oldFrame == frame) {
            return;
        }
        oldFrame = frame;
        if (bone != null) {
            bone.getLocalRotation().set(rotations[frame]);
            bone.getLocalTranslation().set(translations[frame]);
            bone.propogateBoneChange(true);
        }
    }



But now there is no code like this in version 2.

Even if animation(No interpolation) is updated with time '0.0',
(In other words, no animation frame is changed)

BoneTransform.setFrame()  is called  =>  Bone.boneChanged = true
(by propagateBoneChange() )

Now,
Bone.updateWorldVectors()  can call Bone.fireBoneChange()  => SkinNode.needsRefresh = true
(by SkinNode.boneChanged() )

Finally, SkinNode.updateSkin() is called.

I think that the updateSkin() consumes CPU time intensively,
If so, This may be a hint to the performace.
Thanks for the reading.  XD

Patch is created and tested.

Just for the animations with no interpolation.

When frame is not changed, updateSkin() is not called.

I'm not sure the patch is applicable.

If not, consider another way to reduce updateSkin() call  :cry:



Index: src/com/jme/animation/BoneTransform.java
===================================================================
--- src/com/jme/animation/BoneTransform.java   (revision 3959)
+++ src/com/jme/animation/BoneTransform.java   (working copy)
@@ -63,6 +63,7 @@
     private Vector3f[] translations;
     private Bone bone;
     private String boneId;
+    private int oldFrame;
 
     private static Quaternion tempQuat1 = new Quaternion();
     private static Vector3f tempVec1 = new Vector3f();
@@ -160,6 +161,9 @@
                 bone.getLocalRotation().set(rotations[frame]);
                 bone.propogateBoneChange(true);
             } else {
+               if (oldFrame == frame)
+                  return;
+               oldFrame = frame;
                 bone.getLocalRotation().set(rotations[frame]);
                 bone.getLocalTranslation().set(translations[frame]);
                 bone.propogateBoneChange(true);