mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fix: camera rotation not updating when menu is open
This commit is contained in:
parent
21c630024a
commit
801354c15d
2 changed files with 15 additions and 3 deletions
|
|
@ -49,10 +49,20 @@ CameraControl::CameraControl(
|
|||
offset(0.0f, 0.7f, 0.0f) {
|
||||
}
|
||||
|
||||
void CameraControl::refresh() {
|
||||
void CameraControl::refreshPosition() {
|
||||
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) {
|
||||
glm::vec3 rotation = player.getRotation();
|
||||
|
||||
|
|
@ -177,7 +187,7 @@ void CameraControl::update(
|
|||
const auto& spCamera = player.spCamera;
|
||||
const auto& tpCamera = player.tpCamera;
|
||||
|
||||
refresh();
|
||||
refreshPosition();
|
||||
|
||||
camera->updateVectors();
|
||||
if (player.currentCamera == spCamera) {
|
||||
|
|
@ -274,6 +284,7 @@ void PlayerController::postUpdate(float delta, bool input, bool pause) {
|
|||
if (!pause && input) {
|
||||
camControl.updateMouse(this->input);
|
||||
}
|
||||
camControl.refreshRotation();
|
||||
player.postUpdate();
|
||||
camControl.update(this->input, pause ? 0.0f : delta, *player.chunks);
|
||||
if (input) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue