Open kring opened 1 month ago
I was originally going to do this as part of #1515, but decided against it in order to avoid merge conflicts. @azrogers is currently making significant changes to this same code as part of the Unreal side of CesiumGS/cesium-native#926.
CesiumGltfComponent.cpp
copies the glTF vertex data into aTArray<FStaticMeshBuildVertex>
, which represents the mesh as an array of structures. Then, it callsInit
on various Unreal "vertex buffer" classes to copy that data into Unreal's structure of arrays form.This is pointless. We can just copy the glTF data into the
FPositionVertexBuffer
,FColorVertexBuffer
, andFStaticMeshVertexBuffer
instances directly and save some heap allocations and a pass over the vertex data. The only slightly tricky thing about this is that we need to determine the total number of texture coordinates required before we can start populating any of them. Previously, we could count and copy simultaneously. So this will require a slight reorganization of the code.