Convert std::vector to TArray
So I'm stumped. I am working with a third-party library that outputs a std::vector. This vector is to be converted into a TArray for use in the CreateMeshSection_LinearColor element of the procedural mesh generation system. I have yet to find an effective method to convert this data, because converting from vectors to TArrays is not terribly clean, and the transition from float to fvector is not common. This may be an impossible task (at which point I may have to edit the third party library), however I thought I would ask to see if this was possible. Thanks!
asked Apr 02 '17 at 03:33 AM in C++ Programming
Well you wont find a premade method for that, but it can be very simply don manually like this for example:
You can of course also convert any types in that loop if you need to.
answered Apr 02 '17 at 06:30 AM
The other answer doing it using a loop is absolutely correct, but there is also a more compact solution using the raw version of
Note that this does only work for std::vector and C arrays, because the memory used internally has to be in continuous order, which is only guaranteed by std::vector. Don't use it with std::list, std::deque or any other std container.
Or using an C array
answered Apr 02 '17 at 08:51 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here