mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 14:13:57 -06:00
Follow-up of d6fdf2d5c2
-> Automatic generation of missing thumbnails
This commit is contained in:
parent
0cdc54b710
commit
44d31f9bf2
7 changed files with 140 additions and 73 deletions
|
@ -25,19 +25,19 @@ std::string Camera::get_type_as_string() const
|
|||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case Unknown: return "unknown";
|
||||
case Perspective: return "perspective";
|
||||
case EType::Unknown: return "unknown";
|
||||
case EType::Perspective: return "perspective";
|
||||
default:
|
||||
case Ortho: return "orthographic";
|
||||
case EType::Ortho: return "orthographic";
|
||||
};
|
||||
}
|
||||
|
||||
void Camera::set_type(EType type)
|
||||
{
|
||||
if (m_type != type) {
|
||||
if (m_type != type && (type == EType::Ortho || type == EType::Perspective)) {
|
||||
m_type = type;
|
||||
if (m_update_config_on_type_change_enabled) {
|
||||
wxGetApp().app_config->set("use_perspective_camera", (m_type == Perspective) ? "1" : "0");
|
||||
wxGetApp().app_config->set("use_perspective_camera", (m_type == EType::Perspective) ? "1" : "0");
|
||||
wxGetApp().app_config->save();
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void Camera::set_type(EType type)
|
|||
void Camera::select_next_type()
|
||||
{
|
||||
unsigned char next = (unsigned char)m_type + 1;
|
||||
if (next == (unsigned char)Num_types)
|
||||
if (next == (unsigned char)EType::Num_types)
|
||||
next = 1;
|
||||
|
||||
set_type((EType)next);
|
||||
|
@ -95,10 +95,10 @@ double Camera::get_fov() const
|
|||
{
|
||||
switch (m_type)
|
||||
{
|
||||
case Perspective:
|
||||
case EType::Perspective:
|
||||
return 2.0 * Geometry::rad2deg(std::atan(1.0 / m_projection_matrix.matrix()(1, 1)));
|
||||
default:
|
||||
case Ortho:
|
||||
case EType::Ortho:
|
||||
return 0.0;
|
||||
};
|
||||
}
|
||||
|
@ -143,12 +143,12 @@ void Camera::apply_projection(const BoundingBoxf3& box, double near_z, double fa
|
|||
switch (m_type)
|
||||
{
|
||||
default:
|
||||
case Ortho:
|
||||
case EType::Ortho:
|
||||
{
|
||||
m_gui_scale = 1.0;
|
||||
break;
|
||||
}
|
||||
case Perspective:
|
||||
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;
|
||||
|
@ -165,12 +165,12 @@ void Camera::apply_projection(const BoundingBoxf3& box, double near_z, double fa
|
|||
switch (m_type)
|
||||
{
|
||||
default:
|
||||
case Ortho:
|
||||
case EType::Ortho:
|
||||
{
|
||||
glsafe(::glOrtho(-w, w, -h, h, m_frustrum_zs.first, m_frustrum_zs.second));
|
||||
break;
|
||||
}
|
||||
case Perspective:
|
||||
case EType::Perspective:
|
||||
{
|
||||
glsafe(::glFrustum(-w, w, -h, h, m_frustrum_zs.first, m_frustrum_zs.second));
|
||||
break;
|
||||
|
@ -501,7 +501,7 @@ void Camera::set_default_orientation()
|
|||
const Vec3d camera_pos = m_target + m_distance * Vec3d(sin_theta * ::sin(phi_rad), sin_theta * ::cos(phi_rad), ::cos(theta_rad));
|
||||
m_view_rotation = Eigen::AngleAxisd(theta_rad, Vec3d::UnitX()) * Eigen::AngleAxisd(phi_rad, Vec3d::UnitZ());
|
||||
m_view_rotation.normalize();
|
||||
m_view_matrix.fromPositionOrientationScale(m_view_rotation * (- camera_pos), m_view_rotation, Vec3d(1., 1., 1.));
|
||||
m_view_matrix.fromPositionOrientationScale(m_view_rotation * (-camera_pos), m_view_rotation, Vec3d::Ones());
|
||||
}
|
||||
|
||||
Vec3d Camera::validate_target(const Vec3d& target) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue