Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix move object rotation when optional args are not set #753

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Server/Components/Objects/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,30 @@ class BaseObject : public ObjectType, public PoolIDProvider, public NoCopy
moving_ = true;
moveData_ = data;

/// targetRot being NAN will result in rotSpeed being NAN resulting in no rotation
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)
{
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