Choose your operating system:
Windows
macOS
Linux
Module |
|
Header |
/Engine/Source/Runtime/GeometryCore/Public/DynamicMesh/DynamicMesh3.h |
Include |
#include "DynamicMesh/DynamicMesh3.h" |
class FDynamicMesh3
FDynamicMesh3 is a dynamic triangle mesh class. The mesh has has connectivity, is an indexed mesh, and allows for gaps in the index space.
internally, all data is stored in POD-type buffers, except for the vertex->edge links, which are stored as List<int>'s. The arrays of POD data are stored in TDynamicVector's, so they grow in chunks, which is relatively efficient. The actual blocks are arrays, so they can be efficiently mem-copied into larger buffers if necessary.
Reference counts for verts/tris/edges are stored as separate FRefCountVector instances.
Vertices are stored as doubles, although this should be easily changed if necessary, as the internal data structure is not exposed
Per-vertex Vertex Normals, Colors, and UVs are optional and stored as floats.
For each vertex, VertexEdgeLists[i] is the unordered list of connected edges. The elements of the list are indices into the edges list. This list is unsorted but can be traversed in-order (ie cw/ccw) at some additional cost.
Triangles are stored as 3 ints, with optionally a per-triangle integer group id.
The edges of a triangle are similarly stored as 3 ints, in triangle_edes. If the triangle is [v1,v2,v3], then the triangle edges [e1,e2,e3] are e1=edge(v1,v2), e2=edge(v2,v3), e3=edge(v3,v1), where the e# are indexes into edges.
Edges are stored as tuples of 4 ints. If the edge is between v1 and v2, with neighbour tris t1 and t2, then the edge is [min(v1,v2), max(v1,v2), t1, t2]. For a boundary edge, t2 is InvalidID. t1 is never InvalidID.
Most of the class assumes that the mesh is manifold. Many functions will work if the topology is non-manifold, but behavior of operators like Split/Flip/Collapse edge is untested.
The function CheckValidity() does extensive sanity checking on the mesh data structure. Use this to test your code, both for mesh construction and editing!!
Name | Description | ||
---|---|---|---|
|
TUniquePtr< FDy... |
AttributeSet |
Extended Attributes for the Mesh (UV layers, Hard Normals, additional Polygroup Layers, etc) |
|
bEnableShapeChangeStamp |
Enable/Disable updating of ShapeChangeStamp. |
|
|
EdgeRefCounts |
Reference counts of edge indices. |
|
|
TDynamicVector<... |
Edges |
List of edge elements. |
|
int |
GroupIDCounter |
Upper bound on the triangle group IDs used in the mesh (may be larger than the actual maximum if triangles have been deleted) |
|
std::atomic< ui... |
ShapeChangeStamp |
If bEnableShapeChangeStamp=true, The shape change stamp is incremented any time a function that modifies the mesh shape or topology is called |
|
std::atomic< ui... |
TopologyChangeStamp |
The topology change stamp is incremented any time a function that modifies the mesh topology is called |
|
TDynamicVector<... |
TriangleEdges |
List of triangle edge triplets [Edge0 Edge1 Edge2] |
|
TriangleGroups |
(optional) List of per-triangle group identifiers |
|
|
TriangleRefCounts |
Reference counts of triangle indices. |
|
|
TDynamicVector<... |
Triangles |
List of triangle vertex-index triplets [Vert0 Vert1 Vert2] |
|
VertexColors |
(optional) List of per-vertex colors |
|
|
VertexEdgeLists |
List of per-vertex edge one-rings |
|
|
VertexNormals |
(optional) List of per-vertex normals |
|
|
VertexRefCounts |
Reference counts of vertex indices. |
|
|
VertexUVs |
(optional) List of per-vertex uv's |
|
|
TDynamicVector<... |
Vertices |
List of vertex positions |
Name | Description | |
---|---|---|
|
FDynamicMesh3() |
Default constructor |
|
FDynamicMesh3 ( |
Copy/Move construction |
|
FDynamicMesh3 ( |
|
|
FDynamicMesh3 ( |
Default constructor |
|
FDynamicMesh3 ( |
Construction from Mesh Generator |
|
FDynamicMesh3 |
Construct an empty mesh with specified attributes |
Name | Description | |
---|---|---|
|
~FDynamicMesh3() |
Destructor |
Name | Description | ||
---|---|---|---|
|
int |
AddEdgeInternal ( |
|
|
AddTriangleEdge ( |
||
|
int |
AddTriangleInternal ( |
|
|
AllocateEdgesList ( |
||
|
int |
AllocateTriangleGroup() |
|
|
int |
AppendTriangle ( |
|
|
int |
AppendTriangle ( |
|
|
int |
AppendVertex ( |
Append vertex at position, returns vid |
|
int |
AppendVertex ( |
Copy vertex SourceVertexID from existing SourceMesh, returns new vertex id |
|
int |
AppendVertex ( |
Mesh ConstructionAppend vertex at position and other fields, returns vid |
|
FDynamicMesh... |
Attributes() |
|
|
const FDynam... |
Attributes() |
|
|
BeginUnsafeTrianglesInsert() |
Call this before a set of unsafe InsertTriangle() calls |
|
|
BeginUnsafeVerticesInsert() |
Support for inserting vertex and triangle at specific IDs. |
|
|
FRefCountVec... |
BoundaryEdgeIndicesItr() |
|
|
double |
CalculateWindingNumber ( |
Compute mesh winding number, from Jacobson et. |
|
CheckValidity ( |
Checks that the mesh is well-formed, ie all internal data structures are consistent |
|
|
Clear() |
Discard all data |
|
|
CollapseEdge ( |
Collapse the edge between the two vertices, if topologically possible. |
|
|
CollapseEdge ( |
||
|
CompactCopy ( |
Copy input mesh while compacting, i.e. removing unused vertices/triangles/edges. |
|
|
CompactInPlace ( |
Mesh Edit operations Compact mesh in-place, by moving vertices around and rewriting indices. |
|
|
double |
CompactMetric() |
Returns measure of compactness in range [0,1], where 1 is fully compacted |
|
Copy ( |
Initialize mesh from the output of a MeshShapeGenerator (assumes Generate() was already called) |
|
|
Copy ( |
Set internal data structures to be a copy of input mesh using the specified attributes |
|
|
DiscardAttributes() |
||
|
DiscardTriangleGroups() |
||
|
DiscardVertexColors() |
||
|
DiscardVertexNormals() |
||
|
DiscardVertexUVs() |
||
|
int |
EdgeCount() |
|
|
EdgeHasTriangle ( |
||
|
EdgeHasVertex ( |
||
|
edge_iterato... |
EdgeIndicesItr() |
|
|
value_iterat... |
EdgesItr() |
Enumerate edges. |
|
EnableAttributes() |
||
|
EnableMeshComponents ( |
Vertex and Triangle attribute arrays Enable requested set of mesh components (triangle groups and vertex normals/colors/UVs) and discard any that are not requested |
|
|
EnableTriangleGroups ( |
||
|
EnableVertexColors ( |
||
|
EnableVertexNormals ( |
||
|
EnableVertexUVs ( |
||
|
EndUnsafeTrianglesInsert() |
Call after a set of unsafe InsertTriangle() calls to rebuild free list |
|
|
EndUnsafeVerticesInsert() |
Call after a set of unsafe InsertVertex() calls to rebuild free list |
|
|
EnumerateVertexEdges ( |
Call EdgeFunc for each one-ring edge of a vertex. |
|
|
EnumerateVertexTriangles ( |
Call ApplyFunc for each one-ring triangle of a vertex. |
|
|
EnumerateVertexVertices ( |
Call VertexFunc for each one-ring vertex neighbour of a vertex. |
|
|
int |
FindEdge ( |
Find id of edge connecting A and B |
|
int |
FindEdgeFromTri ( |
Find edgeid for edge [a,b] from triangle that contains the edge. |
|
int |
FindEdgeFromTriPair ( |
Find edgeid for edge connecting two triangles |
|
FindEdgeInternal |
||
|
int |
FindTriangle ( |
Find triangle made up of any permutation of vertices [a,b,c] |
|
int |
FindTriangleEdge ( |
Returns edge ID |
|
FlipEdge ( |
Calls FlipEdge() on the edge between two vertices, if it exists |
|
|
FlipEdge ( |
Flip/Rotate an edge of the mesh. |
|
|
GetAllVertexGroups ( |
Returns all group IDs at vertex |
|
|
int |
GetAllVtxBoundaryEdges ( |
Find edge ids of boundary edges connected to vertex. |
|
FAxisAligned... |
GetBounds ( |
Geometric queriesReturns bounding box of all mesh vertices (including unreferenced vertices) |
|
GetChangeStamp() |
ChangeStamp is a combination of the Shape and Topology ChangeStamps |
|
|
const TDynam... |
GetColorsBuffer() |
|
|
int |
GetComponentsFlags() |
|
|
GetEdge ( |
Get the vertices and triangles of an edge, returned as [v0,v1,t0,t1], where t1 may be InvalidID |
|
|
GetEdgeNormal ( |
Returns average normal of connected face normals |
|
|
GetEdgeOpposingV ( |
If edge has vertices [a,b], and is connected two triangles [a,b,c] and [a,b,d], this returns [c,d], or [c,InvalidID] for a boundary edge |
|
|
GetEdgePoint ( |
Get point along edge, t clamped to range [0,1] |
|
|
const FEdge ... |
GetEdgeRef ( |
Get the vertices and triangles of an edge, returned as [v0,v1,t0,t1], where t1 may be InvalidID |
|
const TDynam... |
GetEdgesBuffer() |
|
|
const FRefCo... |
GetEdgesRefCounts() |
|
|
GetEdgeT ( |
Get the triangle pair for an edge. The second triangle may be InvalidID |
|
|
GetEdgeV ( |
Get the vertex pair for an edge |
|
|
GetEdgeV |
Get the vertex positions of an edge |
|
|
int |
GetMaxVtxEdgeCount() |
|
|
const TDynam... |
GetNormalsBuffer() |
|
|
GetOrderedOneRingEdgeTris ( |
Utility function that returns one or two triangles of edge, used to enumerate vertex one-ring triangles The logic is a bit tricky to follow without drawing it out on paper, but this will only return each triangle once, for the 'outgoing' edge from the vertex, and each triangle only has one such edge at any vertex (including boundary triangles) |
|
|
GetOrientedBoundaryEdgeV ( |
Return edge vertex indices, but oriented based on attached triangle (rather than min-sorted) |
|
|
int |
GetOtherEdgeTriangle ( |
|
|
int |
GetOtherEdgeVertex ( |
|
|
GetShapeChangeStamp() |
ShapeChangeStamp is incremented any time a mesh vertex position is changed or the mesh topology is modified, if bEnableShapeChangeStamp=true |
|
|
GetTopologyChangeStamp() |
TopologyChangeStamp is incremented when the mesh topology is modified |
|
|
GetTriangle ( |
Get triangle vertices |
|
|
const TDynam... |
GetTriangleEdges() |
|
|
int |
GetTriangleGroup ( |
|
|
const TDynam... |
GetTriangleGroupsBuffer() |
|
|
const FIndex... |
GetTriangleRef ( |
Get triangle vertices |
|
const TDynam... |
GetTrianglesBuffer() |
|
|
const FRefCo... |
GetTrianglesRefCounts() |
|
|
double |
GetTriArea ( |
Calculate area triangle |
|
GetTriBaryNormal ( |
Interpolate vertex normals of triangle using barycentric coordinates |
|
|
GetTriBaryPoint ( |
Compute interpolated vertex attributes at point of triangle |
|
|
GetTriBaryPoint ( |
Interpolate vertex positions of triangle using barycentric coordinates |
|
|
FAxisAligned... |
GetTriBounds ( |
Construct bounding box of triangle as efficiently as possible |
|
GetTriCentroid ( |
Compute centroid of triangle |
|
|
int |
GetTriEdge ( |
Get one of the edges of a triangle |
|
GetTriEdges ( |
Get triangle edges |
|
|
const FIndex... |
GetTriEdgesRef ( |
Get triangle edges |
|
GetTriFrame ( |
Construct stable frame at triangle centroid, where frame.Z is face normal, and frame.X is aligned with edge nEdge of triangle. |
|
|
GetTriInfo |
Compute triangle normal, area, and centroid all at once. |
|
|
double |
GetTriInternalAngleR ( |
Compute internal angle at vertex i of triangle (where i is 0,1,2); |
|
GetTriInternalAnglesR ( |
Compute internal angles at all vertices of triangle |
|
|
GetTriNeighbourTris ( |
Find the neighbour triangles of a triangle (any of them might be InvalidID) |
|
|
GetTriNormal ( |
Calculate face normal of triangle |
|
|
double |
GetTriSolidAngle ( |
Compute solid angle of oriented triangle tID relative to point p - see WindingNumber() |
|
GetTriVertex ( |
Get the position of one of the vertices of a triangle |
|
|
GetTriVertices ( |
Get the three vertex positions of a triangle |
|
|
const TDynam... |
GetUVBuffer() |
|
|
GetVertex ( |
Vertex/Tri/Edge accessors |
|
|
GetVertex ( |
Get extended vertex information |
|
|
GetVertexColor ( |
||
|
const FSmall... |
GetVertexEdges() |
|
|
GetVertexEdgesList ( |
||
|
GetVertexFrame |
Compute a normal/tangent frame at vertex that is "stable" as long as the mesh topology doesn't change, meaning that one axis of the frame will be computed from projection of outgoing edge. |
|
|
GetVertexGroups ( |
Returns up to 4 group IDs at vertex. Returns false if > 4 encountered |
|
|
GetVertexInfo ( |
Get all vertex information available |
|
|
GetVertexNormal ( |
||
|
const FVecto... |
GetVertexRef ( |
|
|
GetVertexUV ( |
||
|
const TDynam... |
GetVerticesBuffer() |
Direct buffer access |
|
const FRefCo... |
GetVerticesRefCounts() |
|
|
int |
GetVtxBoundaryEdges ( |
Returns count of boundary edges at vertex, and the first two boundary edges if found. |
|
GetVtxContiguousTriangles |
Get triangles connected to vertex in contiguous order, with multiple groups if vertex is a bowtie. |
|
|
int |
GetVtxEdgeCount ( |
|
|
GetVtxNbrhood ( |
Given an edge and vertex on that edge, returns other vertex of edge, the two opposing verts, and the two connected triangles (OppVert2Out and Tri2Out are be InvalidID for boundary edge) |
|
|
GetVtxOneRingCentroid ( |
Fastest possible one-ring centroid. |
|
|
int |
GetVtxSingleTriangle ( |
|
|
int |
GetVtxTriangleCount ( |
Return # of triangles attached to vID, or -1 if invalid vertex |
|
GetVtxTriangles ( |
Get triangle one-ring at vertex. |
|
|
HasAttributes() |
||
|
HasShapeChangeStampEnabled() |
||
|
HasTriangleGroups() |
||
|
HasVertexColors() |
||
|
HasVertexNormals() |
||
|
HasVertexUVs() |
||
|
InsertTriangle |
Insert triangle at given index, assuming it is unused. |
|
|
InsertVertex ( |
Insert vertex at given index, assuming it is unused. |
|
|
IsBoundaryEdge ( |
Topological queriesReturns true if edge is on the mesh boundary, ie only connected to one triangle |
|
|
IsBoundaryTriangle ( |
Returns true if any edge of triangle is a boundary edge |
|
|
IsBoundaryVertex ( |
Returns true if the vertex is part of any boundary edges |
|
|
IsBowtieVertex ( |
Returns true if vID is a "bowtie" vertex, ie multiple disjoint triangle sets in one-ring |
|
|
IsClosed() |
||
|
IsCompact() |
Returns true if vertices, edges, and triangles are all dense (Count == MaxID) |
|
|
IsCompactT() |
||
|
IsCompactV() |
||
|
IsEdge ( |
||
|
IsGroupBoundaryEdge ( |
Returns true if the two triangles connected to edge have different group IDs |
|
|
IsGroupBoundaryVertex ( |
Returns true if vertex has more than one tri group in its tri nbrhood |
|
|
IsGroupJunctionVertex ( |
Returns true if more than two group boundary edges meet at vertex (ie 3+ groups meet at this vertex) |
|
|
IsReferencedVertex ( |
||
|
IsSameAs ( |
Check if another mesh is the same as this mesh. |
|
|
IsTriangle ( |
||
|
IsVertex ( |
||
|
int |
MaxEdgeID() |
|
|
int |
MaxGroupID() |
|
|
int |
MaxTriangleID() |
|
|
int |
MaxVertexID() |
|
|
MergeEdges ( |
Given two edges of the mesh, weld both their vertices, so that one edge is removed. |
|
|
MeshInfoString() |
Debug utility functions Returns a debug string that contains mesh statistics and other information |
|
|
PokeTriangle ( |
Insert a new vertex inside a triangle, ie do a 1 to 3 triangle split |
|
|
PokeTriangle ( |
Call PokeTriangle at the centroid of the triangle |
|
|
RemoveTriangle |
Remove a triangle from the mesh. |
|
|
RemoveVertex ( |
Remove vertex VertexID and all connected triangles. |
|
|
int |
ReplaceEdgeTriangle ( |
|
|
int |
ReplaceEdgeVertex ( |
|
|
int |
ReplaceTriangleEdge ( |
|
|
int |
ReplaceTriangleVertex ( |
|
|
ReverseOrientation ( |
Reverse the ccw/cw orientation of all triangles in the mesh, and optionally flip the vertex normals if they exist |
|
|
ReverseTriOrientation ( |
Reverse the ccw/cw orientation of a triangle |
|
|
ReverseTriOrientationInternal ( |
||
|
Serialize ( |
Serialize the mesh to an archive. |
|
|
SerializeInternal |
Internal implementations for serialization to allow for better code separation between different versions and other implementation details. |
|
|
SerializeInternal |
||
|
SerializeInternal |
||
|
SerializeInternal |
||
|
SerializeInternal |
||
|
SetEdgeTrianglesInternal ( |
||
|
SetEdgeVerticesInternal ( |
||
|
SetShapeChangeStampEnabled ( |
Change Tracking supportEnable/Disable incrementing of the ShapeChangeStamp |
|
|
SetTriangle |
Rewrite the triangle to reference the new tuple of vertices. |
|
|
SetTriangleEdgesInternal ( |
||
|
SetTriangleGroup ( |
||
|
SetTriangleInternal ( |
Internal functions |
|
|
SetVertex |
Set vertex position |
|
|
SetVertexColor ( |
||
|
SetVertexNormal ( |
||
|
SetVertexUV ( |
||
|
SplitEdge ( |
Split an edge of the mesh by inserting a vertex. |
|
|
SplitEdge ( |
Splits the edge between two vertices at the midpoint, if this edge exists |
|
|
SplitVertex ( |
Clones the given vertex and updates any provided triangles to use the new vertex if/where they used the old one. |
|
|
SplitVertexWouldLeaveIsolated ( |
Tests whether splitting the given vertex with the given triangles would leave no triangles attached to the original vertex (creating an isolated vertex) |
|
|
int |
TriangleCount() |
|
|
TriangleHasVertex ( |
||
|
triangle_ite... |
TriangleIndicesItr() |
|
|
value_iterat... |
TrianglesItr() |
Enumerate all triangles in the mesh |
|
TriHasNeighbourTri ( |
||
|
TriHasSequentialVertices ( |
||
|
UpdateChangeStamps |
Increment the specified ChangeStamps, if they are enabled. Thread-safe. |
|
|
int |
VertexCount() |
|
|
vertex_itera... |
VertexIndicesItr() |
|
|
value_iterat... |
VerticesItr() |
Enumerate positions of all vertices in mesh |
|
FSmallListSe... |
VtxEdgesItr ( |
|
|
vtx_triangle... |
VtxTrianglesItr ( |
|
|
FSmallListSe... |
VtxVerticesItr ( |
Name | Description | ||
---|---|---|---|
|
const FDynam... |
operator= ( |
|
|
const FDynam... |
operator= ( |
Copy and move assignment |
Name |
Description |
|
---|---|---|
|
FEdge |
|
|
FSameAsOptions |
Options for the IsSameAs check |
|
FValidityOptions |
Options for what the validity check will permit |
Name |
Description |
---|---|
edge_iterator |
|
FEdgeCollapseInfo |
|
FEdgeFlipInfo |
TODO: |
FEdgeSplitInfo |
|
FMergeEdgesInfo |
|
FPokeTriangleInfo |
|
FVertexSplitInfo |
|
triangle_iterator |
|
value_iteration |
|
vertex_iterator |
Simplify names for iterations |
vtx_triangles_enumerable |
Name |
Description |
---|---|
DuplicateTriangleID |
DuplicateTriangleID is returned by AppendTriangle() to indicate that the added triangle already exists in the mesh, and was ignored because we do not support duplicate triangles |
InvalidEdge |
|
InvalidID |
InvalidID indicates that a vertex/edge/triangle ID is invalid |
InvalidTriangle |
|
InvalidVertex |
|
NonManifoldID |
NonManifoldID is returned by AppendTriangle() to indicate that the added triangle would result in nonmanifold geometry and hence was ignored |