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-04-10 12:20:09 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-04-10 12:20:09 +0300
commite61be7d260d40caf2b9d4edf128e086ca4d3144f (patch)
tree5d49be910ad5a5b859215b515a77979be816b7f9 /src/slic3r/GUI/3DScene.cpp
parentffde52510011ec1a34f128b26ee882dbf6de723f (diff)
Render picking pass renders volumes in the same order as the regular render pass
Diffstat (limited to 'src/slic3r/GUI/3DScene.cpp')
-rw-r--r--src/slic3r/GUI/3DScene.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp
index 3dd680820..61920220e 100644
--- a/src/slic3r/GUI/3DScene.cpp
+++ b/src/slic3r/GUI/3DScene.cpp
@@ -721,32 +721,31 @@ int GLVolumeCollection::load_wipe_tower_preview(
return int(this->volumes.size() - 1);
}
-typedef std::pair<GLVolume*, double> GLVolumeWithZ;
-typedef std::vector<GLVolumeWithZ> GLVolumesWithZList;
-static GLVolumesWithZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCollection::ERenderType type, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func)
+GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCollection::ERenderType type, const Transform3d& view_matrix, std::function<bool(const GLVolume&)> filter_func)
{
- GLVolumesWithZList list;
+ GLVolumeWithIdAndZList list;
list.reserve(volumes.size());
- for (GLVolume* volume : volumes)
+ for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i)
{
+ GLVolume* volume = volumes[i];
bool is_transparent = (volume->render_color[3] < 1.0f);
if ((((type == GLVolumeCollection::Opaque) && !is_transparent) ||
((type == GLVolumeCollection::Transparent) && is_transparent) ||
(type == GLVolumeCollection::All)) &&
(! filter_func || filter_func(*volume)))
- list.emplace_back(std::make_pair(volume, 0.0));
+ list.emplace_back(std::make_pair(volume, std::make_pair(i, 0.0)));
}
if ((type == GLVolumeCollection::Transparent) && (list.size() > 1))
{
- for (GLVolumeWithZ& volume : list)
+ for (GLVolumeWithIdAndZ& volume : list)
{
- volume.second = volume.first->bounding_box.transformed(view_matrix * volume.first->world_matrix()).max(2);
+ volume.second.second = volume.first->bounding_box.transformed(view_matrix * volume.first->world_matrix()).max(2);
}
std::sort(list.begin(), list.end(),
- [](const GLVolumeWithZ& v1, const GLVolumeWithZ& v2) -> bool { return v1.second < v2.second; }
+ [](const GLVolumeWithIdAndZ& v1, const GLVolumeWithIdAndZ& v2) -> bool { return v1.second.second < v2.second.second; }
);
}
@@ -784,8 +783,8 @@ void GLVolumeCollection::render_VBOs(GLVolumeCollection::ERenderType type, bool
if (z_range_id != -1)
glsafe(::glUniform2fv(z_range_id, 1, (const GLfloat*)z_range));
- GLVolumesWithZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
- for (GLVolumeWithZ& volume : to_render) {
+ GLVolumeWithIdAndZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
+ for (GLVolumeWithIdAndZ& volume : to_render) {
volume.first->set_render_color();
volume.first->render_VBOs(color_id, print_box_detection_id, print_box_worldmatrix_id);
}
@@ -814,8 +813,8 @@ void GLVolumeCollection::render_legacy(ERenderType type, bool disable_cullface,
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
- GLVolumesWithZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
- for (GLVolumeWithZ& volume : to_render)
+ GLVolumeWithIdAndZList to_render = volumes_to_render(this->volumes, type, view_matrix, filter_func);
+ for (GLVolumeWithIdAndZ& volume : to_render)
{
volume.first->set_render_color();
volume.first->render_legacy();