mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Merge branch 'dev_native' into vb_dev_native_background_processing
This commit is contained in:
commit
edc79cb922
47 changed files with 1617 additions and 238 deletions
|
@ -412,6 +412,7 @@ void Model::convert_multipart_object(unsigned int max_extruders)
|
|||
|
||||
ModelObject* object = new ModelObject(this);
|
||||
object->input_file = this->objects.front()->input_file;
|
||||
object->name = this->objects.front()->name;
|
||||
|
||||
reset_auto_extruder_id();
|
||||
|
||||
|
@ -694,9 +695,13 @@ void ModelObject::center_around_origin()
|
|||
|
||||
if (!this->instances.empty()) {
|
||||
for (ModelInstance *i : this->instances) {
|
||||
#if ENABLE_MIRROR
|
||||
i->set_offset(i->get_offset() - shift);
|
||||
#else
|
||||
// apply rotation and scaling to vector as well before translating instance,
|
||||
// in order to leave final position unaltered
|
||||
i->set_offset(i->get_offset() + i->transform_vector(-shift, true));
|
||||
#endif // ENABLE_MIRROR
|
||||
}
|
||||
this->invalidate_bounding_box();
|
||||
}
|
||||
|
@ -1064,6 +1069,38 @@ void ModelInstance::set_rotation(Axis axis, double rotation)
|
|||
m_rotation(axis) = rotation;
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
void ModelInstance::set_scaling_factor(const Vec3d& scaling_factor)
|
||||
{
|
||||
set_scaling_factor(X, scaling_factor(0));
|
||||
set_scaling_factor(Y, scaling_factor(1));
|
||||
set_scaling_factor(Z, scaling_factor(2));
|
||||
}
|
||||
|
||||
void ModelInstance::set_scaling_factor(Axis axis, double scaling_factor)
|
||||
{
|
||||
m_scaling_factor(axis) = std::abs(scaling_factor);
|
||||
}
|
||||
|
||||
void ModelInstance::set_mirror(const Vec3d& mirror)
|
||||
{
|
||||
set_mirror(X, mirror(0));
|
||||
set_mirror(Y, mirror(1));
|
||||
set_mirror(Z, mirror(2));
|
||||
}
|
||||
|
||||
void ModelInstance::set_mirror(Axis axis, double mirror)
|
||||
{
|
||||
double abs_mirror = std::abs(mirror);
|
||||
if (abs_mirror == 0.0)
|
||||
mirror = 1.0;
|
||||
else if (abs_mirror != 1.0)
|
||||
mirror /= abs_mirror;
|
||||
|
||||
m_mirror(axis) = mirror;
|
||||
}
|
||||
#endif // ENABLE_MIRROR
|
||||
|
||||
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
||||
{
|
||||
mesh->transform(world_matrix(dont_translate).cast<float>());
|
||||
|
@ -1114,12 +1151,21 @@ void ModelInstance::transform_polygon(Polygon* polygon) const
|
|||
polygon->scale(this->m_scaling_factor(0), this->m_scaling_factor(1)); // scale around polygon origin
|
||||
}
|
||||
|
||||
#if ENABLE_MIRROR
|
||||
Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
||||
#else
|
||||
Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, bool dont_scale) const
|
||||
#endif // ENABLE_MIRROR
|
||||
{
|
||||
Vec3d translation = dont_translate ? Vec3d::Zero() : m_offset;
|
||||
Vec3d rotation = dont_rotate ? Vec3d::Zero() : m_rotation;
|
||||
Vec3d scale = dont_scale ? Vec3d::Ones() : m_scaling_factor;
|
||||
#if ENABLE_MIRROR
|
||||
Vec3d mirror = dont_mirror ? Vec3d::Ones() : m_mirror;
|
||||
return Geometry::assemble_transform(translation, rotation, scale, mirror);
|
||||
#else
|
||||
return Geometry::assemble_transform(translation, rotation, scale);
|
||||
#endif // ENABLE_MIRROR
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue