Fixed convex hull and volume offset after object split to part

This commit is contained in:
Enrico Turri 2018-11-13 10:12:42 +01:00
parent 3d4e37ceb6
commit dc8523cac8

View File

@ -165,6 +165,9 @@ ModelObject* Model::add_object(const char *name, const char *path, const Triangl
new_object->name = name;
new_object->input_file = path;
ModelVolume *new_volume = new_object->add_volume(mesh);
#if ENABLE_MODELVOLUME_TRANSFORM
new_volume->center_geometry();
#endif // ENABLE_MODELVOLUME_TRANSFORM
new_volume->name = name;
new_object->invalidate_bounding_box();
return new_object;
@ -177,6 +180,9 @@ ModelObject* Model::add_object(const char *name, const char *path, TriangleMesh
new_object->name = name;
new_object->input_file = path;
ModelVolume *new_volume = new_object->add_volume(std::move(mesh));
#if ENABLE_MODELVOLUME_TRANSFORM
new_volume->center_geometry();
#endif // ENABLE_MODELVOLUME_TRANSFORM
new_volume->name = name;
new_object->invalidate_bounding_box();
return new_object;
@ -1251,11 +1257,15 @@ size_t ModelVolume::split(unsigned int max_extruders)
for (TriangleMesh *mesh : meshptrs) {
mesh->repair();
if (idx == 0)
{
this->mesh = std::move(*mesh);
this->calculate_convex_hull();
}
else
this->object->volumes.insert(this->object->volumes.begin() + (++ivolume), new ModelVolume(object, *this, std::move(*mesh)));
#if ENABLE_MODELVOLUME_TRANSFORM
this->object->volumes[ivolume]->set_offset(Vec3d::Zero());
this->object->volumes[ivolume]->center_geometry();
this->object->volumes[ivolume]->translate(offset);
#endif // ENABLE_MODELVOLUME_TRANSFORM