Fix gyroscope on walldriving surface properly

This commit is contained in:
Benau 2022-04-30 10:45:33 +08:00
parent 98eb912a76
commit ae2cfb4162

View File

@ -432,9 +432,13 @@ void CameraNormal::positionCamera(float dt, float above_kart, float cam_angle,
if (cam_roll_angle != 0.0f)
{
irr::core::vector3df rotated = straight_up;
rotated.rotateXYBy(cam_roll_angle * (180.0f / M_PI));
btQuaternion q = shortestArcQuat(Vec3(straight_up), Vec3(rotated).normalize());
m_camera->setUpVector(Vec3(quatRotate(q, up)).toIrrVector());
#ifdef IOS_STK
cam_roll_angle *= -1.0f;
#endif
btQuaternion q(m_kart->getSmoothedTrans().getBasis().getColumn(2),
cam_roll_angle);
q *= m_kart->getSmoothedTrans().getRotation();
btMatrix3x3 m(q);
m_camera->setUpVector(((Vec3)m.getColumn(1)).toIrrVector());
}
} // positionCamera