Files
tyson brochu 49d64a7e11 Add a Thicken node to GeometryFlow. Accepts vertex weights and a scalar and moves vertices in the normal direction accordingly.
#jira UETOOL-2943
#rb jimmy.andrews

#ROBOMERGE-OWNER: tyson.brochu
#ROBOMERGE-AUTHOR: tyson.brochu
#ROBOMERGE-SOURCE: CL 15424119 in //UE5/Release-5.0-EarlyAccess/...
#ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668)
#ROBOMERGE-CONFLICT from-shelf

[CL 15426283 by tyson brochu in ue5-main branch]
2021-02-16 19:58:02 -04:00

51 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MeshProcessingNodes/MeshThickenNode.h"
#include "DynamicMesh3.h"
#include "Operations/DisplaceMesh.h"
#include "MeshNormals.h"
using namespace UE::GeometryFlow;
void FMeshThickenNode::ProcessMesh(
const FNamedDataMap& DatasIn,
const FMeshThickenSettings& SettingsIn,
const FDynamicMesh3& MeshIn,
FDynamicMesh3& MeshOut)
{
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)
{
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);
}