2#define NANORT_USE_CPP11_FEATURE
11 template <
typename T>
class MeshInfo;
22 double3(
double xx,
double yy,
double zz) {
60 if (fabs(len) > 1.0e-6) {
61 double inv_len = 1.0 / len;
111 template <
typename T>
124 accel.
Build(num_indices, triangle_mesh, triangle_pred, build_options);
153 template <
typename dist_type = real_t,
typename N>
154 inline NanoRay ConstructRay(
const N& origin,
const N& direction, dist_type max_dist = std::numeric_limits<dist_type>::max()) {
156 out_ray.
org[0] = origin[0]; out_ray.
org[1] = origin[1]; out_ray.
org[2] = origin[2];
157 out_ray.
dir[0] = direction[0]; out_ray.
dir[1] = direction[1]; out_ray.
dir[2] = direction[2];
165 out_hit.
u = -1; out_hit.
v = -1; out_hit.
t = -1; out_hit.
prim_id = -1;
169 template <
typename po
int_type,
typename dist_type>
170 inline void MovePoint(point_type & point,
const point_type & dir, dist_type dist) {
171 point[0] += (dir[0] * dist);
172 point[1] += (dir[1] * dist);
173 point[2] += (dir[2] * dist);
183 template<
typename po
int_type,
typename dist_type = real_t>
185 const point_type& origin,
186 const point_type& dir,
187 dist_type distance = -1.0,
190 dist_type max_dist = (distance < 0) ? std::numeric_limits<dist_type>::max() : distance;
192 NanoRay ray = ConstructRay<dist_type>(origin, dir, max_dist);
207 template<
typename po
int_type>
209 const point_type& origin,
210 const point_type& dir,
214 return Intersect(origin, dir, distance, mesh_id).DidHit();
217 template<
typename po
int_type>
220 const point_type & dir,
224 auto res =
Intersect(origin, dir, distance, mesh_id);
Cast rays to determine if and where they intersect geometry.
Manipulate and load geometry from disk.
nanort::BVHAccel< double > nanoRT_BVH(Mesh &mesh)
bool nanoRT_Intersect(Mesh &mesh, nanort::BVHAccel< double > &accel, nanoRT_Data &intersector)
bool nanoRT_RayCast(nanort::BVHAccel< double > &accel, nanort::TriangleIntersector< double, nanort::TriangleIntersection< double > > &triangle_intersector, nanort::Ray< double > &ray, nanort::TriangleIntersection< double > &isect)
A collection of vertices and indices representing geometry.
A simple hit struct to carry all relevant information about hits.
Bounding Volume Hierarchy acceleration.
bool Traverse(const Ray< T > &ray, const I &intersector, H *isect, const BVHTraceOptions &options=BVHTraceOptions()) const
Traverse into BVH along ray and find closest hit point & primitive if found.
bool Build(const unsigned int num_primitives, const Prim &p, const Pred &pred, const BVHBuildOptions< T > &options=BVHBuildOptions< T >())
Build BVH for input primitives.
double3 operator-(const double3 &f2) const
double & operator[](int i)
double3 & operator+=(const double3 &f2)
double3 operator+(const double3 &f2) const
double3(double xx, double yy, double zz)
double3 operator/(const double3 &f2) const
double3 operator*(double f) const
double operator[](int i) const
double3 operator*(const double3 &f2) const
HF::nanoGeom::Mesh * mesh
nanort::Ray< double > ray
nanort::TriangleIntersection< double > hit
bool Occluded(const point_type &origin, const point_type &dir, float distance=-1, int mesh_id=-1)
std::unique_ptr< Intersector > intersector
Triangle Intersector.
void MovePoint(point_type &point, const point_type &dir, dist_type dist)
std::vector< real_t > vertices
bool PointIntersection(point_type &origin, const point_type &dir, float distance=-1, int mesh_id=-1)
HitStruct< real_t > Intersect(const point_type &origin, const point_type &dir, dist_type distance=-1.0, int mesh_id=-1)
std::vector< unsigned int > indices
NanoRay ConstructRay(const N &origin, const N &direction, dist_type max_dist=std::numeric_limits< dist_type >::max())