// Copyright Epic Games, Inc. All Rights Reserved. #include "Dataflow/ChaosFleshConstructTetGridNode.h" #include "Chaos/Utilities.h" #include "ChaosFlesh/FleshCollection.h" #include "ChaosFlesh/ChaosFlesh.h" #include "ChaosLog.h" #include "Dataflow/ChaosFleshNodesUtility.h" //============================================================================= // FConstructTetGridNode //============================================================================= void FConstructTetGridNode::Evaluate(UE::Dataflow::FContext& Context, const FDataflowOutput* Out) const { if (Out->IsA(&Collection)) { TUniquePtr InCollection(GetValue(Context, &Collection).NewCopy()); Chaos::TVector Counts(GridCellCount[0], GridCellCount[1], GridCellCount[2]); Chaos::TVector MinCorner = -.5 * GridDomain; Chaos::TVector MaxCorner = .5 * GridDomain; Chaos::TUniformGrid Grid(MinCorner, MaxCorner, Counts, 0); TArray Tets; TArray X; Chaos::Utilities::TetMeshFromGrid(Grid, Tets, X); UE_LOG(LogChaosFlesh, Display, TEXT("TetGrid generated %d points and %d tetrahedra."), X.Num(), Tets.Num()); TArray Tris = UE::Dataflow::GetSurfaceTriangles(Tets, !bDiscardInteriorTriangles); TUniquePtr TetCollection( FTetrahedralCollection::NewTetrahedralCollection(X, Tris, Tets)); InCollection->AppendGeometry(*TetCollection.Get()); SetValue(Context, *InCollection, &Collection); } }