mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	A little refactoring of loading meshes in VBO / non VBO case.
This commit is contained in:
		
							parent
							
								
									4904359399
								
							
						
					
					
						commit
						1fffae4e0b
					
				
					 1 changed files with 6 additions and 31 deletions
				
			
		|  | @ -594,10 +594,7 @@ int GLVolumeCollection::load_object_volume( | |||
|     this->volumes.emplace_back(new GLVolume(color)); | ||||
|     GLVolume &v = *this->volumes.back(); | ||||
|     v.set_color_from_model_volume(model_volume); | ||||
|     if (use_VBOs) | ||||
|         v.indexed_vertex_array.load_mesh_full_shading(mesh); | ||||
|     else | ||||
|         v.indexed_vertex_array.load_mesh_flat_shading(mesh); | ||||
|     v.indexed_vertex_array.load_mesh(mesh, use_VBOs); | ||||
| 
 | ||||
|     // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
 | ||||
|     v.bounding_box = v.indexed_vertex_array.bounding_box(); | ||||
|  | @ -642,10 +639,7 @@ void GLVolumeCollection::load_object_auxiliary( | |||
|         const ModelInstance &model_instance = *print_object->model_object()->instances[instance_idx.first]; | ||||
|         this->volumes.emplace_back(new GLVolume((milestone == slaposBasePool) ? GLVolume::SLA_PAD_COLOR : GLVolume::SLA_SUPPORT_COLOR)); | ||||
|         GLVolume &v = *this->volumes.back(); | ||||
|         if (use_VBOs) | ||||
|             v.indexed_vertex_array.load_mesh_full_shading(mesh); | ||||
|         else | ||||
|             v.indexed_vertex_array.load_mesh_flat_shading(mesh); | ||||
|         v.indexed_vertex_array.load_mesh(mesh, use_VBOs); | ||||
|         // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
 | ||||
|         v.bounding_box = v.indexed_vertex_array.bounding_box(); | ||||
|         v.indexed_vertex_array.finalize_geometry(use_VBOs); | ||||
|  | @ -716,14 +710,8 @@ int GLVolumeCollection::load_wipe_tower_preview( | |||
| 
 | ||||
|     this->volumes.emplace_back(new GLVolume(color)); | ||||
|     GLVolume &v = *this->volumes.back(); | ||||
| 
 | ||||
|     if (use_VBOs) | ||||
|         v.indexed_vertex_array.load_mesh_full_shading(mesh); | ||||
|     else | ||||
|         v.indexed_vertex_array.load_mesh_flat_shading(mesh); | ||||
| 
 | ||||
|     v.indexed_vertex_array.load_mesh(mesh, use_VBOs); | ||||
|     v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0)); | ||||
| 
 | ||||
|     // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry().
 | ||||
|     v.bounding_box = v.indexed_vertex_array.bounding_box(); | ||||
|     v.indexed_vertex_array.finalize_geometry(use_VBOs); | ||||
|  | @ -1854,12 +1842,7 @@ bool GLArrow::on_init(bool useVBOs) | |||
|     triangles.emplace_back(7, 13, 6); | ||||
| 
 | ||||
|     m_useVBOs = useVBOs; | ||||
| 
 | ||||
|     if (m_useVBOs) | ||||
|         m_volume.indexed_vertex_array.load_mesh_full_shading(TriangleMesh(vertices, triangles)); | ||||
|     else | ||||
|         m_volume.indexed_vertex_array.load_mesh_flat_shading(TriangleMesh(vertices, triangles)); | ||||
| 
 | ||||
| 	m_volume.indexed_vertex_array.load_mesh(TriangleMesh(vertices, triangles), useVBOs); | ||||
|     m_volume.finalize_geometry(m_useVBOs); | ||||
|     return true; | ||||
| } | ||||
|  | @ -1974,12 +1957,7 @@ bool GLCurvedArrow::on_init(bool useVBOs) | |||
|     triangles.emplace_back(vertices_per_level, 2 * vertices_per_level + 1, vertices_per_level + 1); | ||||
| 
 | ||||
|     m_useVBOs = useVBOs; | ||||
| 
 | ||||
|     if (m_useVBOs) | ||||
|         m_volume.indexed_vertex_array.load_mesh_full_shading(TriangleMesh(vertices, triangles)); | ||||
|     else | ||||
|         m_volume.indexed_vertex_array.load_mesh_flat_shading(TriangleMesh(vertices, triangles)); | ||||
| 
 | ||||
| 	m_volume.indexed_vertex_array.load_mesh(TriangleMesh(vertices, triangles), useVBOs); | ||||
|     m_volume.bounding_box = m_volume.indexed_vertex_array.bounding_box(); | ||||
|     m_volume.finalize_geometry(m_useVBOs); | ||||
|     return true; | ||||
|  | @ -2014,10 +1992,7 @@ bool GLBed::on_init_from_file(const std::string& filename, bool useVBOs) | |||
|     TriangleMesh mesh = model.mesh(); | ||||
|     mesh.repair(); | ||||
| 
 | ||||
|     if (m_useVBOs) | ||||
|         m_volume.indexed_vertex_array.load_mesh_full_shading(mesh); | ||||
|     else | ||||
|         m_volume.indexed_vertex_array.load_mesh_flat_shading(mesh); | ||||
| 	m_volume.indexed_vertex_array.load_mesh(mesh, useVBOs); | ||||
| 
 | ||||
|     float color[4] = { 0.235f, 0.235f, 0.235f, 1.0f }; | ||||
|     set_color(color, 4); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bubnikv
						bubnikv