Browse Source

fixed bug in camera placement when a single triangle is shown in the viewer

Former-commit-id: 56d51f1b82834be573e110744a73d40111c80d9e
Daniele Panozzo 9 years ago
parent
commit
4025194e25
2 changed files with 6 additions and 5 deletions
  1. 1 0
      .gitignore
  2. 5 5
      include/igl/viewer/ViewerCore.cpp

+ 1 - 0
.gitignore

@@ -90,3 +90,4 @@ tests/build
 tests/bin
 python/build3
 *.pyc
+python/build4

+ 5 - 5
include/igl/viewer/ViewerCore.cpp

@@ -111,12 +111,12 @@ IGL_INLINE void igl::viewer::ViewerCore::get_scale_and_shift_to_fit_mesh(
   if (V.rows() == 0)
     return;
 
-  //Eigen::SparseMatrix<double> M;
-  //igl::massmatrix(V,F,igl::MASSMATRIX_TYPE_VORONOI,M);
-  //const auto & MV = M*V;
-  //Eigen::RowVector3d centroid  = MV.colwise().sum()/M.diagonal().sum();
   Eigen::MatrixXd BC;
-  igl::barycenter(V,F,BC);
+  if (F.rows() <= 1)
+    BC = V;
+  else
+    igl::barycenter(V,F,BC);
+
   Eigen::RowVector3d min_point = BC.colwise().minCoeff();
   Eigen::RowVector3d max_point = BC.colwise().maxCoeff();
   Eigen::RowVector3d centroid  = 0.5*(min_point + max_point);