UltimateZoneBuilder/Source/Core/Rendering/Vector4.cs

175 lines
4.2 KiB
C#
Raw Normal View History

2019-08-08 16:24:33 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodeImp.DoomBuilder.Rendering
{
public struct Vector4f
2019-08-08 16:24:33 +00:00
{
public Vector4f(float v)
2019-08-08 16:24:33 +00:00
{
X = v;
Y = v;
Z = v;
W = v;
}
public Vector4f(Vector2f xy, float z, float w)
2019-08-08 16:24:33 +00:00
{
X = xy.X;
Y = xy.Y;
Z = z;
W = w;
}
public Vector4f(Vector3f xyz, float w)
2019-08-08 16:24:33 +00:00
{
X = xyz.X;
Y = xyz.Y;
Z = xyz.Z;
W = w;
}
public Vector4f(float x, float y, float z, float w)
2019-08-08 16:24:33 +00:00
{
X = x;
Y = y;
Z = z;
W = w;
}
public float X;
public float Y;
public float Z;
public float W;
public override bool Equals(object o)
{
if (o is Vector4f)
2019-08-08 16:24:33 +00:00
{
Vector4f v = (Vector4f)o;
2019-08-08 16:24:33 +00:00
return this == v;
}
else
{
return false;
}
}
public static Vector4f operator +(Vector4f left, Vector4f right)
2019-08-08 16:24:33 +00:00
{
return new Vector4f(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
2019-08-08 16:24:33 +00:00
}
public static Vector4f operator -(Vector4f left, Vector4f right)
2019-08-08 16:24:33 +00:00
{
return new Vector4f(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
2019-08-08 16:24:33 +00:00
}
public static Vector4f operator -(Vector4f v)
2019-08-08 16:24:33 +00:00
{
return new Vector4f(-v.X, -v.Y, -v.Z, -v.W);
2019-08-08 16:24:33 +00:00
}
public override int GetHashCode()
{
return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
}
public static bool operator ==(Vector4f left, Vector4f right)
2019-08-08 16:24:33 +00:00
{
return left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W;
}
public static bool operator !=(Vector4f left, Vector4f right)
{
return left.X != right.X || left.Y != right.Y || left.Z != right.Z || left.W != right.W;
}
}
public struct Vector4i
{
public Vector4i(int v)
{
X = v;
Y = v;
Z = v;
W = v;
}
public Vector4i(Vector2i xy, int z, int w)
{
X = xy.X;
Y = xy.Y;
Z = z;
W = w;
}
public Vector4i(Vector3i xyz, int w)
{
X = xyz.X;
Y = xyz.Y;
Z = xyz.Z;
W = w;
}
public Vector4i(int x, int y, int z, int w)
{
X = x;
Y = y;
Z = z;
W = w;
}
public int X;
public int Y;
public int Z;
public int W;
public override bool Equals(object o)
{
if (o is Vector4i)
{
Vector4i v = (Vector4i)o;
return this == v;
}
else
{
return false;
}
}
public static Vector4i operator +(Vector4i left, Vector4i right)
{
return new Vector4i(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W);
}
public static Vector4i operator -(Vector4i left, Vector4i right)
{
return new Vector4i(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W);
}
public static Vector4i operator -(Vector4i v)
{
return new Vector4i(-v.X, -v.Y, -v.Z, -v.W);
}
public override int GetHashCode()
{
return X.GetHashCode() + Y.GetHashCode() + Z.GetHashCode() + W.GetHashCode();
}
public static bool operator ==(Vector4i left, Vector4i right)
{
return left.X == right.X && left.Y == right.Y && left.Z == right.Z && left.W == right.W;
}
public static bool operator !=(Vector4i left, Vector4i right)
2019-08-08 16:24:33 +00:00
{
return left.X != right.X || left.Y != right.Y || left.Z != right.Z || left.W != right.W;
}
}
}