3 #include "core/azimuth_elevation.h" 4 #include "core/geo/geometric.h" 5 #include "core/scene_data.h" 6 #include "core/spatial_division/voxel_collection.h" 13 template <
typename Vertex,
typename Surface>
15 static auto compute_triangle_indices(
size_t num) {
16 util::aligned::vector<size_t> ret(num);
17 std::iota(ret.begin(), ret.end(), 0);
31 : scene_{std::move(scene)}
34 [
this](
auto item,
const auto& aabb) {
38 padded(aabb, glm::vec3{0.001}),
39 geo::get_triangle_vec3(
40 scene_.get_triangles()[item],
41 scene_.get_vertices().data()));
43 compute_triangle_indices(scene_.get_triangles().size()),
46 const scene_data& get_scene_data()
const {
return scene_; }
50 template <
typename It>
51 void set_surfaces(It begin, It end) {
61 template <
typename Vertex,
typename Surface,
typename T>
66 std::move(scene), octree_depth, aabb};
69 template <
typename Vertex,
typename Surface,
typename Pad>
74 padded(geo::compute_aabb(scene.get_vertices()), glm::vec3{padding});
75 return make_voxelised_scene_data(std::move(scene), octree_depth, aabb);
80 template <
typename Vertex,
typename Surface>
81 std::experimental::optional<intersection> intersects(
84 size_t to_ignore = ~
size_t{0}) {
85 std::experimental::optional<intersection> state;
86 traverse(voxelised.get_voxels(),
91 float max_dist_inside_voxel) {
92 const auto i = ray_triangle_intersection(
96 voxelised.get_scene_data().get_triangles().data(),
97 voxelised.get_scene_data().get_vertices().data(),
99 if (i && i->inter.t <= max_dist_inside_voxel) {
108 template <
typename Vertex,
typename Surface>
109 std::experimental::optional<size_t> count_intersections(
113 bool degenerate{
false};
115 traverse(voxelised.get_voxels(),
118 const voxel& to_test,
119 float min_dist_inside_voxel,
120 float max_dist_inside_voxel) {
122 for (
const auto i : to_test) {
126 voxelised.get_scene_data().get_triangles()[i],
127 voxelised.get_scene_data().get_vertices().data(),
139 if (min_dist_inside_voxel < intersection->t &&
149 return std::experimental::nullopt;
155 template <
typename Vertex,
typename Surface>
156 std::experimental::optional<bool> is_inside(
159 if (
const auto i = count_intersections(voxelised, ray)) {
162 return std::experimental::nullopt;
166 template <
typename Vertex,
typename Surface>
168 const glm::vec3& pt) {
169 std::default_random_engine engine{std::random_device{}()};
172 const geo::ray ray{pt, sphere_point(rng.get_z(), rng.get_theta())};
173 if (
const auto i{is_inside(voxelised, ray)}) {
Definition: scene_data.h:13
Definition: geometry_structs.h:11
I would do this with a struct, but rays have an invariant:
Definition: geometric.h:19
A generic interface for spatial division algorithms (octree, quadtree)
Definition: ndim_tree.h:38
Definition: voxel_structs.h:9
void set_surfaces(It begin, It end)
Definition: scene_data.h:64
Definition: geometry_structs.h:71
Definition: azimuth_elevation.h:15
Definition: scene_structs.h:28
Definition: capsule_base.h:9
Definition: voxelised_scene_data.h:14