Add equals method to Vector2f, Vector3f and Vector4f.

This commit is contained in:
kappaOne 2013-07-09 17:18:08 +01:00
parent cc14c026ef
commit 476dbf74a7
3 changed files with 39 additions and 2 deletions

View File

@ -34,6 +34,8 @@ package org.lwjgl.util.vector;
import java.io.Serializable;
import java.nio.FloatBuffer;
import org.lwjgl.util.vector.Vector2f;
/**
*
* Holds a 2-tuple vector.
@ -285,6 +287,17 @@ public class Vector2f extends Vector implements Serializable, ReadableVector2f,
*/
public final void setY(float y) {
this.y = y;
}
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Vector2f other = (Vector2f)obj;
if (x == other.x && y == other.y) return true;
return false;
}
}

View File

@ -34,6 +34,8 @@ package org.lwjgl.util.vector;
import java.io.Serializable;
import java.nio.FloatBuffer;
import org.lwjgl.util.vector.Vector3f;
/**
*
* Holds a 3-tuple vector.
@ -344,4 +346,15 @@ public class Vector3f extends Vector implements Serializable, ReadableVector3f,
public float getZ() {
return z;
}
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Vector3f other = (Vector3f)obj;
if (x == other.x && y == other.y && z == other.z) return true;
return false;
}
}

View File

@ -34,6 +34,8 @@ package org.lwjgl.util.vector;
import java.io.Serializable;
import java.nio.FloatBuffer;
import org.lwjgl.util.vector.Vector4f;
/**
*
* Holds a 4-tuple vector.
@ -336,5 +338,14 @@ public class Vector4f extends Vector implements Serializable, ReadableVector4f,
return w;
}
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Vector4f other = (Vector4f)obj;
if (x == other.x && y == other.y && z == other.z && w == other.w) return true;
return false;
}
}