Cone Trace

Going necro on this thread…

It would be useful, especially to implement realistic visibility calculations. My guess (I’m not physics engine expert, so definitely just a guess) is that it wouldn’t be a minimal performance hit.

PhysX supports raycasts and sweeps:

UE4 calls both of these Traces, but one is tracing a ray and the other is sweeping a volume through space.

To try to implement a cone trace with one of these methods, you’d either have to a) shoot a N rays in a cone pattern to approximate it or b) sweep a bunch of objects (spheres or boxes probably).

Both methods suffer from the following problems:

  1. They have variable resolution along the sweeps. At the beginning of the trace/sweep when the rays/objects are near each other, they are good at detecting hits, but as they move along the cone height, they get spread out and may miss hits that fall in the cone. The worst resolution is at the end of the cone, which is a function of the cone’s radius.
  2. They require N traces/sweeps, depending on how much resolution you want. Since you lose resolution as the cone radius increases, you may also want to do more sweeps to compensate, which means users of this function would have to make a choice between performance and resolution.

I don’t know enough about the math behind traces and sweep hit detection to comment intelligently, but I think a cone trace, if possible at all, would require something completely different than they are doing now. For example, to implement a cone trace for visibility calculations like I want with a sweep, the physics engine would have to sweep something like a disc, increasing the size as it moves along.