mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 07:00:40 +08:00
Cut: fixed rendering of individual parts, removed some unnecessary variables
This commit is contained in:
parent
7ea51fc07c
commit
732dd0f6ac
@ -2627,14 +2627,6 @@ bool model_has_multi_part_objects(const Model &model)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool model_has_connectors(const Model &model)
|
|
||||||
{
|
|
||||||
for (const ModelObject *model_object : model.objects)
|
|
||||||
if (!model_object->cut_connectors.empty())
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool model_has_advanced_features(const Model &model)
|
bool model_has_advanced_features(const Model &model)
|
||||||
{
|
{
|
||||||
auto config_is_advanced = [](const ModelConfig &config) {
|
auto config_is_advanced = [](const ModelConfig &config) {
|
||||||
|
@ -467,9 +467,15 @@ public:
|
|||||||
void invalidate_cut();
|
void invalidate_cut();
|
||||||
// delete volumes which are marked as connector for this object
|
// delete volumes which are marked as connector for this object
|
||||||
void delete_connectors();
|
void delete_connectors();
|
||||||
void synchronize_model_after_cut();
|
|
||||||
void apply_cut_attributes(ModelObjectCutAttributes attributes);
|
|
||||||
void clone_for_cut(ModelObject **obj);
|
void clone_for_cut(ModelObject **obj);
|
||||||
|
|
||||||
|
void apply_cut_attributes(ModelObjectCutAttributes attributes);
|
||||||
|
private:
|
||||||
|
// FIXME: These functions would best not be here at all. It might make sense to separate the
|
||||||
|
// cut-related methods elsewhere. Same holds for cut_connectors data member, which is currently
|
||||||
|
// just a temporary variable used by cut gizmo only.
|
||||||
|
void synchronize_model_after_cut();
|
||||||
|
|
||||||
void process_connector_cut(ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
void process_connector_cut(ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
||||||
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower,
|
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower,
|
||||||
std::vector<ModelObject*>& dowels);
|
std::vector<ModelObject*>& dowels);
|
||||||
@ -479,7 +485,7 @@ public:
|
|||||||
ModelObjectCutAttributes attributes, TriangleMesh& upper_mesh, TriangleMesh& lower_mesh);
|
ModelObjectCutAttributes attributes, TriangleMesh& upper_mesh, TriangleMesh& lower_mesh);
|
||||||
void process_solid_part_cut(ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
void process_solid_part_cut(ModelVolume* volume, const Transform3d& instance_matrix, const Transform3d& cut_matrix,
|
||||||
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower);
|
ModelObjectCutAttributes attributes, ModelObject* upper, ModelObject* lower);
|
||||||
|
public:
|
||||||
static void reset_instance_transformation(ModelObject* object, size_t src_instance_idx, const Transform3d& cut_matrix,
|
static void reset_instance_transformation(ModelObject* object, size_t src_instance_idx, const Transform3d& cut_matrix,
|
||||||
bool place_on_cut = false, bool flip = false);
|
bool place_on_cut = false, bool flip = false);
|
||||||
|
|
||||||
@ -1395,8 +1401,6 @@ bool model_has_parameter_modifiers_in_objects(const Model& model);
|
|||||||
// If the model has multi-part objects, then it is currently not supported by the SLA mode.
|
// If the model has multi-part objects, then it is currently not supported by the SLA mode.
|
||||||
// Either the model cannot be loaded, or a SLA printer has to be activated.
|
// Either the model cannot be loaded, or a SLA printer has to be activated.
|
||||||
bool model_has_multi_part_objects(const Model &model);
|
bool model_has_multi_part_objects(const Model &model);
|
||||||
// If the model has objects with cut connectrs, then it is currently not supported by the SLA mode.
|
|
||||||
bool model_has_connectors(const Model& model);
|
|
||||||
// If the model has advanced features, then it cannot be processed in simple mode.
|
// If the model has advanced features, then it cannot be processed in simple mode.
|
||||||
bool model_has_advanced_features(const Model &model);
|
bool model_has_advanced_features(const Model &model);
|
||||||
|
|
||||||
|
@ -3023,22 +3023,6 @@ bool GUI_App::may_switch_to_SLA_preset(const wxString& caption)
|
|||||||
caption);
|
caption);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (model_has_multi_part_objects(model())) {
|
|
||||||
show_info(nullptr,
|
|
||||||
_L("It's impossible to print multi-part object(s) with SLA technology.") + "\n\n" +
|
|
||||||
_L("Please check your object list before preset changing."),
|
|
||||||
caption);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (model_has_connectors(model())) {
|
|
||||||
show_info(nullptr,
|
|
||||||
_L("SLA technology doesn't support cut with connectors") + "\n\n" +
|
|
||||||
_L("Please check your object list before preset changing."),
|
|
||||||
caption);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1402,6 +1402,7 @@ void GLGizmoCut3D::PartSelection::render(const Vec3d* normal)
|
|||||||
|
|
||||||
shader->start_using();
|
shader->start_using();
|
||||||
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
|
||||||
|
shader->set_uniform("emission_factor", 0.f);
|
||||||
|
|
||||||
// FIXME: Cache the transforms.
|
// FIXME: Cache the transforms.
|
||||||
|
|
||||||
@ -1416,7 +1417,6 @@ void GLGizmoCut3D::PartSelection::render(const Vec3d* normal)
|
|||||||
continue;
|
continue;
|
||||||
const Vec3d volume_offset = model_object->volumes[id]->get_offset();
|
const Vec3d volume_offset = model_object->volumes[id]->get_offset();
|
||||||
shader->set_uniform("view_model_matrix", view_inst_matrix * translation_transform(volume_offset));
|
shader->set_uniform("view_model_matrix", view_inst_matrix * translation_transform(volume_offset));
|
||||||
//parts[id].glmodel.set_color(parts[id].selected ? ColorRGBA(1.f, 0.f, 0.f, 1.f) : ColorRGBA(0.f, 1.f, 0.f, 1.f));
|
|
||||||
parts[id].glmodel.set_color(parts[id].selected ? UPPER_PART_COLOR : LOWER_PART_COLOR);
|
parts[id].glmodel.set_color(parts[id].selected ? UPPER_PART_COLOR : LOWER_PART_COLOR);
|
||||||
parts[id].glmodel.render();
|
parts[id].glmodel.render();
|
||||||
}
|
}
|
||||||
@ -1779,14 +1779,13 @@ void GLGizmoCut3D::process_contours()
|
|||||||
const int instance_idx = selection.get_instance_idx();
|
const int instance_idx = selection.get_instance_idx();
|
||||||
const int object_idx = selection.get_object_idx();
|
const int object_idx = selection.get_object_idx();
|
||||||
|
|
||||||
m_cut_part_ptrs.clear();
|
ModelObjectPtrs cut_part_ptrs = model_objects[object_idx]->cut(instance_idx, get_cut_matrix(selection),
|
||||||
m_cut_part_ptrs = model_objects[object_idx]->cut(instance_idx, get_cut_matrix(selection),
|
|
||||||
ModelObjectCutAttribute::KeepUpper |
|
ModelObjectCutAttribute::KeepUpper |
|
||||||
ModelObjectCutAttribute::KeepLower |
|
ModelObjectCutAttribute::KeepLower |
|
||||||
ModelObjectCutAttribute::KeepAsParts);
|
ModelObjectCutAttribute::KeepAsParts);
|
||||||
assert(m_cut_part_ptrs.size() == 1);
|
assert(cut_part_ptrs.size() == 1);
|
||||||
|
|
||||||
m_part_selection = PartSelection(m_cut_part_ptrs.front(), instance_idx, m_plane_center, m_cut_normal);
|
m_part_selection = PartSelection(cut_part_ptrs.front(), instance_idx, m_plane_center, m_cut_normal);
|
||||||
m_parent.toggle_model_objects_visibility(false);
|
m_parent.toggle_model_objects_visibility(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2144,7 +2143,7 @@ bool GLGizmoCut3D::is_outside_of_cut_contour(size_t idx, const CutConnectors& co
|
|||||||
}
|
}
|
||||||
its_transform(mesh, translation_transform(cur_pos) * m_rotation_m);
|
its_transform(mesh, translation_transform(cur_pos) * m_rotation_m);
|
||||||
|
|
||||||
for (auto vertex : vertices) {
|
for (const Vec3f& vertex : vertices) {
|
||||||
if (m_c->object_clipper() && m_c->object_clipper()->is_projection_inside_cut(vertex.cast<double>()) == -1) {
|
if (m_c->object_clipper() && m_c->object_clipper()->is_projection_inside_cut(vertex.cast<double>()) == -1) {
|
||||||
m_info_stats.outside_cut_contour++;
|
m_info_stats.outside_cut_contour++;
|
||||||
return true;
|
return true;
|
||||||
@ -2341,8 +2340,8 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
|||||||
{
|
{
|
||||||
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Cut by Plane"));
|
Plater::TakeSnapshot snapshot(wxGetApp().plater(), _L("Cut by Plane"));
|
||||||
|
|
||||||
const bool cut_by_contour = m_part_selection.valid && !m_cut_part_ptrs.empty();
|
const bool cut_by_contour = m_part_selection.valid;
|
||||||
ModelObject* cut_mo = cut_by_contour ? m_cut_part_ptrs.front() : nullptr;
|
ModelObject* cut_mo = cut_by_contour ? m_part_selection.model_object : nullptr;
|
||||||
if (cut_mo)
|
if (cut_mo)
|
||||||
cut_mo->cut_connectors = mo->cut_connectors;
|
cut_mo->cut_connectors = mo->cut_connectors;
|
||||||
|
|
||||||
@ -2404,7 +2403,7 @@ void GLGizmoCut3D::perform_cut(const Selection& selection)
|
|||||||
delete *(volumes.begin() + id);
|
delete *(volumes.begin() + id);
|
||||||
volumes.erase(volumes.begin(), volumes.begin() + cut_parts_cnt);
|
volumes.erase(volumes.begin(), volumes.begin() + cut_parts_cnt);
|
||||||
|
|
||||||
const auto cut_connectors_obj = cut_mo->cut(instance_idx, get_cut_matrix(selection), attributes);
|
const ModelObjectPtrs cut_connectors_obj = cut_mo->cut(instance_idx, get_cut_matrix(selection), attributes);
|
||||||
assert(create_dowels_as_separate_object ? cut_connectors_obj.size() >= 3 : cut_connectors_obj.size() == 2);
|
assert(create_dowels_as_separate_object ? cut_connectors_obj.size() >= 3 : cut_connectors_obj.size() == 2);
|
||||||
|
|
||||||
for (const ModelVolume* volume : cut_connectors_obj[0]->volumes)
|
for (const ModelVolume* volume : cut_connectors_obj[0]->volumes)
|
||||||
|
@ -149,7 +149,6 @@ class GLGizmoCut3D : public GLGizmoBase
|
|||||||
GLModel glmodel;
|
GLModel glmodel;
|
||||||
MeshRaycaster raycaster;
|
MeshRaycaster raycaster;
|
||||||
bool selected;
|
bool selected;
|
||||||
bool upper;
|
|
||||||
};
|
};
|
||||||
ModelObject* model_object; // FIXME: Ownership !
|
ModelObject* model_object; // FIXME: Ownership !
|
||||||
int instance_idx;
|
int instance_idx;
|
||||||
@ -158,7 +157,6 @@ class GLGizmoCut3D : public GLGizmoBase
|
|||||||
};
|
};
|
||||||
|
|
||||||
PartSelection m_part_selection;
|
PartSelection m_part_selection;
|
||||||
ModelObjectPtrs m_cut_part_ptrs;
|
|
||||||
|
|
||||||
bool m_show_shortcuts{ false };
|
bool m_show_shortcuts{ false };
|
||||||
std::vector<std::pair<wxString, wxString>> m_shortcuts;
|
std::vector<std::pair<wxString, wxString>> m_shortcuts;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user