DayZ 1.28
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 строка 1570

1571 {
1572 // Construct stable trasformation matrix that somewhat aligns with the weapon transform,
1573 // without actually using the weapon as reference - the weapon will move during the lift/obstruction
1574 // in more than 1 axis and is therefore not realiable source of truth.
1575 vector resTM[4];
1576 resTM[0] = Vector(direction[0], 0, direction[2]).Normalized();
1577 resTM[0] = vector.RotateAroundZeroDeg(resTM[0], vector.Up, 90);
1578 resTM[2] = direction;
1579 resTM[1] = resTM[2] * resTM[0];
1580 resTM[3] = start;
1581
1582 // Approximate the roll angle of leaning
1583 float leanAngle = hms.m_fLeaning * 35;
1584 vector rotTM[3];
1585 float xAimHandsOffset = hcw.GetAimingHandsOffsetLR();
1586 float yAimHandsOffset = hcw.GetAimingHandsOffsetUD();
1587 Math3D.YawPitchRollMatrix( Vector(xAimHandsOffset , yAimHandsOffset, leanAngle), rotTM );
1588 Math3D.MatrixMultiply3(resTM, rotTM, resTM);
1589
1590 // Draw relative transformation matrix diagnostic
1591 #ifndef SERVER
1592 #ifdef DIAG_DEVELOPER
1593 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetTransform(resTM);
1594 #endif
1595 #endif
1596
1597 // Compute normalized aiming angles
1598 float udAngle = hcw.GetBaseAimingAngleUD();
1599 float lrAngle = hcw.GetBaseAimingAngleLR();
1600
1601 float ud01 = Math.InverseLerp(DayZPlayerCamera1stPerson.CONST_UD_MIN, DayZPlayerCamera1stPerson.CONST_UD_MAX, udAngle); // 0-1
1602 float ud11 = Math.Clamp((ud01 * 2) - 1, -1, 1); // -1, 1
1603 float lr01 = Math.InverseLerp(DayZPlayerCamera1stPerson.CONST_LR_MIN, DayZPlayerCamera1stPerson.CONST_LR_MAX, lrAngle); // 0-1
1604 float lr11 = Math.Clamp((lr01 * 2) - 1, -1, 1);
1605
1606 #ifndef SERVER
1607 #ifdef DIAG_DEVELOPER
1608 PluginDiagMenuClient.GetWeaponLiftDiag().Data().SetAimAngles(udAngle, lrAngle, ud11, lr11);
1609 #endif
1610 #endif
1611
1612 // Fetch approximate aim offset position based on current state
1613 Blend2DVector aimOffsets = new Blend2DVector();
1614 GetApproximateAimOffsets(aimOffsets, hms.m_iStanceIdx);
1615 vector offset = aimOffsets.Blend(lr11, ud11);
1616
1617 // Apply height offset if any is defined
1619 {
1620 offset[1] = offset[1] + m_WeaponLiftCheckVerticalOffset;
1621 }
1622
1623 // Approximate the shift caused by movement. There is an enormous shift when aiming
1624 // downwards, creating insane shift that we will compensate by shifting the offset
1625 // based on the movement and aiming angle:
1626 vector moveOffset = GetApproximateMovementOffset(localVelocity, hms.m_iStanceIdx, hms.m_fLeaning, ud11, lr11);
1627 offset += moveOffset;
1628
1629 // While changing stances the weapon moves slightly forward and although this may
1630 // cause some unwanted lifts ocasionally, it should prevent some unwanted clipping
1631 if (hcm.IsChangingStance())
1632 {
1633 offset[2] = offset[2] + 0.05;
1634 }
1635
1636 offset = offset.InvMultiply3(rotTM);
1637
1638 // Finally use the computed offset as the start position.
1639 start = offset.Multiply4(resTM);
1640 }
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:1154
float m_fLeaning
current movement (0 idle, 1 walk, 2-run, 3-sprint), only if the command has a movement
Определения human.c:1156
vector GetApproximateMovementOffset(vector localVelocity, int characterStance, float lean, float ud11, float lr11)
Определения Weapon_Base.c:1533
float m_WeaponLiftCheckVerticalOffset
Определения Weapon_Base.c:65
void GetApproximateAimOffsets(Blend2DVector dst, int characterStance)
Определения Weapon_Base.c:1476
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:450
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().