diff --git a/include/igl/opengl/glfw/Viewer.cpp b/include/igl/opengl/glfw/Viewer.cpp index 76d1604a0..7e3999de2 100644 --- a/include/igl/opengl/glfw/Viewer.cpp +++ b/include/igl/opengl/glfw/Viewer.cpp @@ -477,10 +477,6 @@ namespace glfw IGL_INLINE bool Viewer::key_pressed(unsigned int unicode_key,int modifiers) { - if (callback_key_pressed) - if (callback_key_pressed(*this,unicode_key,modifiers)) - return true; - for (unsigned int i = 0; ikey_pressed(unicode_key, modifiers)) @@ -489,6 +485,10 @@ namespace glfw } } + if (callback_key_pressed) + if (callback_key_pressed(*this,unicode_key,modifiers)) + return true; + switch(unicode_key) { case 'A': @@ -563,25 +563,27 @@ namespace glfw IGL_INLINE bool Viewer::key_down(int key,int modifiers) { - if (callback_key_down) - if (callback_key_down(*this,key,modifiers)) - return true; for (unsigned int i = 0; ikey_down(key, modifiers)) return true; + + if (callback_key_down) + if (callback_key_down(*this,key,modifiers)) + return true; + return false; } IGL_INLINE bool Viewer::key_up(int key,int modifiers) { - if (callback_key_up) - if (callback_key_up(*this,key,modifiers)) - return true; - for (unsigned int i = 0; ikey_up(key, modifiers)) return true; + if (callback_key_up) + if (callback_key_up(*this,key,modifiers)) + return true; + return false; } @@ -591,14 +593,14 @@ namespace glfw down_mouse_x = current_mouse_x; down_mouse_y = current_mouse_y; - if (callback_mouse_down) - if (callback_mouse_down(*this,static_cast(button),modifier)) - return true; - for (unsigned int i = 0; imouse_down(static_cast(button),modifier)) return true; + if (callback_mouse_down) + if (callback_mouse_down(*this,static_cast(button),modifier)) + return true; + down = true; down_translation = core.camera_translation; @@ -651,14 +653,14 @@ namespace glfw { down = false; - if (callback_mouse_up) - if (callback_mouse_up(*this,static_cast(button),modifier)) - return true; - for (unsigned int i = 0; imouse_up(static_cast(button),modifier)) return true; + if (callback_mouse_up) + if (callback_mouse_up(*this,static_cast(button),modifier)) + return true; + mouse_mode = MouseMode::None; return true; @@ -675,14 +677,14 @@ namespace glfw current_mouse_x = mouse_x; current_mouse_y = mouse_y; - if (callback_mouse_move) - if (callback_mouse_move(*this,mouse_x,mouse_y)) - return true; - for (unsigned int i = 0; imouse_move(mouse_x, mouse_y)) return true; + if (callback_mouse_move) + if (callback_mouse_move(*this,mouse_x,mouse_y)) + return true; + if (down) { switch (mouse_mode) @@ -752,14 +754,14 @@ namespace glfw { scroll_position += delta_y; - if (callback_mouse_scroll) - if (callback_mouse_scroll(*this,delta_y)) - return true; - for (unsigned int i = 0; imouse_scroll(delta_y)) return true; + if (callback_mouse_scroll) + if (callback_mouse_scroll(*this,delta_y)) + return true; + // Only zoom if there's actually a change if(delta_y != 0) { @@ -821,16 +823,16 @@ namespace glfw } core.clear_framebuffers(); - if (callback_pre_draw) + for (unsigned int i = 0; ipre_draw()) { return; } } - for (unsigned int i = 0; ipre_draw()) + if (callback_pre_draw(*this)) { return; } @@ -839,13 +841,6 @@ namespace glfw { core.draw(data_list[i]); } - if (callback_post_draw) - { - if (callback_post_draw(*this)) - { - return; - } - } for (unsigned int i = 0; ipost_draw()) @@ -853,6 +848,13 @@ namespace glfw break; } } + if (callback_post_draw) + { + if (callback_post_draw(*this)) + { + return; + } + } } IGL_INLINE void Viewer::resize(int w,int h) diff --git a/include/igl/opengl/glfw/imgui/ImGuiMenu.cpp b/include/igl/opengl/glfw/imgui/ImGuiMenu.cpp index 627e055cb..4a9297c51 100644 --- a/include/igl/opengl/glfw/imgui/ImGuiMenu.cpp +++ b/include/igl/opengl/glfw/imgui/ImGuiMenu.cpp @@ -256,7 +256,7 @@ IGL_INLINE void ImGuiMenu::draw_viewer_menu() { if (ImGui::Checkbox("Face-based", &(viewer->data().face_based))) { - viewer->data().set_face_based(viewer->data().face_based); + viewer->data().dirty = MeshGL::DIRTY_ALL; } ImGui::Checkbox("Show texture", &(viewer->data().show_texture)); if (ImGui::Checkbox("Invert normals", &(viewer->data().invert_normals)))