Prechádzať zdrojové kódy

comments, UINT32 support, return values in keydown 401 example

Former-commit-id: 580166369e4e6d055c91d7fe36c6a9f0daf0829e
Alec Jacobson 10 rokov pred
rodič
commit
f8b6a04516

+ 26 - 0
include/igl/ReAntTweakBar.cpp

@@ -416,6 +416,12 @@ IGL_INLINE std::string igl::ReTwBar::get_value_as_string(
         sstr << *(static_cast<int*>(var));
         break;
       }
+    case TW_TYPE_UINT32:
+      {
+        sstr << "TW_TYPE_UINT32" << " ";
+        sstr << *(static_cast<unsigned int*>(var));
+        break;
+      }
     case TW_TYPE_FLOAT:
       {
         sstr << "TW_TYPE_FLOAT" << " ";
@@ -571,6 +577,7 @@ bool igl::ReTwBar::set_value_from_string(
   float f[4];
   double d[4];
   bool b;
+  unsigned int u;
   unsigned char uc;
   std::string s;
 
@@ -670,6 +677,18 @@ bool igl::ReTwBar::set_value_from_string(
         }
         break;
       }
+    case TW_TYPE_UINT32:
+      {
+        if(sscanf(value_str," %u",&u) == 1)
+        {
+          value = &u;
+        }else
+        {
+          printf("ERROR: Bad value format...\n");
+          return false;
+        }
+        break;
+      }
     case TW_TYPE_FLOAT:
       {
         if(sscanf(value_str," %f",&v) == 1)
@@ -808,6 +827,13 @@ bool igl::ReTwBar::set_value_from_string(
             *ivar = *ivalue;
             break;
           }
+        case TW_TYPE_UINT32:
+          {
+            unsigned int * uvar =   static_cast<unsigned int*>(var);
+            unsigned int * uvalue = static_cast<unsigned int*>(value);
+            *uvar = *uvalue;
+            break;
+          }
         case TW_TYPE_FLOAT:
           {
             float * fvar = static_cast<float*>(var);

+ 1 - 0
include/igl/ReAntTweakBar.h

@@ -25,6 +25,7 @@
 //   TW_TYPE_DIR3D
 //   TW_TYPE_BOOL32
 //   TW_TYPE_INT32
+//   TW_TYPE_UINT32
 //   TW_TYPE_FLOAT
 //   TW_TYPE_DOUBLE
 //   TW_TYPE_UINT8

+ 1 - 1
include/igl/viewer/Viewer.cpp

@@ -585,7 +585,7 @@ namespace igl
     if (key == 'A')
       mouse_scroll(-1);
 
-    // Why aren't these handled view AntTweakBar?
+    // Why aren't these handled via AntTweakBar?
     if (key == 'z') // Don't use 'Z' because that clobbers snap_to_canonical_view_quat
       core.trackball_angle << 0.0f, 0.0f, 0.0f, 1.0f;
 

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

@@ -8,6 +8,9 @@
 
 #ifndef IGL_VIEWER_H
 #define IGL_VIEWER_H
+#ifndef IGL_OPENGL_4
+#define IGL_OPENGL_4
+#endif
 
 #include <AntTweakBar.h>
 

+ 8 - 5
include/igl/viewer/ViewerPlugin.h

@@ -20,11 +20,14 @@ namespace igl
 {
 
 // Abstract class for plugins
-// All plugins MUST have this class as their parent and implement all the callbacks
-// For an example of a basic plugins see plugins/skeleton.h
+// All plugins MUST have this class as their parent and may implement any/all
+// the callbacks marked `virtual` here.
 //
-// Return value of callbacks: returning true to any of the callbacks tells Preview3D that the event has been
-// handled and that it should not be passed to other plugins or to other internal functions of Preview3D
+// /////For an example of a basic plugins see plugins/skeleton.h
+//
+// Return value of callbacks: returning true to any of the callbacks tells
+// Viewer that the event has been handled and that it should not be passed to
+// other plugins or to other internal functions of Viewer
 
 // Forward declaration of the viewer
 class Viewer;
@@ -130,7 +133,7 @@ public:
 
   std::string plugin_name;
 protected:
-  // Pointer to the main Preview3D class
+  // Pointer to the main Viewer class
   Viewer *viewer;
 };
 

+ 3 - 2
tutorial/401_BiharmonicDeformation/main.cpp

@@ -46,12 +46,13 @@ bool key_down(igl::Viewer &viewer, unsigned char key, int mods)
   {
     case ' ':
       viewer.core.is_animating = !viewer.core.is_animating;
-      break;
+      return true;
     case 'D':
     case 'd':
       deformation_field = !deformation_field;
-      break;
+      return true;
   }
+  return false;
 }
 
 int main(int argc, char *argv[])