I derived a class from UMeshComponent and extended the FPrimitiveSceneProxy class to render 3D objects, and there was an interruption when I executed the following code:
void FCastomSceneProxy::DrawStaticElements( FStaticPrimitiveDrawInterface* PDI)
const int IndexCount = IndexBuffer32.Indices.Num();
if( VertexBuffer.PositionVertexBuffer.GetNumVertices()> 0 && IndexCount> 0)
const float ScreenSize = 1.0f;
FMeshBatch MeshBatch; MakeMeshBatch( MeshBatch, nullptr); PDI->DrawMesh( MeshBatch, ScreenSize ); }
Output window prompt:
Ensure condition failed: false [File:E:/UEProjects/UnrealEngine/Engine/Source/Runtime/Engine/Private/SceneManagement.cpp] [Line: 1133]
FMeshBatch was not properly setup. FMeshBatch was assigned a PrimitiveUniformBuffer even though the vertex factory fetches primitive shader data through the GPUScene buffer. The assigned PrimitiveUniformBuffer cannot be respected. Use PrimitiveUniformBufferResource instead for dynamic primitive data, or leave both null to get FPrimitiveSceneProxy->UniformBuffer .
VertexFactory[Name: FLocalVertexFactory, Initialized: 1]
This causes the custom extension UMeshComponent to not render properly.In the editor mode, if the component in the scene is selected, it can be drawn,otherwise it will not be displayed.
Please help analyze what caused this problem, thank you very much