i have an list of of 10000 vectors to store but every result is an integer , is there a type or array that would be more efficient than a vector3 array since i assume its stored as floata
I think float and int each take 32 bits, so storing them as floats, in a Vector3, won’t waste any space, and will be easier to use. If you have anything more than 5 or 6 digits, floats will lose the last few, so then you’d need ints. Easy way is to make three int arrays:
int[] xList, yList, zList;
You’d use things like: Vector3 newPos; newPos.x = xList[3]; newPos.y=yList[3]; .... A little bit of a pain, but it runs just as fast (setting p1=p2 is shorter to type, but still makes the computer copy x, y, z one at a time.)
If you want to get cute, make your own Vector3 of 16-bit ints (holds from +/- 2^15, so max of about 32000):
struct IVector3 {
public short x, y, z;
public IVector3(int xx, int yy, int zz)
{ x=(short)xx; y=(short)yy; z=(short)zz; }
// make it easy for user to copy into a Vector3, if needed:
public void copyTo(out Vector3 V) { V.x=x; V.y=y; V.z=z; }
public Vector3 ToVector3() { return new Vector3(x,y,z); }
}
You can make an array of these, and do cutesy stuff like Vector3 V = IV.ToVector3() or IV.copyTo(out V);. It might use two full 32-bit words to store them, wasting the last 16 bits, so only save 1/3rd the space, instead of half.