Merge branch 'dev_native' of https://github.com/prusa3d/Slic3r into dev_native
This commit is contained in:
commit
404ef147b3
@ -1138,6 +1138,7 @@ GLCanvas3D::Selection::VolumeCache::VolumeCache()
|
|||||||
, m_scaling_factor(Vec3d::Ones())
|
, m_scaling_factor(Vec3d::Ones())
|
||||||
{
|
{
|
||||||
m_rotation_matrix = Transform3d::Identity();
|
m_rotation_matrix = Transform3d::Identity();
|
||||||
|
m_scale_matrix = Transform3d::Identity();
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::Selection::VolumeCache::VolumeCache(const Vec3d& position, const Vec3d& rotation, const Vec3d& scaling_factor)
|
GLCanvas3D::Selection::VolumeCache::VolumeCache(const Vec3d& position, const Vec3d& rotation, const Vec3d& scaling_factor)
|
||||||
@ -1146,6 +1147,7 @@ GLCanvas3D::Selection::VolumeCache::VolumeCache(const Vec3d& position, const Vec
|
|||||||
, m_scaling_factor(scaling_factor)
|
, m_scaling_factor(scaling_factor)
|
||||||
{
|
{
|
||||||
m_rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), m_rotation);
|
m_rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), m_rotation);
|
||||||
|
m_scale_matrix = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), m_scaling_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLCanvas3D::Selection::Selection()
|
GLCanvas3D::Selection::Selection()
|
||||||
@ -1415,8 +1417,8 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation)
|
|||||||
(*m_volumes)[i]->set_rotation(rotation);
|
(*m_volumes)[i]->set_rotation(rotation);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> new_matrix = (m * m_cache.volumes_data[i].get_rotation_matrix()).matrix().block(0, 0, 3, 3);
|
// extracts rotations from the composed transformation
|
||||||
Vec3d new_rotation = Geometry::extract_euler_angles(new_matrix);
|
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_rotation_matrix());
|
||||||
|
|
||||||
(*m_volumes)[i]->set_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_position() - m_cache.dragging_center));
|
(*m_volumes)[i]->set_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_position() - m_cache.dragging_center));
|
||||||
(*m_volumes)[i]->set_rotation(new_rotation);
|
(*m_volumes)[i]->set_rotation(new_rotation);
|
||||||
@ -1443,7 +1445,7 @@ void GLCanvas3D::Selection::scale(const Vec3d& scale)
|
|||||||
(*m_volumes)[i]->set_scaling_factor(scale);
|
(*m_volumes)[i]->set_scaling_factor(scale);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> new_matrix = (m * m_cache.volumes_data[i].get_rotation_matrix()).matrix().block(0, 0, 3, 3);
|
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> new_matrix = (m * m_cache.volumes_data[i].get_scale_matrix()).matrix().block(0, 0, 3, 3);
|
||||||
// extracts scaling factors from the composed transformation
|
// extracts scaling factors from the composed transformation
|
||||||
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
|
Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm());
|
||||||
|
|
||||||
|
@ -411,6 +411,7 @@ public:
|
|||||||
Vec3d m_rotation;
|
Vec3d m_rotation;
|
||||||
Vec3d m_scaling_factor;
|
Vec3d m_scaling_factor;
|
||||||
Transform3d m_rotation_matrix;
|
Transform3d m_rotation_matrix;
|
||||||
|
Transform3d m_scale_matrix;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VolumeCache();
|
VolumeCache();
|
||||||
@ -420,6 +421,7 @@ public:
|
|||||||
const Vec3d& get_rotation() const { return m_rotation; }
|
const Vec3d& get_rotation() const { return m_rotation; }
|
||||||
const Vec3d& get_scaling_factor() const { return m_scaling_factor; }
|
const Vec3d& get_scaling_factor() const { return m_scaling_factor; }
|
||||||
const Transform3d& get_rotation_matrix() const { return m_rotation_matrix; }
|
const Transform3d& get_rotation_matrix() const { return m_rotation_matrix; }
|
||||||
|
const Transform3d& get_scale_matrix() const { return m_scale_matrix; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<unsigned int, VolumeCache> VolumesCache;
|
typedef std::map<unsigned int, VolumeCache> VolumesCache;
|
||||||
|
@ -761,7 +761,9 @@ void GLGizmoRotate3D::on_render(const BoundingBoxf3& box) const
|
|||||||
#endif // ENABLE_EXTENDED_SELECTION
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
const float GLGizmoScale3D::Offset = 5.0f;
|
const float GLGizmoScale3D::Offset = 5.0f;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
const Vec3d GLGizmoScale3D::OffsetVec = (double)GLGizmoScale3D::Offset * Vec3d::Ones();
|
const Vec3d GLGizmoScale3D::OffsetVec = (double)GLGizmoScale3D::Offset * Vec3d::Ones();
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent)
|
GLGizmoScale3D::GLGizmoScale3D(GLCanvas3D& parent)
|
||||||
: GLGizmoBase(parent)
|
: GLGizmoBase(parent)
|
||||||
@ -814,9 +816,10 @@ void GLGizmoScale3D::on_start_dragging(const BoundingBoxf3& box)
|
|||||||
{
|
{
|
||||||
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
m_starting_drag_position = m_grabbers[m_hover_id].center;
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
const BoundingBoxf3& box = selection.get_bounding_box();
|
m_starting_box = selection.get_bounding_box();
|
||||||
#endif // ENABLE_EXTENDED_SELECTION
|
#else
|
||||||
m_starting_box = BoundingBoxf3(box.min - OffsetVec, box.max + OffsetVec);
|
m_starting_box = BoundingBoxf3(box.min - OffsetVec, box.max + OffsetVec);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,6 +869,7 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||||||
BoundingBoxf3 box;
|
BoundingBoxf3 box;
|
||||||
Transform3d transform = Transform3d::Identity();
|
Transform3d transform = Transform3d::Identity();
|
||||||
Vec3d angles = Vec3d::Zero();
|
Vec3d angles = Vec3d::Zero();
|
||||||
|
Transform3d rotation = Transform3d::Identity();
|
||||||
|
|
||||||
if (selection.is_from_single_instance())
|
if (selection.is_from_single_instance())
|
||||||
{
|
{
|
||||||
@ -881,18 +885,29 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||||||
|
|
||||||
// extract angles from transform
|
// extract angles from transform
|
||||||
angles = Slic3r::Geometry::extract_euler_angles(transform);
|
angles = Slic3r::Geometry::extract_euler_angles(transform);
|
||||||
|
|
||||||
|
// set rotation-only component of transform
|
||||||
|
rotation = Geometry::assemble_transform(Vec3d::Zero(), angles);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
box = selection.get_bounding_box();
|
box = selection.get_bounding_box();
|
||||||
|
|
||||||
|
m_box = box;
|
||||||
|
#else
|
||||||
|
m_box = BoundingBoxf3(box.min - OffsetVec, box.max + OffsetVec);
|
||||||
#endif // ENABLE_EXTENDED_SELECTION
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
m_box = BoundingBoxf3(box.min - OffsetVec, box.max + OffsetVec);
|
|
||||||
const Vec3d& center = m_box.center();
|
const Vec3d& center = m_box.center();
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
Vec3d offset_x = rotation * Vec3d((double)Offset, 0.0, 0.0);
|
||||||
|
Vec3d offset_y = rotation * Vec3d(0.0, (double)Offset, 0.0);
|
||||||
|
Vec3d offset_z = rotation * Vec3d(0.0, 0.0, (double)Offset);
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
// x axis
|
// x axis
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
m_grabbers[0].center = transform * Vec3d(m_box.min(0), center(1), center(2));
|
m_grabbers[0].center = transform * Vec3d(m_box.min(0), center(1), center(2)) - offset_x;
|
||||||
m_grabbers[1].center = transform * Vec3d(m_box.max(0), center(1), center(2));
|
m_grabbers[1].center = transform * Vec3d(m_box.max(0), center(1), center(2)) + offset_x;
|
||||||
#else
|
#else
|
||||||
m_grabbers[0].center = Vec3d(m_box.min(0), center(1), center(2));
|
m_grabbers[0].center = Vec3d(m_box.min(0), center(1), center(2));
|
||||||
m_grabbers[1].center = Vec3d(m_box.max(0), center(1), center(2));
|
m_grabbers[1].center = Vec3d(m_box.max(0), center(1), center(2));
|
||||||
@ -902,8 +917,8 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||||||
|
|
||||||
// y axis
|
// y axis
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
m_grabbers[2].center = transform * Vec3d(center(0), m_box.min(1), center(2));
|
m_grabbers[2].center = transform * Vec3d(center(0), m_box.min(1), center(2)) - offset_y;
|
||||||
m_grabbers[3].center = transform * Vec3d(center(0), m_box.max(1), center(2));
|
m_grabbers[3].center = transform * Vec3d(center(0), m_box.max(1), center(2)) + offset_y;
|
||||||
#else
|
#else
|
||||||
m_grabbers[2].center = Vec3d(center(0), m_box.min(1), center(2));
|
m_grabbers[2].center = Vec3d(center(0), m_box.min(1), center(2));
|
||||||
m_grabbers[3].center = Vec3d(center(0), m_box.max(1), center(2));
|
m_grabbers[3].center = Vec3d(center(0), m_box.max(1), center(2));
|
||||||
@ -913,8 +928,8 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||||||
|
|
||||||
// z axis
|
// z axis
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
m_grabbers[4].center = transform * Vec3d(center(0), center(1), m_box.min(2));
|
m_grabbers[4].center = transform * Vec3d(center(0), center(1), m_box.min(2)) - offset_z;
|
||||||
m_grabbers[5].center = transform * Vec3d(center(0), center(1), m_box.max(2));
|
m_grabbers[5].center = transform * Vec3d(center(0), center(1), m_box.max(2)) + offset_z;
|
||||||
#else
|
#else
|
||||||
m_grabbers[4].center = Vec3d(center(0), center(1), m_box.min(2));
|
m_grabbers[4].center = Vec3d(center(0), center(1), m_box.min(2));
|
||||||
m_grabbers[5].center = Vec3d(center(0), center(1), m_box.max(2));
|
m_grabbers[5].center = Vec3d(center(0), center(1), m_box.max(2));
|
||||||
@ -924,10 +939,10 @@ void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
|||||||
|
|
||||||
// uniform
|
// uniform
|
||||||
#if ENABLE_EXTENDED_SELECTION
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
m_grabbers[6].center = transform * Vec3d(m_box.min(0), m_box.min(1), center(2));
|
m_grabbers[6].center = transform * Vec3d(m_box.min(0), m_box.min(1), center(2)) - offset_x - offset_y;
|
||||||
m_grabbers[7].center = transform * Vec3d(m_box.max(0), m_box.min(1), center(2));
|
m_grabbers[7].center = transform * Vec3d(m_box.max(0), m_box.min(1), center(2)) + offset_x - offset_y;
|
||||||
m_grabbers[8].center = transform * Vec3d(m_box.max(0), m_box.max(1), center(2));
|
m_grabbers[8].center = transform * Vec3d(m_box.max(0), m_box.max(1), center(2)) + offset_x + offset_y;
|
||||||
m_grabbers[9].center = transform * Vec3d(m_box.min(0), m_box.max(1), center(2));
|
m_grabbers[9].center = transform * Vec3d(m_box.min(0), m_box.max(1), center(2)) - offset_x + offset_y;
|
||||||
#else
|
#else
|
||||||
m_grabbers[6].center = Vec3d(m_box.min(0), m_box.min(1), center(2));
|
m_grabbers[6].center = Vec3d(m_box.min(0), m_box.min(1), center(2));
|
||||||
m_grabbers[7].center = Vec3d(m_box.max(0), m_box.min(1), center(2));
|
m_grabbers[7].center = Vec3d(m_box.max(0), m_box.min(1), center(2));
|
||||||
@ -1083,7 +1098,9 @@ void GLGizmoScale3D::do_scale_z(const Linef3& mouse_ray)
|
|||||||
void GLGizmoScale3D::do_scale_uniform(const Linef3& mouse_ray)
|
void GLGizmoScale3D::do_scale_uniform(const Linef3& mouse_ray)
|
||||||
{
|
{
|
||||||
Vec3d center = m_starting_box.center();
|
Vec3d center = m_starting_box.center();
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
center(2) = m_box.min(2);
|
center(2) = m_box.min(2);
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
double ratio = calc_ratio(0, mouse_ray, center);
|
double ratio = calc_ratio(0, mouse_ray, center);
|
||||||
|
|
||||||
if (ratio > 0.0)
|
if (ratio > 0.0)
|
||||||
|
@ -314,7 +314,9 @@ protected:
|
|||||||
class GLGizmoScale3D : public GLGizmoBase
|
class GLGizmoScale3D : public GLGizmoBase
|
||||||
{
|
{
|
||||||
static const float Offset;
|
static const float Offset;
|
||||||
|
#if !ENABLE_EXTENDED_SELECTION
|
||||||
static const Vec3d OffsetVec;
|
static const Vec3d OffsetVec;
|
||||||
|
#endif // !ENABLE_EXTENDED_SELECTION
|
||||||
|
|
||||||
mutable BoundingBoxf3 m_box;
|
mutable BoundingBoxf3 m_box;
|
||||||
|
|
||||||
@ -329,7 +331,11 @@ public:
|
|||||||
|
|
||||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||||
const Vec3d& get_scale() const { return m_scale; }
|
const Vec3d& get_scale() const { return m_scale; }
|
||||||
|
#if ENABLE_EXTENDED_SELECTION
|
||||||
|
void set_scale(const Vec3d& scale) { m_starting_scale = scale; m_scale = scale; }
|
||||||
|
#else
|
||||||
void set_scale(const Vec3d& scale) { m_starting_scale = scale; }
|
void set_scale(const Vec3d& scale) { m_starting_scale = scale; }
|
||||||
|
#endif // ENABLE_EXTENDED_SELECTION
|
||||||
#else
|
#else
|
||||||
double get_scale_x() const { return m_scale(0); }
|
double get_scale_x() const { return m_scale(0); }
|
||||||
void set_scale_x(double scale) { m_starting_scale(0) = scale; }
|
void set_scale_x(double scale) { m_starting_scale(0) = scale; }
|
||||||
|
Loading…
Reference in New Issue
Block a user