Files
UnrealEngineUWP/Engine/Plugins/Runtime/GeometryProcessing/Source/DynamicMesh/Public/Operations/DisplaceMesh.h
Ryan Schmidt a0cc146b60 GeometryProcessing: clean up mesh timestamps.
- remove FDynamicMesh3::Timestamp (unused), rename Shape/Topology Timestamps to Shape/TopologyChangeStamp, change to atomic<uint32>
- add FDynamicMesh3::bEnableShapeChangeStamp, default to false, to disable ShapeChange tracking. Add ::SetShapeChangeStampEnabled() and ::HasShapeChangeStampEnabled() to configure.
- replace FDynamicMesh3::UpdateTimestamps() with UpdateChangeStamps()
- add bTrackChange param to FDynamicMesh3::SetVertex(), optionally updates ShapeChangeStamp (if enabled). Default true. Remove SetVertex_NoTimeStampUpdate(), update call sites.
- add FDynamicMesh3::GetChangeStamp(), returns combination of Shape and Topology stamps as uint64
- rename TTriangleMeshAdapter::GetTimestamp() to GetChangeStamp(), update usages
- remove TPointSetAdapter::Timestamp()   (was not used in code)
- update TMeshAABBTree3 to use GetChangeStamp(), update internal checks to call IsValid() instead
- update TFastWindingTree w/ similar changes
- update calls in UVEditor, may require further updates
#rb semion.piskarev
#rnx
#jira none
#preflight 6126904c72e9eb00011434fe

[CL 17310271 by Ryan Schmidt in ue5-main branch]
2021-08-25 17:41:42 -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(VertexID, NewPosition, false);
});
Mesh.UpdateChangeStamps(true, false);
}
// TODO: Refactor DisplaceMeshTool to use this class
};
} // end namespace UE::Geometry
} // end namespace UE