Skip to content

Elephant's legUp animation sets Joint translation to NaN #1138

@stephengold

Description

@stephengold

In current master branch, the following test app crashes after 3 seconds:

public class TestIssueXXX extends SimpleApplication {

    SkinningControl sControl;

    public static void main(String... argv) {
        new TestIssueXXX().start();
    }

    @Override
    public void simpleInitApp() {
        Node cgModel = (Node) assetManager.loadModel(
                "Models/Elephant/Elephant.mesh.xml");
        rootNode.attachChild(cgModel);
        AnimComposer composer = cgModel.getControl(AnimComposer.class);
        composer.setCurrentAction("legUp");
        sControl = cgModel.getControl(SkinningControl.class);
    }

    @Override
    public void simpleUpdate(float tpf) {
        for (Joint joint : sControl.getArmature().getJointList()) {
            Vector3f translation = joint.getLocalTranslation();
            if (!Vector3f.isValidVector(translation)) {
                String msg = "Invalid translation for joint " + joint.getName();
                throw new IllegalStateException(msg);
            }
        }
    }
}

The exception message is: "java.lang.IllegalStateException: Invalid translation for joint Oberschenkel_B_R"

I believe the cause is in com.jme3.anim.TransformTrack.getDataAtTime():

        if (time >= times[lastFrame]) {
            startFrame = lastFrame;

            time = time - times[startFrame] + times[startFrame - 1];
            blend = (time - times[startFrame - 1])
                    / (times[startFrame] - times[startFrame - 1]);

I observe time = 2.0876422, lastFrame = 49, times[48] = 2.0833, and times[49] = 2.0833, causing a division by zero which sets blend to Infinity.

Metadata

Metadata

Assignees

Labels

defectSomething that is supposed to work, but doesn't. Less severe than a "bug"

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions