Help with Multi-Threading a RuntimeMeshComponent update.

@Thumper You’ve started down a path that I’ve been debating how to handle for a while now. I see it appears you’ve figured out basic threading within UE4. So I’ll explain the problem you’ll have specific to the RMC (and this applies to the PMC as well to my knowledge).

First up, the RMC does not currently support what you’re trying to do. It assumes all interaction with it is from the game thread, and this is primarily due to the engine as a whole not really supporting/wanting you to touch a UObject from another thread. I’m not an expert in UE4, but this is how I understand the reasoning behind not touching a UObject from custom threads. UE4 runs a custom precise garbage collection system to handle UObjects, and for this to run it has to be able to stop things from accessing the memory it’s tasked with managing. For UE4 this is assumed to just require stopping the game thread, and then it can go do it’s work and then resume the game thread. So if you have another thread that’s accessing a UObject, the garbage collector (GC) doesn’t know anything about it and can potentially delete the object while your other thread is using it.

Next, I’m not sure if you’re using collision, but there’s currently no way to offload that from the game thread so you’ll still get a significant hit from that with large meshes.

The above reason is why the RMC, and PMC, don’t support this type of interaction natively. I’ve been thinking about ways to support it while being safe and playing nicely with the UE4 GC. I’d be interested to know more about your needs, but I have no guarantee I’ll ever really try to add support and even if I do when it will be.