ACF-Team/ACF-3

[BUG] ACF.GetHitAngle occasionally receiving invalid HitNormal

LiddulBOFH opened this issue · 1 comments

Description

Under rare circumstances, the ACF.GetHitAngle will get called despite having no valid hitnormal. To fix this we need more information, such as the whole bullet data table instead of the current hitnormal and bulletvel, so that it can get dumped to console when the error is called.

https://github.com/Stooberton/ACF-3/blob/75c9e33f0d65a2e9d0288e78bebab86cb87e6891/lua/acf/base/util/sh_util.lua#L309

Once we get more information we can narrow down any fatal flaws in bullet calculations, as the function will return a 0, which is equivalent to a direct hit, possibly causing issues with damage being higher than it should.

Branch and Version

All branches, all versions after error check was initially made (with the replacement of the original function).

Console Error Logs (Optional)

invalid angle in ACF.GetHitAngle
>HitNormal: 0.000000 0.000000 0.000000, HitDir (BulletVel): 7200.185547 2.327452 -53.340588

How to Reproduce (Optional)

Inconsistent when it occurs, requires a slight change to the function to take the BulletData to dump to console when this occurs.

Fixed in f3fcaa4

When shooting at a prop, particularly one that is moving towards the shooter, it is possible for the trace to start inside an object.

Traces exhibit unexpected behavior in two relevant ways in this case:

  1. Ending inside an object produces a HitNormal of 1, 0, 0
  2. Starting and ending inside an object produces a fraction of 0 and normal of 1, 0, 0

In the event of issue 1 a ray-mesh intersection is run to calculate the real HitNormal value using the function's second argument rayNormal (usually bullet.Flight) as the ray direction to circumvent issue 2.