Enzo
Loading...
Searching...
No Matches
MeshUtils.h
1#pragma once
2#include "Engine/Core/Types.h"
3#include <array>
4#include <memory>
5#include <span>
6#include <vector>
7
8namespace enzo::geo {
9class Mesh;
10}
11
12namespace enzo::utils {
13
18{
19 std::shared_ptr<geo::Mesh> mesh;
20 std::vector<Offset> faceToOriginal;
21};
22
27TriangulatedMesh triangulateMesh(const geo::Mesh& src);
28
41Vector3 polygonNormal(std::span<const Vector3> positions, std::span<const intT> polygonPoints);
42
52std::vector<std::array<Offset, 3>> earClipTriangleIndices(const geo::Mesh& mesh);
53
64std::vector<std::array<Offset, 3>>
65earClipTriangleIndices(const geo::Mesh& mesh, std::span<const Offset> faceOffsets);
66
68enum class TangentMode
69{
70 // Direction from each point to the next.
71 FirstPoint,
72 // Average of the incoming and outgoing segment directions.
73 TwoPoint
74};
75
90{
91 public:
92 FaceTangents(const geo::Mesh& mesh, TangentMode mode = TangentMode::FirstPoint)
93 : mesh_(mesh), mode_(mode)
94 {
95 }
96
98 std::span<const Vector3> operator()(Offset faceOffset);
99
100 private:
101 const geo::Mesh& mesh_;
102 TangentMode mode_;
103 std::vector<Vector3> tangents_;
104};
105
106} // namespace enzo::utils
Basic attribute, parameter, and node types for Enzo.
size_t Offset
enzo::Offset is the internal discontinuous index of an element in a given AttributeOwner.
Definition Types.h:100
Polygonal mesh primitive with point, vertex, and face attributes.
Tangents along a face in winding order.
Definition MeshUtils.h:90
std::span< const Vector3 > operator()(Offset faceOffset)
Returns the tangents for the given face.
Definition MeshUtils.cpp:210
A triangulated mesh paired with a mapping from each output triangle to its source face.
Definition MeshUtils.h:18