SPE-1655 - Fixed adding an instance to a mirrored object

This commit is contained in:
enricoturri1966 2023-04-13 13:09:32 +02:00
parent a092fdc1ed
commit 5bb7428aa4
3 changed files with 7 additions and 8 deletions

View File

@ -837,13 +837,10 @@ ModelInstance* ModelObject::add_instance(const ModelInstance &other)
return i; return i;
} }
ModelInstance* ModelObject::add_instance(const Vec3d &offset, const Vec3d &scaling_factor, const Vec3d &rotation, const Vec3d &mirror) ModelInstance* ModelObject::add_instance(const Geometry::Transformation& trafo)
{ {
auto *instance = add_instance(); ModelInstance* instance = add_instance();
instance->set_offset(offset); instance->set_transformation(trafo);
instance->set_scaling_factor(scaling_factor);
instance->set_rotation(rotation);
instance->set_mirror(mirror);
return instance; return instance;
} }

View File

@ -392,7 +392,7 @@ public:
ModelInstance* add_instance(); ModelInstance* add_instance();
ModelInstance* add_instance(const ModelInstance &instance); ModelInstance* add_instance(const ModelInstance &instance);
ModelInstance* add_instance(const Vec3d &offset, const Vec3d &scaling_factor, const Vec3d &rotation, const Vec3d &mirror); ModelInstance* add_instance(const Geometry::Transformation& trafo);
void delete_instance(size_t idx); void delete_instance(size_t idx);
void delete_last_instance(); void delete_last_instance();
void clear_instances(); void clear_instances();

View File

@ -6070,7 +6070,9 @@ void Plater::increase_instances(size_t num, int obj_idx/* = -1*/)
double offset = offset_base; double offset = offset_base;
for (size_t i = 0; i < num; i++, offset += offset_base) { for (size_t i = 0; i < num; i++, offset += offset_base) {
Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0); Vec3d offset_vec = model_instance->get_offset() + Vec3d(offset, offset, 0.0);
model_object->add_instance(offset_vec, model_instance->get_scaling_factor(), model_instance->get_rotation(), model_instance->get_mirror()); Geometry::Transformation trafo = model_instance->get_transformation();
trafo.set_offset(offset_vec);
model_object->add_instance(trafo);
// p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec)); // p->print.get_object(obj_idx)->add_copy(Slic3r::to_2d(offset_vec));
} }