Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-08-20 10:51:25 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-08-20 10:51:25 +0300
commit730283a9e9dc06426b1927e60c1dca52ef2da571 (patch)
tree10d4bfbc8b120866cdf4da493fc051d376ef0344 /src/slic3r/GUI/3DScene.cpp
parent1f6aab312b544ff2c0225cc3516c543a3454f078 (diff)
Export to obj file only toolpaths visible in 3D scene
Diffstat (limited to 'src/slic3r/GUI/3DScene.cpp')
-rw-r--r--src/slic3r/GUI/3DScene.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp
index 6d9302ba6..d5fed6d42 100644
--- a/src/slic3r/GUI/3DScene.cpp
+++ b/src/slic3r/GUI/3DScene.cpp
@@ -872,7 +872,7 @@ void GLVolumeCollection::export_toolpaths_to_obj(const char* filename) const
for (const GLVolume* volume : this->volumes)
{
- if (!volume->is_extrusion_path)
+ if (!volume->is_active || !volume->is_extrusion_path)
continue;
std::vector<float> vertices_and_normals_interleaved;
@@ -896,22 +896,30 @@ void GLVolumeCollection::export_toolpaths_to_obj(const char* filename) const
triangle_indices = volume->indexed_vertex_array.triangle_indices;
else if ((volume->indexed_vertex_array.triangle_indices_VBO_id != 0) && (volume->indexed_vertex_array.triangle_indices_size != 0))
{
- triangle_indices = std::vector<int>(volume->indexed_vertex_array.triangle_indices_size, 0);
+ size_t size = std::min(volume->indexed_vertex_array.triangle_indices_size, volume->tverts_range.second - volume->tverts_range.first);
+ if (size != 0)
+ {
+ triangle_indices = std::vector<int>(size, 0);
- glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume->indexed_vertex_array.triangle_indices_VBO_id));
- glsafe(::glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, triangle_indices.size() * sizeof(int), triangle_indices.data()));
- glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
+ glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume->indexed_vertex_array.triangle_indices_VBO_id));
+ glsafe(::glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, volume->tverts_range.first * sizeof(int), size * sizeof(int), triangle_indices.data()));
+ glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
+ }
}
if (!volume->indexed_vertex_array.quad_indices.empty())
quad_indices = volume->indexed_vertex_array.quad_indices;
if ((volume->indexed_vertex_array.quad_indices_VBO_id != 0) && (volume->indexed_vertex_array.quad_indices_size != 0))
{
- quad_indices = std::vector<int>(volume->indexed_vertex_array.quad_indices_size, 0);
+ size_t size = std::min(volume->indexed_vertex_array.quad_indices_size, volume->qverts_range.second - volume->qverts_range.first);
+ if (size != 0)
+ {
+ quad_indices = std::vector<int>(size, 0);
- glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume->indexed_vertex_array.quad_indices_VBO_id));
- glsafe(::glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, quad_indices.size() * sizeof(int), quad_indices.data()));
- glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
+ glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, volume->indexed_vertex_array.quad_indices_VBO_id));
+ glsafe(::glGetBufferSubData(GL_ELEMENT_ARRAY_BUFFER, volume->qverts_range.first * sizeof(int), size * sizeof(int), quad_indices.data()));
+ glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));
+ }
}
if (triangle_indices.empty() && quad_indices.empty())