Files
UnrealEngine/Engine/Plugins/Runtime/HairStrands/Source/HairStrandsDataflow/Public/BuildGroomSkinningNodes.h
2025-05-18 13:04:45 +08:00

173 lines
6.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GroomAsset.h"
#include "ChaosLog.h"
#include "GroomCollectionFacades.h"
#include "Dataflow/DataflowConnectionTypes.h"
#include "Dataflow/DataflowCore.h"
#include "BuildGroomSkinningNodes.generated.h"
/** Build the guides skinning by transfering the indices weights from a skelmesh */
USTRUCT(meta = (Experimental, DataflowGroom))
struct FBuildGuidesSkinningDataflowNode : public FDataflowNode
{
GENERATED_BODY()
DATAFLOW_NODE_DEFINE_INTERNAL(FBuildGuidesSkinningDataflowNode, "TransferSkinWeights", "Groom", "")
public:
FBuildGuidesSkinningDataflowNode(const UE::Dataflow::FNodeParameters& InParam, FGuid InGuid = FGuid::NewGuid())
: FDataflowNode(InParam, InGuid)
{
RegisterInputConnection(&Collection);
RegisterOutputConnection(&Collection, &Collection);
}
//~ Begin FDataflowNode interface
virtual void Evaluate(UE::Dataflow::FContext& Context, const FDataflowOutput* Out) const override;
virtual TArray<UE::Dataflow::FRenderingParameter> GetRenderParametersImpl() const override;
//~ End FDataflowNode interface
/** Managed array collection to be used to store datas */
UPROPERTY(meta = (DataflowInput, DataflowOutput, DisplayName = "Collection", DataflowPassthrough = "Collection"))
FManagedArrayCollection Collection;
/** SkeletalMesh used to transfer the skinning weights. Will be stored onto the groom asset */
UPROPERTY(EditAnywhere, Category="Skeletal Mesh")
TObjectPtr<USkeletalMesh> SkeletalMesh = nullptr;
/** LOD used to transfer the weights */
UPROPERTY(EditAnywhere, Category="Skeletal Mesh", meta = (DisplayName = "LOD Index"))
int32 LODIndex = 0;
/** Group index on which the dats will be transfered. -1 will transfer on all the groups */
UPROPERTY(EditAnywhere, Category="Groom Groups", meta = (DisplayName = "Group Index"))
int32 GroupIndex = INDEX_NONE;
/** The relative transform between the skeletal mesh and the groom asset. */
UPROPERTY(EditAnywhere, Category = "Skeletal Mesh")
FTransform RelativeTransform;
/** Type of curves to use to fill the groom collection (guides/strands) */
UPROPERTY(EditAnywhere, Category = "Groom Groups", meta = (DisplayName = "Curves Type"))
EGroomCollectionType CurvesType = EGroomCollectionType::Guides;
};
/** Extract the points skinning attributes to fill the vertices ones */
USTRUCT(meta = (Experimental, DataflowGroom))
struct FUnpackSkinWeightsDataflowNode : public FDataflowNode
{
GENERATED_BODY()
DATAFLOW_NODE_DEFINE_INTERNAL(FUnpackSkinWeightsDataflowNode, "UnpackSkinWeights", "Groom", "")
public:
FUnpackSkinWeightsDataflowNode(const UE::Dataflow::FNodeParameters& InParam, FGuid InGuid = FGuid::NewGuid())
: FDataflowNode(InParam, InGuid)
{
RegisterInputConnection(&Collection);
RegisterOutputConnection(&Collection, &Collection);
RegisterOutputConnection(&BoneIndicesKey);
RegisterOutputConnection(&BoneWeightsKey);
}
//~ Begin FDataflowNode interface
virtual void Evaluate(UE::Dataflow::FContext& Context, const FDataflowOutput* Out) const override;
virtual TArray<UE::Dataflow::FRenderingParameter> GetRenderParametersImpl() const override;
//~ End FDataflowNode interface
/** Managed array collection to be used to store datas */
UPROPERTY(meta = (DataflowInput, DataflowOutput, DisplayName = "Collection", DataflowPassthrough = "Collection"))
FManagedArrayCollection Collection;
/** The name to be set as a bones indices attribute. */
UPROPERTY(EditAnywhere, Category = "Vertex Attributes", meta = (DisplayName = "Bone Indices"))
FString BoneIndicesName;
/** The name to be set as a bones weights attribute. */
UPROPERTY(EditAnywhere, Category = "Vertex Attributes", meta = (DisplayName = "Bone Weights"))
FString BoneWeightsName;
/** Bone indices key to be used in other nodes if necessary */
UPROPERTY(meta = (DisplayName = "Bone Indices Key", DataflowOutput))
FCollectionAttributeKey BoneIndicesKey;
/** Bone weights key to be used in other nodes if necessary */
UPROPERTY(meta = (DisplayName = "Bone Weights Key", DataflowOutput))
FCollectionAttributeKey BoneWeightsKey;
/** Type of curves to use to fill the groom collection (guides/strands) */
UPROPERTY(EditAnywhere, Category = "Vertex Attributes", meta = (DisplayName = "Curves Type"))
EGroomCollectionType CurvesType = EGroomCollectionType::Guides;
private :
/** Get the bone indices key */
FCollectionAttributeKey GetBoneIndicesKey() const;
/** Get the bone weights key */
FCollectionAttributeKey GetBoneWeightsKey() const;
};
/** Report the vertices skinning attributes to fill the points ones */
USTRUCT(meta = (Experimental, DataflowGroom))
struct FPackSkinWeightsDataflowNode : public FDataflowNode
{
GENERATED_BODY()
DATAFLOW_NODE_DEFINE_INTERNAL(FPackSkinWeightsDataflowNode, "PackSkinWeights", "Groom", "")
public:
FPackSkinWeightsDataflowNode(const UE::Dataflow::FNodeParameters& InParam, FGuid InGuid = FGuid::NewGuid())
: FDataflowNode(InParam, InGuid)
{
RegisterInputConnection(&Collection);
RegisterInputConnection(&BoneIndicesKey);
RegisterInputConnection(&BoneWeightsKey);
RegisterOutputConnection(&Collection, &Collection);
}
//~ Begin FDataflowNode interface
virtual void Evaluate(UE::Dataflow::FContext& Context, const FDataflowOutput* Out) const override;
virtual TArray<UE::Dataflow::FRenderingParameter> GetRenderParametersImpl() const override;
//~ End FDataflowNode interface
/** Managed array collection to be used to store datas */
UPROPERTY(meta = (DataflowInput, DataflowOutput, DisplayName = "Collection", DataflowPassthrough = "Collection"))
FManagedArrayCollection Collection;
/** The name to be set as a weight map attribute. */
UPROPERTY(EditAnywhere, Category = "Vertex Attributes", meta = (DisplayName = "Bone Indices"))
FString BoneIndicesName;
/** The name to be set as a weight map attribute. */
UPROPERTY(EditAnywhere, Category = "Vertex Attributes", meta = (DisplayName = "Bone Weights"))
FString BoneWeightsName;
/** Bone indices key to be used in other nodes if necessary */
UPROPERTY(meta = (DisplayName = "Bone Indices Key", DataflowInput))
FCollectionAttributeKey BoneIndicesKey;
/** Bone weights key to be used in other nodes if necessary */
UPROPERTY(meta = (DisplayName = "Bone Weights Key", DataflowInput))
FCollectionAttributeKey BoneWeightsKey;
/** Type of curves to use to fill the groom collection (guides/strands) */
UPROPERTY(EditAnywhere, Category = "Vertex Attributes", meta = (DisplayName = "Curves Type"))
EGroomCollectionType CurvesType = EGroomCollectionType::Guides;
private :
/** Get the bone indices key */
FCollectionAttributeKey GetBoneIndicesKey(UE::Dataflow::FContext& Context) const;
/** Get the bone weights key */
FCollectionAttributeKey GetBoneWeightsKey(UE::Dataflow::FContext& Context) const;
};