How to access UStaticMesh vertex data with C++ and is it float32?

Having recently migrated from Unity, in C# you would very simply write :

Vector3 vertices = GameObject.GetComponent().mesh.vertices;

To get a reference to the underlying mesh vertices’ positions (float32 Vector3.)

In UE5 I realized the UStaticMeshComponents I was procedurally creating stored the vertex data as FProcMeshVertex (position, uv, normal, tangent, etc.), all as float64 FVector / FVector2D, making the size of a single FProcMeshVertex 152 bytes (!).

How to access UStaticMesh vertex data with C++?

Are the underlying UStaticMesh vertex data values float32?

You kinda can’t.
You need to parse the geometry stuff to do it and it’s essentially a “download sorce. Make a hole and use your custom hole after compile to access”.

You can find some very broken info here.
Take it with many grains of salt. VertexFactory is kinda like that.

If you are trying to modify geometry, forget about it.

You are better off extracing the vertex positions off Blender via a pyton script, parsing the values in engine off a data sheet, right into the proper procedural mesh component which allos you to manipulate the mesh.

And then, if you went and did that, the vetex are just kept in memory for you to access readily… so you went around the main problem alltogether :stuck_out_tongue_winking_eye:

1 Like