Wayverb
geometric.h
1 #pragma once
2 
3 #include "core/cl/geometry_structs.h"
4 #include "core/cl/triangle.h"
5 
6 #include "glm/fwd.hpp"
7 
8 #include <experimental/optional>
9 #include <numeric>
10 
11 namespace wayverb {
12 namespace core {
13 namespace geo {
14 
15 struct triangle_vec3;
16 
18 // the direction is a normalized vector
19 class ray final {
20 public:
21  ray(const glm::vec3& position, const glm::vec3& direction);
22 
23  glm::vec3 get_position() const;
24  glm::vec3 get_direction() const;
25 
26 private:
27  glm::vec3 position_;
28  glm::vec3 direction_;
29 };
30 
32 
33 std::experimental::optional<triangle_inter> triangle_intersection(
34  const triangle_vec3& tri, const ray& ray, size_t ulp = 10);
35 
36 template <typename T>
37 std::experimental::optional<triangle_inter> triangle_intersection(
38  const triangle& tri, const T* v, const ray& ray);
39 
41 
42 template <typename T>
43 std::experimental::optional<intersection> intersection_accumulator(
44  const ray& ray,
45  size_t triangle_index,
46  const triangle* triangles,
47  const T* vertices,
48  const std::experimental::optional<intersection>& current,
49  size_t to_ignore = ~size_t{0});
50 
51 template <typename T>
52 std::experimental::optional<intersection> ray_triangle_intersection(
53  const ray& ray,
54  const size_t* triangle_indices,
55  size_t num_triangle_indices,
56  const triangle* triangles,
57  const T* vertices,
58  size_t to_ignore = ~size_t{0});
59 
60 template <typename T>
61 std::experimental::optional<intersection> ray_triangle_intersection(
62  const ray& ray,
63  const triangle* triangles,
64  size_t num_triangles,
65  const T* vertices,
66  size_t to_ignore = ~size_t{0});
67 
68 bool point_intersection(const glm::vec3& begin,
69  const glm::vec3& point,
70  const triangle* triangles,
71  size_t num_triangles,
72  const glm::vec3* vertices,
73  size_t num_vertices);
74 
75 float point_triangle_distance_squared(const triangle_vec3& triangle,
76  const glm::vec3& point);
77 
78 float point_triangle_distance_squared(const triangle& tri,
79  const glm::vec3* vertices,
80  size_t num_vertices,
81  const glm::vec3& point);
82 
83 glm::vec3 normal(const triangle_vec3& t);
84 
85 glm::vec3 mirror(const glm::vec3& p, const triangle_vec3& t);
86 triangle_vec3 mirror(const triangle_vec3& in, const triangle_vec3& t);
87 
88 } // namespace geo
89 
90 ray convert(const geo::ray& r);
91 
92 geo::ray convert(const ray& r);
93 
94 triangle_verts convert(const geo::triangle_vec3& t);
95 
96 geo::triangle_vec3 convert(const triangle_verts& t);
97 
98 } // namespace core
99 } // namespace wayverb
I would do this with a struct, but rays have an invariant:
Definition: geometric.h:19
Definition: traits.cpp:2
Definition: scene_structs.h:68
Definition: capsule_base.h:9
Definition: triangle_vec.h:16
Definition: triangle.h:8