In CDPR's video, they mentioned the Actor/StaticMeshComponent architecture provided by Unreal Engine.
Although this architecture is not incorrect:
Sometimes, the development team only needs: a visible Mesh with collision.
However, it needs to be lightweight enough to support fast streaming in and out.
In Unreal Engine 5.4, a series of special APIs were added for the purposes mentioned earlier. These APIs allow rendering Static Mesh or Instanced Static Mesh without adding any Components.
Due to the limited resources currently available on this topic, I hope to save time for others who are interested with this brief tutorial.
First, you need to create an instance of FStaticMeshSceneProxyDesc
. The simplest way to populate this instance is to copy it from an existing Component.
TSharedPtr<FStaticMeshSceneProxyDesc> ProxyDesc = MakeShared<FStaticMeshSceneProxyDesc>(MeshActorTemplate->GetStaticMeshComponent());
It's important to note that FStaticMeshSceneProxyDesc
cannot be directly used to add to the scene.
What we need to construct is an instance of the FPrimitiveSceneDesc
type.
This instance has two ways of use, one is the traditional way, which is to populate through UStaticMeshComponent. The other is what we are doing now:
FPrimitiveSceneDesc