Translation of ModelVolume as transformation component (without modifying the mesh)

This commit is contained in:
Enrico Turri 2018-11-02 12:11:28 +01:00
parent 93ef2de667
commit 3aad8b5fd2
11 changed files with 384 additions and 39 deletions

View file

@ -1227,7 +1227,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path> &input_
std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &model_objects)
{
const BoundingBoxf bed_shape = bed_shape_bb();
#if !ENABLE_MODELVOLUME_TRANSFORM
const Vec3d bed_center = Slic3r::to_3d(bed_shape.center().cast<double>(), 0.0);
#endif // !ENABLE_MODELVOLUME_TRANSFORM
const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast<double>(), 1.0);
bool need_arrange = false;
@ -1246,8 +1248,12 @@ std::vector<size_t> Plater::priv::load_model_objects(const ModelObjectPtrs &mode
// add a default instance and center object around origin
object->center_around_origin(); // also aligns object to Z = 0
auto *instance = object->add_instance();
ModelInstance* instance = object->add_instance();
#if ENABLE_MODELVOLUME_TRANSFORM
instance->set_offset(Slic3r::to_3d(bed_shape.center().cast<double>(), -object->origin_translation(2)));
#else
instance->set_offset(bed_center);
#endif // ENABLE_MODELVOLUME_TRANSFORM
}
const Vec3d size = object->bounding_box().size();