Skip to content

Commit

Permalink
Fix glued cockpit
Browse files Browse the repository at this point in the history
Fixes issue when cockpit becomes "glued" on random occasions.
  • Loading branch information
Max5377 authored Sep 18, 2023
1 parent 1957b8d commit 48b103c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ShipCockpit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,23 @@ void ShipCockpit::Render(Graphics::Renderer *renderer, const Camera *camera, con

inline void ShipCockpit::resetInternalCameraController()
{
m_icc = static_cast<InternalCameraController *>(Pi::game->GetWorldView()->shipView->GetCameraController());
//Use dynamic_cast here to return NULL, if GetCameraController() returns derived CameraController class other than InternalCameraController
m_icc = dynamic_cast<InternalCameraController *>(Pi::game->GetWorldView()->shipView->GetCameraController());
}

void ShipCockpit::Update(const Player *player, float timeStep)
{
m_transform = matrix4x4d::Identity();

if (m_icc == nullptr) {
//Check if current view is exterior, so resetInternalCameraController() will not set m_icc to NULL
if (Pi::game->GetWorldView()->shipView->IsExteriorView())
{
return;
}
// I don't know where to put this
resetInternalCameraController();
}

m_transform = matrix4x4d::Identity();
double rotX;
double rotY;
m_icc->getRots(rotX, rotY);
Expand Down

0 comments on commit 48b103c

Please sign in to comment.