Merge pull request #454 from MeFisto94/MECloneIssue

Allow MotionEvents to be cloned (NPE)
cleanup_build_scripts
Rémy Bouquet 9 years ago
commit 27f6f85dab
  1. 22
      jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009-2012 jMonkeyEngine * Copyright (c) 2009-2016 jMonkeyEngine
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -64,9 +64,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
protected int currentWayPoint; protected int currentWayPoint;
protected float currentValue; protected float currentValue;
protected Vector3f direction = new Vector3f(); protected Vector3f direction = new Vector3f();
protected Vector3f lookAt; protected Vector3f lookAt = null;
protected Vector3f upVector = Vector3f.UNIT_Y; protected Vector3f upVector = Vector3f.UNIT_Y;
protected Quaternion rotation; protected Quaternion rotation = null;
protected Direction directionType = Direction.None; protected Direction directionType = Direction.None;
protected MotionPath path; protected MotionPath path;
private boolean isControl = true; private boolean isControl = true;
@ -209,9 +209,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
public void write(JmeExporter ex) throws IOException { public void write(JmeExporter ex) throws IOException {
super.write(ex); super.write(ex);
OutputCapsule oc = ex.getCapsule(this); OutputCapsule oc = ex.getCapsule(this);
oc.write(lookAt, "lookAt", Vector3f.ZERO); oc.write(lookAt, "lookAt", null);
oc.write(upVector, "upVector", Vector3f.UNIT_Y); oc.write(upVector, "upVector", Vector3f.UNIT_Y);
oc.write(rotation, "rotation", Quaternion.IDENTITY); oc.write(rotation, "rotation", null);
oc.write(directionType, "directionType", Direction.None); oc.write(directionType, "directionType", Direction.None);
oc.write(path, "path", null); oc.write(path, "path", null);
} }
@ -220,9 +220,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
public void read(JmeImporter im) throws IOException { public void read(JmeImporter im) throws IOException {
super.read(im); super.read(im);
InputCapsule in = im.getCapsule(this); InputCapsule in = im.getCapsule(this);
lookAt = (Vector3f) in.readSavable("lookAt", Vector3f.ZERO); lookAt = (Vector3f) in.readSavable("lookAt", null);
upVector = (Vector3f) in.readSavable("upVector", Vector3f.UNIT_Y); upVector = (Vector3f) in.readSavable("upVector", Vector3f.UNIT_Y);
rotation = (Quaternion) in.readSavable("rotation", Quaternion.IDENTITY); rotation = (Quaternion) in.readSavable("rotation", null);
directionType = in.readEnum("directionType", Direction.class, Direction.None); directionType = in.readEnum("directionType", Direction.class, Direction.None);
path = (MotionPath) in.readSavable("path", null); path = (MotionPath) in.readSavable("path", null);
} }
@ -280,9 +280,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
control.currentWayPoint = currentWayPoint; control.currentWayPoint = currentWayPoint;
control.currentValue = currentValue; control.currentValue = currentValue;
control.direction = direction.clone(); control.direction = direction.clone();
control.lookAt = lookAt.clone(); control.lookAt = lookAt;
control.upVector = upVector.clone(); control.upVector = upVector.clone();
control.rotation = rotation.clone(); control.rotation = rotation;
control.initialDuration = initialDuration; control.initialDuration = initialDuration;
control.speed = speed; control.speed = speed;
control.loopMode = loopMode; control.loopMode = loopMode;
@ -299,9 +299,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
control.currentWayPoint = currentWayPoint; control.currentWayPoint = currentWayPoint;
control.currentValue = currentValue; control.currentValue = currentValue;
control.direction = direction.clone(); control.direction = direction.clone();
control.lookAt = lookAt.clone(); control.lookAt = lookAt;
control.upVector = upVector.clone(); control.upVector = upVector.clone();
control.rotation = rotation.clone(); control.rotation = rotation;
control.initialDuration = initialDuration; control.initialDuration = initialDuration;
control.speed = speed; control.speed = speed;
control.loopMode = loopMode; control.loopMode = loopMode;

Loading…
Cancel
Save