Fixed import of rotations from 3mf files
This commit is contained in:
parent
07274589a3
commit
a079f2a34e
@ -1278,13 +1278,14 @@ namespace Slic3r {
|
||||
double inv_sy = 1.0 / sy;
|
||||
double inv_sz = 1.0 / sz;
|
||||
|
||||
Eigen::Matrix3d m3x3;
|
||||
Eigen::Matrix<double, 3, 3, Eigen::DontAlign> m3x3;
|
||||
m3x3 << transform(0, 0) * inv_sx, transform(0, 1) * inv_sy, transform(0, 2) * inv_sz,
|
||||
transform(1, 0) * inv_sx, transform(1, 1) * inv_sy, transform(1, 2) * inv_sz,
|
||||
transform(2, 0) * inv_sx, transform(2, 1) * inv_sy, transform(2, 2) * inv_sz;
|
||||
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
Vec3d rotation = m3x3.eulerAngles(0, 1, 2);
|
||||
Vec3d angles = m3x3.eulerAngles(2, 1, 0);
|
||||
Vec3d rotation(angles(2), angles(1), angles(0));
|
||||
#else
|
||||
Eigen::AngleAxisd rotation;
|
||||
rotation.fromRotationMatrix(m3x3);
|
||||
|
@ -74,6 +74,20 @@ inline std::string header_slic3r_generated() { return std::string("generated by
|
||||
// getpid platform wrapper
|
||||
extern unsigned get_current_pid();
|
||||
|
||||
template <typename Real>
|
||||
Real round_nearest(Real value, unsigned int decimals)
|
||||
{
|
||||
Real res = (Real)0;
|
||||
if (decimals == 0)
|
||||
res = ::round(value);
|
||||
else
|
||||
{
|
||||
Real power = ::pow((Real)10, (int)decimals);
|
||||
res = ::round(value * power + (Real)0.5) / power;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Compute the next highest power of 2 of 32-bit v
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html
|
||||
template<typename T>
|
||||
|
@ -1837,16 +1837,16 @@ void update_rotation_value(double angle, Axis axis)
|
||||
}
|
||||
}
|
||||
|
||||
og->set_value(axis_str, int(Geometry::rad2deg(angle)));
|
||||
og->set_value(axis_str, round_nearest(int(Geometry::rad2deg(angle)), 0));
|
||||
}
|
||||
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
void update_rotation_value(const Vec3d& rotation)
|
||||
{
|
||||
auto og = get_optgroup(ogFrequentlyObjectSettings);
|
||||
og->set_value("rotation_x", int(Geometry::rad2deg(rotation(0))));
|
||||
og->set_value("rotation_y", int(Geometry::rad2deg(rotation(1))));
|
||||
og->set_value("rotation_z", int(Geometry::rad2deg(rotation(2))));
|
||||
og->set_value("rotation_x", int(round_nearest(Geometry::rad2deg(rotation(0)), 0)));
|
||||
og->set_value("rotation_y", int(round_nearest(Geometry::rad2deg(rotation(1)), 0)));
|
||||
og->set_value("rotation_z", int(round_nearest(Geometry::rad2deg(rotation(2)), 0)));
|
||||
}
|
||||
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user