Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import com.jme3.util.clone.Cloner;
import com.jme3.util.clone.JmeCloneable;
import java.io.IOException;
import java.util.Objects;

/**
* A MotionEvent is a control over the spatial that manages
Expand All @@ -65,7 +66,7 @@ public class MotionEvent extends AbstractCinematicEvent implements Control, JmeC
protected float currentValue;
protected Vector3f direction = new Vector3f();
protected Vector3f lookAt = null;
protected Vector3f upVector = Vector3f.UNIT_Y;
protected Vector3f upVector = Vector3f.UNIT_Y.clone();
protected Quaternion rotation = null;
protected Direction directionType = Direction.None;
protected MotionPath path;
Expand Down Expand Up @@ -231,7 +232,7 @@ public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
lookAt = (Vector3f) ic.readSavable("lookAt", null);
upVector = (Vector3f) ic.readSavable("upVector", Vector3f.UNIT_Y);
upVector = (Vector3f) ic.readSavable("upVector", Vector3f.UNIT_Y.clone());
rotation = (Quaternion) ic.readSavable("rotation", null);
directionType = ic.readEnum("directionType", Direction.class, Direction.None);
path = (MotionPath) ic.readSavable("path", null);
Expand Down Expand Up @@ -392,8 +393,8 @@ public void setDirection(Vector3f direction) {
* @param upVector the up vector to consider for this direction.
*/
public void setDirection(Vector3f direction, Vector3f upVector) {
this.direction.set(direction);
this.upVector.set(upVector);
this.direction.set(Objects.requireNonNull(direction, "direction cannot be null"));
this.upVector.set(Objects.requireNonNull(upVector, "upVector cannot be null"));
}

/**
Expand Down Expand Up @@ -422,7 +423,7 @@ public void setDirectionType(Direction directionType) {
*/
public void setLookAt(Vector3f lookAt, Vector3f upVector) {
this.lookAt = lookAt;
this.upVector = upVector;
this.upVector.set(upVector);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
public class ParticleEmitter extends Geometry {

private boolean enabled = true;
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO);
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO.clone());
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer();
private ParticleEmitterControl control;
private EmitterShape shape = DEFAULT_SHAPE;
Expand Down Expand Up @@ -476,8 +476,10 @@ public Vector3f getFaceNormal() {
public void setFaceNormal(Vector3f faceNormal) {
if (faceNormal == null || !Vector3f.isValidVector(faceNormal)) {
this.faceNormal.set(Vector3f.NAN);
} else if (this.faceNormal == null) {
this.faceNormal = faceNormal.clone();
} else {
this.faceNormal = faceNormal;
this.faceNormal.set(faceNormal);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.jme3.math.Vector3f;
import com.jme3.util.clone.Cloner;
import java.io.IOException;
import java.util.Objects;

/**
* An {@link EmitterShape} that emits particles randomly within the bounds of an axis-aligned box.
Expand Down Expand Up @@ -74,7 +75,7 @@ public EmitterBoxShape(Vector3f min, Vector3f max) {
throw new IllegalArgumentException("min or max cannot be null");
}

this.min = min;
this.min = min.clone();
this.len = new Vector3f();
this.len.set(max).subtractLocal(min);
}
Expand Down Expand Up @@ -151,7 +152,7 @@ public Vector3f getMin() {
* @param min The new minimum corner.
*/
public void setMin(Vector3f min) {
this.min = min;
this.min = Objects.requireNonNull(min, "min cannot be null").clone();
}

/**
Expand All @@ -171,7 +172,7 @@ public Vector3f getLen() {
* @param len The new length vector.
*/
public void setLen(Vector3f len) {
this.len = len;
this.len = Objects.requireNonNull(len, "len cannot be null").clone();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.jme3.math.Vector3f;
import com.jme3.util.clone.Cloner;
import java.io.IOException;
import java.util.Objects;

/**
* An {@link EmitterShape} that emits particles randomly from within the volume of a sphere.
Expand Down Expand Up @@ -155,7 +156,7 @@ public Vector3f getCenter() {
* @param center The new center point.
*/
public void setCenter(Vector3f center) {
this.center = center;
this.center = Objects.requireNonNull(center, "center cannot be null");
}

/**
Expand All @@ -179,14 +180,14 @@ public void setRadius(float radius) {
@Override
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(center, "center", null);
oc.write(center, "center", Vector3f.ZERO);
oc.write(radius, "radius", 0);
}

@Override
public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
center = (Vector3f) ic.readSavable("center", null);
center = (Vector3f) ic.readSavable("center", Vector3f.ZERO);
radius = ic.readFloat("radius", 0);
}
}
2 changes: 1 addition & 1 deletion jme3-core/src/main/java/com/jme3/scene/Spatial.java
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ public void read(JmeImporter im) throws IOException {
shadowMode = ic.readEnum("shadow_mode", ShadowMode.class,
ShadowMode.Inherit);

localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY);
localTransform = (Transform) ic.readSavable("transform", Transform.IDENTITY.clone());

localLights = (LightList) ic.readSavable("lights", null);
localLights.setOwner(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void simpleInitApp() {

// Add ambient light
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.multLocal(0.4f));
al.setColor(ColorRGBA.White.mult(0.4f));
rootNode.addLight(al);

final int SHADOWMAP_SIZE = 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ public void read(JmeImporter im) throws IOException {
rotationalLimitMotor.setTargetVelocity(capsule.readFloat("rotMotor" + i + "_TargetVelocity", 0));
rotationalLimitMotor.setEnableMotor(capsule.readBoolean("rotMotor" + i + "_EnableMotor", false));
}
getTranslationalLimitMotor().setAccumulatedImpulse((Vector3f) capsule.readSavable("transMotor_AccumulatedImpulse", Vector3f.ZERO));
getTranslationalLimitMotor().setAccumulatedImpulse((Vector3f) capsule.readSavable("transMotor_AccumulatedImpulse", Vector3f.ZERO.clone()));
getTranslationalLimitMotor().setDamping(capsule.readFloat("transMotor_Damping", 1.0f));
getTranslationalLimitMotor().setLimitSoftness(capsule.readFloat("transMotor_LimitSoftness", 0.7f));
getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO));
getTranslationalLimitMotor().setLowerLimit((Vector3f) capsule.readSavable("transMotor_LowerLimit", Vector3f.ZERO.clone()));
getTranslationalLimitMotor().setRestitution(capsule.readFloat("transMotor_Restitution", 0.5f));
getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO));
getTranslationalLimitMotor().setUpperLimit((Vector3f) capsule.readSavable("transMotor_UpperLimit", Vector3f.ZERO.clone()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ public void write(JmeExporter ex) throws IOException {
oc.write(totalSize, "totalSize", 16);
oc.write(quadrant, "quadrant", (short)0);
oc.write(stepScale, "stepScale", Vector3f.UNIT_XYZ);
oc.write(offset, "offset", Vector3f.UNIT_XYZ);
oc.write(offset, "offset", Vector2f.ZERO);
oc.write(offsetAmount, "offsetAmount", 0);
//oc.write(lodCalculator, "lodCalculator", null);
//oc.write(lodCalculatorFactory, "lodCalculatorFactory", null);
Expand All @@ -920,7 +920,7 @@ public void read(JmeImporter im) throws IOException {
totalSize = ic.readInt("totalSize", 16);
quadrant = ic.readShort("quadrant", (short)0);
stepScale = (Vector3f) ic.readSavable("stepScale", Vector3f.UNIT_XYZ);
offset = (Vector2f) ic.readSavable("offset", Vector3f.UNIT_XYZ);
offset = (Vector2f) ic.readSavable("offset", Vector2f.ZERO);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this case represent a radical change? After all, the value used to be (1, 1, 1), whereas now it is (0, 0, 0)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was likely a bug, because the writer defaults to ZERO

offsetAmount = ic.readFloat("offsetAmount", 0);
//lodCalculator = (LodCalculator) ic.readSavable("lodCalculator", new DistanceLodCalculator());
//lodCalculator.setTerrainPatch(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public class TerrainQuad extends Node implements Terrain {
private BoundingBox affectedAreaBBox; // only set in the root quad

private TerrainPicker picker = new BresenhamTerrainPicker(this);
private Vector3f lastScale = Vector3f.UNIT_XYZ;
private Vector3f lastScale = Vector3f.UNIT_XYZ.clone();

protected NeighbourFinder neighbourFinder;

Expand Down Expand Up @@ -885,7 +885,7 @@ protected boolean needToRecalculateNormals() {
return true;
if (!lastScale.equals(getWorldScale())) {
affectedAreaBBox = new BoundingBox(getWorldTranslation(), Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
lastScale = getWorldScale();
lastScale.set(getWorldScale());
return true;
}
return false;
Expand Down
Loading