You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira UETOOL-3823 #rb lonnie.li #preflight 617b1aea5794a500014f544a #ROBOMERGE-AUTHOR: michael.balzer #ROBOMERGE-SOURCE: CL 17972239 in //UE5/Release-5.0/... via CL 17972248 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v885-17909292) #ROBOMERGE[STARSHIP]: UE5-Main [CL 17972256 by michael balzer in ue5-release-engine-test branch]
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "WeightMapUtil.h"
|
|
#include "MeshDescription.h"
|
|
|
|
|
|
void UE::WeightMaps::FindVertexWeightMaps(const FMeshDescription* Mesh, TArray<FName>& PropertyNamesOut)
|
|
{
|
|
const TAttributesSet<FVertexID>& VertexAttribs = Mesh->VertexAttributes();
|
|
VertexAttribs.ForEach([&](const FName AttributeName, auto AttributesRef)
|
|
{
|
|
if (VertexAttribs.HasAttributeOfType<float>(AttributeName))
|
|
{
|
|
PropertyNamesOut.Add(AttributeName);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
bool UE::WeightMaps::GetVertexWeightMap(const FMeshDescription* Mesh, FName AttributeName, FIndexedWeightMap1f& WeightMap, float DefaultValue)
|
|
{
|
|
WeightMap.DefaultValue = DefaultValue;
|
|
TArray<float>& Values = WeightMap.Values;
|
|
|
|
int32 VertexCount = Mesh->Vertices().Num();
|
|
if (Values.Num() < VertexCount)
|
|
{
|
|
Values.SetNum(VertexCount);
|
|
}
|
|
|
|
const TAttributesSet<FVertexID>& VertexAttribs = Mesh->VertexAttributes();
|
|
TVertexAttributesConstRef<float> Attrib = VertexAttribs.GetAttributesRef<float>(AttributeName);
|
|
if (Attrib.IsValid())
|
|
{
|
|
for (int32 k = 0; k < VertexCount; ++k)
|
|
{
|
|
Values[k] = Attrib.Get(FVertexID(k));
|
|
}
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
for (int32 k = 0; k < VertexCount; ++k)
|
|
{
|
|
Values[k] = DefaultValue;
|
|
}
|
|
return false;
|
|
}
|
|
}
|