then inside a function, I tried to assign a FVector value to the array element and it doesn’t work:
FVector point = someActor->GetActorLocation();
int index = CalculateIndexSomeHow();
Vertices[index] = point;
//Here I’ll get a compile error that says: No operator “=” matches these operand. Operand types are: TArray<FVector, FDefaultAllocator> = FVector.
I think this is a trivial issue, but I didn’t know how to figure it out. I tried making pointer FVectors and dereferencing them for assigning value to the TArray and didn’t work.
Yup man, I did mixed it up with C++ basic arrays assuming (with no rational reason) that every single operator of basic Cpp arrays is overloaded for me not to bother learning about TArrays.
Could be, but it’s common practice to just always use int32 for indices in loops even if you don’t need that many.
(I don’t know if there is also a technical reason for doing that)
Yeah I guess Unreal compilation will result in assembly code of the game that fits the proper size for each platform CPU’s word size and instruction set. (memory addresses of 4 byte, 2 bytes, etc for the integer variable ). I think most CPUs allow you to partition memory access in not less than a byte step, or at least loading the whole word (32 || 64) and then partitioning access to its content in the registers based on specific instruction command, which would potentially slice memory access times in half or quarter.
So it seems to me the best practice is to use only the size you’ll need, that would give some performance improvement on some platforms.
This is all speculations from my side anyhow, but it seems to be true, because otherwise why Unreal offers int16 or int8 to begin with.