瀏覽代碼

fixed bug in EmbreeIntersector

Former-commit-id: 0f1514fe653329c795d2aedc7b34f89eb39f2558
schuellc 10 年之前
父節點
當前提交
a5afe2b5e4
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      include/igl/embree/EmbreeIntersector.h

+ 9 - 9
include/igl/embree/EmbreeIntersector.h

@@ -110,7 +110,7 @@ namespace igl
       //   tnear      start of ray segment
       //   tfar       end of ray segment
       //   masks      a 32 bit mask to identify active geometries.
-      //   geoId      id of geometry mask (default -1 if no: no masking)
+      //   geoId      id of geometry mask (default std::numeric_limits<float>::infinity() if no: no masking)
       //   closestHit true for gets closest hit, false for furthest hit
       // Output:
       //   hit        information about hit
@@ -120,7 +120,7 @@ namespace igl
         const Eigen::RowVector3f& direction,
         Hit& hit,
         float tnear = 0,
-        float tfar = -1,
+        float tfar = std::numeric_limits<float>::infinity(),
         int mask = 0xFFFFFFFF,
         int geoId = -1,
         bool closestHit = true) const;
@@ -388,7 +388,8 @@ inline bool igl::embree::EmbreeIntersector::intersectBeam(
       float tfar,
       int mask,
       int geoId,
-      bool closestHit) const
+      bool closestHit,
+	  unsigned int samples) const
 {
   bool hasHit = false;
   Hit bestHit;
@@ -398,19 +399,18 @@ inline bool igl::embree::EmbreeIntersector::intersectBeam(
   else
     bestHit.t = 0;
 
-  if(hasHit = ((intersectRay(origin,direction,hit,tnear,tfar,mask)) && (hit.gid == geoId || geoId == -1)))
+  if(hasHit = (intersectRay(origin,direction,hit,tnear,tfar,mask) && (hit.gid == geoId || geoId == -1)))
     bestHit = hit;
   
   // sample points around actual ray (conservative hitcheck)
-  float eps= 1e-5;
-  int density = 4;
+  const float eps= 1e-5;
         
   Eigen::RowVector3f up(0,1,0);
   Eigen::RowVector3f offset = direction.cross(up).normalized();
 
-  Eigen::Matrix3f rot = Eigen::AngleAxis<float>(2*3.14159265358979/density,direction).toRotationMatrix();
+  Eigen::Matrix3f rot = Eigen::AngleAxis<float>(2*3.14159265358979/samples,direction).toRotationMatrix();
         
-  for(int r=0;r<density;r++)
+  for(int r=0;r<samples;r++)
   {
     if(intersectRay(origin+offset*eps,direction,hit,tnear,tfar,mask) && ((closestHit && (hit.t < bestHit.t)) || (!closestHit && (hit.t > bestHit.t))) && (hit.gid == geoId || geoId == -1))
     {
@@ -447,7 +447,7 @@ igl::embree::EmbreeIntersector
   double min_t = tnear;
   bool large_hits_warned = false;
   RTCRay ray;
-  createRay(ray,origin,direction,tnear,std::numeric_limits<float>::infinity(),mask);
+  createRay(ray,origin,direction,tnear,tfar,mask);
 
   while(true)
   {