Fix of a "split" function issue.

1) Load a multi-part stl
2) Rotate it by 90 degrees
3) Split it.

Before this fix, the split object jumped away from the print bed.

This sound similar to
https://github.com/prusa3d/Slic3r/issues/309
This commit is contained in:
bubnikv 2017-06-19 14:26:19 +02:00
parent c33ed9144c
commit 7ca02bda0f
2 changed files with 10 additions and 5 deletions

View File

@ -1158,6 +1158,8 @@ sub split_object {
$self->resume_background_process;
return;
}
$_->center_around_origin for (@model_objects);
$self->remove($obj_idx);
$current_object = $obj_idx = undef;

View File

@ -496,7 +496,7 @@ void ModelObject::center_around_origin()
// apply rotation and scaling to vector as well before translating instance,
// in order to leave final position unaltered
Vectorf3 v = vector.negative();
v.rotate(i->rotation, i->offset);
v.rotate(i->rotation);
v.scale(i->scaling_factor);
i->offset.translate(v.x, v.y);
}
@ -639,19 +639,22 @@ void ModelObject::split(ModelObjectPtrs* new_objects)
ModelVolume* volume = this->volumes.front();
TriangleMeshPtrs meshptrs = volume->mesh.split();
for (TriangleMeshPtrs::iterator mesh = meshptrs.begin(); mesh != meshptrs.end(); ++mesh) {
(*mesh)->repair();
for (TriangleMesh *mesh : meshptrs) {
// Snap the mesh to Z=0.
float z0 = FLT_MAX;
mesh->repair();
ModelObject* new_object = m_model->add_object(*this, false);
new_object->input_file = "";
ModelVolume* new_volume = new_object->add_volume(**mesh);
ModelVolume* new_volume = new_object->add_volume(*mesh);
new_volume->name = volume->name;
new_volume->config = volume->config;
new_volume->modifier = volume->modifier;
new_volume->material_id(volume->material_id());
new_objects->push_back(new_object);
delete *mesh;
delete mesh;
}
return;