Просмотр исходного кода

Merge branch 'master' of https://github.com/danielepanozzo/libigl

Former-commit-id: 9198bf897644b24a1b6e2cc73924c960ac798f83
schuellc 10 лет назад
Родитель
Сommit
765cfaa72c

+ 2 - 8
include/igl/boundary_loop.cpp

@@ -63,16 +63,10 @@ IGL_INLINE void igl::boundary_loop(
           if (F(fid,1) == v) vLoc = 1;
           if (F(fid,1) == v) vLoc = 1;
           if (F(fid,2) == v) vLoc = 2;
           if (F(fid,2) == v) vLoc = 2;
 
 
-          int vPrev = F(fid,(vLoc + F.cols()-1) % F.cols());
           int vNext = F(fid,(vLoc + 1) % F.cols());
           int vNext = F(fid,(vLoc + 1) % F.cols());
 
 
-          bool newBndEdge = false;
-          if (unvisited[vPrev] && TT(fid,(vLoc+2) % F.cols()) < 0)
-          {
-            next = vPrev;
-            newBndEdge = true;
-          }
-          else if (unvisited[vNext] && TT(fid,vLoc) < 0)
+          newBndEdge = false;
+          if (unvisited[vNext] && TT(fid,vLoc) < 0)
           {
           {
             next = vNext;
             next = vNext;
             newBndEdge = true;
             newBndEdge = true;

+ 6 - 4
include/igl/embree/EmbreeIntersector.h

@@ -137,7 +137,7 @@ namespace igl
       std::vector<Hit > &hits,
       std::vector<Hit > &hits,
       int& num_rays,
       int& num_rays,
       float tnear = 0,
       float tnear = 0,
-      float tfar = -1,
+      float tfar = std::numeric_limits<float>::infinity(),
       int mask = 0xFFFFFFFF) const;
       int mask = 0xFFFFFFFF) const;
 
 
     // Given a ray find the first hit
     // Given a ray find the first hit
@@ -436,7 +436,9 @@ igl::EmbreeIntersector
   {
   {
     ray.tnear = min_t;
     ray.tnear = min_t;
     ray.tfar = tfar;
     ray.tfar = tfar;
-    ray.primID = -1;
+    ray.geomID = RTC_INVALID_GEOMETRY_ID;
+    ray.primID = RTC_INVALID_GEOMETRY_ID;
+    ray.instID = RTC_INVALID_GEOMETRY_ID;
     num_rays++;
     num_rays++;
     rtcIntersect(scene,ray);
     rtcIntersect(scene,ray);
     if(ray.geomID != RTC_INVALID_GEOMETRY_ID)
     if(ray.geomID != RTC_INVALID_GEOMETRY_ID)
@@ -447,9 +449,9 @@ igl::EmbreeIntersector
         // push min_t a bit more
         // push min_t a bit more
         //double t_push = pow(2.0,self_hits-4)*(hit.t<eps?eps:hit.t);
         //double t_push = pow(2.0,self_hits-4)*(hit.t<eps?eps:hit.t);
         double t_push = pow(2.0,self_hits)*eps;
         double t_push = pow(2.0,self_hits)*eps;
-#ifdef IGL_VERBOSE
+        #ifdef IGL_VERBOSE
         std::cerr<<"  t_push: "<<t_push<<endl;
         std::cerr<<"  t_push: "<<t_push<<endl;
-#endif
+        #endif
         //o = o+t_push*d;
         //o = o+t_push*d;
         min_t += t_push;
         min_t += t_push;
         self_hits++;
         self_hits++;

+ 5 - 2
include/igl/embree/unproject_onto_mesh.cpp

@@ -52,8 +52,11 @@ IGL_INLINE bool igl::unproject_onto_mesh(
   Eigen::Vector3f bc;
   Eigen::Vector3f bc;
   bool hit = unproject_onto_mesh(pos,F,model,proj,viewport,ei,fid,bc);
   bool hit = unproject_onto_mesh(pos,F,model,proj,viewport,ei,fid,bc);
   int i;
   int i;
-  bc.maxCoeff(&i);
-  vid = F(fid,i);
+  if (hit)
+  {
+    bc.maxCoeff(&i);
+    vid = F(fid,i);
+  }
   return hit;
   return hit;
 }
 }
 
 

+ 1 - 1
include/igl/png/texture_from_png.cpp

@@ -62,7 +62,7 @@ IGL_INLINE bool igl::texture_from_png(
       R(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).r;
       R(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).r;
       G(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).g;
       G(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).g;
       B(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).b;
       B(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).b;
-      A(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).a;
+      //1A(i,j) = yimg.at(yimg.width()-1-i,yimg.height()-1-j).a;
     }
     }
   }
   }
 
 

+ 1 - 0
include/igl/viewer/OpenGL_state.cpp

@@ -293,6 +293,7 @@ IGL_INLINE void igl::OpenGL_state::bind_mesh()
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_u, tex_v, 0, GL_RGB, GL_UNSIGNED_BYTE, tex.data());
     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tex_u, tex_v, 0, GL_RGB, GL_UNSIGNED_BYTE, tex.data());
   }
   }
   glUniform1i(shader_mesh.uniform("tex"), 0);
   glUniform1i(shader_mesh.uniform("tex"), 0);

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

@@ -211,7 +211,7 @@ IGL_INLINE void igl::ViewerData::set_uv(const Eigen::MatrixXd& UV)
 IGL_INLINE void igl::ViewerData::set_uv(const Eigen::MatrixXd& UV_V, const Eigen::MatrixXi& UV_F)
 IGL_INLINE void igl::ViewerData::set_uv(const Eigen::MatrixXd& UV_V, const Eigen::MatrixXi& UV_F)
 {
 {
   set_face_based(true);
   set_face_based(true);
-  V_uv = UV_V;
+  V_uv = UV_V.block(0,0,UV_V.rows(),2);
   F_uv = UV_F;
   F_uv = UV_F;
   dirty |= DIRTY_UV;
   dirty |= DIRTY_UV;
 }
 }

+ 2 - 2
tutorial/501_HarmonicParam/main.cpp

@@ -31,7 +31,7 @@ bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
 int main(int argc, char *argv[])
 int main(int argc, char *argv[])
 {
 {
   // Load a mesh in OFF format
   // Load a mesh in OFF format
-  igl::readOFF("D:/libraries/libigl/tutorial/shared/camelhead.off", V, F);
+  igl::readOFF("../shared/camelhead.off", V, F);
 
 
   // Find the open boundary
   // Find the open boundary
   Eigen::VectorXi bnd;
   Eigen::VectorXi bnd;
@@ -43,7 +43,7 @@ int main(int argc, char *argv[])
 
 
   // Harmonic parametrization for the internal vertices
   // Harmonic parametrization for the internal vertices
   igl::harmonic(V,F,bnd,bnd_uv,1,V_uv);
   igl::harmonic(V,F,bnd,bnd_uv,1,V_uv);
-
+  
   // Scale UV to make the texture more clear
   // Scale UV to make the texture more clear
   V_uv *= 5;
   V_uv *= 5;