What happened:
When I got shot from the back, the pain compass show the damage is from the right side, and vice versa.
See the code:
|
{ |
|
if (side > EPSILON) |
|
m_fAttack[0] = max(m_fAttack[0], side); |
|
if (side < -EPSILON) |
|
m_fAttack[1] = max(m_fAttack[1], 0 - side ); |
|
if (front > EPSILON) |
|
m_fAttack[2] = max(m_fAttack[2], front); |
|
if (front < -EPSILON) |
|
m_fAttack[3] = max(m_fAttack[3], 0 - front ); |
|
} |
The issue:
if (side < -EPSILON)
m_fAttack[1] = ...; // Rear source written into RIGHT slot
if (front > EPSILON)
m_fAttack[2] = ...; // Right source written into REAR slot
| Actual attacker direction |
Array slot written |
Slot is rendered as |
Result |
| Front |
0 |
Front/top |
Correct |
| Back |
1 |
Right |
Wrong |
| Right |
2 |
Rear/bottom |
Wrong |
| Left |
3 |
Left |
Correct |
The solution you might want:
forwardDot = DotProduct (vecFrom, forward);
rightDot = DotProduct (vecFrom, right);
// ...
{
if (forwardDot > EPSILON)
m_fAttack[ATK_FRONT] = max(m_fAttack[ATK_FRONT], forwardDot);
if (forwardDot < -EPSILON)
m_fAttack[ATK_REAR] = max(m_fAttack[ATK_REAR], 0 - forwardDot );
if (rightDot > EPSILON)
m_fAttack[ATK_RIGHT] = max(m_fAttack[ATK_RIGHT], rightDot);
if (rightDot < -EPSILON)
m_fAttack[ATK_LEFT] = max(m_fAttack[ATK_LEFT], 0 - rightDot );
}
What happened:
When I got shot from the back, the pain compass show the damage is from the right side, and vice versa.
See the code:
cs16-client/cl_dll/health.cpp
Lines 327 to 336 in d6916e6
The issue:
The solution you might want: