I am developing a visual recognition system, and I want a character to “see” an object or other character by raycasting a representative sample of mesh vertices. It can be quite expensive if done sequentially, is it possible to parallelize calls to raycast functions in Unreal? Is the Unreal API thread safe?
The PhysX API provides a method to batch scene queries together (docs), but this has not been exposed by UE4 as far as I’m aware. I’m not even sure the PhysX version takes advantage of spatial coherence either, which is what you’d want in these situations when the rays are all likely to be very similar.
As for parallelizing it on a CPU threading level, I doubt it would be worth it. Due to the setup/tear down costs of the raycasts, I’m pretty sure you’d gain a lot more just from having it batched at a lower level, ie. write your own variation of the UE4 methods utilising PxBatchQuery. Alternatively maybe put in a feature request to Epic, I don’t think this would be a big job for them.