FIX:fix abnormal pixel issue
Jira: none Change-Id: Ia2a5a2edf17637338ff88c626294a29df3efde46 (cherry picked from commit 77ef554c94d4153ec3495a1c2b0bbab6b5714af1)
This commit is contained in:
parent
e7a57325d9
commit
5ced03779b
|
@ -2110,8 +2110,9 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w,
|
|||
use_top_view, for_picking, ban_light);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{ render_thumbnail_legacy(thumbnail_data, w, h, thumbnail_params, wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type);
|
||||
default:{
|
||||
render_thumbnail_legacy(thumbnail_data, w, h, thumbnail_params, wxGetApp().plater()->get_partplate_list(), model_objects, volumes, colors, shader, camera_type,
|
||||
use_top_view, for_picking, ban_light);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5801,7 +5802,9 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const
|
|||
|
||||
glsafe(::glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT));
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
|
||||
if (ban_light) {
|
||||
glsafe(::glDisable(GL_BLEND));
|
||||
}
|
||||
if (for_picking) {
|
||||
//if (OpenGLManager::can_multisample())
|
||||
// This flag is often ignored by NVIDIA drivers if rendering into a screen buffer.
|
||||
|
@ -6115,7 +6118,10 @@ void GLCanvas3D::render_thumbnail_framebuffer_ext(ThumbnailData& thumbnail_data,
|
|||
// glsafe(::glDisable(GL_MULTISAMPLE));
|
||||
}
|
||||
|
||||
void GLCanvas3D::render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, PartPlateList &partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors, GLShaderProgram* shader, Camera::EType camera_type)
|
||||
void GLCanvas3D::render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, PartPlateList &partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors, GLShaderProgram* shader, Camera::EType camera_type,
|
||||
bool use_top_view,
|
||||
bool for_picking,
|
||||
bool ban_light)
|
||||
{
|
||||
// check that thumbnail size does not exceed the default framebuffer size
|
||||
const Size& cnv_size = get_canvas_size();
|
||||
|
@ -6131,7 +6137,8 @@ void GLCanvas3D::render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned
|
|||
if (!thumbnail_data.is_valid())
|
||||
return;
|
||||
|
||||
render_thumbnail_internal(thumbnail_data, thumbnail_params, partplate_list, model_objects, volumes, extruder_colors, shader, camera_type);
|
||||
render_thumbnail_internal(thumbnail_data, thumbnail_params, partplate_list, model_objects, volumes, extruder_colors, shader, camera_type, use_top_view, for_picking,
|
||||
ban_light);
|
||||
|
||||
glsafe(::glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, (void*)thumbnail_data.pixels.data()));
|
||||
#if ENABLE_THUMBNAIL_GENERATOR_DEBUG_OUTPUT
|
||||
|
|
|
@ -1156,7 +1156,19 @@ private:
|
|||
bool _render_orient_menu(float left, float right, float bottom, float top);
|
||||
bool _render_arrange_menu(float left, float right, float bottom, float top);
|
||||
// render thumbnail using the default framebuffer
|
||||
void render_thumbnail_legacy(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params, PartPlateList& partplate_list, ModelObjectPtrs& model_objects, const GLVolumeCollection& volumes, std::vector<std::array<float, 4>>& extruder_colors, GLShaderProgram* shader, Camera::EType camera_type);
|
||||
void render_thumbnail_legacy(ThumbnailData & thumbnail_data,
|
||||
unsigned int w,
|
||||
unsigned int h,
|
||||
const ThumbnailsParams & thumbnail_params,
|
||||
PartPlateList & partplate_list,
|
||||
ModelObjectPtrs & model_objects,
|
||||
const GLVolumeCollection & volumes,
|
||||
std::vector<std::array<float, 4>> &extruder_colors,
|
||||
GLShaderProgram * shader,
|
||||
Camera::EType camera_type,
|
||||
bool use_top_view = false,
|
||||
bool for_picking = false,
|
||||
bool ban_light = false);
|
||||
|
||||
void _update_volumes_hover_state();
|
||||
|
||||
|
|
|
@ -4077,11 +4077,15 @@ void SelectMachineDialog::clone_thumbnail_data() {
|
|||
if (m_preview_colors_in_thumbnail.size() != m_materialList.size()) {
|
||||
m_preview_colors_in_thumbnail.resize(m_materialList.size());
|
||||
}
|
||||
if (m_cur_colors_in_thumbnail.size() != m_materialList.size()) {
|
||||
m_cur_colors_in_thumbnail.resize(m_materialList.size());
|
||||
}
|
||||
while (iter != m_materialList.end()) {
|
||||
int id = iter->first;
|
||||
Material * item = iter->second;
|
||||
MaterialItem *m = item->item;
|
||||
m_preview_colors_in_thumbnail[id] = m->m_material_coloul;
|
||||
m_cur_colors_in_thumbnail[id] = m->m_ams_coloul;
|
||||
iter++;
|
||||
}
|
||||
//copy data
|
||||
|
@ -4228,10 +4232,10 @@ void SelectMachineDialog::updata_thumbnail_data_after_connected_printer()
|
|||
is_connect_printer = false;
|
||||
break;
|
||||
}
|
||||
change_default_normal(id, m->m_ams_coloul);
|
||||
iter++;
|
||||
}
|
||||
if (is_connect_printer) {
|
||||
if (is_connect_printer) {
|
||||
change_default_normal(-1, wxColour());
|
||||
final_deal_edge_pixels_data(m_preview_thumbnail_data);
|
||||
set_default_normal(m_preview_thumbnail_data);
|
||||
}
|
||||
|
@ -4239,7 +4243,9 @@ void SelectMachineDialog::updata_thumbnail_data_after_connected_printer()
|
|||
|
||||
void SelectMachineDialog::change_default_normal(int old_filament_id, wxColour temp_ams_color)
|
||||
{
|
||||
wxColour ams_color = adjust_color_for_render(temp_ams_color);
|
||||
if (old_filament_id >= 0) {
|
||||
m_cur_colors_in_thumbnail[old_filament_id] = temp_ams_color;
|
||||
}
|
||||
ThumbnailData& data =m_plater->get_partplate_list().get_curr_plate()->thumbnail_data;
|
||||
ThumbnailData& no_light_data = m_plater->get_partplate_list().get_curr_plate()->no_light_thumbnail_data;
|
||||
if (data.width > 0 && data.height > 0 && data.width == no_light_data.width && data.height == no_light_data.height) {
|
||||
|
@ -4249,7 +4255,14 @@ void SelectMachineDialog::change_default_normal(int old_filament_id, wxColour te
|
|||
unsigned char *no_light_px = (unsigned char *) no_light_data.pixels.data() + 4 * (rr + c);
|
||||
unsigned char *origin_px = (unsigned char *) data.pixels.data() + 4 * (rr + c);
|
||||
unsigned char *new_px = (unsigned char *) m_preview_thumbnail_data.pixels.data() + 4 * (rr + c);
|
||||
if (no_light_px[3] == (255 - old_filament_id) && m_edge_pixels[r * data.width + c] == false) {
|
||||
if (origin_px[3] > 0 && m_edge_pixels[r * data.width + c] == false) {
|
||||
auto filament_id = 255 - no_light_px[3];
|
||||
if (filament_id >= m_cur_colors_in_thumbnail.size()) {
|
||||
continue;
|
||||
}
|
||||
wxColour temp_ams_color_in_loop = m_cur_colors_in_thumbnail[filament_id];
|
||||
wxColour ams_color = adjust_color_for_render(temp_ams_color_in_loop);
|
||||
//change color
|
||||
new_px[3] = origin_px[3]; // alpha
|
||||
int origin_rgb = origin_px[0] + origin_px[1] + origin_px[2];
|
||||
int no_light_px_rgb = no_light_px[0] + no_light_px[1] + no_light_px[2];
|
||||
|
|
|
@ -445,6 +445,7 @@ protected:
|
|||
ScalableBitmap * enable_ams{nullptr};
|
||||
ThumbnailData m_preview_thumbnail_data;//when ams map change
|
||||
std::vector<wxColour> m_preview_colors_in_thumbnail;
|
||||
std::vector<wxColour> m_cur_colors_in_thumbnail;
|
||||
std::vector<bool> m_edge_pixels;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue