fix: camera rotation not updating when menu is open
This commit is contained in:
parent
21c630024a
commit
801354c15d
@ -49,10 +49,20 @@ CameraControl::CameraControl(
|
|||||||
offset(0.0f, 0.7f, 0.0f) {
|
offset(0.0f, 0.7f, 0.0f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CameraControl::refresh() {
|
void CameraControl::refreshPosition() {
|
||||||
camera->position = player.getPosition() + offset;
|
camera->position = player.getPosition() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CameraControl::refreshRotation() {
|
||||||
|
const glm::vec3& rotation = player.getRotation();
|
||||||
|
camera->rotation = glm::mat4(1.0f);
|
||||||
|
camera->rotate(
|
||||||
|
glm::radians(rotation.y),
|
||||||
|
glm::radians(rotation.x),
|
||||||
|
glm::radians(rotation.z)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void CameraControl::updateMouse(PlayerInput& input) {
|
void CameraControl::updateMouse(PlayerInput& input) {
|
||||||
glm::vec3 rotation = player.getRotation();
|
glm::vec3 rotation = player.getRotation();
|
||||||
|
|
||||||
@ -177,7 +187,7 @@ void CameraControl::update(
|
|||||||
const auto& spCamera = player.spCamera;
|
const auto& spCamera = player.spCamera;
|
||||||
const auto& tpCamera = player.tpCamera;
|
const auto& tpCamera = player.tpCamera;
|
||||||
|
|
||||||
refresh();
|
refreshPosition();
|
||||||
|
|
||||||
camera->updateVectors();
|
camera->updateVectors();
|
||||||
if (player.currentCamera == spCamera) {
|
if (player.currentCamera == spCamera) {
|
||||||
@ -274,6 +284,7 @@ void PlayerController::postUpdate(float delta, bool input, bool pause) {
|
|||||||
if (!pause && input) {
|
if (!pause && input) {
|
||||||
camControl.updateMouse(this->input);
|
camControl.updateMouse(this->input);
|
||||||
}
|
}
|
||||||
|
camControl.refreshRotation();
|
||||||
player.postUpdate();
|
player.postUpdate();
|
||||||
camControl.update(this->input, pause ? 0.0f : delta, *player.chunks);
|
camControl.update(this->input, pause ? 0.0f : delta, *player.chunks);
|
||||||
if (input) {
|
if (input) {
|
||||||
|
|||||||
@ -42,7 +42,8 @@ public:
|
|||||||
CameraControl(Player& player, const CameraSettings& settings);
|
CameraControl(Player& player, const CameraSettings& settings);
|
||||||
void updateMouse(PlayerInput& input);
|
void updateMouse(PlayerInput& input);
|
||||||
void update(PlayerInput input, float delta, const Chunks& chunks);
|
void update(PlayerInput input, float delta, const Chunks& chunks);
|
||||||
void refresh();
|
void refreshPosition();
|
||||||
|
void refreshRotation();
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerController {
|
class PlayerController {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user