DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ ApproximateWeaponLiftTransform()

void Weapon::ApproximateWeaponLiftTransform ( inout vector start,
inout vector direction,
HumanMovementState hms,
HumanInputController hic,
HumanCommandWeapons hcw,
HumanCommandMove hcm,
vector localVelocity = "0 0 0" )
inlineprotected

Update provided start position and lift check direction to include appproximated character state.

Аргументы
startRay start position, to be modified
directionRay direction

См. определение в файле Weapon_Base.c строка 1564

1565 {
1566 // Construct stable trasformation matrix that somewhat aligns with the weapon transform,
1567 // without actually using the weapon as reference - the weapon will move during the lift/obstruction
1568 // in more than 1 axis and is therefore not realiable source of truth.
1569 vector resTM[4];
1570 resTM[0] = Vector(direction[0], 0, direction[2]).Normalized();
1571 resTM[0] = vector.RotateAroundZeroDeg(resTM[0], vector.Up, 90);
1572 resTM[2] = direction;
1573 resTM[1] = resTM[2] * resTM[0];
1574 resTM[3] = start;
1575
1576 // Approximate the roll angle of leaning
1577 float leanAngle = hms.m_fLeaning * 35;
1578 vector rotTM[3];
1579 float xAimHandsOffset = hcw.GetAimingHandsOffsetLR();
1580 float yAimHandsOffset = hcw.GetAimingHandsOffsetUD();
1581 Math3D.YawPitchRollMatrix( Vector(xAimHandsOffset , yAimHandsOffset, leanAngle), rotTM );
1582 Math3D.MatrixMultiply3(resTM, rotTM, resTM);
1583
1584 // Draw relative transformation matrix diagnostic
1585 #ifndef SERVER
1586 #ifdef DIAG_DEVELOPER
1587 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetTransform(resTM);
1588 #endif
1589 #endif
1590
1591 // Compute normalized aiming angles
1592 float udAngle = hcw.GetBaseAimingAngleUD();
1593 float lrAngle = hcw.GetBaseAimingAngleLR();
1594
1595 float ud01 = Math.InverseLerp(DayZPlayerCamera1stPerson.CONST_UD_MIN, DayZPlayerCamera1stPerson.CONST_UD_MAX, udAngle); // 0-1
1596 float ud11 = Math.Clamp((ud01 * 2) - 1, -1, 1); // -1, 1
1597 float lr01 = Math.InverseLerp(DayZPlayerCamera1stPerson.CONST_LR_MIN, DayZPlayerCamera1stPerson.CONST_LR_MAX, lrAngle); // 0-1
1598 float lr11 = Math.Clamp((lr01 * 2) - 1, -1, 1);
1599
1600 #ifndef SERVER
1601 #ifdef DIAG_DEVELOPER
1602 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetAimAngles(udAngle, lrAngle, ud11, lr11);
1603 #endif
1604 #endif
1605
1606 // Fetch approximate aim offset position based on current state
1607 Blend2DVector aimOffsets = new Blend2DVector();
1608 GetApproximateAimOffsets(aimOffsets, hms.m_iStanceIdx);
1609 vector offset = aimOffsets.Blend(lr11, ud11);
1610
1611 // Apply height offset if any is defined
1613 {
1614 offset[1] = offset[1] + m_WeaponLiftCheckVerticalOffset;
1615 }
1616
1617 // Approximate the shift caused by movement. There is an enormous shift when aiming
1618 // downwards, creating insane shift that we will compensate by shifting the offset
1619 // based on the movement and aiming angle:
1620 vector moveOffset = GetApproximateMovementOffset(localVelocity, hms.m_iStanceIdx, hms.m_fLeaning, ud11, lr11);
1621 offset += moveOffset;
1622
1623 // While changing stances the weapon moves slightly forward and although this may
1624 // cause some unwanted lifts ocasionally, it should prevent some unwanted clipping
1625 if (hcm.IsChangingStance())
1626 {
1627 offset[2] = offset[2] + 0.05;
1628 }
1629
1630 offset = offset.InvMultiply3(rotTM);
1631
1632 // Finally use the computed offset as the start position.
1633 start = offset.Multiply4(resTM);
1634 }
class Blend2D< Class T > Blend2DVector
void DayZPlayerCamera1stPerson(DayZPlayer pPlayer, HumanInputController pInput)
Определения DayZPlayerCamera1stPerson.c:112
proto native bool IsChangingStance()
returns true if character is changing stance
proto native float GetAimingHandsOffsetUD()
returns aiming hands up/down (y) offset angle
proto native float GetBaseAimingAngleLR()
returns base aiming angle LR - without sway/offsets/...
proto native float GetAimingHandsOffsetLR()
returns aiming hands left/right (x) offset angle
proto native float GetBaseAimingAngleUD()
returns base aiming angle UD - without sway/offsets/...
int m_iStanceIdx
current command's id
Определения human.c:1183
float m_fLeaning
current movement (0 idle, 1 walk, 2-run, 3-sprint), only if the command has a movement
Определения human.c:1185
vector GetApproximateMovementOffset(vector localVelocity, int characterStance, float lean, float ud11, float lr11)
Определения Weapon_Base.c:1527
float m_WeaponLiftCheckVerticalOffset
Определения Weapon_Base.c:65
void GetApproximateAimOffsets(Blend2DVector dst, int characterStance)
Определения Weapon_Base.c:1470
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
proto vector Multiply4(vector mat[4])
Transforms position.
static vector RotateAroundZeroDeg(vector vec, vector axis, float angle)
Rotate a vector around 0,0,0 by an angle in degrees.
Определения EnConvert.c:484
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
proto native vector Vector(float x, float y, float z)
Vector constructor from components.

Перекрестные ссылки Blend2DVector, Math::Clamp(), HumanCommandWeapons::GetAimingHandsOffsetLR(), HumanCommandWeapons::GetAimingHandsOffsetUD(), Weapon_Base::GetApproximateAimOffsets(), Weapon_Base::GetApproximateMovementOffset(), HumanCommandWeapons::GetBaseAimingAngleLR(), HumanCommandWeapons::GetBaseAimingAngleUD(), Math::InverseLerp(), vector::InvMultiply3(), HumanCommandMove::IsChangingStance(), HumanMovementState::m_fLeaning, HumanMovementState::m_iStanceIdx, m_WeaponLiftCheckVerticalOffset, Math3D::MatrixMultiply3(), vector::Multiply4(), vector::Normalized(), vector::RotateAroundZeroDeg(), vector::Up, Vector() и Math3D::YawPitchRollMatrix().

Используется в LiftWeaponCheckEx().