Get pointer to data from FVector (like std::vector.data())
In std::vector you have vector.data() function that returns a type* pointer to the start of the vector.
You can use that in combination with vector.size() for functions requiring dynamic arrays like:
so you can call:
Is there any way I can do this with FVector, without having to convert FVector to std::vector and back again?
TArray (which analogous to std::vector) has a GetData method.
So, it would be
answered Jun 02 '17 at 02:39 PM
In C++ you can.... cast.
Not the most elegant thing to do in general but probably fairly safe here.
I believe C++ defines that elements within a single private/protected/public block will be in order. As FVector doesn't have virtual functions you don't have to worry about a pointer (typically at the start of an object, but doesn't have to be).
Given that X is the first element you could also go with:
float *pFloat = &myVector.X;
pFloat will be Y,  will be Z.
answered Jun 03 '17 at 11:00 PM
If you want the same functionality as an std::vector you want to be using a TArray. An FVector is a 3D point used for math (X, Y, Z).
TArray has a .GetData() as well as a .Num()
answered Jan 16 '18 at 08:09 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here