mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 12:11:15 -06:00 
			
		
		
		
	Merge branch 'master' of https://github.com/Prusa3d/Slic3r
This commit is contained in:
		
						commit
						40ffe8270a
					
				
					 6 changed files with 86 additions and 22 deletions
				
			
		|  | @ -290,7 +290,12 @@ void GLVolume::set_render_color(const float* rgba, unsigned int size) | |||
| void GLVolume::set_render_color() | ||||
| { | ||||
|     if (force_native_color) | ||||
|         set_render_color(color, 4); | ||||
|     { | ||||
|         if (is_outside && shader_outside_printer_detection_enabled) | ||||
|             set_render_color(OUTSIDE_COLOR, 4); | ||||
|         else | ||||
|             set_render_color(color, 4); | ||||
|     } | ||||
|     else { | ||||
|         if (hover == HS_Select) | ||||
|             set_render_color(HOVER_SELECT_COLOR, 4); | ||||
|  | @ -554,6 +559,9 @@ void GLVolume::render_legacy() const | |||
|         glFrontFace(GL_CCW); | ||||
| } | ||||
| 
 | ||||
| bool GLVolume::is_sla_support() const { return this->composite_id.volume_id == -int(slaposSupportTree); } | ||||
| bool GLVolume::is_sla_pad() const { return this->composite_id.volume_id == -int(slaposBasePool); } | ||||
| 
 | ||||
| std::vector<int> GLVolumeCollection::load_object( | ||||
|     const ModelObject       *model_object, | ||||
|     int                      obj_idx, | ||||
|  |  | |||
|  | @ -422,6 +422,9 @@ public: | |||
|     void                release_geometry() { this->indexed_vertex_array.release_geometry(); } | ||||
| 
 | ||||
|     void                set_bounding_boxes_as_dirty() { m_transformed_bounding_box_dirty = true; m_transformed_convex_hull_bounding_box_dirty = true; } | ||||
| 
 | ||||
|     bool                is_sla_support() const; | ||||
|     bool                is_sla_pad() const; | ||||
| }; | ||||
| 
 | ||||
| typedef std::vector<GLVolume*> GLVolumePtrs; | ||||
|  |  | |||
|  | @ -718,6 +718,7 @@ void GLCanvas3D::WarningTexture::activate(WarningTexture::Warning warning, bool | |||
|     switch (m_warnings.back()) { | ||||
|         case ObjectOutside      : text = L("An object outside the print area was detected"); break; | ||||
|         case ToolpathOutside    : text = L("A toolpath outside the print area was detected"); break; | ||||
|         case SlaSupportsOutside : text = L("SLA supports outside the print area were detected"); break; | ||||
|         case SomethingNotShown  : text = L("Some objects are not visible when editing supports"); break; | ||||
|         case ObjectClashed: { | ||||
|             text = L("An object outside the print area was detected\n" | ||||
|  | @ -2072,6 +2073,7 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re | |||
| 	} | ||||
| 
 | ||||
|     m_gizmos.update_data(*this); | ||||
|     m_gizmos.refresh_on_off_state(m_selection); | ||||
| 
 | ||||
|     // Update the toolbar
 | ||||
| 	if (update_object_list) | ||||
|  | @ -2157,13 +2159,13 @@ void GLCanvas3D::load_gcode_preview(const GCodePreviewData& preview_data, const | |||
|                 m_volumes.volumes.erase(std::remove_if(m_volumes.volumes.begin(), m_volumes.volumes.end(), | ||||
|                     [](const GLVolume* volume) { return volume->print_zs.empty(); }), m_volumes.volumes.end()); | ||||
| 
 | ||||
|                 _load_shells_fff(); | ||||
|                 _load_fff_shells(); | ||||
|             } | ||||
|             _update_toolpath_volumes_outside_state(); | ||||
|         } | ||||
|          | ||||
|         _update_gcode_volumes_visibility(preview_data); | ||||
|         _show_warning_texture_if_needed(); | ||||
|         _show_warning_texture_if_needed(WarningTexture::ToolpathOutside); | ||||
| 
 | ||||
|         if (m_volumes.empty()) | ||||
|             reset_legend_texture(); | ||||
|  | @ -2178,7 +2180,9 @@ void GLCanvas3D::load_sla_preview() | |||
|     if ((m_canvas != nullptr) && (print != nullptr)) | ||||
|     { | ||||
|         _set_current(); | ||||
|         _load_shells_sla(); | ||||
|         _load_sla_shells(); | ||||
|         _update_sla_shells_outside_state(); | ||||
|         _show_warning_texture_if_needed(WarningTexture::SlaSupportsOutside); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | @ -2204,7 +2208,7 @@ void GLCanvas3D::load_preview(const std::vector<std::string>& str_tool_colors, c | |||
|     } | ||||
| 
 | ||||
|     _update_toolpath_volumes_outside_state(); | ||||
|     _show_warning_texture_if_needed(); | ||||
|     _show_warning_texture_if_needed(WarningTexture::ToolpathOutside); | ||||
|     if (color_print_values.empty()) | ||||
|         reset_legend_texture(); | ||||
|     else { | ||||
|  | @ -5373,7 +5377,7 @@ void GLCanvas3D::_load_gcode_unretractions(const GCodePreviewData& preview_data) | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_load_shells_fff() | ||||
| void GLCanvas3D::_load_fff_shells() | ||||
| { | ||||
|     size_t initial_volumes_count = m_volumes.volumes.size(); | ||||
|     m_gcode_preview_volume_index.first_volumes.emplace_back(GCodePreviewVolumeIndex::Shell, 0, (unsigned int)initial_volumes_count); | ||||
|  | @ -5422,7 +5426,7 @@ void GLCanvas3D::_load_shells_fff() | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_load_shells_sla() | ||||
| void GLCanvas3D::_load_sla_shells() | ||||
| { | ||||
|     //FIXME use reload_scene
 | ||||
| #if 1 | ||||
|  | @ -5431,13 +5435,13 @@ void GLCanvas3D::_load_shells_sla() | |||
|         // nothing to render, return
 | ||||
|         return; | ||||
| 
 | ||||
|     auto add_volume = [this](const SLAPrintObject &object, const SLAPrintObject::Instance& instance,  | ||||
|                              const TriangleMesh &mesh, const float color[4], bool outside_printer_detection_enabled) { | ||||
|     auto add_volume = [this](const SLAPrintObject &object, int volume_id, const SLAPrintObject::Instance& instance, | ||||
|         const TriangleMesh &mesh, const float color[4], bool outside_printer_detection_enabled) { | ||||
|         m_volumes.volumes.emplace_back(new GLVolume(color)); | ||||
|         GLVolume& v = *m_volumes.volumes.back(); | ||||
|         v.indexed_vertex_array.load_mesh(mesh, m_use_VBOs); | ||||
| 		v.shader_outside_printer_detection_enabled = outside_printer_detection_enabled; | ||||
|         v.composite_id.volume_id = -1; | ||||
|         v.composite_id.volume_id = volume_id; | ||||
|         v.set_instance_offset(unscale(instance.shift(0), instance.shift(1), 0)); | ||||
|         v.set_instance_rotation(Vec3d(0.0, 0.0, (double)instance.rotation)); | ||||
|         v.set_instance_mirror(X, object.is_left_handed() ? -1. : 1.); | ||||
|  | @ -5448,15 +5452,14 @@ void GLCanvas3D::_load_shells_sla() | |||
|         if (obj->is_step_done(slaposSliceSupports)) { | ||||
|             unsigned int initial_volumes_count = (unsigned int)m_volumes.volumes.size(); | ||||
|             for (const SLAPrintObject::Instance& instance : obj->instances()) { | ||||
|                 add_volume(*obj, instance, obj->transformed_mesh(), GLVolume::MODEL_COLOR[0], true); | ||||
|                 add_volume(*obj, 0, instance, obj->transformed_mesh(), GLVolume::MODEL_COLOR[0], true); | ||||
|                 // Set the extruder_id and volume_id to achieve the same color as in the 3D scene when
 | ||||
|                 // through the update_volumes_colors_by_extruder() call.
 | ||||
|                 m_volumes.volumes.back()->extruder_id = obj->model_object()->volumes.front()->extruder_id(); | ||||
|                 m_volumes.volumes.back()->composite_id.volume_id = 0; | ||||
|                 if (obj->is_step_done(slaposSupportTree) && obj->has_mesh(slaposSupportTree)) | ||||
|                     add_volume(*obj, instance, obj->support_mesh(), GLVolume::SLA_SUPPORT_COLOR, true); | ||||
|                     add_volume(*obj, -int(slaposSupportTree), instance, obj->support_mesh(), GLVolume::SLA_SUPPORT_COLOR, true); | ||||
|                 if (obj->is_step_done(slaposBasePool) && obj->has_mesh(slaposBasePool)) | ||||
|                     add_volume(*obj, instance, obj->pad_mesh(), GLVolume::SLA_PAD_COLOR, true); | ||||
|                     add_volume(*obj, -int(slaposBasePool), instance, obj->pad_mesh(), GLVolume::SLA_PAD_COLOR, true); | ||||
|             } | ||||
|             double shift_z = obj->get_current_elevation(); | ||||
|             for (unsigned int i = initial_volumes_count; i < m_volumes.volumes.size(); ++ i) { | ||||
|  | @ -5558,10 +5561,35 @@ void GLCanvas3D::_update_toolpath_volumes_outside_state() | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_show_warning_texture_if_needed() | ||||
| void GLCanvas3D::_update_sla_shells_outside_state() | ||||
| { | ||||
|     // tolerance to avoid false detection at bed edges
 | ||||
|     static const double tolerance_x = 0.05; | ||||
|     static const double tolerance_y = 0.05; | ||||
| 
 | ||||
|     BoundingBoxf3 print_volume; | ||||
|     if (m_config != nullptr) | ||||
|     { | ||||
|         const ConfigOptionPoints* opt = dynamic_cast<const ConfigOptionPoints*>(m_config->option("bed_shape")); | ||||
|         if (opt != nullptr) | ||||
|         { | ||||
|             BoundingBox bed_box_2D = get_extents(Polygon::new_scale(opt->values)); | ||||
|             print_volume = BoundingBoxf3(Vec3d(unscale<double>(bed_box_2D.min(0)) - tolerance_x, unscale<double>(bed_box_2D.min(1)) - tolerance_y, 0.0), Vec3d(unscale<double>(bed_box_2D.max(0)) + tolerance_x, unscale<double>(bed_box_2D.max(1)) + tolerance_y, m_config->opt_float("max_print_height"))); | ||||
|             // Allow the objects to protrude below the print bed
 | ||||
|             print_volume.min(2) = -1e10; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     for (GLVolume* volume : m_volumes.volumes) | ||||
|     { | ||||
|         volume->is_outside = ((print_volume.radius() > 0.0) && volume->is_sla_support()) ? !print_volume.contains(volume->transformed_convex_hull_bounding_box()) : false; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void GLCanvas3D::_show_warning_texture_if_needed(WarningTexture::Warning warning) | ||||
| { | ||||
|     _set_current(); | ||||
|     _set_warning_texture(WarningTexture::ToolpathOutside, _is_any_volume_outside()); | ||||
|     _set_warning_texture(warning, _is_any_volume_outside()); | ||||
| } | ||||
| 
 | ||||
| std::vector<float> GLCanvas3D::_parse_colors(const std::vector<std::string>& colors) | ||||
|  |  | |||
|  | @ -344,6 +344,7 @@ class GLCanvas3D | |||
|         enum Warning { | ||||
|             ObjectOutside, | ||||
|             ToolpathOutside, | ||||
|             SlaSupportsOutside, | ||||
|             SomethingNotShown, | ||||
|             ObjectClashed | ||||
|         }; | ||||
|  | @ -695,13 +696,14 @@ private: | |||
|     // generates gcode unretractions geometry
 | ||||
|     void _load_gcode_unretractions(const GCodePreviewData& preview_data); | ||||
|     // generates objects and wipe tower geometry
 | ||||
|     void _load_shells_fff(); | ||||
|     void _load_fff_shells(); | ||||
|     // generates objects geometry for sla
 | ||||
|     void _load_shells_sla(); | ||||
|     void _load_sla_shells(); | ||||
|     // sets gcode geometry visibility according to user selection
 | ||||
|     void _update_gcode_volumes_visibility(const GCodePreviewData& preview_data); | ||||
|     void _update_toolpath_volumes_outside_state(); | ||||
|     void _show_warning_texture_if_needed(); | ||||
|     void _update_sla_shells_outside_state(); | ||||
|     void _show_warning_texture_if_needed(WarningTexture::Warning warning); | ||||
| 
 | ||||
|     // generates the legend texture in dependence of the current shown view type
 | ||||
|     void _generate_legend_texture(const GCodePreviewData& preview_data, const std::vector<float>& tool_colors); | ||||
|  |  | |||
|  | @ -2333,7 +2333,20 @@ void TabPrinter::update_pages() | |||
|     // set m_pages_(technology after changing) to m_pages
 | ||||
|     // m_printer_technology will be set by Tab::load_current_preset()
 | ||||
|     if (new_printer_technology == ptFFF) | ||||
|         m_pages_fff.empty() ? build_fff() : m_pages.swap(m_pages_fff); | ||||
|     { | ||||
|         if (m_pages_fff.empty()) | ||||
|         { | ||||
|             build_fff(); | ||||
|             if (m_extruders_count > 1) | ||||
|             { | ||||
|                 m_preset_bundle->update_multi_material_filament_presets(); | ||||
|                 on_value_change("extruders_count", m_extruders_count); | ||||
|                 wxGetApp().sidebar().update_objects_list_extruder_column(m_extruders_count); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|             m_pages.swap(m_pages_fff); | ||||
|     } | ||||
|     else  | ||||
|         m_pages_sla.empty() ? build_sla() : m_pages.swap(m_pages_sla); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv