![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <DynamicMeshOverlay.h>
Inheritance diagram for UE::Geometry::TDynamicMeshOverlay< RealType, ElementSize >:Public Types | |
| typedef FRefCountVector::IndexEnumerable | element_iterator |
Protected Member Functions | |
| void | SetElementFromLerp (int SetElement, int ElementA, int ElementB, double Alpha) |
| void | SetElementFromBary (int SetElement, int ElementA, int ElementB, int ElementC, const FVector3d &BaryCoords) |
| void | InternalSetTriangle (int TriangleID, const FIndex3i &TriElements, bool bUpdateRefCounts, bool bAllowElementFreeing=true) |
Protected Attributes | |
| FDynamicMesh3 * | ParentMesh |
| FRefCountVector | ElementsRefCounts |
| TDynamicVector< RealType > | Elements |
| TDynamicVector< int > | ParentVertices |
| TDynamicVector< int > | ElementTriangles |
Friends | |
| class | FDynamicMesh3 |
| class | FDynamicMeshAttributeSet |
| FArchive & | operator<< (FArchive &Ar, TDynamicMeshOverlay< RealType, ElementSize > &Overlay) |
TDynamicMeshOverlay is an add-on to a FDynamicMesh3 that allows for per-triangle storage of an "element" (eg like a per-triangle UV or normal). However the elements can be shared between triangles at shared vertices because the elements are stored in a separate indexable list.
Each element has one vertex in the parent mesh as its parent, whereas each vertex may be the parent of multiple elements in cases where neighboring triangles are not sharing a single element for that vertex. This means that there may be "seam" boundary edges in the overlay topology that are not mesh boundary edges in the associated/parent mesh, but the overlay topology will not connect triangles that were not connected in the parent mesh or create any topologically degenerate triangles, since the parent vids of the elements of a triangle will have to match up to the vids of the triangle.
A "seam" edge is one where at least one of the elements of the triangles on either side of the edge is not shared between the two triangles.
The FDynamicMesh3 mesh topology operations (eg split/flip/collapse edge, poke face, etc) can be mirrored to the overlay via OnSplitEdge(), etc.
Note that although this is a template, many of the functions are defined in the .cpp file. As a result you need to explicitly instantiate and export the instance of the template that you wish to use in the block at the top of DynamicMeshOverlay.cpp
| typedef FRefCountVector::IndexEnumerable UE::Geometry::TDynamicMeshOverlay< RealType, ElementSize >::element_iterator |
|
inline |
Create an empty overlay
|
inline |
Create an overlay for the given parent mesh
|
inline |
|
inline |
| int TDynamicMeshOverlay::AppendElement | ( | const RealType * | Value | ) |
Allocate a new element with the given value
| int TDynamicMeshOverlay::AppendElement | ( | RealType | ConstantValue | ) |
Allocate a new element with the given constant value
| bool TDynamicMeshOverlay::AreTrianglesConnected | ( | int | TriangleID0, |
| int | TriangleID1 | ||
| ) | const |
|
inline |
Call this before a set of unsafe InsertVertex() calls
| bool TDynamicMeshOverlay::CheckValidity | ( | bool | bAllowNonManifoldVertices = true, |
| EValidityCheckFailMode | FailMode = EValidityCheckFailMode::Check |
||
| ) | const |
Checks that the overlay mesh is well-formed, ie all internal data structures are consistent
Discard all elements.
|
inline |
Discard elements for given triangles.
|
inline |
Copy the Copy overlay to a compact rep, also updating parent references based on the CompactMaps
|
inline |
Compact overlay and update links to parent based on CompactMaps
|
inline |
Set this overlay to contain the same arrays as the copy overlay
| int TDynamicMeshOverlay::CountVertexElements | ( | int | VertexID, |
| bool | bBruteForce = false |
||
| ) | const |
Count the number of unique elements for a given parent-mesh vertex
| void TDynamicMeshOverlay::CreateFromPredicate | ( | TFunctionRef< bool(int ParentVertexIdx, int TriIDA, int TriIDB)> | TrisCanShareVertexPredicate, |
| RealType | InitElementValue | ||
| ) |
Build overlay topology from a predicate function, e.g. to build topology for sharp normals
| TrisCanShareVertexPredicate | Indicator function returns true if the given vertex can be shared for the given pair of triangles Note if a vertex can be shared between tris A and B, and B and C, it will be shared between all three |
| InitElementValue | Initial element value, copied into all created elements |
| void TDynamicMeshOverlay::CreatePerVertex | ( | RealType | InitElementValue | ) |
Build overlay topology with one element per vertex. Note: Faster-but-equivalent-to calling CreateFromPredicate() with a CanShareVertex predicate that always returns true
|
inline |
|
inline |
|
inline |
Call after a set of unsafe InsertVertex() calls to rebuild free list
| void UE::Geometry::TDynamicMeshOverlay< RealType, ElementSize >::FreeUnusedElements | ( | const TSet< int > * | ElementsToCheck = nullptr | ) |
Goes through elements and frees any whose reference counts indicate that they are not being used. This is usually not necessary since most operations that remove references will go ahead and do this, but it may be used, for instance, after SetTriangle is called with bAllowElementFreeing set to false.
| ElementsToCheck | If provided, only these element ID's will be checked. |
|
inline |
|
inline |
Get the element at a given index
|
inline |
Get the element at a given index
|
inline |
Get the Element value associated with a vertex of a triangle.
| TriangleID | ID of a triangle containing the Element |
| VertexID | ID of the Element's parent vertex |
| Data | Value contained at the Element |
| int TDynamicMeshOverlay::GetElementIDAtVertex | ( | int | TriangleID, |
| int | VertexID | ||
| ) | const |
Find the element ID at a vertex of a triangle.
| void TDynamicMeshOverlay::GetElementTriangles | ( | int | ElementID, |
| TArray< int > & | OutTriangles | ||
| ) | const |
find the triangles connected to an element
|
inline |
|
inline |
|
inline |
Get the parent vertex id for the element at a given index
|
inline |
Get the element index tuple for a triangle
|
inline |
If the triangle is set to valid element indices, return the indices in TriangleOut and return true, otherwise return false
|
inline |
Compute interpolated parameter value inside triangle using barycentric coordinates
| TriangleID | index of triangle |
| BaryCoords | 3 barycentric coordinates inside triangle |
| DataOut | resulting interpolated overlay parameter value (of size ElementSize) |
| void TDynamicMeshOverlay::GetVertexElements | ( | int | VertexID, |
| TArray< int > & | OutElements | ||
| ) | const |
find the elements associated with a given parent-mesh vertex
| bool TDynamicMeshOverlay::HasInteriorSeamEdges | ( | ) | const |
| void TDynamicMeshOverlay::InitializeNewTriangle | ( | int | TriangleID | ) |
Set a triangle's element indices to InvalidID
| void TDynamicMeshOverlay::InitializeTriangles | ( | int | MaxTriangleID | ) |
Initialize the triangle list to the given size, and set all triangles to InvalidID
| EMeshResult TDynamicMeshOverlay::InsertElement | ( | int | ElementID, |
| const RealType * | Value, | ||
| bool | bUnsafe = false |
||
| ) |
Insert element at given index, assuming it is unused. If bUnsafe, we use fast id allocation that does not update free list. You should only be using this between BeginUnsafeElementsInsert() / EndUnsafeElementsInsert() calls
|
protected |
updates the triangles array and optionally the element reference counts
| bool TDynamicMeshOverlay::IsBowtieInOverlay | ( | int32 | VertexID | ) | const |
Determines whether the base-mesh vertex has "bowtie" topology in the Overlay. Bowtie topology means that one or more elements at the vertex are shared across disconnected UV-components.
|
inline |
|
inline |
| bool TDynamicMeshOverlay::IsSameAs | ( | const TDynamicMeshOverlay< RealType, ElementSize > & | Other, |
| bool | bIgnoreDataLayout | ||
| ) | const |
Returns true if this overlay is the same as Other.
| bool TDynamicMeshOverlay::IsSeamEdge | ( | int | EdgeID, |
| bool * | bIsNonIntersectingOut = nullptr |
||
| ) | const |
Returns true if the parent-mesh edge is a "Seam" in this overlay.
If present, bIsNonIntersectingOut will be true only if this is a seam edge that does not intersect with another seam or the end of the seam.
| bool TDynamicMeshOverlay::IsSeamEndEdge | ( | int | EdgeID | ) | const |
Returns true if the parent-mesh edge is a "Seam End" in this overlay, meaning the adjacent element triangles share one element, not two
| bool TDynamicMeshOverlay::IsSeamIntersectionVertex | ( | int32 | VertexID | ) | const |
Returns true if the parent-mesh vertex is at a seam 'intersection' – i.e., the end of a seam, or the intersection w/ another seam.
| bool TDynamicMeshOverlay::IsSeamVertex | ( | int | VertexID, |
| bool | bBoundaryIsSeam = true |
||
| ) | const |
Returns true if the parent-mesh vertex is connected to any seam edges
|
inline |
|
inline |
| bool TDynamicMeshOverlay::MergeElement | ( | int | SourceElementID, |
| int | TargetElementID | ||
| ) |
Collapse SourceElementID into TargetElementID, resulting in connecting any containing triangles and reducing the total elements in the overlay.
| SourceElementID | the element to merge away |
| TargetElementID | the element to merge into |
| void TDynamicMeshOverlay::OnCollapseEdge | ( | const DynamicMeshInfo::FEdgeCollapseInfo & | CollapseInfo | ) |
Update the overlay to reflect an edge collapse in the parent mesh
| void TDynamicMeshOverlay::OnFlipEdge | ( | const DynamicMeshInfo::FEdgeFlipInfo & | FlipInfo | ) |
Update the overlay to reflect an edge flip in the parent mesh
| void TDynamicMeshOverlay::OnMergeEdges | ( | const DynamicMeshInfo::FMergeEdgesInfo & | MergeInfo | ) |
Update the overlay to reflect an edge merge in the parent mesh
| void TDynamicMeshOverlay::OnMergeVertices | ( | const DynamicMeshInfo::FMergeVerticesInfo & | MergeInfo | ) |
Update the overlay to reflect a vertex merge in the parent mesh
| void TDynamicMeshOverlay::OnPokeTriangle | ( | const DynamicMeshInfo::FPokeTriangleInfo & | PokeInfo | ) |
Update the overlay to reflect a face poke in the parent mesh
| void TDynamicMeshOverlay::OnRemoveTriangle | ( | int | TriangleID | ) |
Remove a triangle from the overlay
| void TDynamicMeshOverlay::OnReverseTriOrientation | ( | int | TriangleID | ) |
Reverse the orientation of a triangle's elements
| void TDynamicMeshOverlay::OnSplitEdge | ( | const DynamicMeshInfo::FEdgeSplitInfo & | SplitInfo | ) |
Update the overlay to reflect an edge split in the parent mesh
| void TDynamicMeshOverlay::OnSplitVertex | ( | const DynamicMeshInfo::FVertexSplitInfo & | SplitInfo, |
| const TArrayView< const int > & | TrianglesToUpdate | ||
| ) |
Update the overlay to reflect a vertex split in the parent mesh
| void TDynamicMeshOverlay::Serialize | ( | FArchive & | Ar, |
| const FCompactMaps * | CompactMaps, | ||
| bool | bUseCompression | ||
| ) |
Serialize to and from an archive.
| Ar | Archive to serialize with. |
| CompactMaps | If this is not a null pointer, the mesh serialization compacted the vertex and/or triangle data using the provided mapping. |
| bUseCompression | Use compression for serializing bulk data. |
|
inline |
Set the element at a given index
|
inline |
Set the element at a given index
|
protected |
Set the value at an Element to be a barycentric interpolation of three other Elements
|
protected |
Set the value at an Element to be a linear interpolation of two other Elements
|
inline |
| EMeshResult TDynamicMeshOverlay::SetTriangle | ( | int | TriangleID, |
| const FIndex3i & | TriElements, | ||
| bool | bAllowElementFreeing = true |
||
| ) |
Set the triangle to the given Element index tuple, and increment element reference counts
| bAllowElementFreeing | If true, then any elements that were only referenced by this triangle become immediately unallocated if the triangle no longer references them. This can be set to false when remeshing across existing elements to avoid them being freed while temporarily unreferenced, but then it should eventually be followed by a call to FreeUnusedElements(). |
| void TDynamicMeshOverlay::SplitBowties | ( | bool | bParallel = true | ) |
Refine an existing overlay topology by splitting any bowties
| bParallel | Whether to run bowtie detection in parallel |
| void TDynamicMeshOverlay::SplitBowtiesAtVertex | ( | int32 | Vid, |
| TArray< int32 > * | NewElementIDs = nullptr |
||
| ) |
Split any bowties at given vertex.
| NewElementIDs | If not null, newly created element IDs are placed here. Note that this array is intentionally not cleared before appending to it. |
| int TDynamicMeshOverlay::SplitElement | ( | int | ElementID, |
| const TArrayView< const int > & | TrianglesToUpdate | ||
| ) |
Create a new copy of ElementID, and update connected triangles in the TrianglesToUpdate array to reference the copy of ElementID where they used to reference ElementID (Note: This just calls "SplitElementWithNewParent" with the existing element's parent id.)
| ElementID | the element to copy |
| TrianglesToUpdate | the triangles that should now reference the new element |
| int TDynamicMeshOverlay::SplitElementWithNewParent | ( | int | ElementID, |
| int | SplitParentVertexID, | ||
| const TArrayView< const int > & | TrianglesToUpdate | ||
| ) |
Create a new copy of ElementID, and update connected triangles in the TrianglesToUpdate array to reference the copy of ElementID where they used to reference ElementID. The new element will have the given parent vertex ID. Deletes any elements that are no longer used after the triangles are changed.
| ElementID | the element to copy |
| SplitParentVertexID | the new parent vertex for copied elements |
| TrianglesToUpdate | the triangles that should now reference the new element. Note: this is allowed to include triangles that do not have the element at all; sometimes you may want to do so to avoid creating a new array for each call. |
| void TDynamicMeshOverlay::SplitVerticesWithPredicate | ( | TFunctionRef< bool(int ElementIdx, int TriID)> | ShouldSplitOutVertex, |
| TFunctionRef< void(int ElementIdx, int TriID, RealType *FillVect)> | GetNewElementValue | ||
| ) |
Refine an existing overlay topology. For any element on a given triangle, if the predicate returns true, it gets topologically split out so it isn't shared by any other triangle. Used for creating sharp vertices in the normals overlay.
| ShouldSplitOutVertex | predicate returns true of the element should be split out and not shared w/ any other triangle |
| GetNewElementValue | function to assign a new value to any element that is split out |
|
inline |
| void TDynamicMeshOverlay::UnsetTriangle | ( | int | TriangleID, |
| bool | bAllowElementFreeing = true |
||
| ) |
Set the triangle to have InvalidID element IDs, decrementing element reference counts if needed.
| bAllowElementFreeing | If true, then any elements that were only referenced by this triangle become immediately unallocated. This can be set to false as part of a remeshing, but then it should eventually be followed by a call to FreeUnusedElements(). |
|
friend |
|
friend |
|
friend |
Serialization operator for FDynamicMeshOverlay.
| Ar | Archive to serialize with. |
| Overlay | Mesh overlay to serialize. |
|
protected |
List of element values
|
protected |
Reference counts of element indices. Iterate over this to find out which elements are valid.
|
protected |
List of triangle element-index triplets [Elem0 Elem1 Elem2]
|
protected |
The parent mesh this overlay belongs to
|
protected |
List of parent vertex indices, one per element