mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	Tech ENABLE_SEAMS_USING_INSTANCED_MODELS merged into tech ENABLE_SEAMS_USING_MODELS
This commit is contained in:
		
							parent
							
								
									dd5beee0bd
								
							
						
					
					
						commit
						9c4eeeaa18
					
				
					 6 changed files with 30 additions and 166 deletions
				
			
		|  | @ -51,8 +51,6 @@ | |||
| #define ENABLE_RETRACT_ACCELERATION (1 && ENABLE_2_4_0_ALPHA0) | ||||
| // Enable rendering seams (and other options) in preview using models
 | ||||
| #define ENABLE_SEAMS_USING_MODELS (1 && ENABLE_2_4_0_ALPHA0) | ||||
| // Enable rendering seams (and other options) in preview using instanced models
 | ||||
| #define ENABLE_SEAMS_USING_INSTANCED_MODELS (1 && ENABLE_SEAMS_USING_MODELS) | ||||
| 
 | ||||
| 
 | ||||
| #endif // _prusaslicer_technologies_h_
 | ||||
|  |  | |||
|  | @ -95,7 +95,7 @@ void GCodeViewer::VBuffer::reset() | |||
|     count = 0; | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| void GCodeViewer::InstanceVBuffer::Ranges::reset() | ||||
| { | ||||
|     for (Range& range : ranges) { | ||||
|  | @ -113,7 +113,7 @@ void GCodeViewer::InstanceVBuffer::reset() | |||
|     buffer.clear(); | ||||
|     render_ranges.reset(); | ||||
| } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
| void GCodeViewer::IBuffer::reset() | ||||
| { | ||||
|  | @ -159,11 +159,7 @@ bool GCodeViewer::Path::matches(const GCodeProcessor::MoveVertex& move) const | |||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| void GCodeViewer::TBuffer::Model::reset() | ||||
| { | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|     instances.reset(); | ||||
| #else | ||||
|     instances.clear(); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| } | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|  | @ -813,11 +809,7 @@ void GCodeViewer::render() | |||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|                 if (wxGetApp().is_gl_version_greater_or_equal_to(3, 1)) { | ||||
|                     buffer.render_primitive_type = TBuffer::ERenderPrimitiveType::Model; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|                     buffer.shader = "gouraud_light_instanced"; | ||||
| #else | ||||
|                     buffer.shader = "gouraud_light"; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|                     buffer.model.model.init_from(diamond(16)); | ||||
|                     buffer.model.color = option_color(type); | ||||
|                 } | ||||
|  | @ -870,9 +862,9 @@ void GCodeViewer::render() | |||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER_STATISTICS | ||||
|     m_statistics.reset_opengl(); | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     m_statistics.total_instances_gpu_size = 0; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| #endif // ENABLE_GCODE_VIEWER_STATISTICS
 | ||||
| 
 | ||||
|     // OpenGL data must be initialized after the glContext has been created.
 | ||||
|  | @ -1444,7 +1436,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
|     }; | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|     // format data into the buffers to be rendered as model
 | ||||
|     auto add_model_instance = [](const GCodeProcessor::MoveVertex& curr, InstanceBuffer& instances, InstanceIdBuffer& instances_ids, size_t move_id) { | ||||
|         // append position
 | ||||
|  | @ -1459,16 +1450,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
|         // append id
 | ||||
|         instances_ids.push_back(move_id); | ||||
|     }; | ||||
| #else | ||||
|     auto add_model_instance = [](const GCodeProcessor::MoveVertex& curr, TBuffer::Model::Instances& instances, size_t move_id) { | ||||
|         TBuffer::Model::Instance instance; | ||||
|         instance.position = curr.position; | ||||
|         instance.width = 1.2f * curr.width; | ||||
|         instance.height = 1.2f * curr.height; | ||||
|         instance.s_id = move_id; | ||||
|         instances.emplace_back(instance); | ||||
|     }; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
| #if ENABLE_GCODE_VIEWER_STATISTICS | ||||
|  | @ -1513,10 +1494,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
| 
 | ||||
|     std::vector<MultiVertexBuffer> vertices(m_buffers.size()); | ||||
|     std::vector<MultiIndexBuffer> indices(m_buffers.size()); | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     std::vector<InstanceBuffer> instances(m_buffers.size()); | ||||
|     std::vector<InstanceIdBuffer> instances_ids(m_buffers.size()); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|     std::vector<float> options_zs; | ||||
| 
 | ||||
|     // toolpaths data -> extract vertices from result
 | ||||
|  | @ -1541,10 +1522,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
|         const unsigned char id = buffer_id(curr.type); | ||||
|         TBuffer& t_buffer = m_buffers[id]; | ||||
|         MultiVertexBuffer& v_multibuffer = vertices[id]; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         InstanceBuffer& inst_buffer = instances[id]; | ||||
|         InstanceIdBuffer& inst_id_buffer = instances_ids[id]; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|         // ensure there is at least one vertex buffer
 | ||||
|         if (v_multibuffer.empty()) | ||||
|  | @ -1571,11 +1552,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         case TBuffer::ERenderPrimitiveType::Model: | ||||
|         { | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             add_model_instance(curr, inst_buffer, inst_id_buffer, i); | ||||
| #else | ||||
|             add_model_instance(curr, t_buffer.model.instances, i); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #if ENABLE_GCODE_VIEWER_STATISTICS | ||||
|             ++m_statistics.instances_count; | ||||
| #endif // ENABLE_GCODE_VIEWER_STATISTICS
 | ||||
|  | @ -1752,17 +1729,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if !ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|     for (size_t i = 0; i < m_buffers.size(); ++i) { | ||||
|         TBuffer& t_buffer = m_buffers[i]; | ||||
|         if (t_buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Model) { | ||||
|             t_buffer.model.instances.shrink_to_fit(); | ||||
|         } | ||||
|     } | ||||
| #endif // !ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|     // move the wipe toolpaths half height up to render them on proper position
 | ||||
|     MultiVertexBuffer& wipe_vertices = vertices[buffer_id(EMoveType::Wipe)]; | ||||
|     for (VertexBuffer& v_buffer : wipe_vertices) { | ||||
|  | @ -1771,15 +1737,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
|         } | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|     // send vertices data to gpu, where needed
 | ||||
| #else | ||||
|     // send vertices data to gpu
 | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|     for (size_t i = 0; i < m_buffers.size(); ++i) { | ||||
|         TBuffer& t_buffer = m_buffers[i]; | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|         if (t_buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Model) { | ||||
|             const InstanceBuffer& inst_buffer = instances[i]; | ||||
|             if (!inst_buffer.empty()) { | ||||
|  | @ -1788,9 +1749,6 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
|             } | ||||
|         } | ||||
|         else { | ||||
| #else | ||||
|         if (t_buffer.render_primitive_type != TBuffer::ERenderPrimitiveType::Model) { | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|             const MultiVertexBuffer& v_multibuffer = vertices[i]; | ||||
|             for (const VertexBuffer& v_buffer : v_multibuffer) { | ||||
|  | @ -1827,10 +1785,10 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) | |||
| 
 | ||||
|     // dismiss vertices data, no more needed
 | ||||
|     std::vector<MultiVertexBuffer>().swap(vertices); | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     std::vector<InstanceBuffer>().swap(instances); | ||||
|     std::vector<InstanceIdBuffer>().swap(instances_ids); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|     // toolpaths data -> extract indices from result
 | ||||
|     // paths may have been filled while extracting vertices,
 | ||||
|  | @ -2217,7 +2175,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
| 
 | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Model) { | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             for (size_t id : buffer.model.instances.s_ids) { | ||||
|                 if (id < m_layers.get_endpoints_at(m_layers_z_range[0]).first || m_layers.get_endpoints_at(m_layers_z_range[1]).last < id) | ||||
|                     continue; | ||||
|  | @ -2233,23 +2190,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
|                     top_layer_endpoints.last = std::max(top_layer_endpoints.last, id); | ||||
|                 } | ||||
|             } | ||||
| #else | ||||
|             for (const TBuffer::Model::Instance& inst : buffer.model.instances) { | ||||
|                 if (inst.s_id < m_layers.get_endpoints_at(m_layers_z_range[0]).first || m_layers.get_endpoints_at(m_layers_z_range[1]).last < inst.s_id) | ||||
|                     continue; | ||||
| 
 | ||||
|                 global_endpoints.first = std::min(global_endpoints.first, inst.s_id); | ||||
|                 global_endpoints.last = std::max(global_endpoints.last, inst.s_id); | ||||
| 
 | ||||
|                 if (top_layer_only) { | ||||
|                     if (inst.s_id < m_layers.get_endpoints_at(m_layers_z_range[1]).first || m_layers.get_endpoints_at(m_layers_z_range[1]).last < inst.s_id) | ||||
|                         continue; | ||||
| 
 | ||||
|                     top_layer_endpoints.first = std::min(top_layer_endpoints.first, inst.s_id); | ||||
|                     top_layer_endpoints.last = std::max(top_layer_endpoints.last, inst.s_id); | ||||
|                 } | ||||
|             } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|         } | ||||
|         else { | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|  | @ -2295,16 +2235,11 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
|     sequential_view->current.first = !top_layer_only && keep_sequential_current_first ? std::clamp(sequential_view->current.first, global_endpoints.first, global_endpoints.last) : global_endpoints.first; | ||||
|     sequential_view->current.last = keep_sequential_current_last ? std::clamp(sequential_view->current.last, global_endpoints.first, global_endpoints.last) : global_endpoints.last; | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|     // get the world position from the vertex buffer
 | ||||
| #else | ||||
|     // get the world position from gpu
 | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|     bool found = false; | ||||
|     for (const TBuffer& buffer : m_buffers) { | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         if (buffer.render_primitive_type == TBuffer::ERenderPrimitiveType::Model) { | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             for (size_t i = 0; i < buffer.model.instances.s_ids.size(); ++i) { | ||||
|                 if (buffer.model.instances.s_ids[i] == m_sequential_view.current.last) { | ||||
|                     size_t offset = i * buffer.model.instances.instance_size_floats(); | ||||
|  | @ -2316,15 +2251,6 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
|                     break; | ||||
|                 } | ||||
|             } | ||||
| #else | ||||
|             for (const TBuffer::Model::Instance& inst : buffer.model.instances) { | ||||
|                 if (inst.s_id == m_sequential_view.current.last) { | ||||
|                     sequential_view->current_position = inst.position; | ||||
|                     found = true; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|         } | ||||
|         else { | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|  | @ -2473,7 +2399,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
| #endif  | ||||
|     } | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     // second pass: for buffers using instanced models, update the instances render ranges
 | ||||
|     for (size_t b = 0; b < m_buffers.size(); ++b) { | ||||
|         TBuffer& buffer = const_cast<TBuffer&>(m_buffers[b]); | ||||
|  | @ -2513,7 +2439,7 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
|             } | ||||
|         } | ||||
|     } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|     // set sequential data to their final value
 | ||||
|     sequential_view->endpoints = top_layer_only ? top_layer_endpoints : global_endpoints; | ||||
|  | @ -2643,13 +2569,9 @@ void GCodeViewer::refresh_render_paths(bool keep_sequential_current_first, bool | |||
|             statistics->render_paths_size += SLIC3R_STDVEC_MEMSIZE(path.offsets, size_t); | ||||
|         } | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|         statistics->models_instances_size += SLIC3R_STDVEC_MEMSIZE(buffer.model.instances.buffer, float); | ||||
|         statistics->models_instances_size += SLIC3R_STDVEC_MEMSIZE(buffer.model.instances.s_ids, size_t); | ||||
|         statistics->models_instances_size += SLIC3R_STDVEC_MEMSIZE(buffer.model.instances.render_ranges.ranges, InstanceVBuffer::Ranges::Range); | ||||
| #else | ||||
|         statistics->models_instances_size += SLIC3R_STDVEC_MEMSIZE(buffer.model.instances, TBuffer::Model::Instance); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|     } | ||||
|     statistics->refresh_paths_time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start_time).count(); | ||||
|  | @ -2742,11 +2664,8 @@ void GCodeViewer::render_toolpaths() | |||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     auto render_as_instanced_model = [this] | ||||
|         (TBuffer& buffer, GLShaderProgram & shader) { | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|         for (auto& range : buffer.model.instances.render_ranges.ranges) { | ||||
|             if (range.vbo == 0 && range.count > 0) { | ||||
|                 std::cout << range.offset * buffer.model.instances.instance_size_bytes() << " + " << range.count * buffer.model.instances.instance_size_bytes() << " = " << buffer.model.instances.buffer.size() * sizeof(float) << "\n"; | ||||
| 
 | ||||
|                 glsafe(::glGenBuffers(1, &range.vbo)); | ||||
|                 glsafe(::glBindBuffer(GL_ARRAY_BUFFER, range.vbo)); | ||||
|                 glsafe(::glBufferData(GL_ARRAY_BUFFER, range.count * buffer.model.instances.instance_size_bytes(), (const void*)&buffer.model.instances.buffer[range.offset * buffer.model.instances.instance_size_floats()], GL_STATIC_DRAW)); | ||||
|  | @ -2762,28 +2681,6 @@ void GCodeViewer::render_toolpaths() | |||
| #endif // ENABLE_GCODE_VIEWER_STATISTICS
 | ||||
|             } | ||||
|         } | ||||
| #else | ||||
|         for (const TBuffer::Model::Instance& inst : buffer.model.instances) { | ||||
|             bool top_layer_only = get_app_config()->get("seq_top_layer_only") == "1"; | ||||
|             bool visible = top_layer_only ? | ||||
|                 m_sequential_view.global.first <= inst.s_id && inst.s_id <= m_sequential_view.global.last : | ||||
|                 m_sequential_view.current.first <= inst.s_id && inst.s_id <= m_sequential_view.current.last; | ||||
| 
 | ||||
|             if (visible) { | ||||
|                 glsafe(::glPushMatrix()); | ||||
|                 glsafe(::glTranslatef(inst.position.x(), inst.position.y(), inst.position.z() - 0.5f * inst.height)); | ||||
|                 glsafe(::glScalef(inst.width, inst.width, inst.height)); | ||||
|                 Color color = (top_layer_only && m_sequential_view.current.last != m_sequential_view.global.last && inst.s_id < m_sequential_view.endpoints.first) ? | ||||
|                     Neutral_Color : buffer.model.color; | ||||
|                 buffer.model.model.set_color(-1, color); | ||||
|                 buffer.model.model.render(); | ||||
|                 glsafe(::glPopMatrix()); | ||||
| #if ENABLE_GCODE_VIEWER_STATISTICS | ||||
|                 ++m_statistics.gl_models_calls_count; | ||||
| #endif // ENABLE_GCODE_VIEWER_STATISTICS
 | ||||
|             } | ||||
|         } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|     }; | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|  | @ -3852,11 +3749,7 @@ void GCodeViewer::render_statistics() | |||
|         add_counter(std::string("Multi GL_TRIANGLES:"), m_statistics.gl_multi_triangles_calls_count); | ||||
|         add_counter(std::string("GL_TRIANGLES:"), m_statistics.gl_triangles_calls_count); | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|         add_counter(std::string("Instanced models:"), m_statistics.gl_instanced_models_calls_count); | ||||
| #else | ||||
|         add_counter(std::string("Models:"), m_statistics.gl_models_calls_count); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|     } | ||||
| 
 | ||||
|  | @ -3874,9 +3767,9 @@ void GCodeViewer::render_statistics() | |||
|     if (ImGui::CollapsingHeader("GPU memory")) { | ||||
|         add_memory(std::string("Vertices:"), m_statistics.total_vertices_gpu_size); | ||||
|         add_memory(std::string("Indices:"), m_statistics.total_indices_gpu_size); | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         add_memory(std::string("Instances:"), m_statistics.total_instances_gpu_size); | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|         ImGui::Separator(); | ||||
|         add_memory(std::string("Max VBuffer:"), m_statistics.max_vbuffer_gpu_size); | ||||
|         add_memory(std::string("Max IBuffer:"), m_statistics.max_ibuffer_gpu_size); | ||||
|  |  | |||
|  | @ -27,10 +27,10 @@ class GCodeViewer | |||
|     using MultiVertexBuffer = std::vector<VertexBuffer>; | ||||
|     using IndexBuffer = std::vector<IBufferType>; | ||||
|     using MultiIndexBuffer = std::vector<IndexBuffer>; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     using InstanceBuffer = std::vector<float>; | ||||
|     using InstanceIdBuffer = std::vector<size_t>; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|     static const std::vector<Color> Extrusion_Role_Colors; | ||||
|     static const std::vector<Color> Options_Colors; | ||||
|  | @ -104,7 +104,7 @@ class GCodeViewer | |||
|         void reset(); | ||||
|     }; | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     // buffer containing instances data used to render a toolpaths using instanced models
 | ||||
|     // instance record format: 5 floats -> position.x|position.y|position.z|width|height
 | ||||
|     // which is sent to the shader as -> vec3 (offset) + vec2 (scales) in GLModel::render_instanced()
 | ||||
|  | @ -143,7 +143,7 @@ class GCodeViewer | |||
| 
 | ||||
|         void reset(); | ||||
|     }; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|     // ibo buffer containing indices data (for lines/triangles) used to render a specific toolpath type
 | ||||
|     struct IBuffer | ||||
|  | @ -295,24 +295,9 @@ class GCodeViewer | |||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         struct Model | ||||
|         { | ||||
| #if !ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             struct Instance | ||||
|             { | ||||
|                 Vec3f position; | ||||
|                 float width; | ||||
|                 float height; | ||||
|                 size_t s_id; | ||||
|             }; | ||||
|             using Instances = std::vector<Instance>; | ||||
| #endif // !ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| 
 | ||||
|             GLModel model; | ||||
|             Color color; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             InstanceVBuffer instances; | ||||
| #else | ||||
|             Instances instances; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| 
 | ||||
|             void reset(); | ||||
|         }; | ||||
|  | @ -377,11 +362,7 @@ class GCodeViewer | |||
|             case ERenderPrimitiveType::Triangle: { | ||||
|                 return !vertices.vbos.empty() && vertices.vbos.front() != 0 && !indices.empty() && indices.front().ibo != 0; | ||||
|             } | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             case ERenderPrimitiveType::Model: { return model.model.is_initialized() && !model.instances.buffer.empty(); } | ||||
| #else | ||||
|             case ERenderPrimitiveType::Model: { return model.model.is_initialized() && !model.instances.empty(); } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
|             default: { return false; } | ||||
|             } | ||||
|         } | ||||
|  | @ -538,19 +519,15 @@ class GCodeViewer | |||
|         int64_t gl_multi_triangles_calls_count{ 0 }; | ||||
|         int64_t gl_triangles_calls_count{ 0 }; | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|         int64_t gl_instanced_models_calls_count{ 0 }; | ||||
| #else | ||||
|         int64_t gl_models_calls_count{ 0 }; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|         // memory
 | ||||
