22#ifndef EOS_RENDER_VERTEX_VISIBILITY_HPP
23#define EOS_RENDER_VERTEX_VISIBILITY_HPP
25#include "eos/render/detail/RayDirection.hpp"
26#include "eos/render/ray_triangle_intersect.hpp"
53 const std::vector<Eigen::Vector3f>& mesh_vertices,
54 const std::vector<std::array<int, 3>>& mesh_triangle_vertex_indices,
55 detail::RayDirection ray_direction_type)
57 using Eigen::Vector3f;
60 const Vector3f ray_origin = probe_vertex;
61 const Vector3f ray_direction = [&ray_direction_type, &probe_vertex]() {
62 if (ray_direction_type == detail::RayDirection::Parallel)
65 return Vector3f(0, 0, 1);
70 return Vector3f(-probe_vertex);
78 for (
const auto& tri : mesh_triangle_vertex_indices)
80 const auto& v0 = mesh_vertices[tri[0]];
81 const auto& v1 = mesh_vertices[tri[1]];
82 const auto& v2 = mesh_vertices[tri[2]];
84 const auto intersect =
87 if (intersect.first ==
true)
92 if (intersect.second.value() <= 1e-4)
118inline std::vector<bool>
120 const std::vector<std::array<int, 3>>& triangle_vertex_indices,
121 detail::RayDirection ray_direction_type)
124 std::vector<bool> per_vertex_visibility;
125 for (
const auto& vertex : viewspace_vertices)
128 is_vertex_visible(vertex, viewspace_vertices, triangle_vertex_indices, ray_direction_type);
129 per_vertex_visibility.push_back(visible);
131 return per_vertex_visibility;
147inline std::vector<bool>
149 const std::vector<std::array<int, 3>>& triangle_vertex_indices,
150 const Eigen::Matrix4f& modelview, detail::RayDirection ray_direction_type)
152 std::vector<Eigen::Vector3f> viewspace_vertices;
153 std::for_each(std::begin(vertices), std::end(vertices), [&viewspace_vertices, &modelview](
const auto& v) {
154 const Eigen::Vector4f transformed_vertex = modelview * v.homogeneous();
155 viewspace_vertices.push_back(transformed_vertex.head<3>());
std::pair< bool, cpp17::optional< float > > ray_triangle_intersect(const Eigen::Vector3f &ray_origin, const Eigen::Vector3f &ray_direction, const Eigen::Vector3f &v0, const Eigen::Vector3f &v1, const Eigen::Vector3f &v2, bool enable_backculling)
Computes the intersection of the given ray with the given triangle.
Definition: ray_triangle_intersect.hpp:57
bool is_vertex_visible(const Eigen::Vector3f &probe_vertex, const std::vector< Eigen::Vector3f > &mesh_vertices, const std::vector< std::array< int, 3 > > &mesh_triangle_vertex_indices, detail::RayDirection ray_direction_type)
Definition: vertex_visibility.hpp:52
std::vector< bool > compute_per_vertex_self_occlusion(const std::vector< Eigen::Vector3f > &viewspace_vertices, const std::vector< std::array< int, 3 > > &triangle_vertex_indices, detail::RayDirection ray_direction_type)
Definition: vertex_visibility.hpp:119
core::Image4u render(const core::Mesh &mesh, const Eigen::Matrix4f &model_view_matrix, const Eigen::Matrix4f &projection_matrix, int viewport_width, int viewport_height, bool enable_backface_culling=false, bool enable_near_clipping=true, bool enable_far_clipping=true)
Definition: render.hpp:52
Namespace containing all of eos's 3D model fitting functionality.