Unravel Engine C++ Reference
Loading...
Searching...
No Matches
flip_mesh.hpp
Go to the documentation of this file.
1#ifndef GENERATOR_FLIPMESH_HPP
2#define GENERATOR_FLIPMESH_HPP
3
4#include "transform_mesh.hpp"
5#include "triangle.hpp"
6
7namespace generator
8{
9
11template<typename mesh_t>
13{
14private:
16 impl_t transform_mesh_;
17
18public:
20 {
21 public:
23 {
24 triangle_t triangle = triangles_.generate();
25 std::swap(triangle.vertices[0], triangle.vertices[2]);
26 return triangle;
27 }
28
29 bool done() const noexcept
30 {
31 return triangles_.done();
32 }
33
34 void next()
35 {
36 triangles_.next();
37 }
38
39 private:
41
42 explicit triangles_t(const transform_mesh_t<mesh_t>& mesh) : triangles_{mesh.triangles()}
43 {
44 }
45
46 friend class flip_mesh_t;
47 };
48
50 flip_mesh_t(mesh_t mesh)
51 : transform_mesh_{std::move(mesh),
52 [](mesh_vertex_t& vertex)
53 {
54 vertex.normal *= -1.0;
55 }}
56 {
57 }
58
59 triangles_t triangles() const noexcept
60 {
61 return triangles_t{this->transform_mesh_};
62 }
63
65
66 vertices_t vertices() const noexcept
67 {
68 return transform_mesh_.vertices();
69 }
70};
71
72template<typename mesh_t>
74{
75 return flip_mesh_t<mesh_t>{std::move(mesh)};
76}
77} // namespace generator
78
79#endif
manifold_type type
Flips mesh inside out. Reverses triangles and normals.
Definition flip_mesh.hpp:13
triangles_t triangles() const noexcept
Definition flip_mesh.hpp:59
typename impl_t::vertices_t vertices_t
Definition flip_mesh.hpp:64
vertices_t vertices() const noexcept
Definition flip_mesh.hpp:66
flip_mesh_t(mesh_t mesh)
Definition flip_mesh.hpp:50
Apply a mutator function to each vertex.
gml::ivec3 vertices
Zero based indices of the triangle vertices in counterclockwise order.
Definition triangle.hpp:13
flip_mesh_t< mesh_t > flip_mesh(mesh_t mesh)
Definition flip_mesh.hpp:73