mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-11 16:00:17 -07:00
Building igl statically and moving to the dep scripts
Fixing dep build script on Windows and removing some warnings. Use bundled igl by default. Not building with the dependency scripts if not explicitly stated. This way, it will stay in Fix the libigl patch to include C source files in header only mode.
This commit is contained in:
parent
89e39e3895
commit
2ae2672ee9
1095 changed files with 181 additions and 5 deletions
584
src/libigl/igl/embree/EmbreeIntersector.h
Normal file
584
src/libigl/igl/embree/EmbreeIntersector.h
Normal file
|
|
@ -0,0 +1,584 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// 2014 Christian Schüller <schuellchr@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
// igl function interface for Embree2.2
|
||||
//
|
||||
// Necessary changes to switch from previous Embree versions:
|
||||
// * Use igl:Hit instead of embree:Hit (where id0 -> id)
|
||||
// * For Embree2.2
|
||||
// * Uncomment #define __USE_RAY_MASK__ in platform.h to enable masking
|
||||
|
||||
#ifndef IGL_EMBREE_EMBREE_INTERSECTOR_H
|
||||
#define IGL_EMBREE_EMBREE_INTERSECTOR_H
|
||||
|
||||
#include "../Hit.h"
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
|
||||
#include "embree2/rtcore.h"
|
||||
#include "embree2/rtcore_ray.h"
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
class EmbreeIntersector
|
||||
{
|
||||
public:
|
||||
// Initialize embree engine. This will be called on instance `init()`
|
||||
// calls. If already inited then this function does nothing: it is harmless
|
||||
// to call more than once.
|
||||
static inline void global_init();
|
||||
private:
|
||||
// Deinitialize the embree engine.
|
||||
static inline void global_deinit();
|
||||
public:
|
||||
typedef Eigen::Matrix<float,Eigen::Dynamic,3> PointMatrixType;
|
||||
typedef Eigen::Matrix<int,Eigen::Dynamic,3> FaceMatrixType;
|
||||
public:
|
||||
inline EmbreeIntersector();
|
||||
private:
|
||||
// Copying and assignment are not allowed.
|
||||
inline EmbreeIntersector(const EmbreeIntersector & that);
|
||||
inline EmbreeIntersector & operator=(const EmbreeIntersector &);
|
||||
public:
|
||||
virtual inline ~EmbreeIntersector();
|
||||
|
||||
// Initialize with a given mesh.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 3 list of vertex positions
|
||||
// F #F by 3 list of Oriented triangles
|
||||
// isStatic scene is optimized for static geometry
|
||||
// Side effects:
|
||||
// The first time this is ever called the embree engine is initialized.
|
||||
inline void init(
|
||||
const PointMatrixType& V,
|
||||
const FaceMatrixType& F,
|
||||
bool isStatic = false);
|
||||
|
||||
// Initialize with a given mesh.
|
||||
//
|
||||
// Inputs:
|
||||
// V vector of #V by 3 list of vertex positions for each geometry
|
||||
// F vector of #F by 3 list of Oriented triangles for each geometry
|
||||
// masks a 32 bit mask to identify active geometries.
|
||||
// isStatic scene is optimized for static geometry
|
||||
// Side effects:
|
||||
// The first time this is ever called the embree engine is initialized.
|
||||
inline void init(
|
||||
const std::vector<const PointMatrixType*>& V,
|
||||
const std::vector<const FaceMatrixType*>& F,
|
||||
const std::vector<int>& masks,
|
||||
bool isStatic = false);
|
||||
|
||||
// Deinitialize embree datasctructures for current mesh. Also called on
|
||||
// destruction: no need to call if you just want to init() once and
|
||||
// destroy.
|
||||
inline void deinit();
|
||||
|
||||
// Given a ray find the first hit
|
||||
//
|
||||
// Inputs:
|
||||
// origin 3d origin point of ray
|
||||
// direction 3d (not necessarily normalized) direction vector of ray
|
||||
// tnear start of ray segment
|
||||
// tfar end of ray segment
|
||||
// masks a 32 bit mask to identify active geometries.
|
||||
// Output:
|
||||
// hit information about hit
|
||||
// Returns true if and only if there was a hit
|
||||
inline bool intersectRay(
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
Hit& hit,
|
||||
float tnear = 0,
|
||||
float tfar = std::numeric_limits<float>::infinity(),
|
||||
int mask = 0xFFFFFFFF) const;
|
||||
|
||||
// Given a ray find the first hit
|
||||
// This is a conservative hit test where multiple rays within a small radius
|
||||
// will be tested and only the closesest hit is returned.
|
||||
//
|
||||
// Inputs:
|
||||
// origin 3d origin point of ray
|
||||
// direction 3d (not necessarily normalized) direction vector of ray
|
||||
// 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 std::numeric_limits<float>::infinity() if no: no masking)
|
||||
// closestHit true for gets closest hit, false for furthest hit
|
||||
// Output:
|
||||
// hit information about hit
|
||||
// Returns true if and only if there was a hit
|
||||
inline bool intersectBeam(
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
Hit& hit,
|
||||
float tnear = 0,
|
||||
float tfar = std::numeric_limits<float>::infinity(),
|
||||
int mask = 0xFFFFFFFF,
|
||||
int geoId = -1,
|
||||
bool closestHit = true,
|
||||
unsigned int samples = 4) const;
|
||||
|
||||
// Given a ray find all hits in order
|
||||
//
|
||||
// Inputs:
|
||||
// origin 3d origin point of ray
|
||||
// direction 3d (not necessarily normalized) direction vector of ray
|
||||
// tnear start of ray segment
|
||||
// tfar end of ray segment
|
||||
// masks a 32 bit mask to identify active geometries.
|
||||
// Output:
|
||||
// hit information about hit
|
||||
// num_rays number of rays shot (at least one)
|
||||
// Returns true if and only if there was a hit
|
||||
inline bool intersectRay(
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
std::vector<Hit > &hits,
|
||||
int& num_rays,
|
||||
float tnear = 0,
|
||||
float tfar = std::numeric_limits<float>::infinity(),
|
||||
int mask = 0xFFFFFFFF) const;
|
||||
|
||||
// Given a ray find the first hit
|
||||
//
|
||||
// Inputs:
|
||||
// a 3d first end point of segment
|
||||
// ab 3d vector from a to other endpoint b
|
||||
// Output:
|
||||
// hit information about hit
|
||||
// Returns true if and only if there was a hit
|
||||
inline bool intersectSegment(
|
||||
const Eigen::RowVector3f& a,
|
||||
const Eigen::RowVector3f& ab,
|
||||
Hit &hit,
|
||||
int mask = 0xFFFFFFFF) const;
|
||||
|
||||
private:
|
||||
|
||||
struct Vertex {float x,y,z,a;};
|
||||
struct Triangle {int v0, v1, v2;};
|
||||
|
||||
RTCScene scene;
|
||||
unsigned geomID;
|
||||
Vertex* vertices;
|
||||
Triangle* triangles;
|
||||
bool initialized;
|
||||
|
||||
inline void createRay(
|
||||
RTCRay& ray,
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
float tnear,
|
||||
float tfar,
|
||||
int mask) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Implementation
|
||||
#include <igl/EPS.h>
|
||||
// This unfortunately cannot be a static field of EmbreeIntersector because it
|
||||
// would depend on the template and then we might end up with initializing
|
||||
// embree twice. If only there was a way to ask embree if it's already
|
||||
// initialized...
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Keeps track of whether the **Global** Embree intersector has been
|
||||
// initialized. This should never been done at the global scope.
|
||||
static bool EmbreeIntersector_inited = false;
|
||||
}
|
||||
}
|
||||
|
||||
inline void igl::embree::EmbreeIntersector::global_init()
|
||||
{
|
||||
if(!EmbreeIntersector_inited)
|
||||
{
|
||||
rtcInit();
|
||||
if(rtcGetError() != RTC_NO_ERROR)
|
||||
std::cerr << "Embree: An error occurred while initializing embree core!" << std::endl;
|
||||
#ifdef IGL_VERBOSE
|
||||
else
|
||||
std::cerr << "Embree: core initialized." << std::endl;
|
||||
#endif
|
||||
EmbreeIntersector_inited = true;
|
||||
}
|
||||
}
|
||||
|
||||
inline void igl::embree::EmbreeIntersector::global_deinit()
|
||||
{
|
||||
EmbreeIntersector_inited = false;
|
||||
rtcExit();
|
||||
}
|
||||
|
||||
inline igl::embree::EmbreeIntersector::EmbreeIntersector()
|
||||
:
|
||||
//scene(NULL),
|
||||
geomID(0),
|
||||
vertices(NULL),
|
||||
triangles(NULL),
|
||||
initialized(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline igl::embree::EmbreeIntersector::EmbreeIntersector(
|
||||
const EmbreeIntersector &)
|
||||
:// To make -Weffc++ happy
|
||||
//scene(NULL),
|
||||
geomID(0),
|
||||
vertices(NULL),
|
||||
triangles(NULL),
|
||||
initialized(false)
|
||||
{
|
||||
assert(false && "Embree: Copying EmbreeIntersector is not allowed");
|
||||
}
|
||||
|
||||
inline igl::embree::EmbreeIntersector & igl::embree::EmbreeIntersector::operator=(
|
||||
const EmbreeIntersector &)
|
||||
{
|
||||
assert(false && "Embree: Assigning an EmbreeIntersector is not allowed");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void igl::embree::EmbreeIntersector::init(
|
||||
const PointMatrixType& V,
|
||||
const FaceMatrixType& F,
|
||||
bool isStatic)
|
||||
{
|
||||
std::vector<const PointMatrixType*> Vtemp;
|
||||
std::vector<const FaceMatrixType*> Ftemp;
|
||||
std::vector<int> masks;
|
||||
Vtemp.push_back(&V);
|
||||
Ftemp.push_back(&F);
|
||||
masks.push_back(0xFFFFFFFF);
|
||||
init(Vtemp,Ftemp,masks,isStatic);
|
||||
}
|
||||
|
||||
inline void igl::embree::EmbreeIntersector::init(
|
||||
const std::vector<const PointMatrixType*>& V,
|
||||
const std::vector<const FaceMatrixType*>& F,
|
||||
const std::vector<int>& masks,
|
||||
bool isStatic)
|
||||
{
|
||||
|
||||
if(initialized)
|
||||
deinit();
|
||||
|
||||
using namespace std;
|
||||
global_init();
|
||||
|
||||
if(V.size() == 0 || F.size() == 0)
|
||||
{
|
||||
std::cerr << "Embree: No geometry specified!";
|
||||
return;
|
||||
}
|
||||
|
||||
// create a scene
|
||||
RTCSceneFlags flags = RTC_SCENE_ROBUST | RTC_SCENE_HIGH_QUALITY;
|
||||
if(isStatic)
|
||||
flags = flags | RTC_SCENE_STATIC;
|
||||
scene = rtcNewScene(flags,RTC_INTERSECT1);
|
||||
|
||||
for(int g=0;g<(int)V.size();g++)
|
||||
{
|
||||
// create triangle mesh geometry in that scene
|
||||
geomID = rtcNewTriangleMesh(scene,RTC_GEOMETRY_STATIC,F[g]->rows(),V[g]->rows(),1);
|
||||
|
||||
// fill vertex buffer
|
||||
vertices = (Vertex*)rtcMapBuffer(scene,geomID,RTC_VERTEX_BUFFER);
|
||||
for(int i=0;i<(int)V[g]->rows();i++)
|
||||
{
|
||||
vertices[i].x = (float)V[g]->coeff(i,0);
|
||||
vertices[i].y = (float)V[g]->coeff(i,1);
|
||||
vertices[i].z = (float)V[g]->coeff(i,2);
|
||||
}
|
||||
rtcUnmapBuffer(scene,geomID,RTC_VERTEX_BUFFER);
|
||||
|
||||
// fill triangle buffer
|
||||
triangles = (Triangle*) rtcMapBuffer(scene,geomID,RTC_INDEX_BUFFER);
|
||||
for(int i=0;i<(int)F[g]->rows();i++)
|
||||
{
|
||||
triangles[i].v0 = (int)F[g]->coeff(i,0);
|
||||
triangles[i].v1 = (int)F[g]->coeff(i,1);
|
||||
triangles[i].v2 = (int)F[g]->coeff(i,2);
|
||||
}
|
||||
rtcUnmapBuffer(scene,geomID,RTC_INDEX_BUFFER);
|
||||
|
||||
rtcSetMask(scene,geomID,masks[g]);
|
||||
}
|
||||
|
||||
rtcCommit(scene);
|
||||
|
||||
if(rtcGetError() != RTC_NO_ERROR)
|
||||
std::cerr << "Embree: An error occurred while initializing the provided geometry!" << endl;
|
||||
#ifdef IGL_VERBOSE
|
||||
else
|
||||
std::cerr << "Embree: geometry added." << endl;
|
||||
#endif
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
igl::embree::EmbreeIntersector
|
||||
::~EmbreeIntersector()
|
||||
{
|
||||
if(initialized)
|
||||
deinit();
|
||||
}
|
||||
|
||||
void igl::embree::EmbreeIntersector::deinit()
|
||||
{
|
||||
if(EmbreeIntersector_inited && scene)
|
||||
{
|
||||
rtcDeleteScene(scene);
|
||||
|
||||
if(rtcGetError() != RTC_NO_ERROR)
|
||||
{
|
||||
std::cerr << "Embree: An error occurred while resetting!" << std::endl;
|
||||
}
|
||||
#ifdef IGL_VERBOSE
|
||||
else
|
||||
{
|
||||
std::cerr << "Embree: geometry removed." << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline bool igl::embree::EmbreeIntersector::intersectRay(
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
Hit& hit,
|
||||
float tnear,
|
||||
float tfar,
|
||||
int mask) const
|
||||
{
|
||||
RTCRay ray;
|
||||
createRay(ray, origin,direction,tnear,tfar,mask);
|
||||
|
||||
// shot ray
|
||||
rtcIntersect(scene,ray);
|
||||
#ifdef IGL_VERBOSE
|
||||
if(rtcGetError() != RTC_NO_ERROR)
|
||||
std::cerr << "Embree: An error occurred while resetting!" << std::endl;
|
||||
#endif
|
||||
|
||||
if((unsigned)ray.geomID != RTC_INVALID_GEOMETRY_ID)
|
||||
{
|
||||
hit.id = ray.primID;
|
||||
hit.gid = ray.geomID;
|
||||
hit.u = ray.u;
|
||||
hit.v = ray.v;
|
||||
hit.t = ray.tfar;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool igl::embree::EmbreeIntersector::intersectBeam(
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
Hit& hit,
|
||||
float tnear,
|
||||
float tfar,
|
||||
int mask,
|
||||
int geoId,
|
||||
bool closestHit,
|
||||
unsigned int samples) const
|
||||
{
|
||||
bool hasHit = false;
|
||||
Hit bestHit;
|
||||
|
||||
if(closestHit)
|
||||
bestHit.t = std::numeric_limits<float>::max();
|
||||
else
|
||||
bestHit.t = 0;
|
||||
|
||||
if((intersectRay(origin,direction,hit,tnear,tfar,mask) && (hit.gid == geoId || geoId == -1)))
|
||||
{
|
||||
bestHit = hit;
|
||||
hasHit = true;
|
||||
}
|
||||
|
||||
// sample points around actual ray (conservative hitcheck)
|
||||
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/samples,direction).toRotationMatrix();
|
||||
|
||||
for(int r=0;r<(int)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))
|
||||
{
|
||||
bestHit = hit;
|
||||
hasHit = true;
|
||||
}
|
||||
offset = rot*offset.transpose();
|
||||
}
|
||||
|
||||
hit = bestHit;
|
||||
return hasHit;
|
||||
}
|
||||
|
||||
inline bool
|
||||
igl::embree::EmbreeIntersector
|
||||
::intersectRay(
|
||||
const Eigen::RowVector3f& origin,
|
||||
const Eigen::RowVector3f& direction,
|
||||
std::vector<Hit > &hits,
|
||||
int& num_rays,
|
||||
float tnear,
|
||||
float tfar,
|
||||
int mask) const
|
||||
{
|
||||
using namespace std;
|
||||
num_rays = 0;
|
||||
hits.clear();
|
||||
int last_id0 = -1;
|
||||
double self_hits = 0;
|
||||
// This epsilon is directly correleated to the number of missed hits, smaller
|
||||
// means more accurate and slower
|
||||
//const double eps = DOUBLE_EPS;
|
||||
const double eps = FLOAT_EPS;
|
||||
double min_t = tnear;
|
||||
bool large_hits_warned = false;
|
||||
RTCRay ray;
|
||||
createRay(ray,origin,direction,tnear,tfar,mask);
|
||||
|
||||
while(true)
|
||||
{
|
||||
ray.tnear = min_t;
|
||||
ray.tfar = tfar;
|
||||
ray.geomID = RTC_INVALID_GEOMETRY_ID;
|
||||
ray.primID = RTC_INVALID_GEOMETRY_ID;
|
||||
ray.instID = RTC_INVALID_GEOMETRY_ID;
|
||||
num_rays++;
|
||||
rtcIntersect(scene,ray);
|
||||
if((unsigned)ray.geomID != RTC_INVALID_GEOMETRY_ID)
|
||||
{
|
||||
// Hit self again, progressively advance
|
||||
if(ray.primID == last_id0 || ray.tfar <= min_t)
|
||||
{
|
||||
// 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)*eps;
|
||||
#ifdef IGL_VERBOSE
|
||||
std::cerr<<" t_push: "<<t_push<<endl;
|
||||
#endif
|
||||
//o = o+t_push*d;
|
||||
min_t += t_push;
|
||||
self_hits++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Hit hit;
|
||||
hit.id = ray.primID;
|
||||
hit.gid = ray.geomID;
|
||||
hit.u = ray.u;
|
||||
hit.v = ray.v;
|
||||
hit.t = ray.tfar;
|
||||
hits.push_back(hit);
|
||||
#ifdef IGL_VERBOSE
|
||||
std::cerr<<" t: "<<hit.t<<endl;
|
||||
#endif
|
||||
// Instead of moving origin, just change min_t. That way calculations
|
||||
// all use exactly same origin values
|
||||
min_t = ray.tfar;
|
||||
|
||||
// reset t_scale
|
||||
self_hits = 0;
|
||||
}
|
||||
last_id0 = ray.primID;
|
||||
}
|
||||
else
|
||||
break; // no more hits
|
||||
|
||||
if(hits.size()>1000 && !large_hits_warned)
|
||||
{
|
||||
std::cout<<"Warning: Large number of hits..."<<endl;
|
||||
std::cout<<"[ ";
|
||||
for(vector<Hit>::iterator hit = hits.begin(); hit != hits.end();hit++)
|
||||
{
|
||||
std::cout<<(hit->id+1)<<" ";
|
||||
}
|
||||
|
||||
std::cout.precision(std::numeric_limits< double >::digits10);
|
||||
std::cout<<"[ ";
|
||||
|
||||
for(vector<Hit>::iterator hit = hits.begin(); hit != hits.end(); hit++)
|
||||
{
|
||||
std::cout<<(hit->t)<<endl;;
|
||||
}
|
||||
|
||||
std::cout<<"]"<<endl;
|
||||
large_hits_warned = true;
|
||||
|
||||
return hits.empty();
|
||||
}
|
||||
}
|
||||
|
||||
return hits.empty();
|
||||
}
|
||||
|
||||
inline bool
|
||||
igl::embree::EmbreeIntersector
|
||||
::intersectSegment(const Eigen::RowVector3f& a, const Eigen::RowVector3f& ab, Hit &hit, int mask) const
|
||||
{
|
||||
RTCRay ray;
|
||||
createRay(ray,a,ab,0,1.0,mask);
|
||||
|
||||
rtcIntersect(scene,ray);
|
||||
|
||||
if((unsigned)ray.geomID != RTC_INVALID_GEOMETRY_ID)
|
||||
{
|
||||
hit.id = ray.primID;
|
||||
hit.gid = ray.geomID;
|
||||
hit.u = ray.u;
|
||||
hit.v = ray.v;
|
||||
hit.t = ray.tfar;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline void
|
||||
igl::embree::EmbreeIntersector
|
||||
::createRay(RTCRay& ray, const Eigen::RowVector3f& origin, const Eigen::RowVector3f& direction, float tnear, float tfar, int mask) const
|
||||
{
|
||||
ray.org[0] = origin[0];
|
||||
ray.org[1] = origin[1];
|
||||
ray.org[2] = origin[2];
|
||||
ray.dir[0] = direction[0];
|
||||
ray.dir[1] = direction[1];
|
||||
ray.dir[2] = direction[2];
|
||||
ray.tnear = tnear;
|
||||
ray.tfar = tfar;
|
||||
ray.geomID = RTC_INVALID_GEOMETRY_ID;
|
||||
ray.primID = RTC_INVALID_GEOMETRY_ID;
|
||||
ray.instID = RTC_INVALID_GEOMETRY_ID;
|
||||
ray.mask = mask;
|
||||
ray.time = 0.0f;
|
||||
}
|
||||
|
||||
#endif //EMBREE_INTERSECTOR_H
|
||||
37
src/libigl/igl/embree/Embree_convenience.h
Normal file
37
src/libigl/igl/embree/Embree_convenience.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_EMBREE_CONVENIENCE_H
|
||||
#define IGL_EMBREE_EMBREE_CONVENIENCE_H
|
||||
|
||||
#undef interface
|
||||
#undef near
|
||||
#undef far
|
||||
// Why are these in quotes? isn't that a bad idea?
|
||||
#ifdef __GNUC__
|
||||
// This is how it should be done
|
||||
# if __GNUC__ >= 4
|
||||
# if __GNUC_MINOR__ >= 6
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Weffc++"
|
||||
# endif
|
||||
# endif
|
||||
// This is a hack
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
#include <embree/include/embree.h>
|
||||
#include <embree/include/intersector1.h>
|
||||
#include <embree/common/ray.h>
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# if __GNUC_MINOR__ >= 6
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
62
src/libigl/igl/embree/ambient_occlusion.cpp
Normal file
62
src/libigl/igl/embree/ambient_occlusion.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "ambient_occlusion.h"
|
||||
#include "../ambient_occlusion.h"
|
||||
#include "EmbreeIntersector.h"
|
||||
#include "../Hit.h"
|
||||
|
||||
template <
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::embree::ambient_occlusion(
|
||||
const igl::embree::EmbreeIntersector & ei,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
const auto & shoot_ray = [&ei](
|
||||
const Eigen::Vector3f& s,
|
||||
const Eigen::Vector3f& dir)->bool
|
||||
{
|
||||
igl::Hit hit;
|
||||
const float tnear = 1e-4f;
|
||||
return ei.intersectRay(s,dir,hit,tnear);
|
||||
};
|
||||
return igl::ambient_occlusion(shoot_ray,P,N,num_samples,S);
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::embree::ambient_occlusion(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
using namespace Eigen;
|
||||
EmbreeIntersector ei;
|
||||
ei.init(V.template cast<float>(),F.template cast<int>());
|
||||
ambient_occlusion(ei,P,N,num_samples,S);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
59
src/libigl/igl/embree/ambient_occlusion.h
Normal file
59
src/libigl/igl/embree/ambient_occlusion.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_AMBIENT_OCCLUSION_H
|
||||
#define IGL_EMBREE_AMBIENT_OCCLUSION_H
|
||||
#include "../igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Forward define
|
||||
class EmbreeIntersector;
|
||||
// Compute ambient occlusion per given point
|
||||
//
|
||||
// Inputs:
|
||||
// ei EmbreeIntersector containing (V,F)
|
||||
// P #P by 3 list of origin points
|
||||
// N #P by 3 list of origin normals
|
||||
// Outputs:
|
||||
// S #P list of ambient occlusion values between 1 (fully occluded) and
|
||||
// 0 (not occluded)
|
||||
//
|
||||
template <
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void ambient_occlusion(
|
||||
const EmbreeIntersector & ei,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
// Wrapper which builds new EmbreeIntersector for (V,F). That's expensive so
|
||||
// avoid this if repeatedly calling.
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void ambient_occlusion(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
}
|
||||
};
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "ambient_occlusion.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
116
src/libigl/igl/embree/bone_heat.cpp
Normal file
116
src/libigl/igl/embree/bone_heat.cpp
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "bone_heat.h"
|
||||
#include "EmbreeIntersector.h"
|
||||
#include "bone_visible.h"
|
||||
#include "../project_to_line_segment.h"
|
||||
#include "../cotmatrix.h"
|
||||
#include "../massmatrix.h"
|
||||
#include "../mat_min.h"
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
bool igl::embree::bone_heat(
|
||||
const Eigen::MatrixXd & V,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixXd & C,
|
||||
const Eigen::VectorXi & P,
|
||||
const Eigen::MatrixXi & BE,
|
||||
const Eigen::MatrixXi & CE,
|
||||
Eigen::MatrixXd & W)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
assert(CE.rows() == 0 && "Cage edges not supported.");
|
||||
assert(C.cols() == V.cols() && "V and C should have same #cols");
|
||||
assert(BE.cols() == 2 && "BE should have #cols=2");
|
||||
assert(F.cols() == 3 && "F should contain triangles.");
|
||||
assert(V.cols() == 3 && "V should contain 3D positions.");
|
||||
|
||||
const int n = V.rows();
|
||||
const int np = P.rows();
|
||||
const int nb = BE.rows();
|
||||
const int m = np + nb;
|
||||
|
||||
// "double sided lighting"
|
||||
MatrixXi FF;
|
||||
FF.resize(F.rows()*2,F.cols());
|
||||
FF << F, F.rowwise().reverse();
|
||||
// Initialize intersector
|
||||
EmbreeIntersector ei;
|
||||
ei.init(V.cast<float>(),F.cast<int>());
|
||||
|
||||
typedef Matrix<bool,Dynamic,1> VectorXb;
|
||||
typedef Matrix<bool,Dynamic,Dynamic> MatrixXb;
|
||||
MatrixXb vis_mask(n,m);
|
||||
// Distances
|
||||
MatrixXd D(n,m);
|
||||
// loop over points
|
||||
for(int j = 0;j<np;j++)
|
||||
{
|
||||
const Vector3d p = C.row(P(j));
|
||||
D.col(j) = (V.rowwise()-p.transpose()).rowwise().norm();
|
||||
VectorXb vj;
|
||||
bone_visible(V,F,ei,p,p,vj);
|
||||
vis_mask.col(j) = vj;
|
||||
}
|
||||
|
||||
// loop over bones
|
||||
for(int j = 0;j<nb;j++)
|
||||
{
|
||||
const Vector3d s = C.row(BE(j,0));
|
||||
const Vector3d d = C.row(BE(j,1));
|
||||
VectorXd t,sqrD;
|
||||
project_to_line_segment(V,s,d,t,sqrD);
|
||||
D.col(np+j) = sqrD.array().sqrt();
|
||||
VectorXb vj;
|
||||
bone_visible(V,F,ei,s,d,vj);
|
||||
vis_mask.col(np+j) = vj;
|
||||
}
|
||||
|
||||
if(CE.rows() > 0)
|
||||
{
|
||||
cerr<<"Error: Cage edges are not supported. Ignored."<<endl;
|
||||
}
|
||||
|
||||
MatrixXd PP = MatrixXd::Zero(n,m);
|
||||
VectorXd min_D;
|
||||
VectorXd Hdiag = VectorXd::Zero(n);
|
||||
VectorXi J;
|
||||
mat_min(D,2,min_D,J);
|
||||
for(int i = 0;i<n;i++)
|
||||
{
|
||||
PP(i,J(i)) = 1;
|
||||
if(vis_mask(i,J(i)))
|
||||
{
|
||||
double hii = pow(min_D(i),-2.);
|
||||
Hdiag(i) = (hii>1e10?1e10:hii);
|
||||
}
|
||||
}
|
||||
SparseMatrix<double> Q,L,M;
|
||||
cotmatrix(V,F,L);
|
||||
massmatrix(V,F,MASSMATRIX_TYPE_DEFAULT,M);
|
||||
const auto & H = Hdiag.asDiagonal();
|
||||
Q = (-L+M*H);
|
||||
SimplicialLLT <SparseMatrix<double > > llt;
|
||||
llt.compute(Q);
|
||||
switch(llt.info())
|
||||
{
|
||||
case Eigen::Success:
|
||||
break;
|
||||
case Eigen::NumericalIssue:
|
||||
cerr<<"Error: Numerical issue."<<endl;
|
||||
return false;
|
||||
default:
|
||||
cerr<<"Error: Other."<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto & rhs = M*H*PP;
|
||||
W = llt.solve(rhs);
|
||||
return true;
|
||||
}
|
||||
47
src/libigl/igl/embree/bone_heat.h
Normal file
47
src/libigl/igl/embree/bone_heat.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_BONE_HEAT_H
|
||||
#define IGL_EMBREE_BONE_HEAT_H
|
||||
#include "../igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// BONE_HEAT Compute skinning weights W given a surface mesh (V,F) and an
|
||||
// internal skeleton (C,BE) according to "Automatic Rigging" [Baran and
|
||||
// Popovic 2007].
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 3 list of mesh vertex positions
|
||||
// F #F by 3 list of mesh corner indices into V
|
||||
// C #C by 3 list of joint locations
|
||||
// P #P list of point handle indices into C
|
||||
// BE #BE by 2 list of bone edge indices into C
|
||||
// CE #CE by 2 list of cage edge indices into **P**
|
||||
// Outputs:
|
||||
// W #V by #P+#BE matrix of weights.
|
||||
// Returns true only on success.
|
||||
//
|
||||
IGL_INLINE bool bone_heat(
|
||||
const Eigen::MatrixXd & V,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixXd & C,
|
||||
const Eigen::VectorXi & P,
|
||||
const Eigen::MatrixXi & BE,
|
||||
const Eigen::MatrixXi & CE,
|
||||
Eigen::MatrixXd & W);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "bone_heat.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
145
src/libigl/igl/embree/bone_visible.cpp
Normal file
145
src/libigl/igl/embree/bone_visible.cpp
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "bone_visible.h"
|
||||
#include "../project_to_line.h"
|
||||
#include "../EPS.h"
|
||||
#include "../Hit.h"
|
||||
#include "../Timer.h"
|
||||
#include <iostream>
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedSD,
|
||||
typename Derivedflag>
|
||||
IGL_INLINE void igl::embree::bone_visible(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & s,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & d,
|
||||
Eigen::PlainObjectBase<Derivedflag> & flag)
|
||||
{
|
||||
// "double sided lighting"
|
||||
Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,Eigen::Dynamic> FF;
|
||||
FF.resize(F.rows()*2,F.cols());
|
||||
FF << F, F.rowwise().reverse();
|
||||
// Initialize intersector
|
||||
EmbreeIntersector ei;
|
||||
ei.init(V.template cast<float>(),FF.template cast<int>());
|
||||
return bone_visible(V,F,ei,s,d,flag);
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedSD,
|
||||
typename Derivedflag>
|
||||
IGL_INLINE void igl::embree::bone_visible(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const EmbreeIntersector & ei,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & s,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & d,
|
||||
Eigen::PlainObjectBase<Derivedflag> & flag)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
flag.resize(V.rows());
|
||||
const double sd_norm = (s-d).norm();
|
||||
// Embree seems to be parallel when constructing but not when tracing rays
|
||||
#pragma omp parallel for
|
||||
// loop over mesh vertices
|
||||
for(int v = 0;v<V.rows();v++)
|
||||
{
|
||||
const Vector3d Vv = V.row(v);
|
||||
// Project vertex v onto line segment sd
|
||||
//embree.intersectSegment
|
||||
double t,sqrd;
|
||||
Vector3d projv;
|
||||
// degenerate bone, just snap to s
|
||||
if(sd_norm < DOUBLE_EPS)
|
||||
{
|
||||
t = 0;
|
||||
sqrd = (Vv-s).array().pow(2).sum();
|
||||
projv = s;
|
||||
}else
|
||||
{
|
||||
// project onto (infinite) line
|
||||
project_to_line(
|
||||
Vv(0),Vv(1),Vv(2),s(0),s(1),s(2),d(0),d(1),d(2),
|
||||
projv(0),projv(1),projv(2),t,sqrd);
|
||||
// handle projections past endpoints
|
||||
if(t<0)
|
||||
{
|
||||
t = 0;
|
||||
sqrd = (Vv-s).array().pow(2).sum();
|
||||
projv = s;
|
||||
} else if(t>1)
|
||||
{
|
||||
t = 1;
|
||||
sqrd = (Vv-d).array().pow(2).sum();
|
||||
projv = d;
|
||||
}
|
||||
}
|
||||
igl::Hit hit;
|
||||
// perhaps 1.0 should be 1.0-epsilon, or actually since we checking the
|
||||
// incident face, perhaps 1.0 should be 1.0+eps
|
||||
const Vector3d dir = (Vv-projv)*1.0;
|
||||
if(ei.intersectSegment(
|
||||
projv.template cast<float>(),
|
||||
dir.template cast<float>(),
|
||||
hit))
|
||||
{
|
||||
// mod for double sided lighting
|
||||
const int fi = hit.id % F.rows();
|
||||
|
||||
//if(v == 1228-1)
|
||||
//{
|
||||
// Vector3d bc,P;
|
||||
// bc << 1 - hit.u - hit.v, hit.u, hit.v; // barycentric
|
||||
// P = V.row(F(fi,0))*bc(0) +
|
||||
// V.row(F(fi,1))*bc(1) +
|
||||
// V.row(F(fi,2))*bc(2);
|
||||
// cout<<(fi+1)<<endl;
|
||||
// cout<<bc.transpose()<<endl;
|
||||
// cout<<P.transpose()<<endl;
|
||||
// cout<<hit.t<<endl;
|
||||
// cout<<(projv + dir*hit.t).transpose()<<endl;
|
||||
// cout<<Vv.transpose()<<endl;
|
||||
//}
|
||||
|
||||
// Assume hit is valid, so not visible
|
||||
flag(v) = false;
|
||||
// loop around corners of triangle
|
||||
for(int c = 0;c<F.cols();c++)
|
||||
{
|
||||
if(F(fi,c) == v)
|
||||
{
|
||||
// hit self, so no hits before, so vertex v is visible
|
||||
flag(v) = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Hit is actually past v
|
||||
if(!flag(v) && (hit.t*hit.t*dir.squaredNorm())>sqrd)
|
||||
{
|
||||
flag(v) = true;
|
||||
}
|
||||
}else
|
||||
{
|
||||
// no hit so vectex v is visible
|
||||
flag(v) = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::embree::bone_visible<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::bone_visible<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
68
src/libigl/igl/embree/bone_visible.h
Normal file
68
src/libigl/igl/embree/bone_visible.h
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_BONE_VISIBLE_H
|
||||
#define IGL_EMBREE_BONE_VISIBLE_H
|
||||
#include <igl/igl_inline.h>
|
||||
#include <Eigen/Core>
|
||||
#include "EmbreeIntersector.h"
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
//
|
||||
// BONE_VISIBLE test whether vertices of mesh are "visible" to a given bone,
|
||||
// where "visible" is defined as in [Baran & Popovic 07]. Instead of checking
|
||||
// whether each point can see *any* of the bone, we just check if each point
|
||||
// can see its own projection onto the bone segment. In other words, we project
|
||||
// each vertex v onto the bone, projv. Then we check if there are any
|
||||
// intersections between the line segment (projv-->v) and the mesh.
|
||||
//
|
||||
// [flag] = bone_visible(V,F,s,d);
|
||||
//
|
||||
// Input:
|
||||
// V #V by 3 list of vertex positions
|
||||
// F #F by 3 list of triangle indices
|
||||
// s row vector of position of start end point of bone
|
||||
// d row vector of position of dest end point of bone
|
||||
// Output:
|
||||
// flag #V by 1 list of bools (true) visible, (false) obstructed
|
||||
//
|
||||
// Note: This checks for hits along the segment which are facing in *any*
|
||||
// direction from the ray.
|
||||
//
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedSD,
|
||||
typename Derivedflag>
|
||||
IGL_INLINE void bone_visible(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & s,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & d,
|
||||
Eigen::PlainObjectBase<Derivedflag> & flag);
|
||||
// Inputs:
|
||||
// ei EmbreeIntersector for mesh (V,F) should be double sided
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedSD,
|
||||
typename Derivedflag>
|
||||
IGL_INLINE void bone_visible(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const EmbreeIntersector & ei,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & s,
|
||||
const Eigen::PlainObjectBase<DerivedSD> & d,
|
||||
Eigen::PlainObjectBase<Derivedflag> & flag);
|
||||
}
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "bone_visible.cpp"
|
||||
#endif
|
||||
#endif
|
||||
257
src/libigl/igl/embree/embree2/rtcore.h
Normal file
257
src/libigl/igl/embree/embree2/rtcore.h
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_H__
|
||||
#define __RTCORE_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(_M_X64)
|
||||
typedef long long ssize_t;
|
||||
#else
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef RTCORE_API
|
||||
#if defined(_WIN32) && !defined(ENABLE_STATIC_LIB)
|
||||
# define RTCORE_API extern "C" __declspec(dllimport)
|
||||
#else
|
||||
# define RTCORE_API extern "C"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# define RTCORE_ALIGN(...) __declspec(align(__VA_ARGS__))
|
||||
#else
|
||||
# define RTCORE_ALIGN(...) __attribute__((aligned(__VA_ARGS__)))
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define RTCORE_DEPRECATED __attribute__((deprecated))
|
||||
#elif defined(_MSC_VER)
|
||||
#define RTCORE_DEPRECATED __declspec(deprecated)
|
||||
#else
|
||||
#define RTCORE_DEPRECATED
|
||||
#endif
|
||||
|
||||
/*! Embree API version */
|
||||
#define RTCORE_VERSION_MAJOR 2
|
||||
#define RTCORE_VERSION_MINOR 9
|
||||
#define RTCORE_VERSION_PATCH 0
|
||||
#define RTCORE_VERSION 20900
|
||||
|
||||
/*! \file rtcore.h Defines the Embree Ray Tracing Kernel API for C and C++
|
||||
|
||||
This file defines the Embree ray tracing kernel API for C and
|
||||
C++. The user is supposed to include this file, and alternatively
|
||||
the rtcore_ray.h file, but none of the other .h files in this
|
||||
folder. */
|
||||
|
||||
/*! \{ */
|
||||
|
||||
/*! Axis aligned bounding box representation */
|
||||
struct RTCORE_ALIGN(16) RTCBounds
|
||||
{
|
||||
float lower_x, lower_y, lower_z, align0;
|
||||
float upper_x, upper_y, upper_z, align1;
|
||||
};
|
||||
|
||||
/*! \brief Defines an opaque device type */
|
||||
typedef struct __RTCDevice {}* RTCDevice;
|
||||
|
||||
/*! \brief Creates a new Embree device.
|
||||
|
||||
Creates a new Embree device to be used by the application. An
|
||||
application typically creates only a single Embree device, but it is
|
||||
valid to use multiple devices inside an application. A configuration
|
||||
string can be passed at construction time, that allows to configure
|
||||
implementation specific parameters. If this string is NULL, a
|
||||
default configuration is used. The following configuration flags are
|
||||
supported by the Embree implementation of the API:
|
||||
|
||||
verbose = num, // sets verbosity level (default is 0)
|
||||
|
||||
If Embree is started on an unsupported CPU, rtcNewDevice will fail and
|
||||
set the RTC_UNSUPPORTED_CPU error code.
|
||||
|
||||
*/
|
||||
RTCORE_API RTCDevice rtcNewDevice(const char* cfg = NULL);
|
||||
|
||||
/*! \brief Deletes an Embree device.
|
||||
|
||||
Deletes the Embree device again. After deletion, all scene handles
|
||||
are invalid. The application should invoke this call before
|
||||
terminating. */
|
||||
RTCORE_API void rtcDeleteDevice(RTCDevice device);
|
||||
|
||||
/*! \brief Initializes the Embree ray tracing core
|
||||
|
||||
WARNING: This function is deprecated, use rtcNewDevice instead.
|
||||
|
||||
Initializes the ray tracing core and passed some configuration
|
||||
string. The configuration string allows to configure implementation
|
||||
specific parameters. If this string is NULL, a default configuration
|
||||
is used. The following configuration flags are supported by the
|
||||
Embree implementation of the API:
|
||||
|
||||
verbose = num, // sets verbosity level (default is 0)
|
||||
|
||||
If Embree is started on an unsupported CPU, rtcInit will fail and
|
||||
set the RTC_UNSUPPORTED_CPU error code.
|
||||
|
||||
*/
|
||||
RTCORE_API RTCORE_DEPRECATED void rtcInit(const char* cfg = NULL);
|
||||
|
||||
/*! \brief Shuts down Embree
|
||||
|
||||
WARNING: This function is deprecated, use rtcDeleteDevice instead.
|
||||
|
||||
Shuts down the ray tracing core. After shutdown, all scene handles
|
||||
are invalid, and invoking any API call except rtcInit is not
|
||||
allowed. The application should invoke this call before
|
||||
terminating. It is safe to call rtcInit again after an rtcExit
|
||||
call. */
|
||||
RTCORE_API RTCORE_DEPRECATED void rtcExit();
|
||||
|
||||
/*! \brief Parameters that can get configured using the rtcSetParameter functions. */
|
||||
enum RTCParameter {
|
||||
RTC_SOFTWARE_CACHE_SIZE = 0, /*! Configures the software cache size (used
|
||||
to cache subdivision surfaces for
|
||||
instance). The size is specified as an
|
||||
integer number of bytes. The software
|
||||
cache cannot be configured during
|
||||
rendering. (write only) */
|
||||
|
||||
RTC_CONFIG_INTERSECT1 = 1, //!< checks if rtcIntersect1 is supported (read only)
|
||||
RTC_CONFIG_INTERSECT4 = 2, //!< checks if rtcIntersect4 is supported (read only)
|
||||
RTC_CONFIG_INTERSECT8 = 3, //!< checks if rtcIntersect8 is supported (read only)
|
||||
RTC_CONFIG_INTERSECT16 = 4, //!< checks if rtcIntersect16 is supported (read only)
|
||||
RTC_CONFIG_INTERSECTN = 5, //!< checks if rtcIntersectN is supported (read only)
|
||||
|
||||
RTC_CONFIG_RAY_MASK = 6, //!< checks if ray masks are supported (read only)
|
||||
RTC_CONFIG_BACKFACE_CULLING = 7, //!< checks if backface culling is supported (read only)
|
||||
RTC_CONFIG_INTERSECTION_FILTER = 8, //!< checks if intersection filters are enabled (read only)
|
||||
RTC_CONFIG_INTERSECTION_FILTER_RESTORE = 9, //!< checks if intersection filters restores previous hit (read only)
|
||||
RTC_CONFIG_BUFFER_STRIDE = 10, //!< checks if buffer strides are supported (read only)
|
||||
RTC_CONFIG_IGNORE_INVALID_RAYS = 11, //!< checks if invalid rays are ignored (read only)
|
||||
RTC_CONFIG_TASKING_SYSTEM = 12, //!< return used tasking system (0 = INTERNAL, 1 = TBB) (read only)
|
||||
|
||||
RTC_CONFIG_VERSION_MAJOR = 13, //!< returns Embree major version (read only)
|
||||
RTC_CONFIG_VERSION_MINOR = 14, //!< returns Embree minor version (read only)
|
||||
RTC_CONFIG_VERSION_PATCH = 15, //!< returns Embree patch version (read only)
|
||||
RTC_CONFIG_VERSION = 16, //!< returns Embree version as integer (e.g. Embree v2.8.2 -> 20802) (read only)
|
||||
};
|
||||
|
||||
/*! \brief Configures some parameters.
|
||||
WARNING: This function is deprecated, use rtcDeviceSetParameter1i instead.
|
||||
*/
|
||||
RTCORE_API RTCORE_DEPRECATED void rtcSetParameter1i(const RTCParameter parm, ssize_t val);
|
||||
|
||||
/*! \brief Reads some device parameter.
|
||||
WARNING: This function is deprecated, use rtcDeviceGetParameter1i instead.
|
||||
*/
|
||||
RTCORE_API RTCORE_DEPRECATED ssize_t rtcGetParameter1i(const RTCParameter parm);
|
||||
|
||||
/*! \brief Configures some device parameters. */
|
||||
RTCORE_API void rtcDeviceSetParameter1i(RTCDevice device, const RTCParameter parm, ssize_t val);
|
||||
|
||||
/*! \brief Reads some device parameter. */
|
||||
RTCORE_API ssize_t rtcDeviceGetParameter1i(RTCDevice device, const RTCParameter parm);
|
||||
|
||||
/*! \brief Error codes returned by the rtcGetError function. */
|
||||
enum RTCError {
|
||||
RTC_NO_ERROR = 0, //!< No error has been recorded.
|
||||
RTC_UNKNOWN_ERROR = 1, //!< An unknown error has occured.
|
||||
RTC_INVALID_ARGUMENT = 2, //!< An invalid argument is specified
|
||||
RTC_INVALID_OPERATION = 3, //!< The operation is not allowed for the specified object.
|
||||
RTC_OUT_OF_MEMORY = 4, //!< There is not enough memory left to execute the command.
|
||||
RTC_UNSUPPORTED_CPU = 5, //!< The CPU is not supported as it does not support SSE2.
|
||||
RTC_CANCELLED = 6, //!< The user has cancelled the operation through the RTC_PROGRESS_MONITOR_FUNCTION callback
|
||||
};
|
||||
|
||||
/*! \brief Returns the value of the per-thread error flag.
|
||||
|
||||
WARNING: This function is deprecated, use rtcDeviceGetError instead.
|
||||
|
||||
If an error occurs this flag is set to an error code if it stores no
|
||||
previous error. The rtcGetError function reads and returns the
|
||||
currently stored error and clears the error flag again. */
|
||||
RTCORE_API RTCORE_DEPRECATED RTCError rtcGetError();
|
||||
|
||||
/*! \brief Returns the value of the per-thread error flag.
|
||||
|
||||
If an error occurs this flag is set to an error code if it stores no
|
||||
previous error. The rtcGetError function reads and returns the
|
||||
currently stored error and clears the error flag again. */
|
||||
RTCORE_API RTCError rtcDeviceGetError(RTCDevice device);
|
||||
|
||||
/*! \brief Type of error callback function. */
|
||||
typedef void (*RTCErrorFunc)(const RTCError code, const char* str);
|
||||
RTCORE_DEPRECATED typedef RTCErrorFunc RTC_ERROR_FUNCTION;
|
||||
|
||||
/*! \brief Sets a callback function that is called whenever an error occurs.
|
||||
WARNING: This function is deprecated, use rtcDeviceSetErrorFunction instead.
|
||||
*/
|
||||
RTCORE_API RTCORE_DEPRECATED void rtcSetErrorFunction(RTCErrorFunc func);
|
||||
|
||||
/*! \brief Sets a callback function that is called whenever an error occurs. */
|
||||
RTCORE_API void rtcDeviceSetErrorFunction(RTCDevice device, RTCErrorFunc func);
|
||||
|
||||
/*! \brief Type of memory consumption callback function. */
|
||||
typedef bool (*RTCMemoryMonitorFunc)(const ssize_t bytes, const bool post);
|
||||
RTCORE_DEPRECATED typedef RTCMemoryMonitorFunc RTC_MEMORY_MONITOR_FUNCTION;
|
||||
|
||||
/*! \brief Sets the memory consumption callback function which is
|
||||
* called before or after the library allocates or frees memory.
|
||||
WARNING: This function is deprecated, use rtcDeviceSetMemoryMonitorFunction instead.
|
||||
*/
|
||||
RTCORE_API RTCORE_DEPRECATED void rtcSetMemoryMonitorFunction(RTCMemoryMonitorFunc func);
|
||||
|
||||
/*! \brief Sets the memory consumption callback function which is
|
||||
* called before or after the library allocates or frees memory. */
|
||||
RTCORE_API void rtcDeviceSetMemoryMonitorFunction(RTCDevice device, RTCMemoryMonitorFunc func);
|
||||
|
||||
/*! \brief Implementation specific (do not call).
|
||||
|
||||
This function is implementation specific and only for debugging
|
||||
purposes. Do not call it. */
|
||||
RTCORE_API RTCORE_DEPRECATED void rtcDebug(); // FIXME: remove
|
||||
|
||||
#include "rtcore_scene.h"
|
||||
#include "rtcore_geometry.h"
|
||||
#include "rtcore_geometry_user.h"
|
||||
|
||||
/*! \brief Helper to easily combing scene flags */
|
||||
inline RTCSceneFlags operator|(const RTCSceneFlags a, const RTCSceneFlags b) {
|
||||
return (RTCSceneFlags)((size_t)a | (size_t)b);
|
||||
}
|
||||
|
||||
/*! \brief Helper to easily combing algorithm flags */
|
||||
inline RTCAlgorithmFlags operator|(const RTCAlgorithmFlags a, const RTCAlgorithmFlags b) {
|
||||
return (RTCAlgorithmFlags)((size_t)a | (size_t)b);
|
||||
}
|
||||
|
||||
/*! \brief Helper to easily combing geometry flags */
|
||||
inline RTCGeometryFlags operator|(const RTCGeometryFlags a, const RTCGeometryFlags b) {
|
||||
return (RTCGeometryFlags)((size_t)a | (size_t)b);
|
||||
}
|
||||
|
||||
/*! \} */
|
||||
|
||||
#endif
|
||||
220
src/libigl/igl/embree/embree2/rtcore.isph
Normal file
220
src/libigl/igl/embree/embree2/rtcore.isph
Normal file
|
|
@ -0,0 +1,220 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_ISPH__
|
||||
#define __RTCORE_ISPH__
|
||||
|
||||
#ifdef _WIN32
|
||||
# define RTCORE_ALIGN(...) // FIXME: need to specify alignment
|
||||
#else
|
||||
# define RTCORE_ALIGN(...) // FIXME: need to specify alignment
|
||||
#endif
|
||||
|
||||
#define RTCORE_DEPRECATED // FIXME: deprecation not supported by ISPC
|
||||
|
||||
/*! Embree API version */
|
||||
#define RTCORE_VERSION_MAJOR 2
|
||||
#define RTCORE_VERSION_MINOR 9
|
||||
#define RTCORE_VERSION_PATCH 0
|
||||
#define RTCORE_VERSION 20900
|
||||
|
||||
/*! \file rtcore.isph Defines the Embree Ray Tracing Kernel API for ISPC.
|
||||
|
||||
This file defines the Embree ray tracing kernel API for C and
|
||||
C++. The user is supposed to include this file, and alternatively
|
||||
the rtcore_ray.isph file, but none of the other .isph files in this
|
||||
folder. */
|
||||
|
||||
/*! \{ */
|
||||
|
||||
/*! Axis aligned bounding box representation */
|
||||
RTCORE_ALIGN(16) struct RTCBounds
|
||||
{
|
||||
float lower_x, lower_y, lower_z, align0;
|
||||
float upper_x, upper_y, upper_z, align1;
|
||||
};
|
||||
|
||||
/*! \brief Defines an opaque device type */
|
||||
typedef uniform struct __RTCDevice {}* uniform RTCDevice;
|
||||
|
||||
/*! \brief Creates a new Embree device.
|
||||
|
||||
Creates a new Embree device to be used by the application. An
|
||||
application typically creates only a single Embree device, but it is
|
||||
valid to use multiple devices inside an application. A configuration
|
||||
string can be passed at construction time, that allows to configure
|
||||
implementation specific parameters. If this string is NULL, a
|
||||
default configuration is used. The following configuration flags are
|
||||
supported by the Embree implementation of the API:
|
||||
|
||||
verbose = num, // sets verbosity level (default is 0)
|
||||
|
||||
If Embree is started on an unsupported CPU, rtcNewDevice will fail and
|
||||
set the RTC_UNSUPPORTED_CPU error code.
|
||||
|
||||
*/
|
||||
RTCDevice rtcNewDevice(const uniform int8* uniform cfg = NULL);
|
||||
|
||||
/*! \brief Deletes an Embree device.
|
||||
|
||||
Deletes the Embree device again. After deletion, all scene handles
|
||||
are invalid. The application should invoke this call before
|
||||
terminating. */
|
||||
void rtcDeleteDevice(RTCDevice device);
|
||||
|
||||
/*! \brief Initializes the Embree ray tracing core
|
||||
|
||||
WARNING: This function is deprecated, use rtcNewDevice instead.
|
||||
|
||||
Initializes the ray tracing core and passed some configuration
|
||||
string. The configuration string allows to configure implementation
|
||||
specific parameters. If this string is NULL, a default configuration
|
||||
is used. The following configuration flags are supported by the
|
||||
Embree implementation of the API:
|
||||
|
||||
verbose = num, // sets verbosity level (default is 0)
|
||||
|
||||
If Embree is started on an unsupported CPU, rtcInit will fail and
|
||||
set the RTC_UNSUPPORTED_CPU error code.
|
||||
|
||||
*/
|
||||
RTCORE_DEPRECATED void rtcInit(const uniform int8* uniform cfg = NULL);
|
||||
|
||||
/*! \brief Shuts down Embree.
|
||||
|
||||
WARNING: This function is deprecated, use rtcDeleteDevice instead.
|
||||
|
||||
Shuts down the ray tracing core. After shutdown, all scene handles
|
||||
are invalid, and invoking any API call except rtcInit is not
|
||||
allowed. The application should invoke this call before
|
||||
terminating. It is safe to call rtcInit again after an rtcExit
|
||||
call. */
|
||||
RTCORE_DEPRECATED void rtcExit();
|
||||
|
||||
/*! \brief Parameters that can get configured using the rtcSetParameter functions. */
|
||||
enum RTCParameter {
|
||||
RTC_SOFTWARE_CACHE_SIZE = 0, /*! Configures the software cache size (used
|
||||
to cache subdivision surfaces for
|
||||
instance). The size is specified as an
|
||||
integer number of bytes. The software
|
||||
cache cannot be configured during
|
||||
rendering. (write only) */
|
||||
|
||||
RTC_CONFIG_INTERSECT1 = 1, //!< checks if rtcIntersect1 is supported (read only)
|
||||
RTC_CONFIG_INTERSECT4 = 2, //!< checks if rtcIntersect4 is supported (read only)
|
||||
RTC_CONFIG_INTERSECT8 = 3, //!< checks if rtcIntersect8 is supported (read only)
|
||||
RTC_CONFIG_INTERSECT16 = 4, //!< checks if rtcIntersect16 is supported (read only)
|
||||
RTC_CONFIG_INTERSECTN = 5, //!< checks if rtcIntersectN is supported (read only)
|
||||
|
||||
RTC_CONFIG_RAY_MASK = 6, //!< checks if ray masks are supported (read only)
|
||||
RTC_CONFIG_BACKFACE_CULLING = 7, //!< checks if backface culling is supported (read only)
|
||||
RTC_CONFIG_INTERSECTION_FILTER = 8, //!< checks if intersection filters are enabled (read only)
|
||||
RTC_CONFIG_INTERSECTION_FILTER_RESTORE = 9, //!< checks if intersection filters restores previous hit (read only)
|
||||
RTC_CONFIG_BUFFER_STRIDE = 10, //!< checks if buffer strides are supported (read only)
|
||||
RTC_CONFIG_IGNORE_INVALID_RAYS = 11, //!< checks if invalid rays are ignored (read only)
|
||||
RTC_CONFIG_TASKING_SYSTEM = 12, //!< return used tasking system (0 = INTERNAL, 1 = TBB) (read only)
|
||||
|
||||
|
||||
RTC_CONFIG_VERSION_MAJOR = 13, //!< returns Embree major version (read only)
|
||||
RTC_CONFIG_VERSION_MINOR = 14, //!< returns Embree minor version (read only)
|
||||
RTC_CONFIG_VERSION_PATCH = 15, //!< returns Embree patch version (read only)
|
||||
RTC_CONFIG_VERSION = 16, //!< returns Embree version as integer (e.g. Embree v2.8.2 -> 20802) (read only)
|
||||
};
|
||||
|
||||
/*! \brief Configures some parameters.
|
||||
WARNING: This function is deprecated, use rtcDeviceSetParameter1i instead.
|
||||
*/
|
||||
RTCORE_DEPRECATED void rtcSetParameter1i(const uniform RTCParameter parm, uniform size_t val); // FIXME: should be ssize_t
|
||||
|
||||
/*! \brief Reads some parameters.
|
||||
WARNING: This function is deprecated, use rtcDeviceGetParameter1i instead.
|
||||
*/
|
||||
uniform size_t rtcGetParameter1i(const uniform RTCParameter parm); // FIXME: should return ssize_t
|
||||
|
||||
/*! \brief Configures some device parameters.*/
|
||||
void rtcDeviceSetParameter1i(RTCDevice device, const uniform RTCParameter parm, uniform size_t val); // FIXME: should be ssize_t
|
||||
|
||||
/*! \brief Reads some device parameters. */
|
||||
uniform size_t rtcDeviceGetParameter1i(RTCDevice device, const uniform RTCParameter parm); // FIXME: should return ssize_t
|
||||
|
||||
/*! \brief Error codes returned by the rtcGetError function. */
|
||||
enum RTCError {
|
||||
RTC_NO_ERROR = 0, //!< No error has been recorded.
|
||||
RTC_UNKNOWN_ERROR = 1, //!< An unknown error has occured.
|
||||
RTC_INVALID_ARGUMENT = 2, //!< An invalid argument is specified
|
||||
RTC_INVALID_OPERATION = 3, //!< The operation is not allowed for the specified object.
|
||||
RTC_OUT_OF_MEMORY = 4, //!< There is not enough memory left to execute the command.
|
||||
RTC_UNSUPPORTED_CPU = 5, //!< The CPU is not supported as it does not support SSE2.
|
||||
RTC_CANCELLED = 6 //!< The user has cancelled the operation through the RTCProgressMonitorFunc callback
|
||||
};
|
||||
|
||||
/*! \brief Returns the value of the per-thread error flag.
|
||||
|
||||
WARNING: This function is deprecated, use rtcDeviceGetError instead.
|
||||
|
||||
If an error occurs this flag is set to an error code if it stores no
|
||||
previous error. The rtcGetError function reads and returns the
|
||||
currently stored error and clears the error flag again. */
|
||||
RTCORE_DEPRECATED uniform RTCError rtcGetError();
|
||||
|
||||
/*! \brief Returns the value of the per-thread error flag.
|
||||
|
||||
If an error occurs this flag is set to an error code if it stores no
|
||||
previous error. The rtcGetError function reads and returns the
|
||||
currently stored error and clears the error flag again. */
|
||||
uniform RTCError rtcDeviceGetError(RTCDevice device);
|
||||
|
||||
/*! \brief Type of error callback function. */
|
||||
typedef void (*uniform RTCErrorFunc)(const uniform RTCError code, const uniform int8* uniform str);
|
||||
RTCORE_DEPRECATED typedef RTCErrorFunc RTC_ERROR_FUNCTION;
|
||||
|
||||
/*! \brief Sets a callback function that is called whenever an error occurs.
|
||||
WARNING: This function is deprecated, use rtcDeviceSetErrorFunction instead.
|
||||
*/
|
||||
RTCORE_DEPRECATED void rtcSetErrorFunction(uniform RTCErrorFunc func);
|
||||
|
||||
/*! \brief Sets a callback function that is called whenever an error occurs. */
|
||||
void rtcDeviceSetErrorFunction(RTCDevice device, uniform RTCErrorFunc func);
|
||||
|
||||
/*! \brief Type of memory consumption callback function. */
|
||||
typedef uniform bool (*uniform RTCMemoryMonitorFunc)(const uniform size_t bytes, const uniform bool post); // FIXME: should be ssize_t
|
||||
RTCORE_DEPRECATED typedef RTCMemoryMonitorFunc RTC_MEMORY_MONITOR_FUNCTION;
|
||||
|
||||
/*! \brief Sets the memory consumption callback function which is
|
||||
* called before the library allocates or after the library frees
|
||||
* memory.
|
||||
* WARNING: This function is deprecated, use rtcDeviceSetMemoryMonitorFunction instead.
|
||||
*/
|
||||
RTCORE_DEPRECATED void rtcSetMemoryMonitorFunction(RTCMemoryMonitorFunc func);
|
||||
|
||||
/*! \brief Sets the memory consumption callback function which is
|
||||
* called before the library allocates or after the library frees
|
||||
* memory. */
|
||||
void rtcDeviceSetMemoryMonitorFunction(RTCDevice device, RTCMemoryMonitorFunc func);
|
||||
|
||||
/*! \brief Implementation specific (do not call).
|
||||
|
||||
This function is implementation specific and only for debugging
|
||||
purposes. Do not call it. */
|
||||
RTCORE_DEPRECATED void rtcDebug(); // FIXME: remove
|
||||
|
||||
#include "rtcore_scene.isph"
|
||||
#include "rtcore_geometry.isph"
|
||||
#include "rtcore_geometry_user.isph"
|
||||
|
||||
/*! \} */
|
||||
|
||||
#endif
|
||||
483
src/libigl/igl/embree/embree2/rtcore_geometry.h
Normal file
483
src/libigl/igl/embree/embree2/rtcore_geometry.h
Normal file
|
|
@ -0,0 +1,483 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_GEOMETRY_H__
|
||||
#define __RTCORE_GEOMETRY_H__
|
||||
|
||||
/*! \ingroup embree_kernel_api */
|
||||
/*! \{ */
|
||||
|
||||
/*! invalid geometry ID */
|
||||
#define RTC_INVALID_GEOMETRY_ID ((unsigned)-1)
|
||||
|
||||
/*! \brief Specifies the type of buffers when mapping buffers */
|
||||
enum RTCBufferType {
|
||||
RTC_INDEX_BUFFER = 0x01000000,
|
||||
|
||||
RTC_VERTEX_BUFFER = 0x02000000,
|
||||
RTC_VERTEX_BUFFER0 = 0x02000000,
|
||||
RTC_VERTEX_BUFFER1 = 0x02000001,
|
||||
|
||||
RTC_USER_VERTEX_BUFFER = 0x02100000,
|
||||
RTC_USER_VERTEX_BUFFER0 = 0x02100000,
|
||||
RTC_USER_VERTEX_BUFFER1 = 0x02100001,
|
||||
|
||||
RTC_FACE_BUFFER = 0x03000000,
|
||||
RTC_LEVEL_BUFFER = 0x04000001,
|
||||
|
||||
RTC_EDGE_CREASE_INDEX_BUFFER = 0x05000000,
|
||||
RTC_EDGE_CREASE_WEIGHT_BUFFER = 0x06000000,
|
||||
|
||||
RTC_VERTEX_CREASE_INDEX_BUFFER = 0x07000000,
|
||||
RTC_VERTEX_CREASE_WEIGHT_BUFFER = 0x08000000,
|
||||
|
||||
RTC_HOLE_BUFFER = 0x09000001,
|
||||
};
|
||||
|
||||
/*! \brief Supported types of matrix layout for functions involving matrices */
|
||||
enum RTCMatrixType {
|
||||
RTC_MATRIX_ROW_MAJOR = 0,
|
||||
RTC_MATRIX_COLUMN_MAJOR = 1,
|
||||
RTC_MATRIX_COLUMN_MAJOR_ALIGNED16 = 2,
|
||||
};
|
||||
|
||||
/*! \brief Supported geometry flags to specify handling in dynamic scenes. */
|
||||
enum RTCGeometryFlags
|
||||
{
|
||||
RTC_GEOMETRY_STATIC = 0, //!< specifies static geometry that will change rarely
|
||||
RTC_GEOMETRY_DEFORMABLE = 1, //!< specifies dynamic geometry with deformable motion (BVH refit possible)
|
||||
RTC_GEOMETRY_DYNAMIC = 2, //!< specifies dynamic geometry with arbitrary motion (BVH refit not possible)
|
||||
};
|
||||
|
||||
/*! \brief Boundary interpolation mode for subdivision surfaces */
|
||||
enum RTCBoundaryMode
|
||||
{
|
||||
RTC_BOUNDARY_NONE = 0, //!< ignores border patches
|
||||
RTC_BOUNDARY_EDGE_ONLY = 1, //!< soft boundary (default)
|
||||
RTC_BOUNDARY_EDGE_AND_CORNER = 2 //!< boundary corner vertices are sharp vertices
|
||||
};
|
||||
|
||||
/*! Intersection filter function for single rays. */
|
||||
typedef void (*RTCFilterFunc)(void* ptr, /*!< pointer to user data */
|
||||
RTCRay& ray /*!< intersection to filter */);
|
||||
|
||||
/*! Intersection filter function for ray packets of size 4. */
|
||||
typedef void (*RTCFilterFunc4)(const void* valid, /*!< pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay4& ray /*!< intersection to filter */);
|
||||
|
||||
/*! Intersection filter function for ray packets of size 8. */
|
||||
typedef void (*RTCFilterFunc8)(const void* valid, /*!< pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay8& ray /*!< intersection to filter */);
|
||||
|
||||
/*! Intersection filter function for ray packets of size 16. */
|
||||
typedef void (*RTCFilterFunc16)(const void* valid, /*!< pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay16& ray /*!< intersection to filter */);
|
||||
|
||||
/*! Displacement mapping function. */
|
||||
typedef void (*RTCDisplacementFunc)(void* ptr, /*!< pointer to user data of geometry */
|
||||
unsigned geomID, /*!< ID of geometry to displace */
|
||||
unsigned primID, /*!< ID of primitive of geometry to displace */
|
||||
const float* u, /*!< u coordinates (source) */
|
||||
const float* v, /*!< v coordinates (source) */
|
||||
const float* nx, /*!< x coordinates of normalized normal at point to displace (source) */
|
||||
const float* ny, /*!< y coordinates of normalized normal at point to displace (source) */
|
||||
const float* nz, /*!< z coordinates of normalized normal at point to displace (source) */
|
||||
float* px, /*!< x coordinates of points to displace (source and target) */
|
||||
float* py, /*!< y coordinates of points to displace (source and target) */
|
||||
float* pz, /*!< z coordinates of points to displace (source and target) */
|
||||
size_t N /*!< number of points to displace */ );
|
||||
|
||||
/*! \brief Creates a new scene instance.
|
||||
|
||||
A scene instance contains a reference to a scene to instantiate and
|
||||
the transformation to instantiate the scene with. An implementation
|
||||
will typically transform the ray with the inverse of the provided
|
||||
transformation and continue traversing the ray through the provided
|
||||
scene. If any geometry is hit, the instance ID (instID) member of
|
||||
the ray will get set to the geometry ID of the instance. */
|
||||
RTCORE_API unsigned rtcNewInstance (RTCScene target, //!< the scene the instance belongs to
|
||||
RTCScene source //!< the scene to instantiate
|
||||
);
|
||||
|
||||
/*! \brief Creates a new scene instance.
|
||||
|
||||
A scene instance contains a reference to a scene to instantiate and
|
||||
the transformation to instantiate the scene with. For motion blurred
|
||||
instances, a number of timesteps can get specified (currently only 1
|
||||
or 2 timesteps are supported). An implementation will typically
|
||||
transform the ray with the inverse of the provided transformation
|
||||
and continue traversing the ray through the provided scene. If any
|
||||
geometry is hit, the instance ID (instID) member of the ray will get
|
||||
set to the geometry ID of the instance. */
|
||||
RTCORE_API unsigned rtcNewInstance2 (RTCScene target, //!< the scene the instance belongs to
|
||||
RTCScene source, //!< the scene to instantiate
|
||||
size_t numTimeSteps = 1); //!< number of timesteps, one matrix per timestep
|
||||
|
||||
/*! \brief Sets transformation of the instance */
|
||||
RTCORE_API void rtcSetTransform (RTCScene scene, //!< scene handle
|
||||
unsigned geomID, //!< ID of geometry
|
||||
RTCMatrixType layout, //!< layout of transformation matrix
|
||||
const float* xfm //!< pointer to transformation matrix
|
||||
);
|
||||
|
||||
|
||||
/*! \brief Sets transformation of the instance for specified timestep */
|
||||
RTCORE_API void rtcSetTransform2 (RTCScene scene, //!< scene handle
|
||||
unsigned int geomID, //!< ID of geometry
|
||||
RTCMatrixType layout, //!< layout of transformation matrix
|
||||
const float* xfm, //!< pointer to transformation matrix
|
||||
size_t timeStep = 0 //!< timestep to set the matrix for
|
||||
);
|
||||
|
||||
/*! \brief Creates a new triangle mesh. The number of triangles
|
||||
(numTriangles), number of vertices (numVertices), and number of time
|
||||
steps (1 for normal meshes, and 2 for linear motion blur), have to
|
||||
get specified. The triangle indices can be set be mapping and
|
||||
writing to the index buffer (RTC_INDEX_BUFFER) and the triangle
|
||||
vertices can be set by mapping and writing into the vertex buffer
|
||||
(RTC_VERTEX_BUFFER). In case of linear motion blur, two vertex
|
||||
buffers have to get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1),
|
||||
one for each time step. The index buffer has the default layout of
|
||||
three 32 bit integer indices for each triangle. An index points to
|
||||
the ith vertex. The vertex buffer stores single precision x,y,z
|
||||
floating point coordinates aligned to 16 bytes. The value of the 4th
|
||||
float used for alignment can be arbitrary. */
|
||||
RTCORE_API unsigned rtcNewTriangleMesh (RTCScene scene, //!< the scene the mesh belongs to
|
||||
RTCGeometryFlags flags, //!< geometry flags
|
||||
size_t numTriangles, //!< number of triangles
|
||||
size_t numVertices, //!< number of vertices
|
||||
size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
|
||||
/*! \brief Creates a new quad mesh. The number of quads
|
||||
(numQuads), number of vertices (numVertices), and number of time
|
||||
steps (1 for normal meshes, and 2 for linear motion blur), have to
|
||||
get specified. The quad indices can be set be mapping and
|
||||
writing to the index buffer (RTC_INDEX_BUFFER) and the quad
|
||||
vertices can be set by mapping and writing into the vertex buffer
|
||||
(RTC_VERTEX_BUFFER). In case of linear motion blur, two vertex
|
||||
buffers have to get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1),
|
||||
one for each time step. The index buffer has the default layout of
|
||||
three 32 bit integer indices for each quad. An index points to
|
||||
the ith vertex. The vertex buffer stores single precision x,y,z
|
||||
floating point coordinates aligned to 16 bytes. The value of the 4th
|
||||
float used for alignment can be arbitrary. */
|
||||
RTCORE_API unsigned rtcNewQuadMesh (RTCScene scene, //!< the scene the mesh belongs to
|
||||
RTCGeometryFlags flags, //!< geometry flags
|
||||
size_t numQuads, //!< number of quads
|
||||
size_t numVertices, //!< number of vertices
|
||||
size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Creates a new subdivision mesh. The number of faces
|
||||
(numFaces), edges/indices (numEdges), vertices (numVertices), edge
|
||||
creases (numEdgeCreases), vertex creases (numVertexCreases), holes
|
||||
(numHoles), and time steps (numTimeSteps) have to get speficied at
|
||||
construction time.
|
||||
|
||||
The following buffers have to get filled by the application: the face
|
||||
buffer (RTC_FACE_BUFFER) contains the number edges/indices (3 or 4)
|
||||
of each of the numFaces faces, the index buffer (RTC_INDEX_BUFFER)
|
||||
contains multiple (3 or 4) 32bit vertex indices for each face and
|
||||
numEdges indices in total, the vertex buffer (RTC_VERTEX_BUFFER)
|
||||
stores numVertices vertices as single precision x,y,z floating point
|
||||
coordinates aligned to 16 bytes. The value of the 4th float used for
|
||||
alignment can be arbitrary.
|
||||
|
||||
Optionally, the application can fill the hole buffer
|
||||
(RTC_HOLE_BUFFER) with numHoles many 32 bit indices of faces that
|
||||
should be considered non-existing.
|
||||
|
||||
Optionally, the application can fill the level buffer
|
||||
(RTC_LEVEL_BUFFER) with a tessellation level for each of the numEdges
|
||||
edges. The subdivision level is a positive floating point value, that
|
||||
specifies how many quads along the edge should get generated during
|
||||
tessellation. The tessellation level is a lower bound, thus the
|
||||
implementation is free to choose a larger level. If no level buffer
|
||||
is specified a level of 1 is used.
|
||||
|
||||
Optionally, the application can fill the sparse edge crease buffers
|
||||
to make some edges appear sharper. The edge crease index buffer
|
||||
(RTC_EDGE_CREASE_INDEX_BUFFER) contains numEdgeCreases many pairs of
|
||||
32 bit vertex indices that specify unoriented edges. The edge crease
|
||||
weight buffer (RTC_EDGE_CREASE_WEIGHT_BUFFER) stores for each of
|
||||
theses crease edges a positive floating point weight. The larger this
|
||||
weight, the sharper the edge. Specifying a weight of infinify is
|
||||
supported and marks an edge as infinitely sharp. Storing an edge
|
||||
multiple times with the same crease weight is allowed, but has lower
|
||||
performance. Storing the an edge multiple times with different
|
||||
crease weights results in undefined behaviour. For a stored edge
|
||||
(i,j), the reverse direction edges (j,i) does not have to get stored,
|
||||
as both are considered the same edge.
|
||||
|
||||
Optionally, the application can fill the sparse vertex crease buffers
|
||||
to make some vertices appear sharper. The vertex crease index buffer
|
||||
(RTC_VERTEX_CREASE_INDEX_BUFFER), contains numVertexCreases many 32
|
||||
bit vertex indices to speficy a set of vertices. The vertex crease
|
||||
weight buffer (RTC_VERTEX_CREASE_WEIGHT_BUFFER) specifies for each of
|
||||
these vertices a positive floating point weight. The larger this
|
||||
weight, the sharper the vertex. Specifying a weight of infinity is
|
||||
supported and makes the vertex infinitely sharp. Storing a vertex
|
||||
multiple times with the same crease weight is allowed, but has lower
|
||||
performance. Storing a vertex multiple times with different crease
|
||||
weights results in undefined behaviour.
|
||||
|
||||
*/
|
||||
RTCORE_API unsigned rtcNewSubdivisionMesh (RTCScene scene, //!< the scene the mesh belongs to
|
||||
RTCGeometryFlags flags, //!< geometry flags
|
||||
size_t numFaces, //!< number of faces
|
||||
size_t numEdges, //!< number of edges
|
||||
size_t numVertices, //!< number of vertices
|
||||
size_t numEdgeCreases, //!< number of edge creases
|
||||
size_t numVertexCreases, //!< number of vertex creases
|
||||
size_t numHoles, //!< number of holes
|
||||
size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Creates a new hair geometry, consisting of multiple hairs
|
||||
represented as cubic bezier curves with varying radii. The number of
|
||||
curves (numCurves), number of vertices (numVertices), and number of
|
||||
time steps (1 for normal curves, and 2 for linear motion blur), have
|
||||
to get specified at construction time. Further, the curve index
|
||||
buffer (RTC_INDEX_BUFFER) and the curve vertex buffer
|
||||
(RTC_VERTEX_BUFFER) have to get set by mapping and writing to the
|
||||
appropiate buffers. In case of linear motion blur, two vertex
|
||||
buffers have to get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1),
|
||||
one for each time step. The index buffer has the default layout of a
|
||||
single 32 bit integer index for each curve, that references the
|
||||
start vertex of the curve. The vertex buffer stores 4 control points
|
||||
per curve, each such control point consists of a single precision
|
||||
(x,y,z) position and radius, stored in that order in
|
||||
memory. Individual hairs are considered to be subpixel sized which
|
||||
allows the implementation to approximate the intersection
|
||||
calculation. This in particular means that zooming onto one hair
|
||||
might show geometric artefacts. */
|
||||
RTCORE_API unsigned rtcNewHairGeometry (RTCScene scene, //!< the scene the curves belong to
|
||||
RTCGeometryFlags flags, //!< geometry flags
|
||||
size_t numCurves, //!< number of curves
|
||||
size_t numVertices, //!< number of vertices
|
||||
size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! Sets a uniform tessellation rate for subdiv meshes and hair
|
||||
* geometry. For subdivision meshes the RTC_LEVEL_BUFFER can also be used
|
||||
* optionally to set a different tessellation rate per edge.*/
|
||||
RTCORE_API void rtcSetTessellationRate (RTCScene scene, unsigned geomID, float tessellationRate);
|
||||
|
||||
/*! \brief Creates a new line segment geometry, consisting of multiple
|
||||
segments with varying radii. The number of line segments (numSegments),
|
||||
number of vertices (numVertices), and number of time steps (1 for
|
||||
normal line segments, and 2 for linear motion blur), have to get
|
||||
specified at construction time. Further, the segment index buffer
|
||||
(RTC_INDEX_BUFFER) and the segment vertex buffer (RTC_VERTEX_BUFFER)
|
||||
have to get set by mapping and writing to the appropiate buffers. In
|
||||
case of linear motion blur, two vertex buffers have to get filled
|
||||
(RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1), one for each time step. The
|
||||
index buffer has the default layout of a single 32 bit integer index
|
||||
for each line segment, that references the start vertex of the segment.
|
||||
The vertex buffer stores 2 end points per line segment, each such point
|
||||
consists of a single precision (x,y,z) position and radius, stored in
|
||||
that order in memory. Individual segments are considered to be subpixel
|
||||
sized which allows the implementation to approximate the intersection
|
||||
calculation. This in particular means that zooming onto one line segment
|
||||
might show geometric artefacts. */
|
||||
RTCORE_API unsigned rtcNewLineSegments (RTCScene scene, //!< the scene the line segments belong to
|
||||
RTCGeometryFlags flags, //!< geometry flags
|
||||
size_t numSegments, //!< number of line segments
|
||||
size_t numVertices, //!< number of vertices
|
||||
size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Sets 32 bit ray mask. */
|
||||
RTCORE_API void rtcSetMask (RTCScene scene, unsigned geomID, int mask);
|
||||
|
||||
/*! \brief Sets boundary interpolation mode for subdivision surfaces */
|
||||
RTCORE_API void rtcSetBoundaryMode(RTCScene scene, unsigned geomID, RTCBoundaryMode mode);
|
||||
|
||||
/*! \brief Maps specified buffer. This function can be used to set index and
|
||||
* vertex buffers of geometries. */
|
||||
RTCORE_API void* rtcMapBuffer(RTCScene scene, unsigned geomID, RTCBufferType type);
|
||||
|
||||
/*! \brief Unmaps specified buffer.
|
||||
|
||||
A buffer has to be unmapped before the rtcEnable, rtcDisable,
|
||||
rtcUpdate, or rtcDeleteGeometry calls are executed. */
|
||||
RTCORE_API void rtcUnmapBuffer(RTCScene scene, unsigned geomID, RTCBufferType type);
|
||||
|
||||
/*! \brief Shares a data buffer between the application and
|
||||
* Embree. The passed buffer is used by Embree to store index and
|
||||
* vertex data. It has to remain valid as long as the mesh exists,
|
||||
* and the user is responsible to free the data when the mesh gets
|
||||
* deleted. One can optionally speficy a byte offset and byte stride
|
||||
* of the elements stored inside the buffer. The addresses
|
||||
* ptr+offset+i*stride have to be aligned to 4 bytes on Xeon CPUs and
|
||||
* 16 bytes on Xeon Phi accelerators. For vertex buffers, the 4 bytes
|
||||
* after the z-coordinate of the last vertex have to be readable memory,
|
||||
* thus padding is required for some layouts. If this function is not
|
||||
* called, Embree will allocate and manage buffers of the default
|
||||
* layout. */
|
||||
RTCORE_API void rtcSetBuffer(RTCScene scene, unsigned geomID, RTCBufferType type,
|
||||
const void* ptr, size_t byteOffset, size_t byteStride);
|
||||
|
||||
/*! \brief Enable geometry. Enabled geometry can be hit by a ray. */
|
||||
RTCORE_API void rtcEnable (RTCScene scene, unsigned geomID);
|
||||
|
||||
/*! \brief Update all geometry buffers.
|
||||
|
||||
Each time geometry buffers got modified, the user has to call some
|
||||
update function to tell the ray tracing engine which buffers got
|
||||
modified. The rtcUpdate function taggs each geometry buffer of the
|
||||
specified geometry as modified. */
|
||||
RTCORE_API void rtcUpdate (RTCScene scene, unsigned geomID);
|
||||
|
||||
/*! \brief Update spefific geometry buffer.
|
||||
|
||||
Each time geometry buffers got modified, the user has to call some
|
||||
update function to tell the ray tracing engine which buffers got
|
||||
modified. The rtcUpdateBuffer function taggs a specific buffer of
|
||||
some geometry as modified. */
|
||||
RTCORE_API void rtcUpdateBuffer (RTCScene scene, unsigned geomID, RTCBufferType type);
|
||||
|
||||
/*! \brief Disable geometry.
|
||||
|
||||
Disabled geometry is not hit by any ray. Disabling and enabling
|
||||
geometry gives higher performance than deleting and recreating
|
||||
geometry. */
|
||||
RTCORE_API void rtcDisable (RTCScene scene, unsigned geomID);
|
||||
|
||||
/*! \brief Sets the displacement function. */
|
||||
RTCORE_API void rtcSetDisplacementFunction (RTCScene scene, unsigned geomID, RTCDisplacementFunc func, RTCBounds* bounds);
|
||||
|
||||
/*! \brief Sets the intersection filter function for single rays. */
|
||||
RTCORE_API void rtcSetIntersectionFilterFunction (RTCScene scene, unsigned geomID, RTCFilterFunc func);
|
||||
|
||||
/*! \brief Sets the intersection filter function for ray packets of size 4. */
|
||||
RTCORE_API void rtcSetIntersectionFilterFunction4 (RTCScene scene, unsigned geomID, RTCFilterFunc4 func);
|
||||
|
||||
/*! \brief Sets the intersection filter function for ray packets of size 8. */
|
||||
RTCORE_API void rtcSetIntersectionFilterFunction8 (RTCScene scene, unsigned geomID, RTCFilterFunc8 func);
|
||||
|
||||
/*! \brief Sets the intersection filter function for ray packets of size 16. */
|
||||
RTCORE_API void rtcSetIntersectionFilterFunction16 (RTCScene scene, unsigned geomID, RTCFilterFunc16 func);
|
||||
|
||||
/*! \brief Sets the occlusion filter function for single rays. */
|
||||
RTCORE_API void rtcSetOcclusionFilterFunction (RTCScene scene, unsigned geomID, RTCFilterFunc func);
|
||||
|
||||
/*! \brief Sets the occlusion filter function for ray packets of size 4. */
|
||||
RTCORE_API void rtcSetOcclusionFilterFunction4 (RTCScene scene, unsigned geomID, RTCFilterFunc4 func);
|
||||
|
||||
/*! \brief Sets the occlusion filter function for ray packets of size 8. */
|
||||
RTCORE_API void rtcSetOcclusionFilterFunction8 (RTCScene scene, unsigned geomID, RTCFilterFunc8 func);
|
||||
|
||||
/*! \brief Sets the occlusion filter function for ray packets of size 16. */
|
||||
RTCORE_API void rtcSetOcclusionFilterFunction16 (RTCScene scene, unsigned geomID, RTCFilterFunc16 func);
|
||||
|
||||
/*! Set pointer for user defined data per geometry. Invokations
|
||||
* of the various user intersect and occluded functions get passed
|
||||
* this data pointer when called. */
|
||||
RTCORE_API void rtcSetUserData (RTCScene scene, unsigned geomID, void* ptr);
|
||||
|
||||
/*! Get pointer for user defined data per geometry based on geomID. */
|
||||
RTCORE_API void* rtcGetUserData (RTCScene scene, unsigned geomID);
|
||||
|
||||
/*! Interpolates user data to some u/v location. The data buffer
|
||||
* specifies per vertex data to interpolate and can be one of the
|
||||
* RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
|
||||
* contain numFloats floating point values to interpolate for each
|
||||
* vertex of the geometry. The dP array will get filled with the
|
||||
* interpolated data and the dPdu and dPdv arrays with the u and v
|
||||
* derivative of the interpolation. If the pointers dP is NULL, the
|
||||
* value will not get calculated. If dPdu and dPdv are NULL the
|
||||
* derivatives will not get calculated. Both dPdu and dPdv have to be
|
||||
* either valid or NULL. The buffer has to be padded at the end such
|
||||
* that the last element can be read safely using SSE
|
||||
* instructions. */
|
||||
RTCORE_API void rtcInterpolate(RTCScene scene, unsigned geomID, unsigned primID, float u, float v, RTCBufferType buffer,
|
||||
float* P, float* dPdu, float* dPdv, size_t numFloats);
|
||||
|
||||
/*! Interpolates user data to some u/v location. The data buffer
|
||||
* specifies per vertex data to interpolate and can be one of the
|
||||
* RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
|
||||
* contain numFloats floating point values to interpolate for each
|
||||
* vertex of the geometry. The P array will get filled with the
|
||||
* interpolated datam the dPdu and dPdv arrays with the u and v
|
||||
* derivative of the interpolation, and the ddPdudu, ddPdvdv, and
|
||||
* ddPdudv arrays with the respective second derivatives. One can
|
||||
* disable 1) the calculation of the interpolated value by setting P
|
||||
* to NULL, 2) the calculation of the 1st order derivatives by
|
||||
* setting dPdu and dPdv to NULL, 3) the calculation of the second
|
||||
* order derivatives by setting ddPdudu, ddPdvdv, and ddPdudv to
|
||||
* NULL. The buffers have to be padded at the end such that the last
|
||||
* element can be read or written safely using SSE instructions. */
|
||||
RTCORE_API void rtcInterpolate2(RTCScene scene, unsigned geomID, unsigned primID, float u, float v, RTCBufferType buffer,
|
||||
float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, size_t numFloats);
|
||||
|
||||
/*! Interpolates user data to an array of u/v locations. The valid
|
||||
* pointer points to an integer array that specified which entries in
|
||||
* the u/v arrays are valid (-1 denotes valid, and 0 invalid). If the
|
||||
* valid pointer is NULL all elements are considers valid. The data
|
||||
* buffer specifies per vertex data to interpolate and can be one of
|
||||
* the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
|
||||
* contain numFloats floating point values to interpolate for each
|
||||
* vertex of the geometry. The P array will get filled with the
|
||||
* interpolated data, and the dPdu and dPdv arrays with the u and v
|
||||
* derivative of the interpolation. If the pointers P is NULL, the
|
||||
* value will not get calculated. If dPdu and dPdv are NULL the
|
||||
* derivatives will not get calculated. Both dPdu and dPdv have to be
|
||||
* either valid or NULL. These destination arrays are filled in
|
||||
* structure of array (SoA) layout. The buffer has to be padded at
|
||||
* the end such that the last element can be read safely using SSE
|
||||
* instructions.*/
|
||||
RTCORE_API void rtcInterpolateN(RTCScene scene, unsigned geomID,
|
||||
const void* valid, const unsigned* primIDs, const float* u, const float* v, size_t numUVs,
|
||||
RTCBufferType buffer,
|
||||
float* P, float* dPdu, float* dPdv, size_t numFloats);
|
||||
|
||||
/*! Interpolates user data to an array of u/v locations. The valid
|
||||
* pointer points to an integer array that specified which entries in
|
||||
* the u/v arrays are valid (-1 denotes valid, and 0 invalid). If the
|
||||
* valid pointer is NULL all elements are considers valid. The data
|
||||
* buffer specifies per vertex data to interpolate and can be one of
|
||||
* the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to
|
||||
* contain numFloats floating point values to interpolate for each
|
||||
* vertex of the geometry. The P array will get filled with the
|
||||
* interpolated datam the dPdu and dPdv arrays with the u and v
|
||||
* derivative of the interpolation, and the ddPdudu, ddPdvdv, and
|
||||
* ddPdudv arrays with the respective second derivatives. One can
|
||||
* disable 1) the calculation of the interpolated value by setting P
|
||||
* to NULL, 2) the calculation of the 1st order derivatives by
|
||||
* setting dPdu and dPdv to NULL, 3) the calculation of the second
|
||||
* order derivatives by setting ddPdudu, ddPdvdv, and ddPdudv to
|
||||
* NULL. These destination arrays are filled in structure of array
|
||||
* (SoA) layout. The buffer has to be padded at the end such that
|
||||
* the last element can be read safely using SSE
|
||||
* instructions. */
|
||||
RTCORE_API void rtcInterpolateN2(RTCScene scene, unsigned geomID,
|
||||
const void* valid, const unsigned* primIDs, const float* u, const float* v, size_t numUVs,
|
||||
RTCBufferType buffer,
|
||||
float* P, float* dPdu, float* dPdv, float* ddPdudu, float* ddPdvdv, float* ddPdudv, size_t numFloats);
|
||||
|
||||
/*! \brief Deletes the geometry. */
|
||||
RTCORE_API void rtcDeleteGeometry (RTCScene scene, unsigned geomID);
|
||||
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
405
src/libigl/igl/embree/embree2/rtcore_geometry.isph
Normal file
405
src/libigl/igl/embree/embree2/rtcore_geometry.isph
Normal file
|
|
@ -0,0 +1,405 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_GEOMETRY_ISPH__
|
||||
#define __RTCORE_GEOMETRY_ISPH__
|
||||
|
||||
/*! \ingroup embree_kernel_api_ispc */
|
||||
/*! \{ */
|
||||
|
||||
/*! invalid geometry ID */
|
||||
#define RTC_INVALID_GEOMETRY_ID ((uniform unsigned int)-1)
|
||||
|
||||
/*! \brief Specifies the type of buffers when mapping buffers */
|
||||
enum RTCBufferType {
|
||||
RTC_INDEX_BUFFER = 0x01000000,
|
||||
|
||||
RTC_VERTEX_BUFFER = 0x02000000,
|
||||
RTC_VERTEX_BUFFER0 = 0x02000000,
|
||||
RTC_VERTEX_BUFFER1 = 0x02000001,
|
||||
|
||||
RTC_USER_VERTEX_BUFFER = 0x02100000,
|
||||
RTC_USER_VERTEX_BUFFER0 = 0x02100000,
|
||||
RTC_USER_VERTEX_BUFFER1 = 0x02100001,
|
||||
|
||||
RTC_FACE_BUFFER = 0x03000000,
|
||||
RTC_LEVEL_BUFFER = 0x04000001,
|
||||
|
||||
RTC_EDGE_CREASE_INDEX_BUFFER = 0x05000000,
|
||||
RTC_EDGE_CREASE_WEIGHT_BUFFER = 0x06000000,
|
||||
|
||||
RTC_VERTEX_CREASE_INDEX_BUFFER = 0x07000000,
|
||||
RTC_VERTEX_CREASE_WEIGHT_BUFFER = 0x08000000,
|
||||
|
||||
RTC_HOLE_BUFFER = 0x09000001,
|
||||
};
|
||||
|
||||
/*! \brief Supported types of matrix layout for functions involving matrices */
|
||||
enum RTCMatrixType {
|
||||
RTC_MATRIX_ROW_MAJOR = 0,
|
||||
RTC_MATRIX_COLUMN_MAJOR = 1,
|
||||
RTC_MATRIX_COLUMN_MAJOR_ALIGNED16 = 2,
|
||||
};
|
||||
|
||||
/*! \brief Supported geometry flags to specify handling in dynamic scenes. */
|
||||
enum RTCGeometryFlags
|
||||
{
|
||||
RTC_GEOMETRY_STATIC = 0, //!< specifies static geometry that will change rarely
|
||||
RTC_GEOMETRY_DEFORMABLE = 1, //!< specifies dynamic geometry with deformable motion (BVH refit possible)
|
||||
RTC_GEOMETRY_DYNAMIC = 2, //!< specifies dynamic geometry with arbitrary motion (BVH refit not possible)
|
||||
};
|
||||
|
||||
/*! \brief Boundary interpolation mode for subdivision surfaces */
|
||||
enum RTCBoundaryMode
|
||||
{
|
||||
RTC_BOUNDARY_NONE = 0, //!< ignores border patches
|
||||
RTC_BOUNDARY_EDGE_ONLY = 1, //!< soft boundary (default)
|
||||
RTC_BOUNDARY_EDGE_AND_CORNER = 2 //!< boundary corner vertices are sharp vertices
|
||||
};
|
||||
|
||||
/*! Intersection filter function for uniform rays. */
|
||||
typedef void (*uniform RTCFilterFuncUniform)(void* uniform ptr, /*!< pointer to user data */
|
||||
uniform RTCRay1& ray /*!< intersection to filter */);
|
||||
|
||||
/*! Intersection filter function for varying rays. */
|
||||
typedef void (*uniform RTCFilterFuncVarying)(void* uniform ptr, /*!< pointer to user data */
|
||||
varying RTCRay& ray /*!< intersection to filter */);
|
||||
|
||||
|
||||
/*! \brief Creates a new scene instance.
|
||||
|
||||
A scene instance contains a reference to a scene to instantiate and
|
||||
the transformation to instantiate the scene with. An implementation
|
||||
will typically transform the ray with the inverse of the provided
|
||||
transformation and continue traversing the ray through the provided
|
||||
scene. If any geometry is hit, the instance ID (instID) member of
|
||||
the ray will get set to the geometry ID of the instance. */
|
||||
uniform unsigned int rtcNewInstance (RTCScene target, //!< the scene the instance belongs to
|
||||
RTCScene source //!< the geometry to instantiate
|
||||
);
|
||||
|
||||
/*! \brief Creates a new scene instance.
|
||||
|
||||
A scene instance contains a reference to a scene to instantiate and
|
||||
the transformation to instantiate the scene with. For motion blurred
|
||||
instances, a number of timesteps can get specified (currently only 1
|
||||
or 2 timesteps are supported). An implementation will typically
|
||||
transform the ray with the inverse of the provided transformation
|
||||
and continue traversing the ray through the provided scene. If any
|
||||
geometry is hit, the instance ID (instID) member of the ray will get
|
||||
set to the geometry ID of the instance. */
|
||||
uniform unsigned rtcNewInstance2 (RTCScene target, //!< the scene the instance belongs to
|
||||
RTCScene source, //!< the scene to instantiate
|
||||
uniform size_t numTimeSteps = 1); //!< number of timesteps, one matrix per timestep
|
||||
|
||||
|
||||
/*! \brief Sets transformation of the instance */
|
||||
void rtcSetTransform (RTCScene scene, //!< scene handle
|
||||
uniform unsigned int geomID, //!< ID of geometry
|
||||
uniform RTCMatrixType layout, //!< layout of transformation matrix
|
||||
const uniform float* uniform xfm //!< pointer to transformation matrix
|
||||
);
|
||||
|
||||
/*! \brief Sets transformation of the instance for specified timestep */
|
||||
void rtcSetTransform2 (RTCScene scene, //!< scene handle
|
||||
uniform unsigned int geomID, //!< ID of geometry
|
||||
uniform RTCMatrixType layout, //!< layout of transformation matrix
|
||||
const uniform float* uniform xfm, //!< pointer to transformation matrix
|
||||
uniform size_t timeStep = 0 //!< timestep to set the matrix for
|
||||
);
|
||||
|
||||
/*! \brief Creates a new triangle mesh. The number of triangles
|
||||
(numTriangles), number of vertices (numVertices), and number of time
|
||||
steps (1 for normal meshes, and 2 for linear motion blur), have to
|
||||
get specified. The triangle indices can be set be mapping and
|
||||
writing to the index buffer (RTC_INDEX_BUFFER) and the triangle
|
||||
vertices can be set by mapping and writing into the vertex buffer
|
||||
(RTC_VERTEX_BUFFER). In case of linear motion blur, two vertex
|
||||
buffers have to get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1),
|
||||
one for each time step. The index buffer has the default layout of
|
||||
three 32 bit integer indices for each triangle. An index points to
|
||||
the ith vertex. The vertex buffer stores single precision x,y,z
|
||||
floating point coordinates aligned to 16 bytes. The value of the 4th
|
||||
float used for alignment can be arbitrary. */
|
||||
uniform unsigned int rtcNewTriangleMesh (RTCScene scene, //!< the scene the mesh belongs to
|
||||
uniform RTCGeometryFlags flags, //!< geometry flags
|
||||
uniform size_t numTriangles, //!< number of triangles
|
||||
uniform size_t numVertices, //!< number of vertices
|
||||
uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Creates a new quad mesh. The number of quads
|
||||
(numQuads), number of vertices (numVertices), and number of time
|
||||
steps (1 for normal meshes, and 2 for linear motion blur), have to
|
||||
get specified. The quad indices can be set be mapping and
|
||||
writing to the index buffer (RTC_INDEX_BUFFER) and the quad
|
||||
vertices can be set by mapping and writing into the vertex buffer
|
||||
(RTC_VERTEX_BUFFER). In case of linear motion blur, two vertex
|
||||
buffers have to get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1),
|
||||
one for each time step. The index buffer has the default layout of
|
||||
three 32 bit integer indices for each quad. An index points to
|
||||
the ith vertex. The vertex buffer stores single precision x,y,z
|
||||
floating point coordinates aligned to 16 bytes. The value of the 4th
|
||||
float used for alignment can be arbitrary. */
|
||||
uniform unsigned int rtcNewQuadMesh (RTCScene scene, //!< the scene the mesh belongs to
|
||||
uniform RTCGeometryFlags flags, //!< geometry flags
|
||||
uniform size_t numQuads, //!< number of quads
|
||||
uniform size_t numVertices, //!< number of vertices
|
||||
uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Creates a new subdivision mesh. The number of faces
|
||||
(numFaces), edges/indices (numEdges), vertices (numVertices), edge
|
||||
creases (numEdgeCreases), vertex creases (numVertexCreases), holes
|
||||
(numHoles), and time steps (numTimeSteps) have to get speficied at
|
||||
construction time.
|
||||
|
||||
The following buffers have to get filled by the application: the face
|
||||
buffer (RTC_FACE_BUFFER) contains the number edges/indices (3 or 4)
|
||||
of each of the numFaces faces, the index buffer (RTC_INDEX_BUFFER)
|
||||
contains multiple (3 or 4) 32bit vertex indices for each face and
|
||||
numEdges indices in total, the vertex buffer (RTC_VERTEX_BUFFER)
|
||||
stores numVertices vertices as single precision x,y,z floating point
|
||||
coordinates aligned to 16 bytes. The value of the 4th float used for
|
||||
alignment can be arbitrary.
|
||||
|
||||
Optionally, the application can fill the hole buffer
|
||||
(RTC_HOLE_BUFFER) with numHoles many 32 bit indices of faces that
|
||||
should be considered non-existing.
|
||||
|
||||
Optionally, the application can fill the level buffer
|
||||
(RTC_LEVEL_BUFFER) with a tessellation level for each of the numEdges
|
||||
edges. The subdivision level is a positive floating point value, that
|
||||
specifies how many quads along the edge should get generated during
|
||||
tessellation. The tessellation level is a lower bound, thus the
|
||||
implementation is free to choose a larger level. If no level buffer
|
||||
is specified a level of 1 is used.
|
||||
|
||||
Optionally, the application can fill the sparse edge crease buffers
|
||||
to make some edges appear sharper. The edge crease index buffer
|
||||
(RTC_EDGE_CREASE_INDEX_BUFFER) contains numEdgeCreases many pairs of
|
||||
32 bit vertex indices that specify unoriented edges. The edge crease
|
||||
weight buffer (RTC_EDGE_CREASE_WEIGHT_BUFFER) stores for each of
|
||||
theses crease edges a positive floating point weight. The larger this
|
||||
weight, the sharper the edge. Specifying a weight of infinify is
|
||||
supported and marks an edge as infinitely sharp. Storing an edge
|
||||
multiple times with the same crease weight is allowed, but has lower
|
||||
performance. Storing the an edge multiple times with different
|
||||
crease weights results in undefined behaviour. For a stored edge
|
||||
(i,j), the reverse direction edges (j,i) does not have to get stored,
|
||||
as both are considered the same edge.
|
||||
|
||||
Optionally, the application can fill the sparse vertex crease buffers
|
||||
to make some vertices appear sharper. The vertex crease index buffer
|
||||
(RTC_VERTEX_CREASE_INDEX_BUFFER), contains numVertexCreases many 32
|
||||
bit vertex indices to speficy a set of vertices. The vertex crease
|
||||
weight buffer (RTC_VERTEX_CREASE_WEIGHT_BUFFER) specifies for each of
|
||||
these vertices a positive floating point weight. The larger this
|
||||
weight, the sharper the vertex. Specifying a weight of infinity is
|
||||
supported and makes the vertex infinitely sharp. Storing a vertex
|
||||
multiple times with the same crease weight is allowed, but has lower
|
||||
performance. Storing a vertex multiple times with different crease
|
||||
weights results in undefined behaviour.
|
||||
|
||||
*/
|
||||
|
||||
uniform unsigned int rtcNewSubdivisionMesh (RTCScene scene, //!< the scene the mesh belongs to
|
||||
uniform RTCGeometryFlags flags, //!< geometry flags
|
||||
uniform size_t numFaces, //!< number of faces
|
||||
uniform size_t numEdges, //!< number of edges
|
||||
uniform size_t numVertices, //!< number of vertices
|
||||
uniform size_t numEdgeCreases, //!< number of edge creases
|
||||
uniform size_t numVertexCreases, //!< number of vertex creases
|
||||
uniform size_t numHoles, //!< number of holes
|
||||
uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Creates a new hair geometry, consisting of multiple hairs
|
||||
represented as cubic bezier curves with varying radii. The number of
|
||||
curves (numCurves), number of vertices (numVertices), and number of
|
||||
time steps (1 for normal curves, and 2 for linear motion blur), have
|
||||
to get specified at construction time. Further, the curve index
|
||||
buffer (RTC_INDEX_BUFFER) and the curve vertex buffer
|
||||
(RTC_VERTEX_BUFFER) have to get set by mapping and writing to the
|
||||
appropiate buffers. In case of linear motion blur, two vertex
|
||||
buffers have to get filled (RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1),
|
||||
one for each time step. The index buffer has the default layout of a
|
||||
single 32 bit integer index for each curve, that references the
|
||||
start vertex of the curve. The vertex buffer stores 4 control points
|
||||
per curve, each such control point consists of a single precision
|
||||
(x,y,z) position and radius, stored in that order in
|
||||
memory. Individual hairs are considered to be subpixel sized which
|
||||
allows the implementation to approximate the intersection
|
||||
calculation. This in particular means that zooming onto one hair
|
||||
might show geometric artefacts. */
|
||||
uniform unsigned int rtcNewHairGeometry (RTCScene scene, //!< the scene the curves belong to
|
||||
uniform RTCGeometryFlags flags, //!< geometry flags
|
||||
uniform size_t numCurves, //!< number of curves
|
||||
uniform size_t numVertices, //!< number of vertices
|
||||
uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! Sets a uniform tessellation rate for subdiv meshes and hair
|
||||
* geometry. For subdivision meshes the RTC_LEVEL_BUFFER can also be used
|
||||
* optionally to set a different tessellation rate per edge.*/
|
||||
void rtcSetTessellationRate (RTCScene scene, uniform unsigned geomID, uniform float tessellationRate);
|
||||
|
||||
/*! \brief Creates a new line segment geometry, consisting of multiple
|
||||
segments with varying radii. The number of line segments (numSegments),
|
||||
number of vertices (numVertices), and number of time steps (1 for
|
||||
normal line segments, and 2 for linear motion blur), have to get
|
||||
specified at construction time. Further, the segment index buffer
|
||||
(RTC_INDEX_BUFFER) and the segment vertex buffer (RTC_VERTEX_BUFFER)
|
||||
have to get set by mapping and writing to the appropiate buffers. In
|
||||
case of linear motion blur, two vertex buffers have to get filled
|
||||
(RTC_VERTEX_BUFFER0, RTC_VERTEX_BUFFER1), one for each time step. The
|
||||
index buffer has the default layout of a single 32 bit integer index
|
||||
for each line segment, that references the start vertex of the segment.
|
||||
The vertex buffer stores 2 end points per line segment, each such point
|
||||
consists of a single precision (x,y,z) position and radius, stored in
|
||||
that order in memory. Individual segments are considered to be subpixel
|
||||
sized which allows the implementation to approximate the intersection
|
||||
calculation. This in particular means that zooming onto one line segment
|
||||
might show geometric artefacts. */
|
||||
uniform unsigned int rtcNewLineSegments (RTCScene scene, //!< the scene the line segments belong to
|
||||
uniform RTCGeometryFlags flags, //!< geometry flags
|
||||
uniform size_t numSegments, //!< number of line segments
|
||||
uniform size_t numVertices, //!< number of vertices
|
||||
uniform size_t numTimeSteps = 1 //!< number of motion blur time steps
|
||||
);
|
||||
|
||||
/*! \brief Sets 32 bit ray mask. */
|
||||
void rtcSetMask (RTCScene scene, uniform unsigned int geomID, uniform int mask);
|
||||
|
||||
/*! \brief Sets boundary interpolation mode for subdivision surfaces */
|
||||
void rtcSetBoundaryMode(RTCScene scene, uniform unsigned int geomID, uniform RTCBoundaryMode mode);
|
||||
|
||||
/*! \brief Maps specified buffer. This function can be used to set index and
|
||||
* vertex buffers of geometries. */
|
||||
void* uniform rtcMapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
|
||||
|
||||
/*! \brief Unmaps specified buffer.
|
||||
|
||||
A buffer has to be unmapped before the rtcEnable, rtcDisable,
|
||||
rtcUpdate, or rtcDeleteGeometry calls are executed. */
|
||||
void rtcUnmapBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
|
||||
|
||||
/*! \brief Shares a data buffer between the application and
|
||||
* Embree. The passed buffer is used by Embree to store index and
|
||||
* vertex data. It has to remain valid as long as the mesh exists,
|
||||
* and the user is responsible to free the data when the mesh gets
|
||||
* deleted. One can optionally speficy a byte offset and byte stride
|
||||
* of the elements stored inside the buffer. The addresses
|
||||
* ptr+offset+i*stride have to be aligned to 4 bytes on Xeon CPUs and
|
||||
* 16 bytes on Xeon Phi accelerators. For vertex buffers, the 4 bytes
|
||||
* after the z-coordinate of the last vertex have to be readable memory,
|
||||
* thus padding is required for some layouts. If this function is not
|
||||
* called, Embree will allocate and manage buffers of the default
|
||||
* layout. */
|
||||
void rtcSetBuffer(RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type,
|
||||
const void* uniform ptr, uniform size_t byteOffset, uniform size_t byteStride);
|
||||
|
||||
/*! \brief Enable geometry. Enabled geometry can be hit by a ray. */
|
||||
void rtcEnable (RTCScene scene, uniform unsigned int geomID);
|
||||
|
||||
/*! \brief Update spefific geometry buffer.
|
||||
|
||||
Each time geometry buffers got modified, the user has to call some
|
||||
update function to tell the ray tracing engine which buffers got
|
||||
modified. The rtcUpdateBuffer function taggs a specific buffer of
|
||||
some geometry as modified. */
|
||||
void rtcUpdate (RTCScene scene, uniform unsigned int geomID);
|
||||
|
||||
/*! \brief Update spefific geometry buffer.
|
||||
|
||||
Each time geometry buffers got modified, the user has to call some
|
||||
update function to tell the ray tracing engine which buffers got
|
||||
modified. The rtcUpdateBuffer function taggs a specific buffer of
|
||||
some geometry as modified. */
|
||||
void rtcUpdateBuffer (RTCScene scene, uniform unsigned int geomID, uniform RTCBufferType type);
|
||||
|
||||
/*! \brief Disable geometry.
|
||||
|
||||
Disabled geometry is not hit by any ray. Disabling and enabling
|
||||
geometry gives higher performance than deleting and recreating
|
||||
geometry. */
|
||||
void rtcDisable (RTCScene scene, uniform unsigned int geomID);
|
||||
|
||||
/*! \brief Sets the intersection filter function for uniform rays. */
|
||||
void rtcSetIntersectionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncUniform func);
|
||||
|
||||
/*! \brief Sets the intersection filter function for varying rays. */
|
||||
void rtcSetIntersectionFilterFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncVarying func);
|
||||
|
||||
/*! \brief Sets the occlusion filter function for uniform rays. */
|
||||
void rtcSetOcclusionFilterFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncUniform func);
|
||||
|
||||
/*! \brief Sets the occlusion filter function for varying rays. */
|
||||
void rtcSetOcclusionFilterFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCFilterFuncVarying func);
|
||||
|
||||
/*! Set pointer for user defined data per geometry. Invokations
|
||||
* of the various user intersect and occluded functions get passed
|
||||
* this data pointer when called. */
|
||||
void rtcSetUserData (RTCScene scene, uniform unsigned int geomID, void* uniform ptr);
|
||||
|
||||
/*! Get pointer for user defined data per geometry based on geomID. */
|
||||
void* uniform rtcGetUserData (RTCScene scene, uniform unsigned int geomID);
|
||||
|
||||
/*! Interpolates user data to some varying u/v location. The data
|
||||
* buffer specifies per vertex data to interpolate and can be one of
|
||||
* the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to contain
|
||||
* numFloats floating point values to interpolate for each vertex of
|
||||
* the geometry. The P array will get filled with the interpolated
|
||||
* data, and the dPdu and dPdv arrays with the u and v derivative of
|
||||
* the interpolation. If the pointers P is NULL, the value will not
|
||||
* get calculated. If dPdu and dPdv are NULL the derivatives will not
|
||||
* get calculated. Both dPdu and dPdv have to be either valid or
|
||||
* NULL. These destination arrays are filled in structure of array
|
||||
* (SoA) layout. The buffer has to be padded at the end such
|
||||
* that the last element can be read safely using SSE
|
||||
* instructions. */
|
||||
void rtcInterpolate(RTCScene scene, uniform unsigned int geomID, varying unsigned int primIDs, varying float u, varying float v,
|
||||
uniform RTCBufferType buffer,
|
||||
varying float* uniform P, varying float* uniform dPdu, varying float* uniform dPdv, uniform size_t numFloats);
|
||||
|
||||
/*! Interpolates user data to some varying u/v location. The data
|
||||
* buffer specifies per vertex data to interpolate and can be one of
|
||||
* the RTC_VERTEX_BUFFER0/1 or RTC_USER_VERTEX_BUFFER0/1 and has to contain
|
||||
* numFloats floating point values to interpolate for each vertex of
|
||||
* the geometry. The P array will get filled with the
|
||||
* interpolated datam the dPdu and dPdv arrays with the u and v
|
||||
* derivative of the interpolation, and the ddPdudu, ddPdvdv, and
|
||||
* ddPdudv arrays with the respective second derivatives. One can
|
||||
* disable 1) the calculation of the interpolated value by setting P
|
||||
* to NULL, 2) the calculation of the 1st order derivatives by
|
||||
* setting dPdu and dPdv to NULL, 3) the calculation of the second
|
||||
* order derivatives by setting ddPdudu, ddPdvdv, and ddPdudv to
|
||||
* NULL. These destination arrays are filled in structure of array
|
||||
* (SoA) layout. The buffer has to be padded at the end such that
|
||||
* the last element can be read safely using SSE
|
||||
* instructions. */
|
||||
void rtcInterpolate2(RTCScene scene, uniform unsigned int geomID, varying unsigned int primIDs, varying float u, varying float v,
|
||||
uniform RTCBufferType buffer,
|
||||
varying float* uniform P, varying float* uniform dPdu, varying float* uniform dPdv,
|
||||
varying float* uniform ddPdudu, varying float* uniform ddPdvdv, varying float* uniform ddPdudv,
|
||||
uniform size_t numFloats);
|
||||
|
||||
/*! \brief Deletes the geometry. */
|
||||
void rtcDeleteGeometry (RTCScene scene, uniform unsigned int geomID);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
154
src/libigl/igl/embree/embree2/rtcore_geometry_user.h
Normal file
154
src/libigl/igl/embree/embree2/rtcore_geometry_user.h
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_USER_GEOMETRY_H__
|
||||
#define __RTCORE_USER_GEOMETRY_H__
|
||||
|
||||
/*! \ingroup embree_kernel_api */
|
||||
/*! \{ */
|
||||
|
||||
/*! Type of bounding function. */
|
||||
typedef void (*RTCBoundsFunc)(void* ptr, /*!< pointer to user data */
|
||||
size_t item, /*!< item to calculate bounds for */
|
||||
RTCBounds& bounds_o /*!< returns calculated bounds */);
|
||||
|
||||
/*! Type of bounding function. */
|
||||
typedef void (*RTCBoundsFunc2)(void* userPtr, /*!< pointer to user data */
|
||||
void* geomUserPtr, /*!< pointer to geometry user data */
|
||||
size_t item, /*!< item to calculate bounds for */
|
||||
RTCBounds* bounds_o /*!< returns calculated bounds */);
|
||||
|
||||
/*! Type of intersect function pointer for single rays. */
|
||||
typedef void (*RTCIntersectFunc)(void* ptr, /*!< pointer to user data */
|
||||
RTCRay& ray, /*!< ray to intersect */
|
||||
size_t item /*!< item to intersect */);
|
||||
|
||||
/*! Type of intersect function pointer for ray packets of size 4. */
|
||||
typedef void (*RTCIntersectFunc4)(const void* valid, /*!< pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay4& ray, /*!< ray packet to intersect */
|
||||
size_t item /*!< item to intersect */);
|
||||
|
||||
/*! Type of intersect function pointer for ray packets of size 8. */
|
||||
typedef void (*RTCIntersectFunc8)(const void* valid, /*!< pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay8& ray, /*!< ray packet to intersect */
|
||||
size_t item /*!< item to intersect */);
|
||||
|
||||
/*! Type of intersect function pointer for ray packets of size 16. */
|
||||
typedef void (*RTCIntersectFunc16)(const void* valid, /*!< pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay16& ray, /*!< ray packet to intersect */
|
||||
size_t item /*!< item to intersect */);
|
||||
|
||||
/*! Type of occlusion function pointer for single rays. */
|
||||
typedef void (*RTCOccludedFunc) (void* ptr, /*!< pointer to user data */
|
||||
RTCRay& ray, /*!< ray to test occlusion */
|
||||
size_t item /*!< item to test for occlusion */);
|
||||
|
||||
/*! Type of occlusion function pointer for ray packets of size 4. */
|
||||
typedef void (*RTCOccludedFunc4) (const void* valid, /*! pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay4& ray, /*!< Ray packet to test occlusion. */
|
||||
size_t item /*!< item to test for occlusion */);
|
||||
|
||||
/*! Type of occlusion function pointer for ray packets of size 8. */
|
||||
typedef void (*RTCOccludedFunc8) (const void* valid, /*! pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay8& ray, /*!< Ray packet to test occlusion. */
|
||||
size_t item /*!< item to test for occlusion */);
|
||||
|
||||
/*! Type of occlusion function pointer for ray packets of size 16. */
|
||||
typedef void (*RTCOccludedFunc16) (const void* valid, /*! pointer to valid mask */
|
||||
void* ptr, /*!< pointer to user data */
|
||||
RTCRay16& ray, /*!< Ray packet to test occlusion. */
|
||||
size_t item /*!< item to test for occlusion */);
|
||||
|
||||
/*! Creates a new user geometry object. This feature makes it possible
|
||||
* to add arbitrary types of geometry to the scene by providing
|
||||
* appropiate bounding, intersect and occluded functions. A user
|
||||
* geometry object is a set of user geometries. As the rtcIntersect
|
||||
* and rtcOccluded functions support different ray packet sizes, the
|
||||
* user also has to provide different versions of intersect and
|
||||
* occluded function pointers for these packet sizes. However, the
|
||||
* ray packet size of the called function pointer always matches the
|
||||
* packet size of the originally invoked rtcIntersect and rtcOccluded
|
||||
* functions. A user data pointer, that points to a user specified
|
||||
* representation of the geometry, is passed to each intersect and
|
||||
* occluded function invokation, as well as the index of the geometry
|
||||
* of the set to intersect. */
|
||||
RTCORE_API unsigned rtcNewUserGeometry (RTCScene scene, /*!< the scene the user geometry set is created in */
|
||||
size_t numGeometries /*!< the number of geometries contained in the set */);
|
||||
|
||||
RTCORE_API unsigned rtcNewUserGeometry2 (RTCScene scene, /*!< the scene the user geometry set is created in */
|
||||
size_t numGeometries, /*!< the number of geometries contained in the set */
|
||||
size_t numTimeSteps = 1 /*!< number of motion blur time steps */);
|
||||
|
||||
/*! Sets the bounding function to calculate bounding boxes of the user
|
||||
* geometry items when building spatial index structures. The
|
||||
* calculated bounding box have to be conservative and should be
|
||||
* tight. */
|
||||
RTCORE_API void rtcSetBoundsFunction (RTCScene scene, unsigned geomID, RTCBoundsFunc bounds);
|
||||
|
||||
/*! Sets the bounding function to calculate bounding boxes of the user
|
||||
* geometry items when building spatial index structures. The
|
||||
* calculated bounding box have to be conservative and should be
|
||||
* tight. */
|
||||
RTCORE_API void rtcSetBoundsFunction2 (RTCScene scene, unsigned geomID, RTCBoundsFunc2 bounds, void* userPtr);
|
||||
|
||||
/*! Set intersect function for single rays. The rtcIntersect function
|
||||
* will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
RTCORE_API void rtcSetIntersectFunction (RTCScene scene, unsigned geomID, RTCIntersectFunc intersect);
|
||||
|
||||
/*! Set intersect function for ray packets of size 4. The
|
||||
* rtcIntersect4 function will call the passed function for
|
||||
* intersecting the user geometry. */
|
||||
RTCORE_API void rtcSetIntersectFunction4 (RTCScene scene, unsigned geomID, RTCIntersectFunc4 intersect4);
|
||||
|
||||
/*! Set intersect function for ray packets of size 8. The
|
||||
* rtcIntersect8 function will call the passed function for
|
||||
* intersecting the user geometry.*/
|
||||
RTCORE_API void rtcSetIntersectFunction8 (RTCScene scene, unsigned geomID, RTCIntersectFunc8 intersect8);
|
||||
|
||||
/*! Set intersect function for ray packets of size 16. The
|
||||
* rtcIntersect16 function will call the passed function for
|
||||
* intersecting the user geometry. */
|
||||
RTCORE_API void rtcSetIntersectFunction16 (RTCScene scene, unsigned geomID, RTCIntersectFunc16 intersect16);
|
||||
|
||||
/*! Set occlusion function for single rays. The rtcOccluded function
|
||||
* will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
RTCORE_API void rtcSetOccludedFunction (RTCScene scene, unsigned geomID, RTCOccludedFunc occluded);
|
||||
|
||||
/*! Set occlusion function for ray packets of size 4. The rtcOccluded4
|
||||
* function will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
RTCORE_API void rtcSetOccludedFunction4 (RTCScene scene, unsigned geomID, RTCOccludedFunc4 occluded4);
|
||||
|
||||
/*! Set occlusion function for ray packets of size 8. The rtcOccluded8
|
||||
* function will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
RTCORE_API void rtcSetOccludedFunction8 (RTCScene scene, unsigned geomID, RTCOccludedFunc8 occluded8);
|
||||
|
||||
/*! Set occlusion function for ray packets of size 16. The
|
||||
* rtcOccluded16 function will call the passed function for
|
||||
* intersecting the user geometry. */
|
||||
RTCORE_API void rtcSetOccludedFunction16 (RTCScene scene, unsigned geomID, RTCOccludedFunc16 occluded16);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
128
src/libigl/igl/embree/embree2/rtcore_geometry_user.isph
Normal file
128
src/libigl/igl/embree/embree2/rtcore_geometry_user.isph
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_USER_GEOMETRY_ISPH__
|
||||
#define __RTCORE_USER_GEOMETRY_ISPH__
|
||||
|
||||
/*! \ingroup embree_kernel_api_ispc */
|
||||
/*! \{ */
|
||||
|
||||
/*! Type of bounding function. */
|
||||
typedef void (*RTCBoundsFunc)(void* uniform ptr, /*!< pointer to user data */
|
||||
uniform size_t item, /*!< item to calculate bounds for */
|
||||
uniform RTCBounds& bounds_o /*!< returns calculated bounds */);
|
||||
|
||||
/*! Type of bounding function. */
|
||||
typedef void (*RTCBoundsFunc2)(void* uniform userPtr, /*!< pointer to user data */
|
||||
void* uniform geomUserPtr, /*!< pointer to geometry user data */
|
||||
uniform size_t item, /*!< item to calculate bounds for */
|
||||
RTCBounds* uniform bounds_o /*!< returns calculated bounds */);
|
||||
|
||||
/*! Type of intersect function pointer for uniform rays. */
|
||||
typedef void (*RTCIntersectFuncUniform)(void* uniform ptr, /*!< pointer to user data */
|
||||
uniform RTCRay1& ray, /*!< ray to intersect */
|
||||
uniform size_t item /*< item to intersect */);
|
||||
|
||||
/*! Type of intersect function pointer for varying rays. */
|
||||
typedef void (*RTCIntersectFuncVarying)(void* uniform ptr, /*!< pointer to user data */
|
||||
varying RTCRay& ray, /*!< ray to intersect */
|
||||
uniform size_t item /*< item to intersect */);
|
||||
|
||||
/*! Type of occlusion function pointer for uniform rays. */
|
||||
typedef void (*RTCOccludedFuncUniform) (void* uniform ptr, /*!< pointer to user data */
|
||||
uniform RTCRay1& ray, /*!< ray to test occlusion */
|
||||
uniform size_t item /*< item to test for occlusion */);
|
||||
|
||||
|
||||
/*! Type of occlusion function pointer for varying rays. */
|
||||
typedef void (*RTCOccludedFuncVarying) (void* uniform ptr, /*!< pointer to user data */
|
||||
varying RTCRay& ray, /*!< ray to test occlusion */
|
||||
uniform size_t item /*< item to test for occlusion */);
|
||||
|
||||
|
||||
typedef void (*RTCDisplacementFunc)(void* uniform ptr, /*!< pointer to user data of geometry */
|
||||
uniform unsigned int geomID, /*!< ID of geometry to displace */
|
||||
uniform unsigned int primID, /*!< ID of primitive of geometry to displace */
|
||||
uniform const float* uniform u, /*!< u coordinates (source) */
|
||||
uniform const float* uniform v, /*!< v coordinates (source) */
|
||||
uniform const float* uniform nx, /*!< x coordinates of normal at point to displace (source) */
|
||||
uniform const float* uniform ny, /*!< y coordinates of normal at point to displace (source) */
|
||||
uniform const float* uniform nz, /*!< z coordinates of normal at point to displace (source) */
|
||||
uniform float* uniform px, /*!< x coordinates of points to displace (source and target) */
|
||||
uniform float* uniform py, /*!< y coordinates of points to displace (source and target) */
|
||||
uniform float* uniform pz, /*!< z coordinates of points to displace (source and target) */
|
||||
uniform size_t N /*!< number of points to displace */ );
|
||||
|
||||
|
||||
/*! Creates a new user geometry object. This feature makes it possible
|
||||
* to add arbitrary types of geometry to the scene by providing
|
||||
* appropiate intersect and occluded functions, as well as a bounding
|
||||
* box of the implemented geometry. As the rtcIntersect and
|
||||
* rtcOccluded functions support different ray packet sizes, the user
|
||||
* also has to provide different versions of intersect and occluded
|
||||
* function pointers for the different packet sized. However, only
|
||||
* rtcIntersect and rtcOccluded functions of specific packet sizes
|
||||
* are called, it is sufficient to provide only the corresponding
|
||||
* function pointer for the user geometry. However, the functions
|
||||
* provided have to intersect the same geometry. A user data pointer,
|
||||
* that points to a user specified representation of the geometry, is
|
||||
* passed to each intersect and occluded function invokation. */
|
||||
uniform unsigned int rtcNewUserGeometry (RTCScene scene, /*!< the scene the user geometry set is created in */
|
||||
uniform size_t numGeometries /*!< the number of geometries contained in the set */);
|
||||
|
||||
uniform unsigned int rtcNewUserGeometry2 (RTCScene scene, /*!< the scene the user geometry set is created in */
|
||||
uniform size_t numGeometries, /*!< the number of geometries contained in the set */
|
||||
uniform size_t numTimeSteps = 1 /*!< number of motion blur time steps */);
|
||||
|
||||
/*! Sets the bounding function to calculate bounding boxes of the user
|
||||
* geometry items when building spatial index structures. The
|
||||
* calculated bounding box have to be conservative and should be
|
||||
* tight.*/
|
||||
void rtcSetBoundsFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCBoundsFunc bounds);
|
||||
|
||||
/*! Sets the bounding function to calculate bounding boxes of the user
|
||||
* geometry items when building spatial index structures. The
|
||||
* calculated bounding box have to be conservative and should be
|
||||
* tight.*/
|
||||
void rtcSetBoundsFunction2 (RTCScene scene, uniform unsigned int geomID, uniform RTCBoundsFunc2 bounds, void* uniform userPtr);
|
||||
|
||||
/*! Set intersect function for uniform rays. The rtcIntersect1
|
||||
* function will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
void rtcSetIntersectFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFuncUniform intersect);
|
||||
|
||||
/*! Set intersect function for varying rays. The rtcIntersect function
|
||||
* will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
void rtcSetIntersectFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCIntersectFuncVarying intersect);
|
||||
|
||||
/*! Set occlusion function for uniform rays. The rtcOccluded1 function
|
||||
* will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
void rtcSetOccludedFunction1 (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFuncUniform occluded);
|
||||
|
||||
/*! Set occlusion function for varying rays. The rtcOccluded function
|
||||
* will call the passed function for intersecting the user
|
||||
* geometry. */
|
||||
void rtcSetOccludedFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCOccludedFuncVarying occluded);
|
||||
|
||||
|
||||
/*! \brief Sets the displacement function. */
|
||||
void rtcSetDisplacementFunction (RTCScene scene, uniform unsigned int geomID, uniform RTCDisplacementFunc func, uniform RTCBounds *uniform bounds);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
195
src/libigl/igl/embree/embree2/rtcore_ray.h
Normal file
195
src/libigl/igl/embree/embree2/rtcore_ray.h
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_RAY_H__
|
||||
#define __RTCORE_RAY_H__
|
||||
|
||||
/*! \ingroup embree_kernel_api */
|
||||
/*! \{ */
|
||||
|
||||
/*! \brief Ray structure for an individual ray */
|
||||
struct RTCORE_ALIGN(16) RTCRay
|
||||
{
|
||||
/* ray data */
|
||||
public:
|
||||
float org[3]; //!< Ray origin
|
||||
float align0;
|
||||
|
||||
float dir[3]; //!< Ray direction
|
||||
float align1;
|
||||
|
||||
float tnear; //!< Start of ray segment
|
||||
float tfar; //!< End of ray segment (set to hit distance)
|
||||
|
||||
float time; //!< Time of this ray for motion blur
|
||||
unsigned mask; //!< Used to mask out objects during traversal
|
||||
|
||||
/* hit data */
|
||||
public:
|
||||
float Ng[3]; //!< Unnormalized geometry normal
|
||||
float align2;
|
||||
|
||||
float u; //!< Barycentric u coordinate of hit
|
||||
float v; //!< Barycentric v coordinate of hit
|
||||
|
||||
unsigned geomID; //!< geometry ID
|
||||
unsigned primID; //!< primitive ID
|
||||
unsigned instID; //!< instance ID
|
||||
};
|
||||
|
||||
/*! Ray structure for packets of 4 rays. */
|
||||
struct RTCORE_ALIGN(16) RTCRay4
|
||||
{
|
||||
/* ray data */
|
||||
public:
|
||||
float orgx[4]; //!< x coordinate of ray origin
|
||||
float orgy[4]; //!< y coordinate of ray origin
|
||||
float orgz[4]; //!< z coordinate of ray origin
|
||||
|
||||
float dirx[4]; //!< x coordinate of ray direction
|
||||
float diry[4]; //!< y coordinate of ray direction
|
||||
float dirz[4]; //!< z coordinate of ray direction
|
||||
|
||||
float tnear[4]; //!< Start of ray segment
|
||||
float tfar[4]; //!< End of ray segment (set to hit distance)
|
||||
|
||||
float time[4]; //!< Time of this ray for motion blur
|
||||
unsigned mask[4]; //!< Used to mask out objects during traversal
|
||||
|
||||
/* hit data */
|
||||
public:
|
||||
float Ngx[4]; //!< x coordinate of geometry normal
|
||||
float Ngy[4]; //!< y coordinate of geometry normal
|
||||
float Ngz[4]; //!< z coordinate of geometry normal
|
||||
|
||||
float u[4]; //!< Barycentric u coordinate of hit
|
||||
float v[4]; //!< Barycentric v coordinate of hit
|
||||
|
||||
unsigned geomID[4]; //!< geometry ID
|
||||
unsigned primID[4]; //!< primitive ID
|
||||
unsigned instID[4]; //!< instance ID
|
||||
};
|
||||
|
||||
/*! Ray structure for packets of 8 rays. */
|
||||
struct RTCORE_ALIGN(32) RTCRay8
|
||||
{
|
||||
/* ray data */
|
||||
public:
|
||||
float orgx[8]; //!< x coordinate of ray origin
|
||||
float orgy[8]; //!< y coordinate of ray origin
|
||||
float orgz[8]; //!< z coordinate of ray origin
|
||||
|
||||
float dirx[8]; //!< x coordinate of ray direction
|
||||
float diry[8]; //!< y coordinate of ray direction
|
||||
float dirz[8]; //!< z coordinate of ray direction
|
||||
|
||||
float tnear[8]; //!< Start of ray segment
|
||||
float tfar[8]; //!< End of ray segment (set to hit distance)
|
||||
|
||||
float time[8]; //!< Time of this ray for motion blur
|
||||
unsigned mask[8]; //!< Used to mask out objects during traversal
|
||||
|
||||
/* hit data */
|
||||
public:
|
||||
float Ngx[8]; //!< x coordinate of geometry normal
|
||||
float Ngy[8]; //!< y coordinate of geometry normal
|
||||
float Ngz[8]; //!< z coordinate of geometry normal
|
||||
|
||||
float u[8]; //!< Barycentric u coordinate of hit
|
||||
float v[8]; //!< Barycentric v coordinate of hit
|
||||
|
||||
unsigned geomID[8]; //!< geometry ID
|
||||
unsigned primID[8]; //!< primitive ID
|
||||
unsigned instID[8]; //!< instance ID
|
||||
};
|
||||
|
||||
/*! \brief Ray structure for packets of 16 rays. */
|
||||
struct RTCORE_ALIGN(64) RTCRay16
|
||||
{
|
||||
/* ray data */
|
||||
public:
|
||||
float orgx[16]; //!< x coordinate of ray origin
|
||||
float orgy[16]; //!< y coordinate of ray origin
|
||||
float orgz[16]; //!< z coordinate of ray origin
|
||||
|
||||
float dirx[16]; //!< x coordinate of ray direction
|
||||
float diry[16]; //!< y coordinate of ray direction
|
||||
float dirz[16]; //!< z coordinate of ray direction
|
||||
|
||||
float tnear[16]; //!< Start of ray segment
|
||||
float tfar[16]; //!< End of ray segment (set to hit distance)
|
||||
|
||||
float time[16]; //!< Time of this ray for motion blur
|
||||
unsigned mask[16]; //!< Used to mask out objects during traversal
|
||||
|
||||
/* hit data */
|
||||
public:
|
||||
float Ngx[16]; //!< x coordinate of geometry normal
|
||||
float Ngy[16]; //!< y coordinate of geometry normal
|
||||
float Ngz[16]; //!< z coordinate of geometry normal
|
||||
|
||||
float u[16]; //!< Barycentric u coordinate of hit
|
||||
float v[16]; //!< Barycentric v coordinate of hit
|
||||
|
||||
unsigned geomID[16]; //!< geometry ID
|
||||
unsigned primID[16]; //!< primitive ID
|
||||
unsigned instID[16]; //!< instance ID
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Ray structure template for packets of N rays in SOA layout. */
|
||||
struct RTCRaySOA
|
||||
{
|
||||
/* ray data */
|
||||
public:
|
||||
|
||||
float* orgx; //!< x coordinate of ray origin
|
||||
float* orgy; //!< y coordinate of ray origin
|
||||
float* orgz; //!< z coordinate of ray origin
|
||||
|
||||
float* dirx; //!< x coordinate of ray direction
|
||||
float* diry; //!< y coordinate of ray direction
|
||||
float* dirz; //!< z coordinate of ray direction
|
||||
|
||||
float* tnear; //!< Start of ray segment (optional)
|
||||
float* tfar; //!< End of ray segment (set to hit distance)
|
||||
|
||||
|
||||
float* time; //!< Time of this ray for motion blur (optional)
|
||||
unsigned* mask; //!< Used to mask out objects during traversal (optional)
|
||||
|
||||
/* hit data */
|
||||
|
||||
public:
|
||||
|
||||
float* Ngx; //!< x coordinate of geometry normal (optional)
|
||||
float* Ngy; //!< y coordinate of geometry normal (optional)
|
||||
float* Ngz; //!< z coordinate of geometry normal (optional)
|
||||
|
||||
|
||||
|
||||
float* u; //!< Barycentric u coordinate of hit
|
||||
float* v; //!< Barycentric v coordinate of hit
|
||||
|
||||
|
||||
unsigned* geomID; //!< geometry ID
|
||||
unsigned* primID; //!< primitive ID
|
||||
unsigned* instID; //!< instance ID (optional)
|
||||
};
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
117
src/libigl/igl/embree/embree2/rtcore_ray.isph
Normal file
117
src/libigl/igl/embree/embree2/rtcore_ray.isph
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_RAY_ISPH__
|
||||
#define __RTCORE_RAY_ISPH__
|
||||
|
||||
/*! \ingroup embree_kernel_api_ispc */
|
||||
/*! \{ */
|
||||
|
||||
/*! Ray structure for uniform (single) rays. */
|
||||
struct RTCRay1
|
||||
{
|
||||
/* ray data */
|
||||
float org[3]; //!< Ray origin
|
||||
float align0; //!< unused member to force alignment of following members
|
||||
|
||||
float dir[3]; //!< Ray direction
|
||||
float align1; //!< unused member to force alignment of following members
|
||||
|
||||
float tnear; //!< Start of ray segment
|
||||
float tfar; //!< End of ray segment (set to hit distance)
|
||||
float time; //!< Time of this ray for motion blur
|
||||
unsigned mask; //!< Used to mask out objects during traversal
|
||||
|
||||
/* hit data */
|
||||
float Ng[3]; //!< Unnormalized geometry normal
|
||||
float align2;
|
||||
|
||||
float u; //!< Barycentric u coordinate of hit
|
||||
float v; //!< Barycentric v coordinate of hit
|
||||
|
||||
unsigned geomID; //!< geometry ID
|
||||
unsigned primID; //!< primitive ID
|
||||
unsigned instID; //!< instance ID
|
||||
varying unsigned align[0]; //!< aligns ray on stack to at least 16 bytes
|
||||
};
|
||||
|
||||
/*! Ray structure for packets of 4 rays. */
|
||||
struct RTCRay
|
||||
{
|
||||
/* ray data */
|
||||
float orgx; //!< x coordinate of ray origin
|
||||
float orgy; //!< y coordinate of ray origin
|
||||
float orgz; //!< z coordinate of ray origin
|
||||
|
||||
float dirx; //!< x coordinate of ray direction
|
||||
float diry; //!< y coordinate of ray direction
|
||||
float dirz; //!< z coordinate of ray direction
|
||||
|
||||
float tnear; //!< Start of ray segment
|
||||
float tfar; //!< End of ray segment
|
||||
float time; //!< Time of this ray for motion blur
|
||||
unsigned mask; //!< Used to mask out objects during traversal
|
||||
|
||||
/* hit data */
|
||||
float Ngx; //!< x coordinate of geometry normal
|
||||
float Ngy; //!< y coordinate of geometry normal
|
||||
float Ngz; //!< z coordinate of geometry normal
|
||||
|
||||
float u; //!< Barycentric u coordinate of hit
|
||||
float v; //!< Barycentric v coordinate of hit
|
||||
|
||||
unsigned geomID; //!< geometry ID
|
||||
unsigned primID; //!< primitive ID
|
||||
unsigned instID; //!< instance ID
|
||||
};
|
||||
|
||||
|
||||
struct RTCRaySOA
|
||||
{
|
||||
/* ray data */
|
||||
|
||||
uniform float* uniform orgx; //!< x coordinate of ray origin
|
||||
uniform float* uniform orgy; //!< y coordinate of ray origin
|
||||
uniform float* uniform orgz; //!< z coordinate of ray origin
|
||||
|
||||
uniform float* uniform dirx; //!< x coordinate of ray direction
|
||||
uniform float* uniform diry; //!< y coordinate of ray direction
|
||||
uniform float* uniform dirz; //!< z coordinate of ray direction
|
||||
|
||||
uniform float* uniform tnear; //!< Start of ray segment (optional)
|
||||
uniform float* uniform tfar; //!< End of ray segment (set to hit distance)
|
||||
|
||||
uniform float* uniform time; //!< Time of this ray for motion blur (optional)
|
||||
uniform unsigned* uniform mask; //!< Used to mask out objects during traversal (optional)
|
||||
|
||||
/* hit data */
|
||||
|
||||
uniform float* uniform Ngx; //!< x coordinate of geometry normal (optional)
|
||||
uniform float* uniform Ngy; //!< y coordinate of geometry normal (optional)
|
||||
uniform float* uniform Ngz; //!< z coordinate of geometry normal (optional)
|
||||
|
||||
uniform float* uniform u; //!< Barycentric u coordinate of hit
|
||||
uniform float* uniform v; //!< Barycentric v coordinate of hit
|
||||
|
||||
uniform unsigned* uniform geomID; //!< geometry ID
|
||||
uniform unsigned* uniform primID; //!< primitive ID
|
||||
uniform unsigned* uniform instID; //!< instance ID (optional)
|
||||
};
|
||||
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
187
src/libigl/igl/embree/embree2/rtcore_scene.h
Normal file
187
src/libigl/igl/embree/embree2/rtcore_scene.h
Normal file
|
|
@ -0,0 +1,187 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_SCENE_H__
|
||||
#define __RTCORE_SCENE_H__
|
||||
|
||||
/*! \ingroup embree_kernel_api */
|
||||
/*! \{ */
|
||||
|
||||
/*! forward declarations for ray structures */
|
||||
struct RTCRay;
|
||||
struct RTCRay4;
|
||||
struct RTCRay8;
|
||||
struct RTCRay16;
|
||||
struct RTCRaySOA;
|
||||
|
||||
/*! scene flags */
|
||||
enum RTCSceneFlags
|
||||
{
|
||||
/* dynamic type flags */
|
||||
RTC_SCENE_STATIC = (0 << 0), //!< specifies static scene
|
||||
RTC_SCENE_DYNAMIC = (1 << 0), //!< specifies dynamic scene
|
||||
|
||||
/* acceleration structure flags */
|
||||
RTC_SCENE_COMPACT = (1 << 8), //!< use memory conservative data structures
|
||||
RTC_SCENE_COHERENT = (1 << 9), //!< optimize data structures for coherent rays
|
||||
RTC_SCENE_INCOHERENT = (1 << 10), //!< optimize data structures for in-coherent rays (enabled by default)
|
||||
RTC_SCENE_HIGH_QUALITY = (1 << 11), //!< create higher quality data structures
|
||||
|
||||
/* traversal algorithm flags */
|
||||
RTC_SCENE_ROBUST = (1 << 16) //!< use more robust traversal algorithms
|
||||
};
|
||||
|
||||
/*! enabled algorithm flags */
|
||||
enum RTCAlgorithmFlags
|
||||
{
|
||||
RTC_INTERSECT1 = (1 << 0), //!< enables the rtcIntersect1 and rtcOccluded1 functions for this scene
|
||||
RTC_INTERSECT4 = (1 << 1), //!< enables the rtcIntersect4 and rtcOccluded4 functions for this scene
|
||||
RTC_INTERSECT8 = (1 << 2), //!< enables the rtcIntersect8 and rtcOccluded8 functions for this scene
|
||||
RTC_INTERSECT16 = (1 << 3), //!< enables the rtcIntersect16 and rtcOccluded16 functions for this scene
|
||||
RTC_INTERPOLATE = (1 << 4), //!< enables the rtcInterpolate function for this scene
|
||||
|
||||
RTC_INTERSECTN = (1 << 5), //!< enables the rtcIntersectN and rtcOccludedN functions for this scene
|
||||
};
|
||||
|
||||
/*! layout flags for ray streams */
|
||||
enum RTCRayNFlags
|
||||
{
|
||||
RTC_RAYN_DEFAULT = (1 << 0)
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Defines an opaque scene type */
|
||||
typedef struct __RTCScene {}* RTCScene;
|
||||
|
||||
/*! Creates a new scene.
|
||||
WARNING: This function is deprecated, use rtcDeviceNewScene instead.
|
||||
*/
|
||||
RTCORE_API RTCORE_DEPRECATED RTCScene rtcNewScene (RTCSceneFlags flags, RTCAlgorithmFlags aflags);
|
||||
|
||||
/*! Creates a new scene. */
|
||||
RTCORE_API RTCScene rtcDeviceNewScene (RTCDevice device, RTCSceneFlags flags, RTCAlgorithmFlags aflags);
|
||||
|
||||
/*! \brief Type of progress callback function. */
|
||||
typedef bool (*RTCProgressMonitorFunc)(void* ptr, const double n);
|
||||
RTCORE_DEPRECATED typedef RTCProgressMonitorFunc RTC_PROGRESS_MONITOR_FUNCTION;
|
||||
|
||||
/*! \brief Sets the progress callback function which is called during hierarchy build of this scene. */
|
||||
RTCORE_API void rtcSetProgressMonitorFunction(RTCScene scene, RTCProgressMonitorFunc func, void* ptr);
|
||||
|
||||
/*! Commits the geometry of the scene. After initializing or modifying
|
||||
* geometries, commit has to get called before tracing
|
||||
* rays. */
|
||||
RTCORE_API void rtcCommit (RTCScene scene);
|
||||
|
||||
/*! Commits the geometry of the scene. The calling threads will be
|
||||
* used internally as a worker threads on some implementations. The
|
||||
* function will wait until 'numThreads' threads have called this
|
||||
* function and all threads return from the function after the scene
|
||||
* commit is finished. The application threads will not be used as
|
||||
* worker threads when the TBB tasking system is enabled (which is
|
||||
* the default). On CPUs, we recommend also using TBB inside your
|
||||
* application to share threads. We recommend using the
|
||||
* rtcCommitThread feature to share threads on the Xeon Phi
|
||||
* coprocessor. */
|
||||
RTCORE_API void rtcCommitThread(RTCScene scene, unsigned int threadID, unsigned int numThreads);
|
||||
|
||||
/*! Returns to AABB of the scene. rtcCommit has to get called
|
||||
* previously to this function. */
|
||||
RTCORE_API void rtcGetBounds(RTCScene scene, RTCBounds& bounds_o);
|
||||
|
||||
/*! Intersects a single ray with the scene. The ray has to be aligned
|
||||
* to 16 bytes. This function can only be called for scenes with the
|
||||
* RTC_INTERSECT1 flag set. */
|
||||
RTCORE_API void rtcIntersect (RTCScene scene, RTCRay& ray);
|
||||
|
||||
/*! Intersects a packet of 4 rays with the scene. The valid mask and
|
||||
* ray have both to be aligned to 16 bytes. This function can only be
|
||||
* called for scenes with the RTC_INTERSECT4 flag set. */
|
||||
RTCORE_API void rtcIntersect4 (const void* valid, RTCScene scene, RTCRay4& ray);
|
||||
|
||||
/*! Intersects a packet of 8 rays with the scene. The valid mask and
|
||||
* ray have both to be aligned to 32 bytes. This function can only be
|
||||
* called for scenes with the RTC_INTERSECT8 flag set. For performance
|
||||
* reasons, the rtcIntersect8 function should only get called if the
|
||||
* CPU supports AVX. */
|
||||
RTCORE_API void rtcIntersect8 (const void* valid, RTCScene scene, RTCRay8& ray);
|
||||
|
||||
/*! Intersects a packet of 16 rays with the scene. The valid mask and
|
||||
* ray have both to be aligned to 64 bytes. This function can only be
|
||||
* called for scenes with the RTC_INTERSECT16 flag set. For
|
||||
* performance reasons, the rtcIntersect16 function should only get
|
||||
* called if the CPU supports the 16-wide SIMD instructions. */
|
||||
RTCORE_API void rtcIntersect16 (const void* valid, RTCScene scene, RTCRay16& ray);
|
||||
|
||||
/*! Intersects a stream of N rays in AOS layout with the scene. This
|
||||
* function can only be called for scenes with the RTC_INTERSECTN
|
||||
* flag set. The stride specifies the offset between rays in
|
||||
* bytes. */
|
||||
RTCORE_API void rtcIntersectN (RTCScene scene, RTCRay* rayN, const size_t N, const size_t stride, const size_t flags = RTC_RAYN_DEFAULT);
|
||||
|
||||
/*! Intersects one or multiple streams of N rays in compact SOA layout
|
||||
* with the scene. This function can only be called for scenes with
|
||||
* the RTC_INTERSECTN flag set. 'streams' specifies the number of
|
||||
* dense SOA ray streams, and 'stride' the offset in bytes between
|
||||
* those. */
|
||||
RTCORE_API void rtcIntersectN_SOA (RTCScene scene, RTCRaySOA& rayN, const size_t N, const size_t streams, const size_t stride, const size_t flags = RTC_RAYN_DEFAULT);
|
||||
|
||||
|
||||
/*! Tests if a single ray is occluded by the scene. The ray has to be
|
||||
* aligned to 16 bytes. This function can only be called for scenes
|
||||
* with the RTC_INTERSECT1 flag set. */
|
||||
RTCORE_API void rtcOccluded (RTCScene scene, RTCRay& ray);
|
||||
|
||||
/*! Tests if a packet of 4 rays is occluded by the scene. This
|
||||
* function can only be called for scenes with the RTC_INTERSECT4
|
||||
* flag set. The valid mask and ray have both to be aligned to 16
|
||||
* bytes. */
|
||||
RTCORE_API void rtcOccluded4 (const void* valid, RTCScene scene, RTCRay4& ray);
|
||||
|
||||
/*! Tests if a packet of 8 rays is occluded by the scene. The valid
|
||||
* mask and ray have both to be aligned to 32 bytes. This function
|
||||
* can only be called for scenes with the RTC_INTERSECT8 flag
|
||||
* set. For performance reasons, the rtcOccluded8 function should
|
||||
* only get called if the CPU supports AVX. */
|
||||
RTCORE_API void rtcOccluded8 (const void* valid, RTCScene scene, RTCRay8& ray);
|
||||
|
||||
/*! Tests if a packet of 16 rays is occluded by the scene. The valid
|
||||
* mask and ray have both to be aligned to 64 bytes. This function
|
||||
* can only be called for scenes with the RTC_INTERSECT16 flag
|
||||
* set. For performance reasons, the rtcOccluded16 function should
|
||||
* only get called if the CPU supports the 16-wide SIMD
|
||||
* instructions. */
|
||||
RTCORE_API void rtcOccluded16 (const void* valid, RTCScene scene, RTCRay16& ray);
|
||||
|
||||
/*! Tests if a stream of N rays on AOS layout is occluded by the
|
||||
* scene. This function can only be called for scenes with the
|
||||
* RTC_INTERSECTN flag set. The stride specifies the offset between
|
||||
* rays in bytes.*/
|
||||
RTCORE_API void rtcOccludedN (RTCScene scene, RTCRay* rayN, const size_t N, const size_t stride, const size_t flags = RTC_RAYN_DEFAULT);
|
||||
|
||||
/*! Intersects one or multiple streams of N rays in compact SOA layout
|
||||
* with the scene. This function can only be called for scenes with
|
||||
* the RTC_INTERSECTN flag set. 'streams' specifies the number of
|
||||
* dense SOA ray streams, and 'stride' the offset in bytes between
|
||||
* those. */
|
||||
RTCORE_API void rtcOccludedN_SOA (RTCScene scene, RTCRaySOA& rayN, const size_t N, const size_t streams, const size_t stride, const size_t flags = RTC_RAYN_DEFAULT);
|
||||
|
||||
/*! Deletes the scene. All contained geometry get also destroyed. */
|
||||
RTCORE_API void rtcDeleteScene (RTCScene scene);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
152
src/libigl/igl/embree/embree2/rtcore_scene.isph
Normal file
152
src/libigl/igl/embree/embree2/rtcore_scene.isph
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
// ======================================================================== //
|
||||
// Copyright 2009-2015 Intel Corporation //
|
||||
// //
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); //
|
||||
// you may not use this file except in compliance with the License. //
|
||||
// You may obtain a copy of the License at //
|
||||
// //
|
||||
// http://www.apache.org/licenses/LICENSE-2.0 //
|
||||
// //
|
||||
// Unless required by applicable law or agreed to in writing, software //
|
||||
// distributed under the License is distributed on an "AS IS" BASIS, //
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
|
||||
// See the License for the specific language governing permissions and //
|
||||
// limitations under the License. //
|
||||
// ======================================================================== //
|
||||
|
||||
#ifndef __RTCORE_SCENE_ISPH__
|
||||
#define __RTCORE_SCENE_ISPH__
|
||||
|
||||
/*! \ingroup embree_kernel_api */
|
||||
/*! \{ */
|
||||
|
||||
/*! forward declarations for ray structures */
|
||||
struct RTCRay1;
|
||||
struct RTCRay;
|
||||
struct RTCRaySOA;
|
||||
|
||||
/*! scene flags */
|
||||
enum RTCSceneFlags
|
||||
{
|
||||
/* dynamic type flags */
|
||||
RTC_SCENE_STATIC = (0 << 0), //!< specifies static scene
|
||||
RTC_SCENE_DYNAMIC = (1 << 0), //!< specifies dynamic scene
|
||||
|
||||
/* acceleration structure flags */
|
||||
RTC_SCENE_COMPACT = (1 << 8), //!< use memory conservative data structures
|
||||
RTC_SCENE_COHERENT = (1 << 9), //!< optimize data structures for coherent rays (enabled by default)
|
||||
RTC_SCENE_INCOHERENT = (1 << 10), //!< optimize data structures for in-coherent rays
|
||||
RTC_SCENE_HIGH_QUALITY = (1 << 11), //!< create higher quality data structures
|
||||
|
||||
/* traversal algorithm flags */
|
||||
RTC_SCENE_ROBUST = (1 << 16) //!< use more robust traversal algorithms
|
||||
};
|
||||
|
||||
/*! enabled algorithm flags */
|
||||
enum RTCAlgorithmFlags
|
||||
{
|
||||
RTC_INTERSECT_UNIFORM = (1 << 0), //!< enables the uniform rtcIntersect1 and uniform rtcOccluded1 functions for this scene
|
||||
RTC_INTERSECT_VARYING = (1 << 1), //!< enables the varying rtcIntersect and varying rtcOccluded functions for this scene
|
||||
RTC_INTERPOLATE = (1 << 4) //!< enables the rtcInterpolate function for this scene
|
||||
};
|
||||
|
||||
/*! layout flags for ray streams */
|
||||
enum RTCRayNFlags
|
||||
{
|
||||
RTC_RAYN_DEFAULT = (1 << 0)
|
||||
};
|
||||
|
||||
|
||||
/*! \brief Defines an opaque scene type */
|
||||
typedef uniform struct __RTCScene {}* uniform RTCScene;
|
||||
|
||||
/*! Creates a new scene.
|
||||
WARNING: This function is deprecated, use rtcDeviceNewScene instead.
|
||||
*/
|
||||
RTCORE_DEPRECATED RTCScene rtcNewScene (uniform RTCSceneFlags flags, uniform RTCAlgorithmFlags aflags);
|
||||
|
||||
/*! Creates a new scene. */
|
||||
RTCScene rtcDeviceNewScene (RTCDevice device, uniform RTCSceneFlags flags, uniform RTCAlgorithmFlags aflags);
|
||||
|
||||
/*! \brief Type of progress callback function. */
|
||||
typedef uniform bool (*uniform RTC_PROGRESS_MONITOR_FUNCTION)(void* uniform ptr, const uniform double n);
|
||||
|
||||
/*! \brief Sets the progress callback function which is called during hierarchy build. */
|
||||
void rtcSetProgressMonitorFunction(RTCScene scene, RTC_PROGRESS_MONITOR_FUNCTION func, void* uniform ptr);
|
||||
|
||||
/*! Commits the geometry of the scene. After initializing or modifying
|
||||
* geometries, commit has to get called before tracing
|
||||
* rays. */
|
||||
void rtcCommit (RTCScene scene);
|
||||
|
||||
/*! Commits the geometry of the scene. The calling threads will be
|
||||
* used internally as a worker threads on some implementations. The
|
||||
* function will wait until 'numThreads' threads have called this
|
||||
* function and all threads return from the function after the scene
|
||||
* commit is finished. The application threads will not be used as
|
||||
* worker threads when the TBB tasking system is enabled (which is
|
||||
* the default). On CPUs, we recommend also using TBB inside your
|
||||
* application to share threads. We recommend using the
|
||||
* rtcCommitThread feature to share threads on the Xeon Phi
|
||||
* coprocessor. */
|
||||
void rtcCommitThread(RTCScene scene, uniform unsigned int threadID, uniform unsigned int numThreads);
|
||||
|
||||
/*! Returns to AABB of the scene. rtcCommit has to get called
|
||||
* previously to this function. */
|
||||
void rtcGetBounds(RTCScene scene, uniform RTCBounds& bounds_o);
|
||||
|
||||
/*! Intersects a uniform ray with the scene. This function can only be
|
||||
* called for scenes with the RTC_INTERSECT_UNIFORM flag set. The ray
|
||||
* has to be aligned to 16 bytes. */
|
||||
void rtcIntersect1 (RTCScene scene, uniform RTCRay1& ray);
|
||||
|
||||
/*! Intersects a varying ray with the scene. This function can only be
|
||||
* called for scenes with the RTC_INTERSECT_VARYING flag set. The
|
||||
* valid mask and ray have both to be aligned to sizeof(varing float)
|
||||
* bytes. */
|
||||
void rtcIntersect (RTCScene scene, varying RTCRay& ray);
|
||||
|
||||
|
||||
/*! Intersects a stream of N rays in AOS layout with the scene. This
|
||||
* function can only be called for scenes with the RTC_INTERSECTN
|
||||
* flag set. The stride specifies the offset between rays in
|
||||
* bytes. */
|
||||
void rtcIntersectN (RTCScene scene, uniform RTCRay* uniform rayN, const uniform size_t N, const uniform size_t stride, const uniform size_t flags);
|
||||
|
||||
/*! Intersects one or multiple streams of N rays in compact SOA layout with the scene. This
|
||||
* function can only be called for scenes with the RTC_INTERSECTN
|
||||
* flag set. 'streams' specifies the number of dense SOA ray
|
||||
* streams, and 'stride' the offset in bytes between those. */
|
||||
void rtcIntersectN_SOA (RTCScene scene, uniform RTCRaySOA& rayN, const uniform size_t N, const uniform size_t streams, const uniform size_t offset, const uniform size_t flags);
|
||||
|
||||
|
||||
/*! Tests if a uniform ray is occluded by the scene. This function can
|
||||
* only be called for scenes with the RTC_INTERSECT_UNIFORM flag
|
||||
* set. The ray has to be aligned to 16 bytes. */
|
||||
void rtcOccluded1 (RTCScene scene, uniform RTCRay1& ray);
|
||||
|
||||
/*! Tests if a varying ray is occluded by the scene. This function can
|
||||
* only be called for scenes with the RTC_INTERSECT_VARYING flag
|
||||
* set. The valid mask and ray have both to be aligned to
|
||||
* sizeof(varing float) bytes. */
|
||||
void rtcOccluded (RTCScene scene, varying RTCRay& ray);
|
||||
|
||||
|
||||
/*! Tests if a stream of N rays on AOS layout is occluded by the
|
||||
* scene. This function can only be called for scenes with the
|
||||
* RTC_INTERSECTN flag set. The stride specifies the offset between
|
||||
* rays in bytes.*/
|
||||
void rtcOccludedN (RTCScene scene, uniform RTCRay* uniform rayN, const uniform size_t N, const uniform size_t stride, const uniform size_t flags);
|
||||
|
||||
/*! Intersects one or multiple streams of N rays in compact SOA layout with the scene. This
|
||||
* function can only be called for scenes with the RTC_INTERSECTN
|
||||
* flag set. 'streams' specifies the number of dense SOA ray
|
||||
* streams, and 'stride' the offset in bytes between those. */
|
||||
void rtcOccludedN_SOA (RTCScene scene, uniform RTCRaySOA& rayN, const uniform size_t N, const uniform size_t streams, const uniform size_t offset, const uniform size_t flags);
|
||||
|
||||
/*! Deletes the geometry again. */
|
||||
void rtcDeleteScene (RTCScene scene);
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif
|
||||
85
src/libigl/igl/embree/line_mesh_intersection.cpp
Normal file
85
src/libigl/igl/embree/line_mesh_intersection.cpp
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "line_mesh_intersection.h"
|
||||
#include "../Hit.h"
|
||||
|
||||
// For error printing
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
|
||||
#include <igl/per_vertex_normals.h>
|
||||
#include <igl/embree/EmbreeIntersector.h>
|
||||
|
||||
template <typename ScalarMatrix, typename IndexMatrix>
|
||||
IGL_INLINE ScalarMatrix igl::embree::line_mesh_intersection
|
||||
(
|
||||
const ScalarMatrix & V_source,
|
||||
const ScalarMatrix & N_source,
|
||||
const ScalarMatrix & V_target,
|
||||
const IndexMatrix & F_target
|
||||
)
|
||||
{
|
||||
|
||||
double tol = 0.00001;
|
||||
|
||||
Eigen::MatrixXd ray_pos = V_source;
|
||||
Eigen::MatrixXd ray_dir = N_source;
|
||||
|
||||
// Allocate matrix for the result
|
||||
ScalarMatrix R;
|
||||
R.resize(V_source.rows(), 3);
|
||||
|
||||
// Initialize embree
|
||||
EmbreeIntersector embree;
|
||||
embree.init(V_target.template cast<float>(),F_target.template cast<int>());
|
||||
|
||||
// Shoot rays from the source to the target
|
||||
for (unsigned i=0; i<ray_pos.rows(); ++i)
|
||||
{
|
||||
igl::Hit A,B;
|
||||
// Shoot ray A
|
||||
Eigen::RowVector3d A_pos = ray_pos.row(i) + tol * ray_dir.row(i);
|
||||
Eigen::RowVector3d A_dir = -ray_dir.row(i);
|
||||
|
||||
bool A_hit = embree.intersectBeam(A_pos.cast<float>(), A_dir.cast<float>(),A);
|
||||
|
||||
Eigen::RowVector3d B_pos = ray_pos.row(i) - tol * ray_dir.row(i);
|
||||
Eigen::RowVector3d B_dir = ray_dir.row(i);
|
||||
|
||||
bool B_hit = embree.intersectBeam(B_pos.cast<float>(), B_dir.cast<float>(),B);
|
||||
|
||||
|
||||
int choice = -1;
|
||||
|
||||
if (A_hit && ! B_hit)
|
||||
choice = 0;
|
||||
else if (!A_hit && B_hit)
|
||||
choice = 1;
|
||||
else if (A_hit && B_hit)
|
||||
choice = A.t > B.t;
|
||||
|
||||
Eigen::RowVector3d temp;
|
||||
|
||||
if (choice == -1)
|
||||
temp << -1, 0, 0;
|
||||
else if (choice == 0)
|
||||
temp << A.id, A.u, A.v;
|
||||
else if (choice == 1)
|
||||
temp << B.id, B.u, B.v;
|
||||
|
||||
R.row(i) = temp;
|
||||
|
||||
}
|
||||
|
||||
return R;
|
||||
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
template Eigen::Matrix<double, -1, -1, 0, -1, -1> igl::embree::line_mesh_intersection<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&);
|
||||
#endif
|
||||
51
src/libigl/igl/embree/line_mesh_intersection.h
Normal file
51
src/libigl/igl/embree/line_mesh_intersection.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_LINE_MESH_INTERSECTION_H
|
||||
#define IGL_EMBREE_LINE_MESH_INTERSECTION_H
|
||||
#include <igl/igl_inline.h>
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
#include <vector>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Project the point cloud V_source onto the triangle mesh
|
||||
// V_target,F_target.
|
||||
// A ray is casted for every vertex in the direction specified by
|
||||
// N_source and its opposite.
|
||||
//
|
||||
// Input:
|
||||
// V_source: #Vx3 Vertices of the source mesh
|
||||
// N_source: #Vx3 Normals of the point cloud
|
||||
// V_target: #V2x3 Vertices of the target mesh
|
||||
// F_target: #F2x3 Faces of the target mesh
|
||||
//
|
||||
// Output:
|
||||
// #Vx3 matrix of baricentric coordinate. Each row corresponds to
|
||||
// a vertex of the projected mesh and it has the following format:
|
||||
// id b1 b2. id is the id of a face of the source mesh. b1 and b2 are
|
||||
// the barycentric coordinates wrt the first two edges of the triangle
|
||||
// To convert to standard global coordinates, see barycentric_to_global.h
|
||||
template <typename ScalarMatrix, typename IndexMatrix>
|
||||
IGL_INLINE ScalarMatrix line_mesh_intersection
|
||||
(
|
||||
const ScalarMatrix & V_source,
|
||||
const ScalarMatrix & N_source,
|
||||
const ScalarMatrix & V_target,
|
||||
const IndexMatrix & F_target
|
||||
);
|
||||
}
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "line_mesh_intersection.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
259
src/libigl/igl/embree/reorient_facets_raycast.cpp
Normal file
259
src/libigl/igl/embree/reorient_facets_raycast.cpp
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "reorient_facets_raycast.h"
|
||||
#include "../per_face_normals.h"
|
||||
#include "../doublearea.h"
|
||||
#include "../random_dir.h"
|
||||
#include "../bfs_orient.h"
|
||||
#include "EmbreeIntersector.h"
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <ctime>
|
||||
#include <limits>
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedI,
|
||||
typename DerivedC>
|
||||
IGL_INLINE void igl::embree::reorient_facets_raycast(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
int rays_total,
|
||||
int rays_minimum,
|
||||
bool facet_wise,
|
||||
bool use_parity,
|
||||
bool is_verbose,
|
||||
Eigen::PlainObjectBase<DerivedI> & I,
|
||||
Eigen::PlainObjectBase<DerivedC> & C)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
assert(F.cols() == 3);
|
||||
assert(V.cols() == 3);
|
||||
|
||||
// number of faces
|
||||
const int m = F.rows();
|
||||
|
||||
MatrixXi FF = F;
|
||||
if (facet_wise) {
|
||||
C.resize(m);
|
||||
for (int i = 0; i < m; ++i) C(i) = i;
|
||||
|
||||
} else {
|
||||
if (is_verbose) cout << "extracting patches... ";
|
||||
bfs_orient(F,FF,C);
|
||||
}
|
||||
if (is_verbose) cout << (C.maxCoeff() + 1) << " components. ";
|
||||
|
||||
// number of patches
|
||||
const int num_cc = C.maxCoeff()+1;
|
||||
|
||||
// Init Embree
|
||||
EmbreeIntersector ei;
|
||||
ei.init(V.template cast<float>(),FF);
|
||||
|
||||
// face normal
|
||||
MatrixXd N;
|
||||
per_face_normals(V,FF,N);
|
||||
|
||||
// face area
|
||||
Matrix<typename DerivedV::Scalar,Dynamic,1> A;
|
||||
doublearea(V,FF,A);
|
||||
double area_total = A.sum();
|
||||
|
||||
// determine number of rays per component according to its area
|
||||
VectorXd area_per_component;
|
||||
area_per_component.setZero(num_cc);
|
||||
for (int f = 0; f < m; ++f)
|
||||
{
|
||||
area_per_component(C(f)) += A(f);
|
||||
}
|
||||
VectorXi num_rays_per_component(num_cc);
|
||||
for (int c = 0; c < num_cc; ++c)
|
||||
{
|
||||
num_rays_per_component(c) = max<int>(static_cast<int>(rays_total * area_per_component(c) / area_total), rays_minimum);
|
||||
}
|
||||
rays_total = num_rays_per_component.sum();
|
||||
|
||||
// generate all the rays
|
||||
if (is_verbose) cout << "generating rays... ";
|
||||
uniform_real_distribution<float> rdist;
|
||||
mt19937 prng;
|
||||
prng.seed(time(nullptr));
|
||||
vector<int > ray_face;
|
||||
vector<Vector3f> ray_ori;
|
||||
vector<Vector3f> ray_dir;
|
||||
ray_face.reserve(rays_total);
|
||||
ray_ori .reserve(rays_total);
|
||||
ray_dir .reserve(rays_total);
|
||||
for (int c = 0; c < num_cc; ++c)
|
||||
{
|
||||
if (area_per_component[c] == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
vector<int> CF; // set of faces per component
|
||||
vector<double> CF_area;
|
||||
for (int f = 0; f < m; ++f)
|
||||
{
|
||||
if (C(f)==c)
|
||||
{
|
||||
CF.push_back(f);
|
||||
CF_area.push_back(A(f));
|
||||
}
|
||||
}
|
||||
// discrete distribution for random selection of faces with probability proportional to their areas
|
||||
discrete_distribution<int> ddist(CF.size(), 0, CF.size(), [&](double i){ return CF_area[static_cast<int>(i)]; }); // simple ctor of (Iter, Iter) not provided by the stupid VC11/12
|
||||
for (int i = 0; i < num_rays_per_component[c]; ++i)
|
||||
{
|
||||
int f = CF[ddist(prng)]; // select face with probability proportional to face area
|
||||
float s = rdist(prng); // random barycentric coordinate (reference: Generating Random Points in Triangles [Turk, Graphics Gems I 1990])
|
||||
float t = rdist(prng);
|
||||
float sqrt_t = sqrtf(t);
|
||||
float a = 1 - sqrt_t;
|
||||
float b = (1 - s) * sqrt_t;
|
||||
float c = s * sqrt_t;
|
||||
Vector3f p = a * V.row(FF(f,0)).template cast<float>().eval() // be careful with the index!!!
|
||||
+ b * V.row(FF(f,1)).template cast<float>().eval()
|
||||
+ c * V.row(FF(f,2)).template cast<float>().eval();
|
||||
Vector3f n = N.row(f).cast<float>();
|
||||
if (n.isZero()) continue;
|
||||
// random direction in hemisphere around n (avoid too grazing angle)
|
||||
Vector3f d;
|
||||
while (true) {
|
||||
d = random_dir().cast<float>();
|
||||
float ndotd = n.dot(d);
|
||||
if (fabsf(ndotd) < 0.1f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (ndotd < 0)
|
||||
{
|
||||
d *= -1.0f;
|
||||
}
|
||||
break;
|
||||
}
|
||||
ray_face.push_back(f);
|
||||
ray_ori .push_back(p);
|
||||
ray_dir .push_back(d);
|
||||
|
||||
if (is_verbose && ray_face.size() % (rays_total / 10) == 0) cout << ".";
|
||||
}
|
||||
}
|
||||
if (is_verbose) cout << ray_face.size() << " rays. ";
|
||||
|
||||
// per component voting: first=front, second=back
|
||||
vector<pair<float, float>> C_vote_distance(num_cc, make_pair(0, 0)); // sum of distance between ray origin and intersection
|
||||
vector<pair<int , int >> C_vote_infinity(num_cc, make_pair(0, 0)); // number of rays reaching infinity
|
||||
vector<pair<int , int >> C_vote_parity(num_cc, make_pair(0, 0)); // sum of parity count for each ray
|
||||
|
||||
if (is_verbose) cout << "shooting rays... ";
|
||||
#pragma omp parallel for
|
||||
for (int i = 0; i < (int)ray_face.size(); ++i)
|
||||
{
|
||||
int f = ray_face[i];
|
||||
Vector3f o = ray_ori [i];
|
||||
Vector3f d = ray_dir [i];
|
||||
int c = C(f);
|
||||
|
||||
// shoot ray toward front & back
|
||||
vector<Hit> hits_front;
|
||||
vector<Hit> hits_back;
|
||||
int num_rays_front;
|
||||
int num_rays_back;
|
||||
ei.intersectRay(o, d, hits_front, num_rays_front);
|
||||
ei.intersectRay(o, -d, hits_back , num_rays_back );
|
||||
if (!hits_front.empty() && hits_front[0].id == f) hits_front.erase(hits_front.begin());
|
||||
if (!hits_back .empty() && hits_back [0].id == f) hits_back .erase(hits_back .begin());
|
||||
|
||||
if (use_parity) {
|
||||
#pragma omp atomic
|
||||
C_vote_parity[c].first += hits_front.size() % 2;
|
||||
#pragma omp atomic
|
||||
C_vote_parity[c].second += hits_back .size() % 2;
|
||||
|
||||
} else {
|
||||
if (hits_front.empty())
|
||||
{
|
||||
#pragma omp atomic
|
||||
C_vote_infinity[c].first++;
|
||||
} else {
|
||||
#pragma omp atomic
|
||||
C_vote_distance[c].first += hits_front[0].t;
|
||||
}
|
||||
|
||||
if (hits_back.empty())
|
||||
{
|
||||
#pragma omp atomic
|
||||
C_vote_infinity[c].second++;
|
||||
} else {
|
||||
#pragma omp atomic
|
||||
C_vote_distance[c].second += hits_back[0].t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
I.resize(m);
|
||||
for(int f = 0; f < m; ++f)
|
||||
{
|
||||
int c = C(f);
|
||||
if (use_parity) {
|
||||
I(f) = C_vote_parity[c].first > C_vote_parity[c].second ? 1 : 0; // Ideally, parity for the front/back side should be 1/0 (i.e., parity sum for all rays should be smaller on the front side)
|
||||
|
||||
} else {
|
||||
I(f) = (C_vote_infinity[c].first == C_vote_infinity[c].second && C_vote_distance[c].first < C_vote_distance[c].second) ||
|
||||
C_vote_infinity[c].first < C_vote_infinity[c].second
|
||||
? 1 : 0;
|
||||
}
|
||||
// To account for the effect of bfs_orient
|
||||
if (F.row(f) != FF.row(f))
|
||||
I(f) = 1 - I(f);
|
||||
}
|
||||
if (is_verbose) cout << "done!" << endl;
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedFF,
|
||||
typename DerivedI>
|
||||
IGL_INLINE void igl::embree::reorient_facets_raycast(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
Eigen::PlainObjectBase<DerivedFF> & FF,
|
||||
Eigen::PlainObjectBase<DerivedI> & I)
|
||||
{
|
||||
const int rays_total = F.rows()*100;
|
||||
const int rays_minimum = 10;
|
||||
const bool facet_wise = false;
|
||||
const bool use_parity = false;
|
||||
const bool is_verbose = false;
|
||||
Eigen::VectorXi C;
|
||||
reorient_facets_raycast(
|
||||
V,F,rays_total,rays_minimum,facet_wise,use_parity,is_verbose,I,C);
|
||||
// Conservative in case FF = F
|
||||
FF.conservativeResize(F.rows(),F.cols());
|
||||
for(int i = 0;i<I.rows();i++)
|
||||
{
|
||||
if(I(i))
|
||||
{
|
||||
FF.row(i) = (F.row(i).reverse()).eval();
|
||||
}else
|
||||
{
|
||||
FF.row(i) = F.row(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::embree::reorient_facets_raycast<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::reorient_facets_raycast<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, int, bool, bool, bool, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::reorient_facets_raycast<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, int, bool, bool, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
73
src/libigl/igl/embree/reorient_facets_raycast.h
Normal file
73
src/libigl/igl/embree/reorient_facets_raycast.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_REORIENT_FACETS_RAYCAST_H
|
||||
#define IGL_EMBREE_REORIENT_FACETS_RAYCAST_H
|
||||
#include "../igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Orient each component (identified by C) of a mesh (V,F) using ambient
|
||||
// occlusion such that the front side is less occluded than back side, as
|
||||
// described in "A Simple Method for Correcting Facet Orientations in
|
||||
// Polygon Meshes Based on Ray Casting" [Takayama et al. 2014].
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 3 list of vertex positions
|
||||
// F #F by 3 list of triangle indices
|
||||
// rays_total Total number of rays that will be shot
|
||||
// rays_minimum Minimum number of rays that each patch should receive
|
||||
// facet_wise Decision made for each face independently, no use of patches
|
||||
// (i.e., each face is treated as a patch)
|
||||
// use_parity Use parity mode
|
||||
// is_verbose Verbose output to cout
|
||||
// Outputs:
|
||||
// I #F list of whether face has been flipped
|
||||
// C #F list of patch ID (output of bfs_orient > manifold patches)
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedI,
|
||||
typename DerivedC>
|
||||
IGL_INLINE void reorient_facets_raycast(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
int rays_total,
|
||||
int rays_minimum,
|
||||
bool facet_wise,
|
||||
bool use_parity,
|
||||
bool is_verbose,
|
||||
Eigen::PlainObjectBase<DerivedI> & I,
|
||||
Eigen::PlainObjectBase<DerivedC> & C);
|
||||
// Outputs:
|
||||
// FF #F by 3 list of reoriented faces
|
||||
// Defaults:
|
||||
// rays_total = F.rows()*100;
|
||||
// rays_minimum = 10;
|
||||
// facet_wise = false;
|
||||
// use_parity = false;
|
||||
// is_verbose = false;
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedFF,
|
||||
typename DerivedI>
|
||||
IGL_INLINE void reorient_facets_raycast(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
Eigen::PlainObjectBase<DerivedFF> & FF,
|
||||
Eigen::PlainObjectBase<DerivedI> & I);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "reorient_facets_raycast.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
69
src/libigl/igl/embree/shape_diameter_function.cpp
Normal file
69
src/libigl/igl/embree/shape_diameter_function.cpp
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "shape_diameter_function.h"
|
||||
#include "../shape_diameter_function.h"
|
||||
#include "EmbreeIntersector.h"
|
||||
#include "../Hit.h"
|
||||
|
||||
template <
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::embree::shape_diameter_function(
|
||||
const igl::embree::EmbreeIntersector & ei,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
const auto & shoot_ray = [&ei](
|
||||
const Eigen::Vector3f& s,
|
||||
const Eigen::Vector3f& dir)->double
|
||||
{
|
||||
igl::Hit hit;
|
||||
const float tnear = 1e-4f;
|
||||
if(ei.intersectRay(s,dir,hit,tnear))
|
||||
{
|
||||
return hit.t;
|
||||
}else
|
||||
{
|
||||
return std::numeric_limits<double>::infinity();
|
||||
}
|
||||
};
|
||||
return igl::shape_diameter_function(shoot_ray,P,N,num_samples,S);
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::embree::shape_diameter_function(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
using namespace Eigen;
|
||||
EmbreeIntersector ei;
|
||||
ei.init(V.template cast<float>(),F.template cast<int>());
|
||||
shape_diameter_function(ei,P,N,num_samples,S);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::embree::shape_diameter_function<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::shape_diameter_function<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::shape_diameter_function<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::shape_diameter_function<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::embree::shape_diameter_function<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
60
src/libigl/igl/embree/shape_diameter_function.h
Normal file
60
src/libigl/igl/embree/shape_diameter_function.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_SHAPE_DIAMETER_FUNCTION_H
|
||||
#define IGL_EMBREE_SHAPE_DIAMETER_FUNCTION_H
|
||||
#include "../igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Forward define
|
||||
class EmbreeIntersector;
|
||||
// Compute shape diamter function per given point
|
||||
//
|
||||
// Inputs:
|
||||
// ei EmbreeIntersector containing (V,F)
|
||||
// P #P by 3 list of origin points
|
||||
// N #P by 3 list of origin normals
|
||||
// Outputs:
|
||||
// S #P list of shape diamater function values between bounding box
|
||||
// diagonal (perfect sphere) and 0 (perfect needle hook)
|
||||
//
|
||||
template <
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void shape_diameter_function(
|
||||
const EmbreeIntersector & ei,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
// Wrapper which builds new EmbreeIntersector for (V,F). That's expensive so
|
||||
// avoid this if repeatedly calling.
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void shape_diameter_function(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::PlainObjectBase<DerivedP> & P,
|
||||
const Eigen::PlainObjectBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
}
|
||||
};
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "shape_diameter_function.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
55
src/libigl/igl/embree/unproject_in_mesh.cpp
Normal file
55
src/libigl/igl/embree/unproject_in_mesh.cpp
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "unproject_in_mesh.h"
|
||||
#include "EmbreeIntersector.h"
|
||||
#include "../unproject_ray.h"
|
||||
#include "../unproject_in_mesh.h"
|
||||
#include <vector>
|
||||
|
||||
template <typename Derivedobj>
|
||||
IGL_INLINE int igl::embree::unproject_in_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
Eigen::PlainObjectBase<Derivedobj> & obj,
|
||||
std::vector<igl::Hit > & hits)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
const auto & shoot_ray = [&ei](
|
||||
const Eigen::Vector3f& s,
|
||||
const Eigen::Vector3f& dir,
|
||||
std::vector<igl::Hit> & hits)
|
||||
{
|
||||
int num_rays_shot;
|
||||
ei.intersectRay(s,dir,hits,num_rays_shot);
|
||||
};
|
||||
return igl::unproject_in_mesh(pos,model,proj,viewport,shoot_ray,obj,hits);
|
||||
}
|
||||
|
||||
template <typename Derivedobj>
|
||||
IGL_INLINE int igl::embree::unproject_in_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
Eigen::PlainObjectBase<Derivedobj> & obj)
|
||||
{
|
||||
std::vector<igl::Hit> hits;
|
||||
return unproject_in_mesh(pos,model,proj,viewport,ei,obj,hits);
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<igl::Hit, std::allocator<igl::Hit> >&);
|
||||
template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&, std::vector<igl::Hit, std::allocator<igl::Hit> >&);
|
||||
template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
||||
#endif
|
||||
72
src/libigl/igl/embree/unproject_in_mesh.h
Normal file
72
src/libigl/igl/embree/unproject_in_mesh.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_UNPROJECT_IN_MESH
|
||||
#define IGL_EMBREE_UNPROJECT_IN_MESH
|
||||
#include <igl/igl_inline.h>
|
||||
#include <Eigen/Core>
|
||||
|
||||
#include <vector>
|
||||
#include "../Hit.h"
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Forward define
|
||||
class EmbreeIntersector;
|
||||
|
||||
// Unproject a screen location (using current opengl viewport, projection, and
|
||||
// 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:
|
||||
// pos screen space coordinates
|
||||
// model model matrix
|
||||
// proj projection matrix
|
||||
// viewport vieweport vector
|
||||
// ei EmbreeIntersector containing (V,F)
|
||||
// Outputs:
|
||||
// obj 3d unprojected mouse point in mesh
|
||||
// hits vector of embree hits
|
||||
// Returns number of hits
|
||||
//
|
||||
// Note: Previous prototype did not require model, proj, and viewport. This
|
||||
// has been removed. Instead replace with:
|
||||
//
|
||||
// Eigen::Matrix4f model,proj;
|
||||
// Eigen::Vector4f viewport;
|
||||
// igl::opengl2::model_proj_viewport(model,proj,viewport);
|
||||
// igl::embree::unproject_in_mesh(Vector2f(x,y),model,proj,viewport,ei,obj,hits);
|
||||
//
|
||||
template < typename Derivedobj>
|
||||
IGL_INLINE int unproject_in_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
Eigen::PlainObjectBase<Derivedobj> & obj,
|
||||
std::vector<igl::Hit > & hits);
|
||||
template < typename Derivedobj>
|
||||
IGL_INLINE int unproject_in_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
Eigen::PlainObjectBase<Derivedobj> & obj);
|
||||
|
||||
}
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "unproject_in_mesh.cpp"
|
||||
#endif
|
||||
#endif
|
||||
59
src/libigl/igl/embree/unproject_onto_mesh.cpp
Normal file
59
src/libigl/igl/embree/unproject_onto_mesh.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "unproject_onto_mesh.h"
|
||||
#include "EmbreeIntersector.h"
|
||||
#include "../unproject_onto_mesh.h"
|
||||
#include <vector>
|
||||
|
||||
IGL_INLINE bool igl::embree::unproject_onto_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::MatrixXi& F,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
int& fid,
|
||||
Eigen::Vector3f& bc)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
const auto & shoot_ray = [&ei](
|
||||
const Eigen::Vector3f& s,
|
||||
const Eigen::Vector3f& dir,
|
||||
igl::Hit & hit)->bool
|
||||
{
|
||||
return ei.intersectRay(s,dir,hit);
|
||||
};
|
||||
return igl::unproject_onto_mesh(pos,model,proj,viewport,shoot_ray,fid,bc);
|
||||
}
|
||||
|
||||
IGL_INLINE bool igl::embree::unproject_onto_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::MatrixXi& F,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
int& fid,
|
||||
int& vid)
|
||||
{
|
||||
Eigen::Vector3f bc;
|
||||
if(!igl::embree::unproject_onto_mesh(pos,F,model,proj,viewport,ei,fid,bc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int i;
|
||||
bc.maxCoeff(&i);
|
||||
vid = F(fid,i);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
#endif
|
||||
73
src/libigl/igl/embree/unproject_onto_mesh.h
Normal file
73
src/libigl/igl/embree/unproject_onto_mesh.h
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EMBREE_UNPROJECT_ONTO_MESH_H
|
||||
#define IGL_EMBREE_UNPROJECT_ONTO_MESH_H
|
||||
#include <igl/igl_inline.h>
|
||||
#include <Eigen/Core>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace embree
|
||||
{
|
||||
// Forward define
|
||||
class EmbreeIntersector;
|
||||
// Unproject a screen location (using the given model, proj and viewport) to find
|
||||
// the first hit on a mesh.
|
||||
//
|
||||
// Inputs:
|
||||
// pos screen space coordinates
|
||||
// F #F by 3 face matrix
|
||||
// model model matrix
|
||||
// proj projection matrix
|
||||
// viewport vieweport vector
|
||||
// ei EmbreeIntersector containing (V,F)
|
||||
// Outputs:
|
||||
// fid id of the first face hit
|
||||
// bc barycentric coordinates of hit
|
||||
// Returns true if there is a hit
|
||||
IGL_INLINE bool unproject_onto_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::MatrixXi& F,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
int& fid,
|
||||
Eigen::Vector3f& bc);
|
||||
|
||||
// Unproject a screen location (using the given model, proj and viewport) to find
|
||||
// the first face on the mesh and the closest vertex
|
||||
//
|
||||
// Inputs:
|
||||
// pos screen space coordinates
|
||||
// F #F by 3 face matrix
|
||||
// model model matrix
|
||||
// proj projection matrix
|
||||
// viewport vieweport vector
|
||||
// ei EmbreeIntersector containing (V,F)
|
||||
// Outputs:
|
||||
// fid id of the first face hit
|
||||
// vid vertex id of the closest vertex hit
|
||||
// Returns true if there is a hit
|
||||
IGL_INLINE bool unproject_onto_mesh(
|
||||
const Eigen::Vector2f& pos,
|
||||
const Eigen::MatrixXi& F,
|
||||
const Eigen::Matrix4f& model,
|
||||
const Eigen::Matrix4f& proj,
|
||||
const Eigen::Vector4f& viewport,
|
||||
const EmbreeIntersector & ei,
|
||||
int& fid,
|
||||
int& vid);
|
||||
}
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "unproject_onto_mesh.cpp"
|
||||
#endif
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue