Transform: implement equals and hashCode
This commit is contained in:
parent
1575e2a1d3
commit
57d560244e
@ -288,6 +288,29 @@ public final class Transform implements Savable, Cloneable, java.io.Serializable
|
|||||||
rot.set(0, 0, 0, 1);
|
rot.set(0, 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 7;
|
||||||
|
hash = 89 * hash + rot.hashCode();
|
||||||
|
hash = 89 * hash + translation.hashCode();
|
||||||
|
hash = 89 * hash + scale.hashCode();
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Transform other = (Transform) obj;
|
||||||
|
return this.translation.equals(other.translation)
|
||||||
|
&& this.scale.equals(other.scale)
|
||||||
|
&& this.rot.equals(other.rot);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return getClass().getSimpleName() + "[ " + translation.x + ", " + translation.y + ", " + translation.z + "]\n"
|
return getClass().getSimpleName() + "[ " + translation.x + ", " + translation.y + ", " + translation.z + "]\n"
|
||||||
@ -307,22 +330,21 @@ public final class Transform implements Savable, Cloneable, java.io.Serializable
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void write(JmeExporter e) throws IOException {
|
public void write(JmeExporter e) throws IOException {
|
||||||
OutputCapsule capsule = e.getCapsule(this);
|
OutputCapsule capsule = e.getCapsule(this);
|
||||||
capsule.write(rot, "rot", new Quaternion());
|
capsule.write(rot, "rot", Quaternion.IDENTITY);
|
||||||
capsule.write(translation, "translation", Vector3f.ZERO);
|
capsule.write(translation, "translation", Vector3f.ZERO);
|
||||||
capsule.write(scale, "scale", Vector3f.UNIT_XYZ);
|
capsule.write(scale, "scale", Vector3f.UNIT_XYZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void read(JmeImporter e) throws IOException {
|
public void read(JmeImporter e) throws IOException {
|
||||||
InputCapsule capsule = e.getCapsule(this);
|
InputCapsule capsule = e.getCapsule(this);
|
||||||
|
|
||||||
rot = (Quaternion)capsule.readSavable("rot", new Quaternion());
|
rot.set((Quaternion)capsule.readSavable("rot", Quaternion.IDENTITY));
|
||||||
translation = (Vector3f)capsule.readSavable("translation", null);
|
translation.set((Vector3f)capsule.readSavable("translation", Vector3f.ZERO));
|
||||||
if( translation == null ) {
|
scale.set((Vector3f)capsule.readSavable("scale", Vector3f.UNIT_XYZ));
|
||||||
translation = new Vector3f();
|
|
||||||
}
|
|
||||||
scale = (Vector3f)capsule.readSavable("scale", Vector3f.UNIT_XYZ);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user