mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Do not allow objects to be placed fully below bed
This commit is contained in:
		
							parent
							
								
									0be2e3bc71
								
							
						
					
					
						commit
						b3010a817b
					
				
					 5 changed files with 34 additions and 5 deletions
				
			
		|  | @ -595,7 +595,7 @@ bool GLVolume::is_sinking() const | |||
| 
 | ||||
| bool GLVolume::is_below_printbed() const | ||||
| { | ||||
|     return transformed_convex_hull_bounding_box().max(2) < 0.0; | ||||
|     return transformed_convex_hull_bounding_box().max.z() < 0.0; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SINKING_CONTOURS | ||||
|  |  | |||
|  | @ -621,7 +621,7 @@ void MainFrame::update_title() | |||
|         if (!dirty_marker.empty() || !project.empty()) { | ||||
|             if (!dirty_marker.empty() && project.empty()) | ||||
|                 project = _("Untitled"); | ||||
|                 title = dirty_marker + project + " - "; | ||||
|             title = dirty_marker + project + " - "; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -683,7 +683,8 @@ void Selection::translate(const Vec3d& displacement, bool local) | |||
|         synchronize_unselected_volumes(); | ||||
| #endif // !DISABLE_INSTANCES_SYNCH
 | ||||
| 
 | ||||
|     this->set_bounding_boxes_dirty(); | ||||
|     ensure_not_below_bed(); | ||||
|     set_bounding_boxes_dirty(); | ||||
| } | ||||
| 
 | ||||
| // Rotate an object around one of the axes. Only one rotation component is expected to be changing.
 | ||||
|  | @ -1712,7 +1713,7 @@ void Selection::calc_unscaled_instance_bounding_box() const | |||
|             if (volume.is_modifier) | ||||
|                 continue; | ||||
|             Transform3d trafo = volume.get_instance_transformation().get_matrix(false, false, true, false) * volume.get_volume_transformation().get_matrix(); | ||||
|             trafo.translation()(2) += volume.get_sla_shift_z(); | ||||
|             trafo.translation().z() += volume.get_sla_shift_z(); | ||||
|             unscaled_instance_bounding_box->merge(volume.transformed_convex_hull_bounding_box(trafo)); | ||||
|         } | ||||
|     } | ||||
|  | @ -1729,7 +1730,7 @@ void Selection::calc_scaled_instance_bounding_box() const | |||
|             if (volume.is_modifier) | ||||
|                 continue; | ||||
|             Transform3d trafo = volume.get_instance_transformation().get_matrix(false, false, false, false) * volume.get_volume_transformation().get_matrix(); | ||||
|             trafo.translation()(2) += volume.get_sla_shift_z(); | ||||
|             trafo.translation().z() += volume.get_sla_shift_z(); | ||||
|             scaled_instance_bounding_box->merge(volume.transformed_convex_hull_bounding_box(trafo)); | ||||
|         } | ||||
|     } | ||||
|  | @ -2134,6 +2135,32 @@ void Selection::ensure_on_bed() | |||
|     } | ||||
| } | ||||
| 
 | ||||
| void Selection::ensure_not_below_bed() | ||||
| { | ||||
|     typedef std::map<std::pair<int, int>, double> InstancesToZMap; | ||||
|     InstancesToZMap instances_max_z; | ||||
| 
 | ||||
|     for (size_t i = 0; i < m_volumes->size(); ++i) { | ||||
|         GLVolume* volume = (*m_volumes)[i]; | ||||
|         if (!volume->is_wipe_tower && !volume->is_modifier) { | ||||
|             const double max_z = volume->transformed_convex_hull_bounding_box().max.z(); | ||||
|             std::pair<int, int> instance = std::make_pair(volume->object_idx(), volume->instance_idx()); | ||||
|             InstancesToZMap::iterator it = instances_max_z.find(instance); | ||||
|             if (it == instances_max_z.end()) | ||||
|                 it = instances_max_z.insert(InstancesToZMap::value_type(instance, -DBL_MAX)).first; | ||||
| 
 | ||||
|             it->second = std::max(it->second, max_z); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     for (GLVolume* volume : *m_volumes) { | ||||
|         std::pair<int, int> instance = std::make_pair(volume->object_idx(), volume->instance_idx()); | ||||
|         InstancesToZMap::iterator it = instances_max_z.find(instance); | ||||
|         if (it != instances_max_z.end() && it->second < SINKING_MIN_Z_THRESHOLD) | ||||
|             volume->set_instance_offset(Z, volume->get_instance_offset(Z) + SINKING_MIN_Z_THRESHOLD - it->second); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool Selection::is_from_fully_selected_instance(unsigned int volume_idx) const | ||||
| { | ||||
|     struct SameInstance | ||||
|  |  | |||
|  | @ -385,6 +385,7 @@ public: | |||
| 
 | ||||
| private: | ||||
|     void ensure_on_bed(); | ||||
|     void ensure_not_below_bed(); | ||||
|     bool is_from_fully_selected_instance(unsigned int volume_idx) const; | ||||
| 
 | ||||
|     void paste_volumes_from_clipboard(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966