Follow-up of ef8ddacdfc -> Fixed rendering of modifiers after cleaning current selection

This commit is contained in:
enricoturri1966 2021-07-16 10:56:29 +02:00
parent afa4776ead
commit beb60b5138
2 changed files with 16 additions and 12 deletions

View File

@ -748,13 +748,12 @@ GLVolumeWithIdAndZList volumes_to_render(const GLVolumePtrs& volumes, GLVolumeCo
GLVolumeWithIdAndZList list; GLVolumeWithIdAndZList list;
list.reserve(volumes.size()); list.reserve(volumes.size());
for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i) for (unsigned int i = 0; i < (unsigned int)volumes.size(); ++i) {
{
GLVolume* volume = volumes[i]; GLVolume* volume = volumes[i];
bool is_transparent = (volume->render_color[3] < 1.0f); bool is_transparent = (volume->render_color[3] < 1.0f);
if ((((type == GLVolumeCollection::ERenderType::Opaque) && !is_transparent) || if (((type == GLVolumeCollection::ERenderType::Opaque && !is_transparent) ||
((type == GLVolumeCollection::ERenderType::Transparent) && is_transparent) || (type == GLVolumeCollection::ERenderType::Transparent && is_transparent) ||
(type == GLVolumeCollection::ERenderType::All)) && type == GLVolumeCollection::ERenderType::All) &&
(! filter_func || filter_func(*volume))) (! filter_func || filter_func(*volume)))
list.emplace_back(std::make_pair(volume, std::make_pair(i, 0.0))); list.emplace_back(std::make_pair(volume, std::make_pair(i, 0.0)));
} }
@ -783,8 +782,10 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
if (shader == nullptr) if (shader == nullptr)
return; return;
glsafe(::glEnable(GL_BLEND)); if (type == ERenderType::Transparent) {
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
}
glsafe(::glCullFace(GL_BACK)); glsafe(::glCullFace(GL_BACK));
if (disable_cullface) if (disable_cullface)
@ -837,7 +838,8 @@ void GLVolumeCollection::render(GLVolumeCollection::ERenderType type, bool disab
if (disable_cullface) if (disable_cullface)
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));
glsafe(::glDisable(GL_BLEND)); if (type == ERenderType::Transparent)
glsafe(::glDisable(GL_BLEND));
} }
bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state) const bool GLVolumeCollection::check_outside_state(const DynamicPrintConfig* config, ModelInstanceEPrintVolumeState* out_state) const

View File

@ -415,7 +415,7 @@ void Selection::remove_all()
// Not taking the snapshot with non-empty Redo stack will likely be more confusing than losing the Redo stack. // Not taking the snapshot with non-empty Redo stack will likely be more confusing than losing the Redo stack.
// Let's wait for user feedback. // Let's wait for user feedback.
// if (!wxGetApp().plater()->can_redo()) // if (!wxGetApp().plater()->can_redo())
wxGetApp().plater()->take_snapshot(_(L("Selection-Remove All"))); wxGetApp().plater()->take_snapshot(_L("Selection-Remove All"));
m_mode = Instance; m_mode = Instance;
clear(); clear();
@ -432,9 +432,9 @@ void Selection::set_deserialized(EMode mode, const std::vector<std::pair<size_t,
m_list.clear(); m_list.clear();
for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++ i) for (unsigned int i = 0; i < (unsigned int)m_volumes->size(); ++ i)
if (std::binary_search(volumes_and_instances.begin(), volumes_and_instances.end(), (*m_volumes)[i]->geometry_id)) if (std::binary_search(volumes_and_instances.begin(), volumes_and_instances.end(), (*m_volumes)[i]->geometry_id))
this->do_add_volume(i); do_add_volume(i);
update_type(); update_type();
this->set_bounding_boxes_dirty(); set_bounding_boxes_dirty();
} }
void Selection::clear() void Selection::clear()
@ -447,12 +447,14 @@ void Selection::clear()
for (unsigned int i : m_list) { for (unsigned int i : m_list) {
(*m_volumes)[i]->selected = false; (*m_volumes)[i]->selected = false;
// ensure the volume gets the proper color before next call to render (expecially needed for transparent volumes)
(*m_volumes)[i]->set_render_color();
} }
m_list.clear(); m_list.clear();
update_type(); update_type();
this->set_bounding_boxes_dirty(); set_bounding_boxes_dirty();
// this happens while the application is closing // this happens while the application is closing
if (wxGetApp().obj_manipul() == nullptr) if (wxGetApp().obj_manipul() == nullptr)