Эх сурвалжийг харах

un-comment default two-hit case, improve doc

Former-commit-id: bc805baa5526d61b34b3da81bb42c9844bdbb8b8
Alec Jacobson 10 жил өмнө
parent
commit
a3706239b5

+ 13 - 15
include/igl/embree/unproject_in_mesh.cpp

@@ -52,17 +52,16 @@ IGL_INLINE int igl::unproject_in_mesh(
     case 0:
       break;
     case 1:
-    default:
-  {
+    {
       obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
       break;
     }
-    // case 2:
-    // default:
-    // {
-    //   obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
-    //   break;
-    // }
+    case 2:
+    default:
+    {
+      obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
+      break;
+    }
   }
   return hits.size();
 }
@@ -99,17 +98,16 @@ IGL_INLINE int igl::unproject_in_mesh(
     case 0:
       break;
     case 1:
-    default:
     {
       obj = (s + dir*hits[0].t).cast<typename Derivedobj::Scalar>();
       break;
     }
-    // case 2:
-    // default:
-    // {
-    //   obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
-    //   break;
-    // }
+    case 2:
+    default:
+    {
+      obj = 0.5*((s + dir*hits[0].t) + (s + dir*hits[1].t)).cast<typename Derivedobj::Scalar>();
+      break;
+    }
   }
   return hits.size();
 }

+ 4 - 1
include/igl/embree/unproject_in_mesh.h

@@ -20,7 +20,10 @@ namespace igl
 
   #ifndef IGL_OPENGL_4
   // Unproject a screen location (using current opengl viewport, projection, and
-  // model view) to a 3D position
+  // model view) to a 3D position _inside_ a given mesh. If the ray through the
+  // given screen location (x,y) _hits_ the mesh more than twice then the 3D
+  // midpoint between the first two hits is return. If it hits once, then that
+  // point is return. If it does not hit the mesh then obj is not set.
   //
   // Inputs:
   //    x  x-coordinate of mouse location