浏览代码

dropped serialization defines
dropped external nanogui
removed all references to nanogui


Former-commit-id: c61ad1fed9dab5b3cba12a97b4470ae8447af01b

Daniele Panozzo 7 年之前
父节点
当前提交
56b46751d6

+ 0 - 5
.gitmodules

@@ -1,8 +1,3 @@
-[submodule "external/nanogui"]
-	path = external/nanogui
-	url=https://github.com/libigl/nanogui.git
-	fetchRecursiveSubmodules = true
-	ignore = dirty
 [submodule "external/embree"]
 	path = external/embree
 	url = https://github.com/embree/embree.git

+ 3 - 3
.travis.yml

@@ -7,8 +7,8 @@ matrix:
       compiler: gcc-4.8.1
       script:
         - git submodule update --init --recursive
-        - mkdir external/nanogui/ext/glfw/include/GL
-        - wget --no-check-certificate -P external/nanogui/ext/glfw/include/GL http://www.opengl.org/registry/api/GL/glcorearb.h
+        - mkdir external/glfw/include/GL
+        - wget --no-check-certificate -P external/glfw/include/GL http://www.opengl.org/registry/api/GL/glcorearb.h
         - cd python
         - mkdir build
         - cd build
@@ -63,5 +63,5 @@ matrix:
         - cd tutorial
         - mkdir build
         - cd build
-        - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -DLIBIGL_WITH_NANOGUI=ON ../
+        - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON 
         - make -j 2

+ 0 - 43
include/igl/opengl/ViewerCore.cpp

@@ -204,32 +204,6 @@ IGL_INLINE void igl::opengl::ViewerCore::draw(
       data.meshgl.draw_mesh(false);
       glUniform4f(fixed_colori, 0.0f, 0.0f, 0.0f, 0.0f);
     }
-
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    if (data.show_vertid)
-    {
-      textrenderer.BeginDraw(view*model, proj, viewport, object_scale);
-      for (int i=0; i<data.V.rows(); ++i)
-        textrenderer.DrawText(data.V.row(i),data.V_normals.row(i),to_string(i));
-      textrenderer.EndDraw();
-    }
-
-    if (data.show_faceid)
-    {
-      textrenderer.BeginDraw(view*model, proj, viewport, object_scale);
-
-      for (int i=0; i<data.F.rows(); ++i)
-      {
-        Eigen::RowVector3d p = Eigen::RowVector3d::Zero();
-        for (int j=0;j<data.F.cols();++j)
-          p += data.V.row(data.F(i,j));
-        p /= data.F.cols();
-
-        textrenderer.DrawText(p, data.F_normals.row(i), to_string(i));
-      }
-      textrenderer.EndDraw();
-    }
-#endif
   }
 
   if (data.show_overlay)
@@ -271,17 +245,6 @@ IGL_INLINE void igl::opengl::ViewerCore::draw(
       data.meshgl.draw_overlay_points();
     }
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    if (data.labels_positions.rows() > 0)
-    {
-      textrenderer.BeginDraw(view*model, proj, viewport, object_scale);
-      for (int i=0; i<data.labels_positions.rows(); ++i)
-        textrenderer.DrawText(data.labels_positions.row(i), Eigen::Vector3d(0.0,0.0,0.0),
-            data.labels_strings[i]);
-      textrenderer.EndDraw();
-    }
-#endif
-
     glEnable(GL_DEPTH_TEST);
   }
 
@@ -424,14 +387,8 @@ IGL_INLINE igl::opengl::ViewerCore::ViewerCore()
 
 IGL_INLINE void igl::opengl::ViewerCore::init()
 {
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  textrenderer.Init();
-#endif
 }
 
 IGL_INLINE void igl::opengl::ViewerCore::shut()
 {
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  textrenderer.Shut();
-#endif
 }

+ 0 - 11
include/igl/opengl/ViewerCore.h

@@ -9,9 +9,6 @@
 #define IGL_OPENGL_VIEWERCORE_H
 
 #include <igl/opengl/MeshGL.h>
-#ifdef IGL_VIEWER_WITH_NANOGUI
-#include <igl/opengl/glfw/TextRenderer.h>
-#endif
 #include <igl/opengl/ViewerData.h>
 
 #include <igl/igl_inline.h>
@@ -96,12 +93,6 @@ public:
 
   // ------------------- Properties
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  // Text rendering helper
-  glfw::TextRenderer textrenderer;
-#endif
-
-
   // Colors
   Eigen::Vector4f background_color;
 
@@ -155,7 +146,6 @@ public:
 }
 }
 
-#ifdef ENABLE_SERIALIZATION
 #include <igl/serialize.h>
 namespace igl {
   namespace serialization {
@@ -211,7 +201,6 @@ namespace igl {
     }
   }
 }
-#endif
 
 #ifndef IGL_STATIC_LIBRARY
 #  include "ViewerCore.cpp"

+ 0 - 2
include/igl/opengl/ViewerData.h

@@ -241,7 +241,6 @@ inline const T & ViewerData::attr() const
 
 ////////////////////////////////////////////////////////////////////////////////
 
-#ifdef ENABLE_SERIALIZATION
 #include <igl/serialize.h>
 namespace igl
 {
@@ -297,7 +296,6 @@ namespace igl
     }
   }
 }
-#endif
 
 #ifndef IGL_STATIC_LIBRARY
 #  include "ViewerData.cpp"

+ 9 - 161
include/igl/opengl/glfw/Viewer.cpp

@@ -26,11 +26,6 @@
 #include <limits>
 #include <cassert>
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-#  include <nanogui/formhelper.h>
-#  include <nanogui/screen.h>
-#endif
-
 #include <igl/project.h>
 #include <igl/get_seconds.h>
 #include <igl/readOBJ.h>
@@ -47,9 +42,7 @@
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/unproject.h>
-#ifdef ENABLE_SERIALIZATION
 #include <igl/serialize.h>
-#endif
 
 // Internal global variables used for glfw event handling
 static igl::opengl::glfw::Viewer * __viewer;
@@ -59,12 +52,6 @@ static double scroll_y = 0;
 
 static void glfw_mouse_press(GLFWwindow* window, int button, int action, int modifier)
 {
-  bool tw_used =
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    __viewer->screen->mouseButtonCallbackEvent(button,action,modifier);
-#else
-    false;
-#endif
 
   igl::opengl::glfw::Viewer::MouseButton mb;
 
@@ -76,17 +63,9 @@ static void glfw_mouse_press(GLFWwindow* window, int button, int action, int mod
     mb = igl::opengl::glfw::Viewer::MouseButton::Middle;
 
   if (action == GLFW_PRESS)
-  {
-    if(!tw_used)
-    {
-      __viewer->mouse_down(mb,modifier);
-    }
-  } else
-  {
-    // Always call mouse_up on up
+    __viewer->mouse_down(mb,modifier);
+  else
     __viewer->mouse_up(mb,modifier);
-  }
-
 }
 
 static void glfw_error_callback(int error, const char* description)
@@ -96,14 +75,7 @@ static void glfw_error_callback(int error, const char* description)
 
 static void glfw_char_mods_callback(GLFWwindow* window, unsigned int codepoint, int modifier)
 {
-  // TODO: pass to nanogui (although it's also using physical key down/up
-  // rather than character codes...
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  if(! __viewer->screen->charCallbackEvent(codepoint) )
-#endif
-  {
-    __viewer->key_pressed(codepoint, modifier);
-  }
+  __viewer->key_pressed(codepoint, modifier);
 }
 
 static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int modifier)
@@ -111,15 +83,10 @@ static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int act
   if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
     glfwSetWindowShouldClose(window, GL_TRUE);
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  if (__viewer->screen->keyCallbackEvent(key,scancode,action,modifier) == false)
-#endif
-  {
-    if (action == GLFW_PRESS)
-      __viewer->key_down(key, modifier);
-    else if(action == GLFW_RELEASE)
-      __viewer->key_up(key, modifier);
-  }
+  if (action == GLFW_PRESS)
+    __viewer->key_down(key, modifier);
+  else if(action == GLFW_RELEASE)
+    __viewer->key_up(key, modifier);
 }
 
 static void glfw_window_size(GLFWwindow* window, int width, int height)
@@ -129,20 +96,11 @@ static void glfw_window_size(GLFWwindow* window, int width, int height)
 
   __viewer->post_resize(w, h);
 
-  // TODO: repositioning of the nanogui
 }
 
 static void glfw_mouse_move(GLFWwindow* window, double x, double y)
 {
-  if(
-#ifdef IGL_VIEWER_WITH_NANOGUI
-      __viewer->screen->cursorPosCallbackEvent(x,y) == false &&
-#endif
-      true
-    )
-  {
-    __viewer->mouse_move(x*highdpi, y*highdpi);
-  }
+  __viewer->mouse_move(x*highdpi, y*highdpi);
 }
 
 static void glfw_mouse_scroll(GLFWwindow* window, double x, double y)
@@ -151,19 +109,11 @@ static void glfw_mouse_scroll(GLFWwindow* window, double x, double y)
   scroll_x += x;
   scroll_y += y;
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  if (__viewer->screen->scrollCallbackEvent(x,y) == false)
-#endif
-  {
-    __viewer->mouse_scroll(y);
-  }
+  __viewer->mouse_scroll(y);
 }
 
 static void glfw_drop_callback(GLFWwindow *window,int count,const char **filenames)
 {
-#ifdef IGL_VIEWER_WITH_NANOGUI
-  __viewer->screen->dropCallbackEvent(count,filenames);
-#endif
 }
 
 namespace igl
@@ -234,11 +184,6 @@ namespace glfw
     #endif
     glfwSetInputMode(window,GLFW_CURSOR,GLFW_CURSOR_NORMAL);
     // Initialize FormScreen
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    screen = new nanogui::Screen();
-    screen->initialize(window, false);
-    ngui = new nanogui::FormHelper(screen);
-#endif
     __viewer = this;
     // Register callbacks
     glfwSetKeyCallback(window, glfw_key_callback);
@@ -305,12 +250,6 @@ namespace glfw
     }
     core.shut();
     shutdown_plugins();
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    delete ngui;
-    //delete screen;
-    screen = nullptr;
-    ngui = nullptr;
-#endif
     glfwDestroyWindow(window);
     glfwTerminate();
     return;
@@ -318,77 +257,6 @@ namespace glfw
 
   IGL_INLINE void Viewer::init()
   {
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    using namespace nanogui;
-
-    ngui->setFixedSize(Eigen::Vector2i(60,20));
-
-    // Create nanogui widgets
-    /* nanogui::Window *window = */ ngui->addWindow(Eigen::Vector2i(10,10),"libIGL-Viewer");
-
-    // ---------------------- LOADING ----------------------
-
-  #ifdef ENABLE_SERIALIZATION
-    ngui->addGroup("Workspace");
-    ngui->addButton("Load",[&](){this->load_scene();});
-    ngui->addButton("Save",[&](){this->save_scene();});
-  #endif
-
-  #ifdef ENABLE_IO
-    ngui->addGroup("Mesh");
-    ngui->addButton("Load",[&](){this->open_dialog_load_mesh();});
-    ngui->addButton("Save",[&](){this->open_dialog_save_mesh();});
-  #endif
-
-    ngui->addGroup("Viewing Options");
-    ngui->addButton("Center object",[&](){this->core.align_camera_center(
-      this->data().V,this->data().F);});
-    ngui->addButton("Snap canonical view",[&]()
-    {
-      this->snap_to_canonical_quaternion();
-    });
-    ngui->addVariable("Zoom", core.camera_zoom);
-    ngui->addVariable("Orthographic view", core.orthographic);
-
-    ngui->addGroup("Draw options");
-
-    ngui->addVariable<bool>("Face-based", [&](bool checked)
-    {
-      this->data().set_face_based(checked);
-    },[&]()
-    {
-      return this->data().face_based;
-    });
-
-    ngui->addVariable("Show texture",this->data().show_texture);
-
-    ngui->addVariable<bool>("Invert normals",[&](bool checked)
-    {
-      this->data().dirty |= MeshGL::DIRTY_NORMAL;
-      this->data().invert_normals = checked;
-    },[&]()
-    {
-      return this->data().invert_normals;
-    });
-
-    // Alec: This will probably just attach to the data() at the time
-    // that addVariable is called. We probably need to use a callback here.
-    ngui->addVariable("Show overlay", data().show_overlay);
-    ngui->addVariable("Show overlay depth", data().show_overlay_depth);
-    ngui->addVariable("Line color", (nanogui::Color &) data().line_color);
-    ngui->addVariable("Background", (nanogui::Color &) core.background_color);
-    ngui->addVariable("Shininess", data().shininess);
-
-    ngui->addGroup("Overlays");
-    ngui->addVariable("Wireframe", data().show_lines);
-    ngui->addVariable("Fill", data().show_faces);
-    ngui->addVariable("Show vertex labels", data().show_vertid);
-    ngui->addVariable("Show faces labels", data().show_faceid);
-
-    screen->setVisible(true);
-    screen->performLayout();
-#endif
-
     core.init();
 
     if (callback_init)
@@ -421,11 +289,6 @@ namespace glfw
   {
     window = nullptr;
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    ngui = nullptr;
-    screen = nullptr;
-#endif
-
     // Temporary variables initialization
     down = false;
     hack_never_moved = true;
@@ -915,16 +778,12 @@ namespace glfw
 
   IGL_INLINE bool Viewer::load_scene(std::string fname)
   {
-#ifdef ENABLE_SERIALIZATION
     igl::deserialize(core,"Core",fname.c_str());
-#ifndef ENABLE_SERIALIZATION_CORE_ONLY
     igl::deserialize(data(),"Data",fname.c_str());
     for(unsigned int i = 0; i <plugins.size(); ++i)
     {
       igl::deserialize(*plugins[i],plugins[i]->plugin_name,fname.c_str());
     }
-#endif
-#endif
     return true;
   }
 
@@ -934,17 +793,10 @@ namespace glfw
     if (fname.length() == 0)
       return false;
 
-#ifdef ENABLE_SERIALIZATION
-
     igl::serialize(core,"Core",fname.c_str(),true);
-
-#ifndef ENABLE_SERIALIZATION_CORE_ONLY
     igl::serialize(data(),"Data",fname.c_str());
     for(unsigned int i = 0; i <plugins.size(); ++i)
       igl::serialize(*plugins[i],plugins[i]->plugin_name,fname.c_str());
-#endif
-
-#endif
 
     return true;
   }
@@ -1001,10 +853,6 @@ namespace glfw
         break;
       }
     }
-#ifdef IGL_VIEWER_WITH_NANOGUI
-	screen->drawContents();
-	screen->drawWidgets();
-#endif
   }
 
   IGL_INLINE void Viewer::resize(int w,int h)

+ 0 - 8
include/igl/opengl/glfw/Viewer.h

@@ -30,10 +30,6 @@
 #define IGL_MOD_ALT             0x0004
 #define IGL_MOD_SUPER           0x0008
 
-#ifdef IGL_VIEWER_WITH_NANOGUI
-namespace nanogui { class FormHelper; class Screen; }
-#endif
-
 struct GLFWwindow;
 
 namespace igl
@@ -131,10 +127,6 @@ namespace glfw
     Eigen::Vector3f down_translation;
     bool down;
     bool hack_never_moved;
-#ifdef IGL_VIEWER_WITH_NANOGUI
-    nanogui::FormHelper* ngui;
-    nanogui::Screen* screen;
-#endif
     // Keep track of the global position of the scrollwheel
     float scroll_position;
     // C++-style functions

+ 0 - 2
include/igl/opengl/glfw/ViewerPlugin.h

@@ -162,7 +162,6 @@ protected:
   Viewer *viewer;
 };
 
-#ifdef ENABLE_SERIALIZATION
 namespace serialization
 {
   inline void serialize(const ViewerPlugin& obj,std::vector<char>& buffer)
@@ -175,7 +174,6 @@ namespace serialization
     obj.deserialize(buffer);
   }
 }
-#endif
 
 }
 }

+ 0 - 3
optional/CMakeLists.txt

@@ -33,9 +33,6 @@ find_package(MATLAB QUIET)
 option(LIBIGL_WITH_MATLAB           "Use Matlab"         "${MATLAB_FOUND}")
 find_package(MOSEK  QUIET)
 option(LIBIGL_WITH_MOSEK            "Use MOSEK"          "${MOSEK_FOUND}")
-### Nanogui is off by default because it has many dependencies and generates
-### many issues
-option(LIBIGL_WITH_NANOGUI          "Use Nanogui menu"   OFF)
 option(LIBIGL_WITH_OPENGL           "Use OpenGL"         ON)
 option(LIBIGL_WITH_OPENGL_GLFW      "Use GLFW"           ON)
 option(LIBIGL_WITH_PNG              "Use PNG"            ON)

+ 0 - 1
python/modules/py_igl_opengl_glfw.cpp

@@ -9,7 +9,6 @@
 #include <Eigen/Sparse>
 
 #include "../python_shared.h"
-#define ENABLE_SERIALIZATION
 #include <igl/opengl/glfw/Viewer.h>
 #include <igl/opengl/ViewerCore.h>
 #include <igl/opengl/ViewerData.h>