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 loud white nosie after mouse steering #5812

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/DynamicBody.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ DynamicBody::DynamicBody(const Json &jsonObj, Space *space) :
throw SavedGameCorruptException();
}

// fix saves with nans
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend this comment be annotated with the current savefile version (see Game.cpp) so that the workaround can be removed when the next savebump occurs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we used to add "todo" notes to SAVEBUMP.txt as well, things to fix for next release, so that might be a good idea.
I should add "checking SAVEBUMP.txt" to the release guide, if we think this is a good strategy?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a good idea on both counts; this definitely deserves to be in the SAVEBUMP.txt file as well.

if (std::isnan(m_angVel.x) || std::isnan(m_angVel.y) || std::isnan(m_angVel.z)) {
m_angVel = vector3d(0.0);
}

m_aiMessage = AIError::AIERROR_NONE;
m_decelerating = false;
}
Expand Down
4 changes: 3 additions & 1 deletion src/ship/PlayerShipController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ struct PlayerShipController::Util {
auto good_speed = sqrt(2 * max_accel * want_rot) * 0.95;
auto frame_speed = want_rot / timeStep;
auto tot_speed = std::min(good_speed, frame_speed / 2);
rot_vel = (ship_dir.Cross(dir) * c.m_ship->GetOrient()).Normalized() * tot_speed;
// this cross product often becomes all-zeros (ship_dir coincides with requested dir)
// NormalizedSafe is crucial there to avoid NaN poisoning
rot_vel = (ship_dir.Cross(dir) * c.m_ship->GetOrient()).NormalizedSafe() * tot_speed;
}
return rot_vel;
};
Expand Down