Files
UnrealEngineUWP/Engine/Plugins/Experimental/GeometryProcessing/Source/DynamicMesh/Public/Operations/DisplaceMesh.h
Ryan Schmidt e196c256e4 GeometryProcessing: remove forwarding headers used in GeometryCore transition, and update all affected includes.
#rb none
#rnx
#jira none
#preflight 60c52c5db9446100014da02d

[CL 16653115 by Ryan Schmidt in ue5-main branch]
2021-06-13 00:35:22 -04:00

52 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "MathUtil.h"
#include "VectorTypes.h"
#include "GeometryTypes.h"
#include "DynamicMesh/MeshNormals.h"
#include "Async/ParallelFor.h"
namespace UE
{
namespace Geometry
{
class FDisplaceMesh
{
public:
inline static void DisplaceMeshWithVertexWeights(FDynamicMesh3& Mesh,
const FMeshNormals& Normals,
const TArray<float>& VertexWeights,
float Intensity)
{
check(VertexWeights.Num() >= Mesh.MaxVertexID());
check(Normals.GetNormals().Num() >= Mesh.MaxVertexID());
int NumVertices = Mesh.MaxVertexID();
ParallelFor(NumVertices, [&Mesh, &VertexWeights, &Normals, Intensity](int32 VertexID)
{
if (!Mesh.IsVertex(VertexID))
{
return;
}
float Offset = VertexWeights[VertexID];
FVector3d NewPosition = Mesh.GetVertexRef(VertexID) + (Offset * Intensity * Normals[VertexID]);
Mesh.SetVertex_NoTimeStampUpdate(VertexID, NewPosition);
});
Mesh.IncrementTimeStamps(1, true, false);
}
// TODO: Refactor DisplaceMeshTool to use this class
};
} // end namespace UE::Geometry
} // end namespace UE