Merge remote-tracking branch 'origin/dev2' into dev_native
This commit is contained in:
commit
20d0f046d2
34 changed files with 1300 additions and 694 deletions
src/libslic3r
|
@ -1066,6 +1066,29 @@ size_t ModelVolume::split(unsigned int max_extruders)
|
|||
return idx;
|
||||
}
|
||||
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
void ModelInstance::set_rotation(const Vec3d& rotation)
|
||||
{
|
||||
set_rotation(X, rotation(0));
|
||||
set_rotation(Y, rotation(1));
|
||||
set_rotation(Z, rotation(2));
|
||||
}
|
||||
|
||||
void ModelInstance::set_rotation(Axis axis, double rotation)
|
||||
{
|
||||
static const double TWO_PI = 2.0 * (double)PI;
|
||||
while (rotation < 0.0)
|
||||
{
|
||||
rotation += TWO_PI;
|
||||
}
|
||||
while (TWO_PI < rotation)
|
||||
{
|
||||
rotation -= TWO_PI;
|
||||
}
|
||||
m_rotation(axis) = rotation;
|
||||
}
|
||||
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
|
||||
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
||||
{
|
||||
mesh->transform(world_matrix(dont_translate).cast<float>());
|
||||
|
@ -1110,7 +1133,12 @@ Vec3d ModelInstance::transform_vector(const Vec3d& v, bool dont_translate) const
|
|||
|
||||
void ModelInstance::transform_polygon(Polygon* polygon) const
|
||||
{
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
// CHECK_ME -> Is the following correct or it should take in account all three rotations ?
|
||||
polygon->rotate(this->m_rotation(2)); // rotate around polygon origin
|
||||
#else
|
||||
polygon->rotate(this->rotation); // rotate around polygon origin
|
||||
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
polygon->scale(this->scaling_factor); // scale around polygon origin
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1154,15 @@ Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, b
|
|||
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
|
||||
|
||||
if (!dont_rotate)
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
{
|
||||
m.rotate(Eigen::AngleAxisd(m_rotation(2), Vec3d::UnitZ()));
|
||||
m.rotate(Eigen::AngleAxisd(m_rotation(1), Vec3d::UnitY()));
|
||||
m.rotate(Eigen::AngleAxisd(m_rotation(0), Vec3d::UnitX()));
|
||||
}
|
||||
#else
|
||||
m.rotate(Eigen::AngleAxisd(rotation, Vec3d::UnitZ()));
|
||||
#endif // ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
|
||||
if (!dont_scale)
|
||||
m.scale(scaling_factor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue