|
@@ -7,7 +7,7 @@ template <
|
|
|
typename PointMatrixType,
|
|
|
typename FaceMatrixType,
|
|
|
typename RowVector3>
|
|
|
-EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
+igl::EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
::EmbreeIntersector(const PointMatrixType & V, const FaceMatrixType & F)
|
|
|
{
|
|
|
static bool inited = false;
|
|
@@ -41,7 +41,7 @@ template <
|
|
|
typename PointMatrixType,
|
|
|
typename FaceMatrixType,
|
|
|
typename RowVector3>
|
|
|
-EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
+igl::EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
::~EmbreeIntersector()
|
|
|
{
|
|
|
embree::rtcFreeMemory();
|
|
@@ -52,12 +52,12 @@ typename PointMatrixType,
|
|
|
typename FaceMatrixType,
|
|
|
typename RowVector3>
|
|
|
bool
|
|
|
-EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
+igl::EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
::intersectRay(const RowVector3& origin, const RowVector3& direction, embree::Hit &hit) const
|
|
|
{
|
|
|
- embree::Ray ray(toVec3f(origin), toVec3f(direction), 1e-4f);
|
|
|
- _intersector->intersect(ray, hit);
|
|
|
- return hit ;
|
|
|
+ embree::Ray ray(toVec3f(origin), toVec3f(direction), 1e-4f);
|
|
|
+ _intersector->intersect(ray, hit);
|
|
|
+ return hit ;
|
|
|
}
|
|
|
|
|
|
template <
|
|
@@ -65,16 +65,47 @@ typename PointMatrixType,
|
|
|
typename FaceMatrixType,
|
|
|
typename RowVector3>
|
|
|
bool
|
|
|
-EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
+igl::EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
+::intersectRay(
|
|
|
+ const RowVector3& origin,
|
|
|
+ const RowVector3& direction,
|
|
|
+ std::vector<embree::Hit > &hits) const
|
|
|
+{
|
|
|
+ hits.clear();
|
|
|
+ embree::Hit hit;
|
|
|
+ embree::Vec3f o = toVec3f(origin);
|
|
|
+ embree::Vec3f d = toVec3f(direction);
|
|
|
+ while(true)
|
|
|
+ {
|
|
|
+ embree::Ray ray(o,d,embree::zero);
|
|
|
+ _intersector->intersect(ray, hit);
|
|
|
+ if(hit)
|
|
|
+ {
|
|
|
+ hits.push_back(hit);
|
|
|
+ o = o+hit.t*d;
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return hits.empty();
|
|
|
+}
|
|
|
+
|
|
|
+template <
|
|
|
+typename PointMatrixType,
|
|
|
+typename FaceMatrixType,
|
|
|
+typename RowVector3>
|
|
|
+bool
|
|
|
+igl::EmbreeIntersector < PointMatrixType, FaceMatrixType, RowVector3>
|
|
|
::intersectSegment(const RowVector3& a, const RowVector3& ab, embree::Hit &hit) const
|
|
|
{
|
|
|
- embree::Ray ray(toVec3f(a), toVec3f(ab), embree::zero, embree::one);
|
|
|
- _intersector->intersect(ray, hit);
|
|
|
- return hit ;
|
|
|
+ embree::Ray ray(toVec3f(a), toVec3f(ab), embree::zero, embree::one);
|
|
|
+ _intersector->intersect(ray, hit);
|
|
|
+ return hit ;
|
|
|
}
|
|
|
|
|
|
#ifndef IGL_HEADER_ONLY
|
|
|
// Explicit template instanciation
|
|
|
#include <Eigen/Core>
|
|
|
-template class EmbreeIntersector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >;
|
|
|
+template class igl::EmbreeIntersector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >;
|
|
|
#endif
|