GeometryScript: Exposed GetAllUVSeamEdges and GetAllVertexPositionsAtEdges to MeshQueryFunctions.

#rb Jimmy.Andrews
#jira UE-215334

[CL 33795823 by lonnie li in ue5-main branch]
This commit is contained in:
lonnie li
2024-05-21 10:55:25 -04:00
parent 53882dc033
commit 3347562fe7
3 changed files with 72 additions and 0 deletions

View File

@@ -391,6 +391,34 @@ UDynamicMesh* UGeometryScriptLibrary_MeshQueryFunctions::GetVertexConnectedVerti
}
UDynamicMesh* UGeometryScriptLibrary_MeshQueryFunctions::GetAllVertexPositionsAtEdges(UDynamicMesh* TargetMesh, const FGeometryScriptIndexList& EdgeIDs, FGeometryScriptVectorList& Start, FGeometryScriptVectorList& End)
{
Start.Reset();
End.Reset();
if (!EdgeIDs.IsCompatibleWith(EGeometryScriptIndexType::Edge) && EdgeIDs.List.IsValid() && EdgeIDs.List->Num() > 0)
{
return TargetMesh;
}
SimpleMeshQuery<bool>(TargetMesh, false,
[&EdgeIDs, &Start, &End](const FDynamicMesh3& Mesh)
{
for (const int EID : *EdgeIDs.List)
{
if (Mesh.IsEdge(EID))
{
FIndex2i VIDs = Mesh.GetEdgeV(EID);
Start.List->Add(Mesh.GetVertex(VIDs[0]));
End.List->Add(Mesh.GetVertex(VIDs[1]));
}
}
return true;
});
return TargetMesh;
}
int32 UGeometryScriptLibrary_MeshQueryFunctions::GetNumUVSets( UDynamicMesh* TargetMesh )
{
return SimpleMeshQuery<int32>(TargetMesh, 0, [&](const FDynamicMesh3& Mesh) {
@@ -480,6 +508,24 @@ UDynamicMesh* UGeometryScriptLibrary_MeshQueryFunctions::GetInterpolatedTriangle
return TargetMesh;
}
UDynamicMesh* UGeometryScriptLibrary_MeshQueryFunctions::GetAllUVSeamEdges(UDynamicMesh* TargetMesh, int32 UVSetIndex, FGeometryScriptIndexList& ElementIDs)
{
ElementIDs.Reset(EGeometryScriptIndexType::Edge);
bool bIsValidUVSet = SimpleMeshUVSetQuery<bool>(TargetMesh, UVSetIndex, bIsValidUVSet, false,
[&](const FDynamicMesh3& Mesh, const FDynamicMeshUVOverlay& UVSet)
{
for (int EID : Mesh.EdgeIndicesItr())
{
if (UVSet.IsSeamEdge(EID))
{
ElementIDs.List->Add(EID);
}
}
return true;
});
return TargetMesh;
}
bool UGeometryScriptLibrary_MeshQueryFunctions::GetHasTriangleNormals( UDynamicMesh* TargetMesh )
{

View File

@@ -304,6 +304,7 @@ enum class EGeometryScriptIndexType : uint8
// Index lists of Any type are compatible with any other index list type
Any,
Triangle,
Edge,
Vertex,
MaterialID,
PolygroupID UMETA(DisplayName = "PolyGroup ID")

View File

@@ -217,6 +217,18 @@ public:
static UPARAM(DisplayName = "Target Mesh") UDynamicMesh*
GetAllVertexPositions( UDynamicMesh* TargetMesh, FGeometryScriptVectorList& PositionList, bool bSkipGaps, bool& bHasVertexIDGaps );
/**
* Returns the vertex positions for each edge in the given index list.
*
* @param TargetMesh The mesh to query
* @param EdgeIDs The edge IDs to query
* @param Start The output list of start vertex positions
* @param End The output list of end vertex positions
* @return The target mesh that was queried
*/
UFUNCTION(BlueprintCallable, Category = "GeometryScript|MeshQueries", meta=(ScriptMethod))
static UPARAM(DisplayName = "Target Mesh") UDynamicMesh*
GetAllVertexPositionsAtEdges( UDynamicMesh* TargetMesh, const FGeometryScriptIndexList& EdgeIDs, FGeometryScriptVectorList& Start, FGeometryScriptVectorList& End);
/**
* Return array of Triangle IDs connected to the given VertexID, ie the triangle one-ring
@@ -282,6 +294,19 @@ public:
FVector2D& InterpolatedUV );
/**
* Returns all edge element IDs that are UV seam edges for a given UV channel.
*
* @param TargetMesh The mesh to query.
* @param UVSetIndex The UV channel to query
* @param ElementIDs The returned edge element IDs
* @return The target mesh that was queried.
*/
UFUNCTION(BlueprintCallable, Category = "GeometryScript|MeshQueries", meta=(ScriptMethod))
static UPARAM(DisplayName = "Target Mesh") UDynamicMesh*
GetAllUVSeamEdges( UDynamicMesh* TargetMesh, UPARAM(DisplayName = "UV Channel") int32 UVSetIndex, FGeometryScriptIndexList& ElementIDs);
//
// Normal queries
//