mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 13:47:59 -06:00
FIX: extra frame request
Do not freeze bargraph in Siplify dialog when no mouse move.
This commit is contained in:
parent
090728b9d5
commit
11c91d781e
4 changed files with 22 additions and 35 deletions
|
@ -2780,11 +2780,10 @@ void GLCanvas3D::on_timer(wxTimerEvent& evt)
|
||||||
|
|
||||||
void GLCanvas3D::on_render_timer(wxTimerEvent& evt)
|
void GLCanvas3D::on_render_timer(wxTimerEvent& evt)
|
||||||
{
|
{
|
||||||
// no need to do anything here
|
m_dirty = true;
|
||||||
// right after this event is recieved, idle event is fired
|
// wxWakeUpIdle();
|
||||||
|
// no need to wake up idle
|
||||||
//m_dirty = true;
|
// right after this event, idle event is fired
|
||||||
//wxWakeUpIdle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2802,21 +2801,15 @@ void GLCanvas3D::schedule_extra_frame(int miliseconds)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Start timer
|
int remaining_time = m_render_timer.GetInterval();
|
||||||
int64_t now = timestamp_now();
|
|
||||||
// Timer is not running
|
// Timer is not running
|
||||||
if (! m_render_timer.IsRunning()) {
|
if (!m_render_timer.IsRunning()) {
|
||||||
m_extra_frame_requested_delayed = miliseconds;
|
|
||||||
m_render_timer.StartOnce(miliseconds);
|
m_render_timer.StartOnce(miliseconds);
|
||||||
m_render_timer_start = now;
|
|
||||||
// Timer is running - restart only if new period is shorter than remaning period
|
// Timer is running - restart only if new period is shorter than remaning period
|
||||||
} else {
|
} else {
|
||||||
const int64_t remaining_time = (m_render_timer_start + m_extra_frame_requested_delayed) - now;
|
|
||||||
if (miliseconds + 20 < remaining_time) {
|
if (miliseconds + 20 < remaining_time) {
|
||||||
m_render_timer.Stop();
|
m_render_timer.Stop();
|
||||||
m_extra_frame_requested_delayed = miliseconds;
|
|
||||||
m_render_timer.StartOnce(miliseconds);
|
m_render_timer.StartOnce(miliseconds);
|
||||||
m_render_timer_start = now;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,15 +463,13 @@ private:
|
||||||
std::string m_sidebar_field;
|
std::string m_sidebar_field;
|
||||||
// when true renders an extra frame by not resetting m_dirty to false
|
// when true renders an extra frame by not resetting m_dirty to false
|
||||||
// see request_extra_frame()
|
// see request_extra_frame()
|
||||||
bool m_extra_frame_requested;
|
bool m_extra_frame_requested;
|
||||||
int m_extra_frame_requested_delayed { std::numeric_limits<int>::max() };
|
|
||||||
bool m_event_handlers_bound{ false };
|
bool m_event_handlers_bound{ false };
|
||||||
|
|
||||||
GLVolumeCollection m_volumes;
|
GLVolumeCollection m_volumes;
|
||||||
GCodeViewer m_gcode_viewer;
|
GCodeViewer m_gcode_viewer;
|
||||||
|
|
||||||
RenderTimer m_render_timer;
|
RenderTimer m_render_timer;
|
||||||
int64_t m_render_timer_start;
|
|
||||||
|
|
||||||
Selection m_selection;
|
Selection m_selection;
|
||||||
const DynamicPrintConfig* m_config;
|
const DynamicPrintConfig* m_config;
|
||||||
|
|
|
@ -184,7 +184,7 @@ void GLGizmoSimplify::on_render_input_window(float x, float y, float bottom_limi
|
||||||
}
|
}
|
||||||
ImGui::SameLine(m_gui_cfg->bottom_left_width);
|
ImGui::SameLine(m_gui_cfg->bottom_left_width);
|
||||||
if (m_imgui->button(_L("Preview"))) {
|
if (m_imgui->button(_L("Preview"))) {
|
||||||
m_state = State::simplifying;
|
m_state = State::preview;
|
||||||
// simplify but not aply on mesh
|
// simplify but not aply on mesh
|
||||||
process();
|
process();
|
||||||
}
|
}
|
||||||
|
@ -263,23 +263,18 @@ void GLGizmoSimplify::process()
|
||||||
if (m_state == State::canceling) {
|
if (m_state == State::canceling) {
|
||||||
throw SimplifyCanceledException();
|
throw SimplifyCanceledException();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::function<void(int)> statusfn = [&](int percent) {
|
std::function<void(int)> statusfn = [&](int percent) {
|
||||||
m_progress = percent;
|
m_progress = percent;
|
||||||
m_parent.schedule_extra_frame(0);
|
m_parent.schedule_extra_frame(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
indexed_triangle_set collapsed;
|
indexed_triangle_set collapsed;
|
||||||
if (m_last_error.has_value()) {
|
if (m_last_error.has_value() && m_last_count.has_value() &&
|
||||||
// is chance to continue with last reduction
|
(!m_configuration.use_count || triangle_count <= *m_last_count) &&
|
||||||
const indexed_triangle_set &its = m_volume->mesh().its;
|
(!m_configuration.use_error || m_configuration.max_error <= *m_last_error)) {
|
||||||
uint32_t last_triangle_count = static_cast<uint32_t>(its.indices.size());
|
// continue from last reduction - speed up
|
||||||
if ((!m_configuration.use_count || triangle_count <= last_triangle_count) &&
|
collapsed = m_volume->mesh().its; // small copy
|
||||||
(!m_configuration.use_error || m_configuration.max_error <= *m_last_error)) {
|
|
||||||
collapsed = its; // small copy
|
|
||||||
} else {
|
|
||||||
collapsed = *m_original_its; // copy
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
collapsed = *m_original_its; // copy
|
collapsed = *m_original_its; // copy
|
||||||
}
|
}
|
||||||
|
@ -288,14 +283,14 @@ void GLGizmoSimplify::process()
|
||||||
its_quadric_edge_collapse(collapsed, triangle_count, &max_error, throw_on_cancel, statusfn);
|
its_quadric_edge_collapse(collapsed, triangle_count, &max_error, throw_on_cancel, statusfn);
|
||||||
set_its(collapsed);
|
set_its(collapsed);
|
||||||
m_is_valid_result = true;
|
m_is_valid_result = true;
|
||||||
|
m_last_count = triangle_count; // need to store last requirement, collapsed count could be count-1
|
||||||
m_last_error = max_error;
|
m_last_error = max_error;
|
||||||
} catch (SimplifyCanceledException &) {
|
} catch (SimplifyCanceledException &) {
|
||||||
// set state out of main thread
|
// set state out of main thread
|
||||||
|
m_last_error = {};
|
||||||
m_state = State::settings;
|
m_state = State::settings;
|
||||||
}
|
}
|
||||||
// need to render last status fn
|
// need to render last status fn to change bar graph to buttons
|
||||||
// without sleep it freezes until mouse move
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
|
||||||
m_parent.schedule_extra_frame(0);
|
m_parent.schedule_extra_frame(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,17 +36,18 @@ private:
|
||||||
size_t m_obj_index;
|
size_t m_obj_index;
|
||||||
|
|
||||||
std::optional<indexed_triangle_set> m_original_its;
|
std::optional<indexed_triangle_set> m_original_its;
|
||||||
|
|
||||||
std::optional<float> m_last_error; // for use previous reduction
|
std::optional<float> m_last_error; // for use previous reduction
|
||||||
|
std::optional<uint32_t> m_last_count;
|
||||||
|
|
||||||
volatile bool m_need_reload; // after simplify, glReload must be on main thread
|
volatile bool m_need_reload; // after simplify, glReload must be on main thread
|
||||||
std::thread m_worker;
|
std::thread m_worker;
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
settings,
|
settings,
|
||||||
simplifying, // start processing
|
preview, // simplify to show preview
|
||||||
canceling, // canceled
|
close_on_end, // simplify with close on end
|
||||||
successfull, // successful simplified
|
canceling // after button click, before canceled
|
||||||
close_on_end
|
|
||||||
};
|
};
|
||||||
volatile State m_state;
|
volatile State m_state;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue