Reduced packet spam when entities idle

* Try not to send look packets when nothing's changed.
This commit is contained in:
Tiger Wang
2020-07-06 20:56:05 +01:00
parent e205d4109b
commit f49f90906c
3 changed files with 12 additions and 4 deletions
+9 -1
View File
@@ -490,14 +490,22 @@ void cMonster::CalcLeashActions(std::chrono::milliseconds a_Dt)
void cMonster::SetPitchAndYawFromDestination(bool a_IsFollowingPath)
{
Vector3d BodyDistance;
if (!a_IsFollowingPath && (GetTarget() != nullptr))
if (!a_IsFollowingPath)
{
if (GetTarget() == nullptr)
{
// Avoid dirtying head position when nothing will change
// Thus avoids creating unnecessary network traffic
return;
}
BodyDistance = GetTarget()->GetPosition() - GetPosition();
}
else
{
BodyDistance = m_NextWayPointPosition - GetPosition();
}
double BodyRotation, BodyPitch;
BodyDistance.Normalize();
VectorToEuler(BodyDistance.x, BodyDistance.y, BodyDistance.z, BodyRotation, BodyPitch);