Reputation: 686
I wonder if there is a Unity's Vector3Int
equivalent in XNA. I don't want to use Vector3 to store three integers in one structure, yet I don't want to create my own class. Is there a structure (like Point<->Vector2 or Rectangle<->Vector4) for Vector3?
Upvotes: 0
Views: 143
Reputation:
The answer is no. Point
is a carryover from System.Drawing
and Rectangle
helps with AABB collisions.
The only caveat to storing integers in floats(they consume the same memory amount) is the possible loss of precision since floats cannot precisely store some values. In most instances this is not a problem. Floating point arithmetic can be slower than integer arithmetic operations.
I would suggest creating a Vector3Int
struct:
public struct Vector3Int
{
public int X;
public int Y;
public int Z;
public Vector3Int()
{
X = 0;
Y = 0;
Z = 0;
}
public Vector3Int(int val)
{
X = val;
Y = val;
Z = val;
}
public Vector3Int(int x, int y, int z)
{
X = x;
Y = y;
Z = z;
}
}
This has the advantages of a struct since it is stored on the stack.
Upvotes: 1