|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DayZPlayerImplementHeading |
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool ClampHeading (float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff) |
|
{ |
|
float aDiff = pModel.m_fHeadingAngle - pModel.m_fOrientationAngle; |
|
if (aDiff < -Math.PI) |
|
{ |
|
aDiff += Math.PI2; |
|
} |
|
else if (aDiff > Math.PI) |
|
{ |
|
aDiff -= Math.PI2; |
|
} |
|
|
|
|
|
|
|
if (pLastHeadingDiff < -Math.PI_HALF && aDiff > 0) |
|
{ |
|
aDiff = -Math.PI + 0.01; |
|
pLastHeadingDiff = aDiff; |
|
pModel.m_fHeadingAngle = pModel.m_fOrientationAngle + aDiff; |
|
|
|
|
|
|
|
return true; |
|
} |
|
else if (pLastHeadingDiff > Math.PI_HALF && aDiff < 0) |
|
{ |
|
aDiff = Math.PI - 0.01; |
|
pLastHeadingDiff = aDiff; |
|
pModel.m_fHeadingAngle = pModel.m_fOrientationAngle + aDiff; |
|
|
|
|
|
|
|
return true; |
|
} |
|
|
|
pLastHeadingDiff = aDiff; |
|
|
|
return false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
static float CONST_ROTLIMIT = Math.PI * 0.95; |
|
|
|
|
|
static bool RotateOrient (float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff) |
|
{ |
|
float aDiff = pModel.m_fHeadingAngle - pModel.m_fOrientationAngle; |
|
|
|
while (aDiff < -Math.PI) |
|
{ |
|
aDiff += Math.PI2; |
|
} |
|
while (aDiff > Math.PI) |
|
{ |
|
aDiff -= Math.PI2; |
|
} |
|
|
|
|
|
|
|
if (pLastHeadingDiff < -Math.PI_HALF && aDiff > 0) |
|
{ |
|
aDiff -= Math.PI2; |
|
} |
|
else if (pLastHeadingDiff > Math.PI_HALF && aDiff < 0) |
|
{ |
|
aDiff += Math.PI2; |
|
} |
|
|
|
pLastHeadingDiff = aDiff; |
|
if (aDiff < -CONST_ROTLIMIT) |
|
{ |
|
|
|
if (aDiff < -(Math.PI_HALF + CONST_ROTLIMIT)) |
|
{ |
|
pLastHeadingDiff = 0; |
|
return false; |
|
} |
|
|
|
pModel.m_fOrientationAngle += aDiff + CONST_ROTLIMIT; |
|
return true; |
|
} |
|
else if (aDiff > CONST_ROTLIMIT) |
|
{ |
|
|
|
if (aDiff > (Math.PI_HALF + CONST_ROTLIMIT)) |
|
{ |
|
pLastHeadingDiff = 0; |
|
return false; |
|
} |
|
|
|
pModel.m_fOrientationAngle += aDiff - CONST_ROTLIMIT; |
|
return true; |
|
} |
|
|
|
|
|
return false; |
|
|
|
} |
|
|
|
static bool NoHeading(float pDt, SDayZPlayerHeadingModel pModel, out float pLastHeadingDiff) |
|
{ |
|
pLastHeadingDiff = 0; |
|
pModel.m_fHeadingAngle = pModel.m_fOrientationAngle; |
|
return true; |
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|