Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception playing Animation without ArmatureMask #2341

Closed
yaRnMcDonuts opened this issue Dec 31, 2024 · 8 comments · Fixed by #2342
Closed

Exception playing Animation without ArmatureMask #2341

yaRnMcDonuts opened this issue Dec 31, 2024 · 8 comments · Fixed by #2342

Comments

@yaRnMcDonuts
Copy link
Member

yaRnMcDonuts commented Dec 31, 2024

I receive the following Exception when attempting to play an animation on an AnimComposer that was created without custom armature masks

Caused by: java.lang.IllegalArgumentException: Unknown layer Default at com.jme3.anim.AnimComposer.getLayer(AnimComposer.java:447) at com.jme3.anim.AnimComposer.setCurrentAction(AnimComposer.java:147) at com.jme3.anim.AnimComposer.setCurrentAction(AnimComposer.java:135) at com.jme3.anim.AnimComposer.setCurrentAction(AnimComposer.java:124) at com.theafflictedforests.InteractiveArchitecture.SpiritStatue.Animal.StagStatue.<init>(StagStatue.java:29) ... 17 more

The majority of my models that have ArmatureMasks setup work fine, so it looks like a recent PR must've made AnimComposer not work without armatureMasks.

It looks like the issue is being caused because the DEFAULT_LAYER (which gets created when you do not provide custom layers in the Armature constructor) is returning null.

There's 3 recent PRs to AnimCompose I see that could've caused this:

https://github.com/jMonkeyEngine/jmonkeyengine/commits/36aac2579b852094df29ec81a3c2074dbb276480/jme3-core/src/main/java/com/jme3/anim/AnimComposer.java

Although none of those 3 stand out to me as code that would cause this to break, except maybe the change to check if layers.isEmpty() before adding the default layer... but I'd assume it is empty at that point and that shouldn't be blocking it being added.

IDK though, I'd probably have to look through more code in the Armature class to find the issue.

If anyone has ideas, let me know.

@capdevon
Copy link
Contributor

Hi Ryan, to effectively troubleshoot the issue, please provide a test case that demonstrates the error. This will significantly aid in identifying and resolving the problem

@yaRnMcDonuts
Copy link
Member Author

yaRnMcDonuts commented Dec 31, 2024

I could make a full test case later when I have time if still needed, however the code to reproduce it is very minimal and should be reproducible with any model that has an AnimComposer.

This is the code that triggers this exception (simply playing an animation on an AnimComposer without setting up any layers or armaterMask) and it should be reproducible by using this code with any animated model in the simpleInitApp() method of a new basic game template when using the newly released 3.8.0-alpha version:

    animControlsNode = (Node) assetManager.loadModel("Models/myModel.j3o");

    animComposer = animControlsNode.getControl(AnimComposer.class);

    animComposer.setCurrentAction("sitDown");`

@neph1
Copy link
Contributor

neph1 commented Dec 31, 2024

Feels like it could be my PR. I'll take a look

@neph1
Copy link
Contributor

neph1 commented Dec 31, 2024

From what I can see, the default layer will always be added when creating a new AnimComposer. If, however, there is no default layer in a model and it gets cloned, the default layer will not be added. May not be a regression, but I did switch out the Savables in my PR, so maybe.
Proposed fix would be to add default layer when using the read and cloneFields methods. This should make sure there is always a default layer.

@stephengold
Copy link
Member

I'm seeing a very similar crash after upgrading my characters-for-jme project to use JME 3.8.0-alpha1. Here is the stack trace:

Jan 02, 2025 12:00:53 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.IllegalArgumentException: Unknown layer Default
	at com.jme3.anim.AnimComposer.getLayer(AnimComposer.java:447)
	at com.jme3.anim.AnimComposer.setCurrentAction(AnimComposer.java:147)
	at com.jme3.anim.AnimComposer.setCurrentAction(AnimComposer.java:135)
	at com.jme3.anim.AnimComposer.setCurrentAction(AnimComposer.java:124)
	at com.github.stephengold.characters.TestCharacter.onAction(TestCharacter.java:242)
	at jme3utilities.ui.DefaultInputMode.onAction(DefaultInputMode.java:186)
	at com.jme3.input.InputManager.invokeActions(InputManager.java:174)
	at com.jme3.input.InputManager.onKeyEventQueued(InputManager.java:474)
	at com.jme3.input.InputManager.processQueue(InputManager.java:871)
	at com.jme3.input.InputManager.update(InputManager.java:923)
	at com.jme3.app.LegacyApplication.update(LegacyApplication.java:805)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:249)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:629)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:719)
	at java.base/java.lang.Thread.run(Thread.java:840)

@stephengold
Copy link
Member

I'm also seeing a similar crash after upgrading my JmePower project to use 3.8.0-alpha1. Stack trace:

Jan 03, 2025 11:52:08 AM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.IllegalArgumentException: Unknown layer Default
	at com.jme3.anim.AnimComposer.getLayer(AnimComposer.java:447)
	at com.jme3.anim.AnimComposer.getCurrentAction(AnimComposer.java:170)
	at com.jme3.cinematic.events.AnimEvent.onPlay(AnimEvent.java:143)
	at com.jme3.cinematic.events.AbstractCinematicEvent.play(AbstractCinematicEvent.java:120)
	at com.jme3.cinematic.KeyFrame.trigger(KeyFrame.java:62)
	at com.jme3.cinematic.Cinematic.onUpdate(Cinematic.java:382)
	at com.jme3.cinematic.events.AbstractCinematicEvent.internalUpdate(AbstractCinematicEvent.java:143)
	at com.jme3.cinematic.Cinematic.update(Cinematic.java:365)
	at com.jme3.app.state.AppStateManager.update(AppStateManager.java:371)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260)
	at com.jme3.system.lwjgl.LwjglWindow.runLoop(LwjglWindow.java:629)
	at com.jme3.system.lwjgl.LwjglWindow.run(LwjglWindow.java:719)
	at java.base/java.lang.Thread.run(Thread.java:840)

Jan 03, 2025 11:52:08 AM com.jme3.system.JmeSystemDelegate lambda$new$0
WARNING: JmeDialogsFactory implementation not found.
Uncaught exception thrown in Thread[jME3 Main,5,main]
IllegalArgumentException: Unknown layer Default

@yaRnMcDonuts
Copy link
Member Author

I'll merge and test the PR fixing this, and then I'll try to have this fix in the next alpha build in a few days.

@stephengold
Copy link
Member

I verified the fix using characters-for-jme and JmePower built with JME v3.8.0-alpha2 . Looks good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants