From c23f28b51ce26f8bd36a2fd65ea28866aa73a15a Mon Sep 17 00:00:00 2001 From: Paul Speed Date: Tue, 26 Nov 2019 04:08:16 -0500 Subject: [PATCH] Modified Line to keep its own start/end instances. This is less of a surprise if a user later chooses to call updatePoints() after having created the line with JME constants... since updatePoints() would actually call set() instead of just replacing the references. The constructor and updatePoints() should match and I chose to err on the side of caution and make them both operate on local instances. --- .../src/main/java/com/jme3/scene/shape/Line.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/shape/Line.java b/jme3-core/src/main/java/com/jme3/scene/shape/Line.java index 93e667d7c..2aabe0288 100644 --- a/jme3-core/src/main/java/com/jme3/scene/shape/Line.java +++ b/jme3-core/src/main/java/com/jme3/scene/shape/Line.java @@ -49,8 +49,8 @@ import java.nio.FloatBuffer; */ public class Line extends Mesh { - private Vector3f start; - private Vector3f end; + private Vector3f start = new Vector3f(); + private Vector3f end = new Vector3f(); /** * No-argument constructor needed by SavableClassUtil. @@ -64,8 +64,8 @@ public class Line extends Mesh { } protected void updateGeometry(Vector3f start, Vector3f end) { - this.start = start; - this.end = end; + this.start.set(start); + this.end.set(end); setBuffer(Type.Position, 3, new float[]{start.x, start.y, start.z, end.x, end.y, end.z,}); @@ -126,7 +126,7 @@ public class Line extends Mesh { super.read(im); InputCapsule in = im.getCapsule(this); - start = (Vector3f) in.readSavable("startVertex", null); - end = (Vector3f) in.readSavable("endVertex", null); + start = (Vector3f) in.readSavable("startVertex", start); + end = (Vector3f) in.readSavable("endVertex", end); } }