Files
tyson brochu 3c7af3d0bd AutoLOD: Pass EvaluationInfo to node ProcessMesh functions. Make GenerateUVs and GenerateConvexHullMesh cancellable.
#rnx
#rb rinat.abdrashitov
#preflight 614cb58d88dbdb000179f1cf

#ROBOMERGE-AUTHOR: tyson.brochu
#ROBOMERGE-SOURCE: CL 17611355 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v871-17566257)
#ROBOMERGE[STARSHIP]: UE5-Release-Engine-Staging Release-5.0

[CL 17611364 by tyson brochu in ue5-release-engine-test branch]
2021-09-23 14:25:03 -04:00

54 lines
1.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MeshProcessingNodes/MeshThickenNode.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "Operations/DisplaceMesh.h"
#include "DynamicMesh/MeshNormals.h"
using namespace UE::Geometry;
using namespace UE::GeometryFlow;
void FMeshThickenNode::ProcessMesh(
const FNamedDataMap& DatasIn,
const FMeshThickenSettings& SettingsIn,
const FDynamicMesh3& MeshIn,
FDynamicMesh3& MeshOut,
TUniquePtr<FEvaluationInfo>& EvaluationInfo)
{
TSafeSharedPtr<IData> WeightMapMeshArg = DatasIn.FindData(InParamWeightMap());
FWeightMap WeightMap;
WeightMapMeshArg->GetDataCopy<FWeightMap>(WeightMap, (int)EMeshProcessingDataTypes::WeightMap);
MeshOut = MeshIn;
ApplyThicken(MeshOut, SettingsIn, WeightMap.Weights);
}
void FMeshThickenNode::ProcessMeshInPlace(
const FNamedDataMap& DatasIn,
const FMeshThickenSettings& Settings,
FDynamicMesh3& MeshInOut,
TUniquePtr<FEvaluationInfo>& EvaluationInfo)
{
TSafeSharedPtr<IData> WeightMapMeshArg = DatasIn.FindData(InParamWeightMap());
FWeightMap WeightMap;
WeightMapMeshArg->GetDataCopy<FWeightMap>(WeightMap, (int)EMeshProcessingDataTypes::WeightMap);
ApplyThicken(MeshInOut, Settings, WeightMap.Weights);
}
void FMeshThickenNode::ApplyThicken(FDynamicMesh3& Mesh, const FMeshThickenSettings& Settings, const TArray<float>& VertexWeights)
{
if (VertexWeights.Num() == 0)
{
return;
}
// TODO: Accept existing normals and/or allow user to choose type of normal to compute
FMeshNormals Normals(&Mesh);
Normals.ComputeVertexNormals();
FDisplaceMesh::DisplaceMeshWithVertexWeights(Mesh, Normals, VertexWeights, Settings.ThickenAmount);
}