Skip to content

Commit

Permalink
only change rot coord if it's below -1k, not all 3 at once
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Oct 25, 2023
1 parent ccef87f commit 924d553
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions Server/Components/Objects/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,30 @@ class BaseObject : public ObjectType, public PoolIDProvider, public NoCopy
moving_ = true;
moveData_ = data;

if (moveData_.targetRot.x == -1000.0f && moveData_.targetRot.y == -1000.0f && moveData_.targetRot.z == -1000.0f)
// Send client current object rotation when passed rotation is smaller than or equal to -1000
if (moveData_.targetRot.x <= -1000.0f)
{
moveData_.targetRot.x = rot_.x;
}

if (moveData_.targetRot.y <= -1000.0f)
{
moveData_.targetRot.y = rot_.y;
}

if (moveData_.targetRot.z <= -1000.0f)
{
moveData_.targetRot.z = rot_.z;
}

float rotDistance = glm::distance(rot_, moveData_.targetRot);
if (rotDistance == 0.0f)
{
/// Send client current object rotation.
moveData_.targetRot = this->rot_;
/// targetRot being NAN will result in rotSpeed being NAN resulting in no server side rotation
rotSpeed_ = NAN;
}
else
{
rotSpeed_ = glm::distance(rot_, moveData_.targetRot) * moveData_.speed / glm::distance(pos_, moveData_.targetPos);
rotSpeed_ = rotDistance * moveData_.speed / glm::distance(pos_, moveData_.targetPos);
}

return makeMovePacket();
Expand Down

0 comments on commit 924d553

Please sign in to comment.