mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Merge remote-tracking branch 'origin/dev2' into dev_native
This commit is contained in:
commit
6260e43f61
30 changed files with 785 additions and 443 deletions
|
@ -1252,13 +1252,13 @@ namespace Slic3r {
|
|||
// we extract from the given matrix only the values currently used
|
||||
|
||||
// translation
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
Vec3d offset(transform(0, 3), transform(1, 3), transform(2, 3));
|
||||
#else
|
||||
double offset_x = transform(0, 3);
|
||||
double offset_y = transform(1, 3);
|
||||
double offset_z = transform(2, 3);
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
|
||||
// scale
|
||||
double sx = ::sqrt(sqr(transform(0, 0)) + sqr(transform(1, 0)) + sqr(transform(2, 0)));
|
||||
|
@ -1269,21 +1269,28 @@ namespace Slic3r {
|
|||
if ((sx == 0.0) || (sy == 0.0) || (sz == 0.0))
|
||||
return;
|
||||
|
||||
#if !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
// non-uniform scale value, return
|
||||
if ((std::abs(sx - sy) > 0.00001) || (std::abs(sx - sz) > 0.00001))
|
||||
return;
|
||||
#endif // !ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
|
||||
double inv_sx = 1.0 / sx;
|
||||
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);
|
||||
#if ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
Vec3d angles = m3x3.eulerAngles(2, 1, 0);
|
||||
Vec3d rotation(angles(2), angles(1), angles(0));
|
||||
|
||||
instance.set_offset(offset);
|
||||
instance.set_scaling_factor(Vec3d(sx, sy, sz));
|
||||
instance.set_rotation(rotation);
|
||||
#else
|
||||
Eigen::AngleAxisd rotation;
|
||||
rotation.fromRotationMatrix(m3x3);
|
||||
|
@ -1293,20 +1300,12 @@ namespace Slic3r {
|
|||
return;
|
||||
|
||||
double angle_z = (rotation.axis() == Vec3d::UnitZ()) ? rotation.angle() : -rotation.angle();
|
||||
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
|
||||
#if ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
instance.set_offset(offset);
|
||||
#else
|
||||
instance.offset(0) = offset_x;
|
||||
instance.offset(1) = offset_y;
|
||||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
instance.scaling_factor = sx;
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
instance.set_rotation(rotation);
|
||||
#else
|
||||
instance.rotation = angle_z;
|
||||
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
#endif // ENABLE_MODELINSTANCE_3D_FULL_TRANSFORM
|
||||
}
|
||||
|
||||
bool _3MF_Importer::_handle_start_config(const char** attributes, unsigned int num_attributes)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue