Skip to content

Commit

Permalink
Downscale axes when viewed from close-up
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasmatena committed Mar 27, 2023
1 parent f591c25 commit 451097b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/slic3r/GUI/CoordAxes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,23 @@ void CoordAxes::render(const Transform3d& trafo, float emission_factor)
shader->start_using();
shader->set_uniform("emission_factor", emission_factor);

// Scale the axes if the camera is close to them to avoid issues
// such as https://github.com/prusa3d/PrusaSlicer/issues/9483
const Camera& camera = wxGetApp().plater()->get_camera();
Transform3d scale_tr = Transform3d::Identity();
scale_tr.scale(std::min(1., camera.get_inv_zoom() * 10.));

// x axis
m_arrow.set_color(ColorRGBA::X());
render_axis(*shader, trafo * Geometry::translation_transform(m_origin) * Geometry::rotation_transform({ 0.0, 0.5 * M_PI, 0.0 }));
render_axis(*shader, trafo * Geometry::translation_transform(m_origin) * Geometry::rotation_transform({ 0.0, 0.5 * M_PI, 0.0 }) * scale_tr);

// y axis
m_arrow.set_color(ColorRGBA::Y());
render_axis(*shader, trafo * Geometry::translation_transform(m_origin) * Geometry::rotation_transform({ -0.5 * M_PI, 0.0, 0.0 }));
render_axis(*shader, trafo * Geometry::translation_transform(m_origin) * Geometry::rotation_transform({ -0.5 * M_PI, 0.0, 0.0 }) * scale_tr);

// z axis
m_arrow.set_color(ColorRGBA::Z());
render_axis(*shader, trafo * Geometry::translation_transform(m_origin));
render_axis(*shader, trafo * Geometry::translation_transform(m_origin) * scale_tr);

shader->stop_using();
if (curr_shader != nullptr)
Expand Down

0 comments on commit 451097b

Please sign in to comment.