3DConnexion devices -> Tweak of sensitivity parameters and dependency of translation from zoom factor

This commit is contained in:
Enrico Turri 2020-01-17 09:36:34 +01:00
parent 34aac7e292
commit 02aa629449
3 changed files with 18 additions and 13 deletions

View File

@ -143,13 +143,14 @@ void Camera::update_zoom(double delta_zoom)
void Camera::set_zoom(double zoom)
{
// Don't allow to zoom too far outside the scene.
double zoom_min = calc_zoom_to_bounding_box_factor(m_scene_box, (int)m_viewport[2], (int)m_viewport[3]);
double zoom_min = min_zoom();
if (zoom_min > 0.0)
zoom = std::max(zoom, zoom_min * 0.7);
zoom = std::max(zoom, zoom_min);
// Don't allow to zoom too close to the scene.
m_zoom = std::min(zoom, 100.0);
m_zoom = std::min(zoom, max_zoom());
}
#if ENABLE_6DOF_CAMERA
void Camera::select_view(const std::string& direction)
{
@ -457,9 +458,9 @@ void Camera::rotate_local_around_pivot(const Vec3d& rotation_rad, const Vec3d& p
translate_world(center);
}
bool Camera::is_looking_downward() const
double Camera::min_zoom() const
{
return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0;
return 0.7 * calc_zoom_to_bounding_box_factor(m_scene_box, (int)m_viewport[2], (int)m_viewport[3]);
}
#endif // ENABLE_6DOF_CAMERA

View File

@ -140,7 +140,10 @@ public:
void rotate_local_around_pivot(const Vec3d& rotation_rad, const Vec3d& pivot);
// returns true if the camera z axis (forward) is pointing in the negative direction of the world z axis
bool is_looking_downward() const;
bool is_looking_downward() const { return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; }
double max_zoom() const { return 100.0; }
double min_zoom() const;
#endif // ENABLE_6DOF_CAMERA
private:

View File

@ -156,7 +156,8 @@ bool Mouse3DController::State::apply(Camera& camera)
{
const Vec3d& translation = m_translation.queue.front();
#if ENABLE_3DCONNEXION_Y_AS_ZOOM
camera.set_target(camera.get_target() + camera.get_inv_zoom() * m_translation_params.scale * (translation(0) * camera.get_dir_right() + translation(2) * camera.get_dir_up()));
double zoom_factor = camera.min_zoom() / camera.get_zoom();
camera.set_target(camera.get_target() + zoom_factor * m_translation_params.scale * (translation(0) * camera.get_dir_right() + translation(2) * camera.get_dir_up()));
if (translation(1) != 0.0)
camera.update_zoom(m_zoom_params.scale * translation(1) / std::abs(translation(1)));
#else
@ -655,12 +656,12 @@ bool Mouse3DController::connect_device()
BOOST_LOG_TRIVIAL(info) << "Path................: '" << path << "'";
// get device parameters from the config, if present
double translation_speed = 1.0;
float rotation_speed = 1.0;
double translation_speed = 4.0;
float rotation_speed = 4.0;
double translation_deadzone = State::DefaultTranslationDeadzone;
float rotation_deadzone = State::DefaultRotationDeadzone;
#if ENABLE_3DCONNEXION_Y_AS_ZOOM
double zoom_speed = 1.0;
double zoom_speed = 2.0;
#endif // ENABLE_3DCONNEXION_Y_AS_ZOOM
wxGetApp().app_config->get_mouse_device_translation_speed(m_device_str, translation_speed);
wxGetApp().app_config->get_mouse_device_translation_deadzone(m_device_str, translation_deadzone);
@ -670,12 +671,12 @@ bool Mouse3DController::connect_device()
wxGetApp().app_config->get_mouse_device_zoom_speed(m_device_str, zoom_speed);
#endif // ENABLE_3DCONNEXION_Y_AS_ZOOM
// clamp to valid values
m_state.set_translation_scale(State::DefaultTranslationScale* std::clamp(translation_speed, 0.1, 10.0));
m_state.set_translation_scale(State::DefaultTranslationScale * std::clamp(translation_speed, 0.1, 10.0));
m_state.set_translation_deadzone(std::clamp(translation_deadzone, 0.0, State::MaxTranslationDeadzone));
m_state.set_rotation_scale(State::DefaultRotationScale* std::clamp(rotation_speed, 0.1f, 10.0f));
m_state.set_rotation_scale(State::DefaultRotationScale * std::clamp(rotation_speed, 0.1f, 10.0f));
m_state.set_rotation_deadzone(std::clamp(rotation_deadzone, 0.0f, State::MaxRotationDeadzone));
#if ENABLE_3DCONNEXION_Y_AS_ZOOM
m_state.set_zoom_scale(State::DefaultZoomScale* std::clamp(zoom_speed, 0.1, 10.0));
m_state.set_zoom_scale(State::DefaultZoomScale * std::clamp(zoom_speed, 0.1, 10.0));
#endif // ENABLE_3DCONNEXION_Y_AS_ZOOM
}
#if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT