So in one of our projects we're using Vector2/Vector3's a lot but we do only use integer/byte values mostly. So up to the point we've implemented our Vector2Int, Vector3Int, Vector2Byte and so structures;
public struct Vector2Int
{
public int X;
public int Z;
public Vector2Int(int x, int z)
{
this.X = x;
this.Z = z;
}
public override bool Equals(object obj)
{
if (obj is Vector2Int) return this.Equals((Vector2Int)obj);
else return false;
}
public bool Equals(Vector2Int other)
{
return ((this.X == other.X) && (this.Z == other.Z));
}
public static bool operator ==(Vector2Int value1, Vector2Int value2)
{
return ((value1.X == value2.X) && (value1.Z == value2.Z));
}
public static bool operator !=(Vector2Int value1, Vector2Int value2)
{
if (value1.X == value2.X) return value1.Z != value2.Z;
return true;
}
public override int GetHashCode()
{
return (this.X.GetHashCode() + this.Z.GetHashCode());
}
public override string ToString()
{
return string.Format("{{X:{0} Z:{1}}}", this.X, this.Z);
}
}
But i don't know if we're on right track? Should we just better use XNA's float based vectors because of performance-wise concerns?
On the other hand a Vector2Byte or Vector3Bytes consumes less space which is also quite important when you use so much vectors.
I've searched for tests / information on XNA's built-in vector performance but couldn't find a bit even on it.
I'm happy to hear your experiences.