I’m trying to access the render data in a packaged build.
I read this post IndexBuffer empty in Cooked Version - Asset Creation - Unreal Engine Forums and looked through the engine as well reading the ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER functions.
I’m not able to get the IndexBuffer successfully in a packaged build though.
This is my code:
int32 NumLODs = MyMesh->StaticMesh->RenderData->LODResources.Num();
FStaticMeshLODResources& LODResource = MyMesh->StaticMesh->RenderData->LODResources[NumLODs - 1];
int numIndices1 = LODResource.IndexBuffer.IndexBufferRHI->GetSize() / sizeof(uint16);
uint16* Indices1 = new uint16[numIndices1];
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
GetIndexBuffer,
FRawStaticIndexBuffer*, IndexBuffer, &LODResource.IndexBuffer,
uint16*, Indices1, Indices1,
{
uint16* indices = (uint16*)RHILockIndexBuffer(IndexBuffer->IndexBufferRHI, 0, IndexBuffer->IndexBufferRHI->GetSize(), RLM_ReadOnly);
memcpy(Indices1, indices, IndexBuffer->IndexBufferRHI->GetSize());
RHIUnlockIndexBuffer(IndexBuffer->IndexBufferRHI);
});
FlushRenderingCommands();
It should do the same thing as this.
FIndexArrayView IndexBufferArray;
IndexBufferArray = LODResource.IndexBuffer.GetArrayView();
Is there something I am misunderstanding?