Wayverb
get_direct.h
1 #pragma once
2 
3 #include "raytracer/cl/structs.h"
4 
5 #include "core/spatial_division/voxelised_scene_data.h"
6 #include "core/unit_constructor.h"
7 
8 namespace wayverb {
9 namespace raytracer {
10 namespace image_source {
11 
14 template <typename Vertex, typename Surface>
15 auto get_direct(const glm::vec3& source,
16  const glm::vec3& receiver,
17  const core::voxelised_scene_data<Vertex, Surface>& scene_data) {
18  constexpr auto channels = typename Surface::bands_t{};
19 
20  if (source == receiver) {
21  return std::experimental::optional<impulse<channels>>{};
22  }
23 
24  const auto source_to_receiver = receiver - source;
25  const auto source_to_receiver_length = glm::length(source_to_receiver);
26  const auto direction = glm::normalize(source_to_receiver);
27  const core::geo::ray to_receiver{source, direction};
28 
29  const auto intersection = intersects(scene_data, to_receiver);
30 
31  if (!intersection ||
32  (intersection && intersection->inter.t >= source_to_receiver_length)) {
33  return std::experimental::make_optional(impulse<channels>{
34  core::unit_constructor_v<
35  ::detail::cl_vector_constructor_t<float, channels>>,
36  core::to_cl_float3{}(source),
37  source_to_receiver_length});
38  }
39 
40  return std::experimental::optional<impulse<channels>>{};
41 }
42 
43 } // namespace image_source
44 } // namespace raytracer
45 } // namespace wayverb
Definition: pressure.h:22
Definition: capsule_base.h:9