|         int64_t results_size{ 0 }; | ||||
|         int64_t total_vertices_gpu_size{ 0 }; | ||||
|         int64_t total_indices_gpu_size{ 0 }; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         int64_t total_instances_gpu_size{ 0 }; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|         int64_t max_vbuffer_gpu_size{ 0 }; | ||||
|         int64_t max_ibuffer_gpu_size{ 0 }; | ||||
|         int64_t paths_size{ 0 }; | ||||
|  | @ -591,11 +568,7 @@ class GCodeViewer | |||
|             gl_multi_triangles_calls_count = 0; | ||||
|             gl_triangles_calls_count = 0; | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
|             gl_instanced_models_calls_count = 0; | ||||
| #else | ||||
|             gl_models_calls_count = 0; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|         } | ||||
| 
 | ||||
|  | @ -603,9 +576,9 @@ class GCodeViewer | |||
|             results_size = 0; | ||||
|             total_vertices_gpu_size = 0; | ||||
|             total_indices_gpu_size = 0; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|             total_instances_gpu_size = 0; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|             max_vbuffer_gpu_size = 0; | ||||
|             max_ibuffer_gpu_size = 0; | ||||
|             paths_size = 0; | ||||
|  |  | |||
|  | @ -208,7 +208,7 @@ void GLModel::render() const | |||
|     } | ||||
| } | ||||
| 
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
| void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instances_count) const | ||||
| { | ||||
|     if (instances_vbo == 0) | ||||
|  | @ -285,7 +285,7 @@ void GLModel::render_instanced(unsigned int instances_vbo, unsigned int instance | |||
| 
 | ||||
|     glsafe(::glBindBuffer(GL_ARRAY_BUFFER, 0)); | ||||
| } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
| void GLModel::send_to_gpu(RenderData& data, const std::vector<float>& vertices, const std::vector<unsigned int>& indices) | ||||
| { | ||||
|  |  | |||
|  | @ -72,9 +72,9 @@ namespace GUI { | |||
| 
 | ||||
|         void reset(); | ||||
|         void render() const; | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|         void render_instanced(unsigned int instances_vbo, unsigned int instances_count) const; | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
| 
 | ||||
|         bool is_initialized() const { return !m_render_data.empty(); } | ||||
| 
 | ||||
|  |  | |||
|  | @ -38,17 +38,17 @@ std::pair<bool, std::string> GLShadersManager::init() | |||
|     // used to render printbed
 | ||||
|     valid &= append_shader("printbed", { "printbed.vs", "printbed.fs" }); | ||||
|     // used to render options in gcode preview
 | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     if (GUI::wxGetApp().is_gl_version_greater_or_equal_to(3, 1)) | ||||
|         valid &= append_shader("gouraud_light_instanced", { "gouraud_light_instanced.vs", "gouraud_light_instanced.fs" }); | ||||
|     else { | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|         valid &= append_shader("options_110", { "options_110.vs", "options_110.fs" }); | ||||
|         if (GUI::wxGetApp().is_glsl_version_greater_or_equal_to(1, 20)) | ||||
|             valid &= append_shader("options_120", { "options_120.vs", "options_120.fs" }); | ||||
| #if ENABLE_SEAMS_USING_INSTANCED_MODELS | ||||
| #if ENABLE_SEAMS_USING_MODELS | ||||
|     } | ||||
| #endif // ENABLE_SEAMS_USING_INSTANCED_MODELS
 | ||||
| #endif // ENABLE_SEAMS_USING_MODELS
 | ||||
|     // used to render extrusion and travel paths as lines in gcode preview
 | ||||
|     valid &= append_shader("toolpaths_lines", { "toolpaths_lines.vs", "toolpaths_lines.fs" }); | ||||
|     // used to render objects in 3d editor
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966