Skip to content

Rear and Right directions of the pain compass are swapped #388

Description

@dkenw

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 );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions