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.
fix-openal-soft-deadlink
Paul Speed 5 years ago
parent 45b1908906
commit c23f28b51c
  1. 12
      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);
}
}

Loading…
Cancel
Save