mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 02:55:55 +08:00
SPE-2572 - Fixed panning of camera, in both 3D view and preview, when using multiple beds (#13621)
This commit is contained in:
parent
b7135049d5
commit
63ce55166d
@ -44,6 +44,8 @@ void Camera::set_type(EType type)
|
|||||||
m_type = type;
|
m_type = type;
|
||||||
if (m_update_config_on_type_change_enabled)
|
if (m_update_config_on_type_change_enabled)
|
||||||
wxGetApp().app_config->set("use_perspective_camera", (m_type == EType::Perspective) ? "1" : "0");
|
wxGetApp().app_config->set("use_perspective_camera", (m_type == EType::Perspective) ? "1" : "0");
|
||||||
|
|
||||||
|
update_projection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -634,6 +636,37 @@ void Camera::update_zenit()
|
|||||||
m_zenit = Geometry::rad2deg(0.5 * M_PI - std::acos(std::clamp(-get_dir_forward().dot(Vec3d::UnitZ()), -1.0, 1.0)));
|
m_zenit = Geometry::rad2deg(0.5 * M_PI - std::acos(std::clamp(-get_dir_forward().dot(Vec3d::UnitZ()), -1.0, 1.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Camera::update_projection()
|
||||||
|
{
|
||||||
|
double w = 0.5 * (double)m_viewport[2];
|
||||||
|
double h = 0.5 * (double)m_viewport[3];
|
||||||
|
|
||||||
|
const double inv_zoom = get_inv_zoom();
|
||||||
|
w *= inv_zoom;
|
||||||
|
h *= inv_zoom;
|
||||||
|
|
||||||
|
switch (m_type)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case EType::Ortho:
|
||||||
|
{
|
||||||
|
m_gui_scale = 1.0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EType::Perspective:
|
||||||
|
{
|
||||||
|
// scale near plane to keep w and h constant on the plane at z = m_distance
|
||||||
|
const double scale = m_frustrum_zs.first / m_distance;
|
||||||
|
w *= scale;
|
||||||
|
h *= scale;
|
||||||
|
m_gui_scale = scale;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply_projection(-w, w, -h, h, m_frustrum_zs.first, m_frustrum_zs.second);
|
||||||
|
}
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
|
||||||
|
@ -164,6 +164,7 @@ private:
|
|||||||
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();
|
||||||
|
void update_projection();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
|
@ -7053,10 +7053,13 @@ Vec3d GLCanvas3D::_mouse_to_3d(const Point& mouse_pos, const float* z)
|
|||||||
return hit.is_valid() ? hit.position.cast<double>() : _mouse_to_bed_3d(mouse_pos);
|
return hit.is_valid() ? hit.position.cast<double>() : _mouse_to_bed_3d(mouse_pos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const Camera& camera = wxGetApp().plater()->get_camera();
|
Camera& camera = wxGetApp().plater()->get_camera();
|
||||||
|
const Camera::EType type = camera.get_type();
|
||||||
|
camera.set_type(Camera::EType::Ortho);
|
||||||
const Vec4i viewport(camera.get_viewport().data());
|
const Vec4i viewport(camera.get_viewport().data());
|
||||||
Vec3d out;
|
Vec3d out;
|
||||||
igl::unproject(Vec3d(mouse_pos.x(), viewport[3] - mouse_pos.y(), *z), camera.get_view_matrix().matrix(), camera.get_projection_matrix().matrix(), viewport, out);
|
igl::unproject(Vec3d(mouse_pos.x(), viewport[3] - mouse_pos.y(), *z), camera.get_view_matrix().matrix(), camera.get_projection_matrix().matrix(), viewport, out);
|
||||||
|
camera.set_type(type);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user