Files
UnrealEngineUWP/Engine/Source/Developer/RigVMDeveloper/Public/RigVMModel/Nodes/RigVMUnitNode.h
helge mathee 3acbeeb2d3 RigVM: Store a hash along side each graph identifying the structural state
Avoid rebuilding graphs if we don't need to. hashes contain the structure of each node, the structure of any used data type and the structure of each used template.

#rb sara.schvartzman
#preflight https://horde.devtools.epicgames.com/job/63ee1c6fc9692d7c04423941

[CL 24280391 by helge mathee in ue5-main branch]
2023-02-17 08:46:05 -05:00

97 lines
3.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "RigVMModel/Nodes/RigVMTemplateNode.h"
#include "RigVMCore/RigVMStruct.h"
#include "UObject/StructOnScope.h"
#include "RigVMUnitNode.generated.h"
/**
* The Struct Node represents a Function Invocation of a RIGVM_METHOD
* declared on a USTRUCT. Struct Nodes have input / output pins for all
* struct UPROPERTY members.
*/
UCLASS(BlueprintType)
class RIGVMDEVELOPER_API URigVMUnitNode : public URigVMTemplateNode
{
GENERATED_BODY()
public:
// UObject interface
virtual void PostLoad() override;
// Override node functions
virtual FString GetNodeTitle() const override;
virtual FText GetToolTipText() const override;
virtual bool IsDefinedAsConstant() const override;
virtual bool IsDefinedAsVarying() const override;
virtual FName GetEventName() const override;
virtual bool CanOnlyExistOnce() const override;
virtual const TArray<FName>& GetControlFlowBlocks() const override;
virtual const bool IsControlFlowBlockSliced(const FName& InBlockName) const override;
virtual TArray<FRigVMUserWorkflow> GetSupportedWorkflows(ERigVMUserWorkflowType InType, const UObject* InSubject) const override;
virtual TArray<URigVMPin*> GetAggregateInputs() const override;
virtual TArray<URigVMPin*> GetAggregateOutputs() const override;
virtual FName GetNextAggregateName(const FName& InLastAggregatePinName) const override;
bool IsDeprecated() const;
FString GetDeprecatedMetadata() const;
// URigVMTemplateNode interface
virtual UScriptStruct* GetScriptStruct() const override;
// Returns the name of the declared RIGVM_METHOD
UFUNCTION(BlueprintCallable, Category = RigVMUnitNode)
virtual FName GetMethodName() const;
// Returns the default value for the struct as text
UFUNCTION(BlueprintCallable, Category = RigVMUnitNode)
FString GetStructDefaultValue() const;
// Returns an instance of the struct with the current values.
// @param bUseDefault If set to true the default struct will be created - otherwise the struct will contains the values from the node
TSharedPtr<FStructOnScope> ConstructStructInstance(bool bUseDefault = false) const;
// Returns a copy of the struct with the current values
template <
typename T,
typename TEnableIf<TModels_V<CRigVMUStruct, T>>::Type* = nullptr
>
T ConstructStructInstance() const
{
if(!ensure(T::StaticStruct() == GetScriptStruct()))
{
return T();
}
TSharedPtr<FStructOnScope> Instance = ConstructStructInstance(false);
const T& InstanceRef = *(const T*)Instance->GetStructMemory();
return InstanceRef;
}
virtual FRigVMStructUpgradeInfo GetUpgradeInfo() const override;
virtual uint32 GetStructureHash() const override;
protected:
virtual FText GetToolTipTextForPin(const URigVMPin* InPin) const override;
virtual bool ShouldInputPinComputeLazily(const URigVMPin* InPin) const override;
private:
#if WITH_EDITORONLY_DATA
UPROPERTY()
TObjectPtr<UScriptStruct> ScriptStruct_DEPRECATED;
UPROPERTY()
FName MethodName_DEPRECATED;
#endif
friend class URigVMController;
};