#3782 - World Z axis always vertical for non-free camera
This commit is contained in:
parent
6723b5f3cd
commit
6c36577e8e
4 changed files with 12 additions and 3 deletions
|
@ -260,7 +260,7 @@ void Camera::debug_render() const
|
||||||
imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
imgui.begin(std::string("Camera statistics"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
|
||||||
|
|
||||||
std::string type = get_type_as_string();
|
std::string type = get_type_as_string();
|
||||||
if (wxGetApp().plater()->get_mouse3d_controller().is_running() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
if (wxGetApp().plater()->get_mouse3d_controller().connected() || (wxGetApp().app_config->get("use_free_camera") == "1"))
|
||||||
type += "/free";
|
type += "/free";
|
||||||
else
|
else
|
||||||
type += "/constrained";
|
type += "/constrained";
|
||||||
|
@ -537,6 +537,7 @@ void Camera::look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up
|
||||||
Vec3d unit_y = unit_z.cross(unit_x).normalized();
|
Vec3d unit_y = unit_z.cross(unit_x).normalized();
|
||||||
|
|
||||||
m_target = target;
|
m_target = target;
|
||||||
|
m_distance = (position - target).norm();
|
||||||
Vec3d new_position = m_target + m_distance * unit_z;
|
Vec3d new_position = m_target + m_distance * unit_z;
|
||||||
|
|
||||||
m_view_matrix(0, 0) = unit_x(0);
|
m_view_matrix(0, 0) = unit_x(0);
|
||||||
|
|
|
@ -122,6 +122,8 @@ public:
|
||||||
// returns true if the camera z axis (forward) is pointing in the negative direction of the world z axis
|
// returns true if the camera z axis (forward) is pointing in the negative direction of the world z axis
|
||||||
bool is_looking_downward() const { return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; }
|
bool is_looking_downward() const { return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; }
|
||||||
|
|
||||||
|
void look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up);
|
||||||
|
|
||||||
double max_zoom() const { return 100.0; }
|
double max_zoom() const { return 100.0; }
|
||||||
double min_zoom() const;
|
double min_zoom() const;
|
||||||
|
|
||||||
|
@ -137,7 +139,6 @@ private:
|
||||||
#endif // ENABLE_THUMBNAIL_GENERATOR
|
#endif // ENABLE_THUMBNAIL_GENERATOR
|
||||||
void set_distance(double distance) const;
|
void set_distance(double distance) const;
|
||||||
|
|
||||||
void look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up);
|
|
||||||
void set_default_orientation();
|
void set_default_orientation();
|
||||||
Vec3d validate_target(const Vec3d& target) const;
|
Vec3d validate_target(const Vec3d& target) const;
|
||||||
void update_zenit();
|
void update_zenit();
|
||||||
|
|
|
@ -3932,7 +3932,6 @@ void GLCanvas3D::handle_layers_data_focus_event(const t_layer_height_range range
|
||||||
|
|
||||||
void GLCanvas3D::update_ui_from_settings()
|
void GLCanvas3D::update_ui_from_settings()
|
||||||
{
|
{
|
||||||
m_camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
|
|
|
@ -2245,6 +2245,14 @@ void Plater::priv::update_ui_from_settings()
|
||||||
// $self->{buttons_sizer}->Layout;
|
// $self->{buttons_sizer}->Layout;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
camera.set_type(wxGetApp().app_config->get("use_perspective_camera"));
|
||||||
|
if (wxGetApp().app_config->get("use_free_camera") != "1")
|
||||||
|
{
|
||||||
|
// forces camera right vector to be parallel to XY plane
|
||||||
|
if (std::abs(camera.get_dir_right()(2)) > EPSILON)
|
||||||
|
camera.look_at(camera.get_position(), camera.get_target(), Vec3d::UnitZ());
|
||||||
|
}
|
||||||
|
|
||||||
view3D->get_canvas3d()->update_ui_from_settings();
|
view3D->get_canvas3d()->update_ui_from_settings();
|
||||||
preview->get_canvas3d()->update_ui_from_settings();
|
preview->get_canvas3d()->update_ui_from_settings();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue