Skip to content
Snippets Groups Projects
Commit ab550ac1 authored by Vanessa Karolek's avatar Vanessa Karolek
Browse files

[#60][Fix] fix scroll input bug

Fixed scroll input being not considered if a gamepad is connected
parent 5da1c965
No related branches found
No related tags found
1 merge request!65Resolve "Kamera - Steuerung mittels Controller"
Pipeline #25977 passed
......@@ -25,6 +25,11 @@ namespace vkcv::camera {
}
void PilotCameraController::changeFov(double offset, Camera &camera){
// update only if there is (valid) input
if (offset == 0.0) {
return;
}
float fov = camera.getFov();
float fov_range = m_fov_max - m_fov_min;
float fov_stepsize = glm::radians(fov_range) / static_cast<float>(m_fov_nsteps);
......
......@@ -32,10 +32,15 @@ namespace vkcv::camera {
}
void TrackballCameraController::updateRadius(double offset, Camera &camera) {
// update only if there is (valid) input
if (offset == 0.0) {
return;
}
glm::vec3 cameraPosition = camera.getPosition();
glm::vec3 cameraCenter = camera.getCenter();
float radius = glm::length(cameraCenter - cameraPosition); // get current camera radius
setRadius(radius - offset * m_scrollSensitivity);
setRadius(radius - static_cast<float>(offset) * m_scrollSensitivity);
}
void TrackballCameraController::updateCamera(double deltaTime, Camera &camera) {
......@@ -109,6 +114,5 @@ namespace vkcv::camera {
double leftYVal = glm::clamp((abs(stickLeftY)-threshold), 0.0, 1.0)
* std::copysign(1.0, stickLeftY) * sensitivity * frametime;
updateRadius(-leftYVal, camera);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment