Browse Source

Fix initial mesh id + make mesh_index const.

Former-commit-id: ba9ca9e2116671e583f562d0dd759a251cb92e0c
Jérémie Dumas 7 years ago
parent
commit
2e43ff6150
2 changed files with 4 additions and 3 deletions
  1. 3 2
      include/igl/opengl/glfw/Viewer.cpp
  2. 1 1
      include/igl/opengl/glfw/Viewer.h

+ 3 - 2
include/igl/opengl/glfw/Viewer.cpp

@@ -286,9 +286,10 @@ namespace glfw
   IGL_INLINE Viewer::Viewer():
   IGL_INLINE Viewer::Viewer():
     data_list(1),
     data_list(1),
     selected_data_index(0),
     selected_data_index(0),
-    next_data_id(0)
+    next_data_id(1)
   {
   {
     window = nullptr;
     window = nullptr;
+    data_list.front().id = 0;
 
 
     // Temporary variables initialization
     // Temporary variables initialization
     down = false;
     down = false;
@@ -934,7 +935,7 @@ namespace glfw
     return true;
     return true;
   }
   }
 
 
-  IGL_INLINE size_t Viewer::mesh_index(const int id) {
+  IGL_INLINE size_t Viewer::mesh_index(const int id) const {
     for (size_t i = 0; i < data_list.size(); ++i)
     for (size_t i = 0; i < data_list.size(); ++i)
     {
     {
       if (data_list[i].id == id)
       if (data_list[i].id == id)

+ 1 - 1
include/igl/opengl/glfw/Viewer.h

@@ -111,7 +111,7 @@ namespace glfw
 
 
     // Retrieve mesh index from its unique identifier
     // Retrieve mesh index from its unique identifier
     // Returns 0 if not found
     // Returns 0 if not found
-    IGL_INLINE size_t mesh_index(const int id);
+    IGL_INLINE size_t mesh_index(const int id) const;
 
 
     // Alec: I call this data_list instead of just data to avoid confusion with
     // Alec: I call this data_list instead of just data to avoid confusion with
     // old "data" variable.
     // old "data" variable.