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

Fix NullPointerException in AnimLayer.update() #1730

Merged
merged 2 commits into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions jme3-core/src/main/java/com/jme3/anim/AnimLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,25 @@ public void setTime(double animationTime) {
* current Action, in seconds
*/
void update(float appDeltaTimeInSeconds) {
if (currentAction == null) {
Action action = currentAction;
if (action == null) {
return;
}

double speedup = currentAction.getSpeed() * composer.getGlobalSpeed();
double speedup = action.getSpeed() * composer.getGlobalSpeed();
double scaledDeltaTime = speedup * appDeltaTimeInSeconds;
time += scaledDeltaTime;

// wrap negative times to the [0, length] range:
if (time < 0.0) {
double length = currentAction.getLength();
double length = action.getLength();
time = (time % length + length) % length;
}

// update the current Action, filtered by this layer's mask:
currentAction.setMask(mask);
boolean running = currentAction.interpolate(time);
currentAction.setMask(null);
action.setMask(mask);
boolean running = action.interpolate(time);
action.setMask(null);

if (!running) { // went past the end of the current Action
time = 0.0;
Expand Down