Wayverb
canonical.h
1 #pragma once
2 
3 #include "raytracer/raytracer.h"
4 #include "raytracer/simulation_parameters.h"
5 
6 #include "core/spatial_division/voxelised_scene_data.h"
7 
8 namespace wayverb {
9 namespace raytracer {
10 
11 std::tuple<reflection_processor::make_image_source,
12  reflection_processor::make_directional_histogram,
13  reflection_processor::make_visual>
14 make_canonical_callbacks(const simulation_parameters& params,
15  size_t visual_items);
16 
17 template <typename Histogram>
18 struct simulation_results final {
19  util::aligned::vector<impulse<core::simulation_bands>> image_source;
20  Histogram stochastic;
21 };
22 
23 template <typename Histogram>
24 auto make_simulation_results(
25  util::aligned::vector<impulse<core::simulation_bands>> image_source,
26  Histogram stochastic) {
27  return simulation_results<Histogram>{std::move(image_source),
28  std::move(stochastic)};
29 }
30 
31 template <typename Histogram>
32 struct canonical_results final {
34  util::aligned::vector<util::aligned::vector<reflection>> visual;
35 };
36 
37 template <typename Histogram>
38 auto make_canonical_results(
40  util::aligned::vector<util::aligned::vector<reflection>> visual) {
41  return canonical_results<Histogram>{std::move(aural), std::move(visual)};
42 }
43 
44 template <typename Callback>
45 auto canonical(
46  const core::compute_context& cc,
47  const core::voxelised_scene_data<cl_float3,
49  scene,
50  const glm::vec3& source,
51  const glm::vec3& receiver,
52  const core::environment& environment,
53  const simulation_parameters& sim_params,
54  size_t visual_items,
55  const std::atomic_bool& keep_going,
56  Callback&& callback) {
57  std::default_random_engine engine{std::random_device{}()};
58 
59  auto tup = run(
60  make_random_direction_generator_iterator(0, engine),
61  make_random_direction_generator_iterator(sim_params.rays, engine),
62  cc,
63  scene,
64  source,
65  receiver,
66  environment,
67  keep_going,
68  std::forward<Callback>(callback),
69  make_canonical_callbacks(sim_params, visual_items));
70  return tup ? std::experimental::make_optional(make_canonical_results(
71  make_simulation_results(std::move(std::get<0>(*tup)),
72  std::move(std::get<1>(*tup))),
73  std::move(std::get<2>(*tup))))
74  : std::experimental::nullopt;
75 }
76 
77 } // namespace raytracer
78 } // namespace wayverb
size_t rays
Definition: simulation_parameters.h:13
Definition: structs.h:38
Definition: canonical.h:32
Definition: pressure.h:22
Definition: canonical.h:18
Definition: environment.h:6
Definition: capsule_base.h:9
invariant: device is a valid device for the context
Definition: common.h:13
Definition: simulation_parameters.h:9
Definition: voxelised_scene_data.h:14