mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Follow-up of 1a91add2e6 -> Improvements to tighter camera frustrum to reduce z-fighting
				
					
				
			This commit is contained in:
		
							parent
							
								
									541f58c656
								
							
						
					
					
						commit
						ac8de0bcaf
					
				
					 5 changed files with 17 additions and 18 deletions
				
			
		|  | @ -211,7 +211,7 @@ const double Bed3D::Axes::ArrowLength = 5.0; | |||
| 
 | ||||
| Bed3D::Axes::Axes() | ||||
| : origin(Vec3d::Zero()) | ||||
| , length(Vec3d::Zero()) | ||||
| , length(25.0 * Vec3d::Ones()) | ||||
| { | ||||
|     m_quadric = ::gluNewQuadric(); | ||||
|     if (m_quadric != nullptr) | ||||
|  | @ -273,7 +273,6 @@ void Bed3D::Axes::render_axis(double length) const | |||
| 
 | ||||
| Bed3D::Bed3D() | ||||
|     : m_type(Custom) | ||||
|     , m_extended_bounding_box_dirty(true) | ||||
| #if ENABLE_TEXTURES_FROM_SVG | ||||
|     , m_vbo_id(0) | ||||
| #endif // ENABLE_TEXTURES_FROM_SVG
 | ||||
|  | @ -314,8 +313,6 @@ bool Bed3D::set_shape(const Pointfs& shape) | |||
|     m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z); | ||||
|     m_axes.length = 0.1 * m_bounding_box.max_size() * Vec3d::Ones(); | ||||
| 
 | ||||
|     m_extended_bounding_box_dirty = true; | ||||
| 
 | ||||
|     // Let the calee to update the UI.
 | ||||
|     return true; | ||||
| } | ||||
|  | @ -413,17 +410,12 @@ void Bed3D::calc_bounding_boxes() const | |||
| 
 | ||||
|     m_extended_bounding_box = m_bounding_box; | ||||
| 
 | ||||
|     if (m_extended_bounding_box_dirty) | ||||
|     { | ||||
|         // extend to contain Z axis
 | ||||
|         m_extended_bounding_box.merge(0.1 * m_bounding_box.max_size() * Vec3d::UnitZ()); | ||||
|     // extend to contain axes
 | ||||
|     m_extended_bounding_box.merge(m_axes.length + Axes::ArrowLength * Vec3d::Ones()); | ||||
| 
 | ||||
|         if (!m_model.get_filename().empty()) | ||||
|             // extend to contain model
 | ||||
|             m_extended_bounding_box.merge(m_model.get_bounding_box()); | ||||
| 
 | ||||
|         m_extended_bounding_box_dirty = false; | ||||
|     } | ||||
|     // extend to contain model, if any
 | ||||
|     if (!m_model.get_filename().empty()) | ||||
|         m_extended_bounding_box.merge(m_model.get_transformed_bounding_box()); | ||||
| } | ||||
| 
 | ||||
| void Bed3D::calc_triangles(const ExPolygon& poly) | ||||
|  |  | |||
|  | @ -87,7 +87,6 @@ private: | |||
|     Pointfs m_shape; | ||||
|     mutable BoundingBoxf3 m_bounding_box; | ||||
|     mutable BoundingBoxf3 m_extended_bounding_box; | ||||
|     mutable bool m_extended_bounding_box_dirty; | ||||
|     Polygon m_polygon; | ||||
|     GeometryBuffer m_triangles; | ||||
|     GeometryBuffer m_gridlines; | ||||
|  |  | |||
|  | @ -555,6 +555,7 @@ public: | |||
| 
 | ||||
|     const std::string& get_filename() const { return m_filename; } | ||||
|     const BoundingBoxf3& get_bounding_box() const { return m_volume.bounding_box; } | ||||
|     const BoundingBoxf3& get_transformed_bounding_box() const { return m_volume.transformed_bounding_box(); } | ||||
| 
 | ||||
|     void reset(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -169,6 +169,7 @@ void Camera::debug_render() const | |||
|     Vec3f up = get_dir_up().cast<float>(); | ||||
|     float nearZ = (float)m_frustrum_zs.first; | ||||
|     float farZ = (float)m_frustrum_zs.second; | ||||
|     float deltaZ = farZ - nearZ; | ||||
| 
 | ||||
|     ImGui::InputText("Type", const_cast<char*>(type.data()), type.length(), ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::Separator(); | ||||
|  | @ -181,6 +182,7 @@ void Camera::debug_render() const | |||
|     ImGui::Separator(); | ||||
|     ImGui::InputFloat("Near Z", &nearZ, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputFloat("Far Z", &farZ, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly); | ||||
|     ImGui::InputFloat("Delta Z", &deltaZ, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly); | ||||
|     imgui.end(); | ||||
| } | ||||
| #endif // ENABLE_CAMERA_STATISTICS
 | ||||
|  | @ -230,7 +232,12 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo | |||
| 
 | ||||
|     // ensure min size
 | ||||
|     if (ret.second - ret.first < FrustrumMinZSize) | ||||
|         ret.second = ret.first + FrustrumMinZSize; | ||||
|     { | ||||
|         double mid_z = 0.5 * (ret.first + ret.second); | ||||
|         double half_size = 0.5 * FrustrumMinZSize; | ||||
|         ret.first = mid_z - half_size; | ||||
|         ret.second = mid_z + half_size; | ||||
|     } | ||||
| 
 | ||||
|     assert(ret.first > 0.0); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1590,8 +1590,8 @@ void GLCanvas3D::render() | |||
|     if (m_camera.requires_zoom_to_bed) | ||||
|     { | ||||
|         zoom_to_bed(); | ||||
|         const Size& cnv_size = get_canvas_size(); | ||||
|         _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height()); | ||||
| //        const Size& cnv_size = get_canvas_size();
 | ||||
| //        _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
 | ||||
|         m_camera.requires_zoom_to_bed = false; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Enrico Turri
						Enrico Turri