Fixed bug into Camera::set_target()

This commit is contained in:
Enrico Turri 2019-11-07 11:48:59 +01:00
parent a624590b36
commit 55a4b99e44
2 changed files with 10 additions and 8 deletions

View file

@ -91,14 +91,16 @@ void Camera::select_next_type()
void Camera::set_target(const Vec3d& target)
{
// We may let these factors be customizable
static const double ScaleFactor = 1.1;
BoundingBoxf3 test_box = m_scene_box;
test_box.translate(-m_scene_box.center());
// We may let this factor be customizable
static const double ScaleFactor = 1.5;
test_box.scale(ScaleFactor);
m_target = target;
m_target(0) = clamp(test_box.min(0), test_box.max(0), m_target(0));
m_target(1) = clamp(test_box.min(1), test_box.max(1), m_target(1));
m_target(2) = clamp(test_box.min(2), test_box.max(2), m_target(2));
test_box.translate(m_scene_box.center());
m_target(0) = clamp(test_box.min(0), test_box.max(0), target(0));
m_target(1) = clamp(test_box.min(1), test_box.max(1), target(1));
m_target(2) = clamp(test_box.min(2), test_box.max(2), target(2));
}
void Camera::set_theta(float theta, bool apply_limit)

View file

@ -1373,7 +1373,7 @@ void GLCanvas3D::set_model(Model* model)
void GLCanvas3D::bed_shape_changed()
{
m_camera.set_scene_box(scene_bounding_box());
refresh_camera_scene_box();
m_camera.requires_zoom_to_bed = true;
m_dirty = true;
if (m_bed.is_prusa())
@ -2116,7 +2116,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re
post_event(Event<bool>(EVT_GLCANVAS_ENABLE_ACTION_BUTTONS, false));
}
m_camera.set_scene_box(scene_bounding_box());
refresh_camera_scene_box();
if (m_selection.is_empty())
{