From 15c9c083cd14b99e0460a2a8930701ff053dfac1 Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Sun, 20 Mar 2016 10:11:04 +0100 Subject: [PATCH 1/2] Allow MotionEvents to be cloned --- .../main/java/com/jme3/cinematic/events/MotionEvent.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java b/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java index dbb9b494c..fc277880b 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java +++ b/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. * * 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 float currentValue; protected Vector3f direction = new Vector3f(); - protected Vector3f lookAt; + protected Vector3f lookAt = Vector3f.ZERO; protected Vector3f upVector = Vector3f.UNIT_Y; - protected Quaternion rotation; + protected Quaternion rotation = Quaternion.IDENTITY; protected Direction directionType = Direction.None; protected MotionPath path; private boolean isControl = true; From 665908cdeef516307ff124f69d001d53e60bfb3c Mon Sep 17 00:00:00 2001 From: MeFisto94 Date: Thu, 24 Mar 2016 20:52:17 +0100 Subject: [PATCH 2/2] Improved the MotionEvent Cloning to not throw an NPE or edit constant Vectors --- .../jme3/cinematic/events/MotionEvent.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java b/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java index fc277880b..af4769841 100644 --- a/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java +++ b/jme3-core/src/main/java/com/jme3/cinematic/events/MotionEvent.java @@ -64,9 +64,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC protected int currentWayPoint; protected float currentValue; protected Vector3f direction = new Vector3f(); - protected Vector3f lookAt = Vector3f.ZERO; + protected Vector3f lookAt = null; protected Vector3f upVector = Vector3f.UNIT_Y; - protected Quaternion rotation = Quaternion.IDENTITY; + protected Quaternion rotation = null; protected Direction directionType = Direction.None; protected MotionPath path; private boolean isControl = true; @@ -213,9 +213,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC public void write(JmeExporter ex) throws IOException { super.write(ex); 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(rotation, "rotation", Quaternion.IDENTITY); + oc.write(rotation, "rotation", null); oc.write(directionType, "directionType", Direction.None); oc.write(path, "path", null); } @@ -224,9 +224,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC public void read(JmeImporter im) throws IOException { super.read(im); 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); - rotation = (Quaternion) in.readSavable("rotation", Quaternion.IDENTITY); + rotation = (Quaternion) in.readSavable("rotation", null); directionType = in.readEnum("directionType", Direction.class, Direction.None); path = (MotionPath) in.readSavable("path", null); } @@ -283,9 +283,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC control.currentWayPoint = currentWayPoint; control.currentValue = currentValue; control.direction = direction.clone(); - control.lookAt = lookAt.clone(); + control.lookAt = lookAt; control.upVector = upVector.clone(); - control.rotation = rotation.clone(); + control.rotation = rotation; control.initialDuration = initialDuration; control.speed = speed; control.loopMode = loopMode; @@ -302,9 +302,9 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC control.currentWayPoint = currentWayPoint; control.currentValue = currentValue; control.direction = direction.clone(); - control.lookAt = lookAt.clone(); + control.lookAt = lookAt; control.upVector = upVector.clone(); - control.rotation = rotation.clone(); + control.rotation = rotation; control.initialDuration = initialDuration; control.speed = speed; control.loopMode = loopMode;