Bladeren bron

hack to get mouse on down

Former-commit-id: 9e8fc0ff5ca7e54d4cec4700c67797025f4f15c4
Alec Jacobson 11 jaren geleden
bovenliggende
commit
99d2984b89
2 gewijzigde bestanden met toevoegingen van 20 en 8 verwijderingen
  1. 13 8
      include/igl/viewer/Viewer.cpp
  2. 7 0
      include/igl/viewer/Viewer.h

+ 13 - 8
include/igl/viewer/Viewer.cpp

@@ -577,11 +577,14 @@ namespace igl
                " label='Light direction' open help='Change the light direction.' ");
 
     // ---------------------- DRAW OPTIONS ----------------------
-    TwAddVarRW(bar, "Toggle Orthographic/Perspective", TW_TYPE_BOOLCPP, &(options.orthographic),
+    TwAddVarRW(bar, "ToggleOrthographic", TW_TYPE_BOOLCPP, &(options.orthographic),
                " group='Viewing Options'"
                " label='Orthographic view' "
                " help='Toggles orthographic / perspective view. Default: perspective.'");
-
+    TwAddVarRW(bar, "Rotation", TW_TYPE_QUAT4F, &(options.trackball_angle),
+      " group='Viewing Options'"
+      " label='Rotation'"
+      " help='Rotates view.'");
     TwAddVarCB(bar,"Face-based Normals/Colors", TW_TYPE_BOOLCPP, set_face_based_cb, get_face_based_cb, this,
                " group='Draw options'"
                " label='Face-based' key=T help='Toggle per face shading/colors.' ");
@@ -677,6 +680,7 @@ namespace igl
 
     // Temporary variables initialization
     down = false;
+    hack_never_moved = true;
     scroll_position = 0.0f;
 
     // Per face
@@ -1027,6 +1031,12 @@ namespace igl
 
   bool Viewer::mouse_move(int mouse_x, int mouse_y)
   {
+    if(hack_never_moved)
+    {
+      down_mouse_x = mouse_x;
+      down_mouse_y = mouse_y;
+      hack_never_moved = false;
+    }
     current_mouse_x = mouse_x;
     current_mouse_y = mouse_y;
 
@@ -2424,12 +2434,7 @@ namespace igl
     __viewer = this;
 
     // Register callbacks
-    glfwSetKeyCallback(window, glfw_key_callback);
-    glfwSetCursorPosCallback(window,glfw_mouse_move);
-    glfwSetWindowSizeCallback(window,glfw_window_size);
-    glfwSetMouseButtonCallback(window,glfw_mouse_press);
-    glfwSetScrollCallback(window,glfw_mouse_scroll);
-    glfwSetCharCallback(window, glfw_char_callback);
+    glfwSetKeyCallback(window, glfw_key_callback); glfwSetCursorPosCallback(window,glfw_mouse_move); glfwSetWindowSizeCallback(window,glfw_window_size); glfwSetMouseButtonCallback(window,glfw_mouse_press); glfwSetScrollCallback(window,glfw_mouse_scroll); glfwSetCharCallback(window, glfw_char_callback);
 
     // Handle retina displays (windows and mac)
     int width, height;

+ 7 - 0
include/igl/viewer/Viewer.h

@@ -327,6 +327,7 @@ namespace igl
     float down_mouse_z;
     Eigen::Vector3f down_translation;
     bool down;
+    bool hack_never_moved;
 
     // Anttweak bar
     TwBar* bar;
@@ -453,6 +454,8 @@ namespace igl
     static void TW_CALL get_face_based_cb(void *param, void *clientData);
     static void TW_CALL set_invert_normals_cb(const void *param, void *clientData);
     static void TW_CALL get_invert_normals_cb(void *param, void *clientData);
+  public:
+      EIGEN_MAKE_ALIGNED_OPERATOR_NEW
   };
 
 
@@ -573,6 +576,8 @@ namespace igl
   protected:
     // Pointer to the main Preview3D class
     Viewer *viewer;
+  public:
+      EIGEN_MAKE_ALIGNED_OPERATOR_NEW
   };
 
   // Keeps the lists of plugins
@@ -595,6 +600,8 @@ namespace igl
     }
 
     std::vector<Viewer_plugin*> plugin_list;
+  public:
+      EIGEN_MAKE_ALIGNED_OPERATOR_NEW
   };