Use position loaded from .3mf

This commit is contained in:
Filip Sykala 2021-10-08 18:09:35 +02:00
parent 3332dfd8b0
commit 905d6f4be7

View File

@ -178,7 +178,6 @@ void GLGizmoEmboss::initialize()
load_font_list(); load_font_list();
m_font_selected = 0; m_font_selected = 0;
bool is_font_loaded = load_font(); bool is_font_loaded = load_font();
@ -302,10 +301,15 @@ bool GLGizmoEmboss::add_volume(const std::string &name, indexed_triangle_set &it
if (its.indices.empty()) return false; if (its.indices.empty()) return false;
// add object // add object
TriangleMesh tm(std::move(its)); TriangleMesh tm(std::move(its));
// center triangle mesh
Vec3d shift = tm.bounding_box().center();
tm.translate(-shift.cast<float>());
GUI_App & app = wxGetApp(); GUI_App & app = wxGetApp();
Plater * plater = app.plater(); Plater * plater = app.plater();
plater->take_snapshot(_L("Add") + " " + name); plater->take_snapshot(_L("Add") + " " + name);
if (m_volume == nullptr) { if (m_volume == nullptr) {
// decide to add as volume or new object
const Selection &selection = m_parent.get_selection(); const Selection &selection = m_parent.get_selection();
if (selection.is_empty()) { if (selection.is_empty()) {
// create new object // create new object
@ -320,6 +324,7 @@ bool GLGizmoEmboss::add_volume(const std::string &name, indexed_triangle_set &it
GLGizmosManager::EType::Emboss); GLGizmosManager::EType::Emboss);
return true; return true;
} else { } else {
// create new volume inside of object
Model & model = plater->model(); Model & model = plater->model();
int object_idx = selection.get_object_idx(); int object_idx = selection.get_object_idx();
ModelObject *obj = model.objects[object_idx]; ModelObject *obj = model.objects[object_idx];
@ -328,9 +333,6 @@ bool GLGizmoEmboss::add_volume(const std::string &name, indexed_triangle_set &it
} else { } else {
m_volume->set_mesh(std::move(tm)); m_volume->set_mesh(std::move(tm));
m_volume->set_new_unique_id(); 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->calculate_convex_hull();
m_volume->get_object()->invalidate_bounding_box(); m_volume->get_object()->invalidate_bounding_box();
} }
@ -379,6 +381,7 @@ void GLGizmoEmboss::draw_window()
if (!m_font.has_value()) { if (!m_font.has_value()) {
ImGui::Text(_L("Warning: No font is selected. Select correct one.").c_str()); ImGui::Text(_L("Warning: No font is selected. Select correct one.").c_str());
} }
if (ImGui::Button("process")) process();
draw_font_list(); draw_font_list();
//ImGui::SameLine(); //ImGui::SameLine();