From 905d6f4be71ed0cd5643ed6f32f497a1a4d5f505 Mon Sep 17 00:00:00 2001 From: Filip Sykala Date: Fri, 8 Oct 2021 18:09:35 +0200 Subject: [PATCH] Use position loaded from .3mf --- src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp index 03ecf0736..a7d180585 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoEmboss.cpp @@ -176,8 +176,7 @@ void GLGizmoEmboss::initialize() // TODO: What to do when icon was NOT loaded? bool success = init_icons(); - load_font_list(); - + load_font_list(); m_font_selected = 0; @@ -302,10 +301,15 @@ bool GLGizmoEmboss::add_volume(const std::string &name, indexed_triangle_set &it if (its.indices.empty()) return false; // add object TriangleMesh tm(std::move(its)); + // center triangle mesh + Vec3d shift = tm.bounding_box().center(); + tm.translate(-shift.cast()); + GUI_App & app = wxGetApp(); Plater * plater = app.plater(); plater->take_snapshot(_L("Add") + " " + name); if (m_volume == nullptr) { + // decide to add as volume or new object const Selection &selection = m_parent.get_selection(); if (selection.is_empty()) { // create new object @@ -320,17 +324,15 @@ bool GLGizmoEmboss::add_volume(const std::string &name, indexed_triangle_set &it GLGizmosManager::EType::Emboss); return true; } else { + // create new volume inside of object Model & model = plater->model(); int object_idx = selection.get_object_idx(); ModelObject *obj = model.objects[object_idx]; m_volume = obj->add_volume(std::move(tm), m_volume_type); } - } else { + } else { m_volume->set_mesh(std::move(tm)); m_volume->set_new_unique_id(); - m_volume->translate(-m_volume->source.mesh_offset); - - m_volume->center_geometry_after_creation(true); m_volume->calculate_convex_hull(); m_volume->get_object()->invalidate_bounding_box(); } @@ -379,6 +381,7 @@ void GLGizmoEmboss::draw_window() if (!m_font.has_value()) { ImGui::Text(_L("Warning: No font is selected. Select correct one.").c_str()); } + if (ImGui::Button("process")) process(); draw_font_list(); //ImGui::SameLine();