Skip to content

Commit 33d9cdc

Browse files
authored
Fix NullPointerException in AnimLayer.update() (#1730)
* NullPointerException in AnimLayer.update() java.lang.NullPointerException: Cannot invoke "com.jme3.anim.tween.action.Action.setMask(com.jme3.anim.AnimationMask)" because "this.currentAction" is null at com.jme3.anim.AnimLayer.update(AnimLayer.java:209) at com.jme3.anim.AnimComposer.controlUpdate(AnimComposer.java:391) at com.jme3.scene.control.AbstractControl.update(AbstractControl.java:118) at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:743) at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:890) at com.jme3.scene.Node.updateLogicalState(Node.java:228) at com.jme3.scene.Node.updateLogicalState(Node.java:239) * rename runningAction -> action
1 parent 25cbaac commit 33d9cdc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

jme3-core/src/main/java/com/jme3/anim/AnimLayer.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,25 @@ public void setTime(double animationTime) {
189189
* current Action, in seconds
190190
*/
191191
void update(float appDeltaTimeInSeconds) {
192-
if (currentAction == null) {
192+
Action action = currentAction;
193+
if (action == null) {
193194
return;
194195
}
195196

196-
double speedup = currentAction.getSpeed() * composer.getGlobalSpeed();
197+
double speedup = action.getSpeed() * composer.getGlobalSpeed();
197198
double scaledDeltaTime = speedup * appDeltaTimeInSeconds;
198199
time += scaledDeltaTime;
199200

200201
// wrap negative times to the [0, length] range:
201202
if (time < 0.0) {
202-
double length = currentAction.getLength();
203+
double length = action.getLength();
203204
time = (time % length + length) % length;
204205
}
205206

206207
// update the current Action, filtered by this layer's mask:
207-
currentAction.setMask(mask);
208-
boolean running = currentAction.interpolate(time);
209-
currentAction.setMask(null);
208+
action.setMask(mask);
209+
boolean running = action.interpolate(time);
210+
action.setMask(null);
210211

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

0 commit comments

Comments
 (0)