Another fix on volumes translation

This commit is contained in:
Enrico Turri 2018-12-19 15:03:49 +01:00
parent 918cb48d45
commit 2548253d59
3 changed files with 14 additions and 12 deletions

View File

@ -1549,7 +1549,7 @@ void GLCanvas3D::Selection::start_dragging()
_set_caches();
}
void GLCanvas3D::Selection::translate(const Vec3d& displacement)
void GLCanvas3D::Selection::translate(const Vec3d& displacement, bool local)
{
if (!m_valid)
return;
@ -1559,7 +1559,7 @@ void GLCanvas3D::Selection::translate(const Vec3d& displacement)
#if ENABLE_MODELVOLUME_TRANSFORM
if ((m_mode == Volume) || (*m_volumes)[i]->is_wipe_tower)
{
if (_requires_local_axes())
if (local)
(*m_volumes)[i]->set_volume_offset(m_cache.volumes_data[i].get_volume_position() + displacement);
else
{
@ -1614,7 +1614,7 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local)
else if (is_single_volume() || is_single_modifier())
#if ENABLE_WORLD_ROTATIONS
{
if (_requires_local_axes())
if (requires_local_axes())
(*m_volumes)[i]->set_volume_rotation(rotation);
else
{
@ -2118,6 +2118,11 @@ void GLCanvas3D::Selection::render_sidebar_hints(const std::string& sidebar_fiel
}
#endif // ENABLE_SIDEBAR_VISUAL_HINTS
bool GLCanvas3D::Selection::requires_local_axes() const
{
return (m_mode == Volume) && is_from_single_instance();
}
void GLCanvas3D::Selection::_update_valid()
{
m_valid = (m_volumes != nullptr) && (m_model != nullptr);
@ -2746,11 +2751,6 @@ void GLCanvas3D::Selection::_ensure_on_bed()
}
#endif // ENABLE_ENSURE_ON_BED_WHILE_SCALING
bool GLCanvas3D::Selection::_requires_local_axes() const
{
return (m_mode == Volume) && is_from_single_instance();
}
const float GLCanvas3D::Gizmos::OverlayIconsScale = 1.0f;
const float GLCanvas3D::Gizmos::OverlayBorder = 5.0f;
const float GLCanvas3D::Gizmos::OverlayGapY = 5.0f * OverlayIconsScale;

View File

@ -578,7 +578,7 @@ public:
void start_dragging();
void translate(const Vec3d& displacement);
void translate(const Vec3d& displacement, bool local = false);
void rotate(const Vec3d& rotation, bool local);
void flattening_rotate(const Vec3d& normal);
void scale(const Vec3d& scale, bool local);
@ -597,6 +597,8 @@ public:
void render_sidebar_hints(const std::string& sidebar_field) const;
#endif // ENABLE_SIDEBAR_VISUAL_HINTS
bool requires_local_axes() const;
private:
void _update_valid();
void _update_type();
@ -626,7 +628,6 @@ public:
#if ENABLE_ENSURE_ON_BED_WHILE_SCALING
void _ensure_on_bed();
#endif // ENABLE_ENSURE_ON_BED_WHILE_SCALING
bool _requires_local_axes() const;
};
class ClippingPlane

View File

@ -361,8 +361,9 @@ void ObjectManipulation::update_rotation_value(const Vec3d& rotation)
void ObjectManipulation::change_position_value(const Vec3d& position)
{
auto canvas = wxGetApp().plater()->canvas3D();
canvas->get_selection().start_dragging();
canvas->get_selection().translate(position - cache_position);
GLCanvas3D::Selection& selection = canvas->get_selection();
selection.start_dragging();
selection.translate(position - cache_position, selection.requires_local_axes());
canvas->do_move();
cache_position = position;