// Copyright 2020 Phyronnaz #pragma once #include "CoreMinimal.h" #include "VoxelMinimal.h" #include "VoxelTexture.h" #include "VoxelGraphOutputs.h" #include "VoxelAxisDependencies.h" #include "VoxelGenerators/VoxelGenerator.h" #include "Engine/EngineTypes.h" #include "EdGraph/EdGraphPin.h" #include "VoxelGraphGenerator.generated.h" class UEdGraph; class UVoxelNode; class UTexture2D; class UVoxelExposedNode; class UVoxelGraphOutputsConfig; class UVoxelGraphPreviewSettings; class FVoxelGraphGeneratorInstance; struct FVoxelCompiledGraphs; UENUM() enum class EVoxelGraphGeneratorDebugLevel : uint8 { BeforeMacroInlining, AfterMacroInlining, AfterBiomeMergeReplace, AfterSmartMinMaxReplace, BeforeFillFunctionSeparators, Output, Function, Axis }; /** * A graph generator */ UCLASS(BlueprintType, HideCategories = (Object), HideDropdown) class VOXELGRAPH_API UVoxelGraphGenerator : public UVoxelTransformableGenerator { GENERATED_BODY() public: UPROPERTY(EditAnywhere, Category = "Config") TObjectPtr Outputs; TMap GetOutputs() const; TArray GetPermutations() const; public: UPROPERTY() bool bAutomaticPreview = true; UPROPERTY() bool bShowFlowMergeAndFunctionsWarnings = true; public: UPROPERTY(EditAnywhere, Category = "Automatic compilation", meta= (DisplayName = "Compile to C++ on Save")) bool bCompileToCppOnSave = false; // Relative to project directory UPROPERTY(EditAnywhere, Category = "Automatic compilation", meta = (FilePathFilter = "h", EditCondition = bCompileToCppOnSave)) FFilePath SaveLocation; #if WITH_EDITORONLY_DATA UPROPERTY() FString LastSavePath; #endif public: // Range analysis gives a pretty significant speed-up. You should not disable it UPROPERTY(EditAnywhere, AdvancedDisplay, Category = "Range Analysis") bool bEnableRangeAnalysis = true; public: // Will show the nodes functions. If DetailedErrors is false, will only show TargetToDebug UPROPERTY(EditAnywhere, Category = "Debug", meta = (Refresh)) bool bShowFunctions = false; // Show errors callstacks UPROPERTY(EditAnywhere, Category = "Debug", meta = (Refresh)) bool bDetailedErrors = false; // Can be enabled in Window->Debug Graph UPROPERTY(EditAnywhere, Category = "Debug", meta = (Refresh)) bool bEnableDebugGraph = false; UPROPERTY(EditAnywhere, Category = "Debug", meta = (EditCondition = bEnableDebugGraph, Refresh)) bool bShowPinsIds = false; UPROPERTY(EditAnywhere, Category = "Debug", meta = (EditCondition = bEnableDebugGraph, Refresh)) bool bShowAxisDependencies = false; // The level of compilation to debug UPROPERTY(EditAnywhere, Category = "Debug", meta = (EditCondition = bEnableDebugGraph, Refresh)) EVoxelGraphGeneratorDebugLevel DebugLevel; // The target to debug, if DebugLevel is below or equal to Target UPROPERTY(EditAnywhere, Category = "Debug", meta = (EditCondition = bEnableDebugGraph, Refresh)) FString TargetToDebug = "Value"; // The function to debug, if DebugLevel is below or equal to Function UPROPERTY(EditAnywhere, Category = "Debug", meta = (EditCondition = bEnableDebugGraph, Refresh)) int32 FunctionToDebug = 0; // The axis to debug, if DebugLevel is Axis UPROPERTY(EditAnywhere, Category = "Debug", meta = (EditCondition = bEnableDebugGraph, Refresh)) EVoxelFunctionAxisDependencies AxisDependenciesToDebug; // Increase this if your macro nodes are overlapping in the debug graph UPROPERTY(EditAnywhere, Category = "Debug", AdvancedDisplay, meta = (EditCondition = bEnableDebugGraph, Refresh)) float NodesDepthScaleFactor = 1; UPROPERTY(EditAnywhere, Category = "Debug", AdvancedDisplay, meta = (EditCondition = bEnableDebugGraph, Refresh)) bool bHideDataNodes = false; public: UPROPERTY() TArray> AllNodes; UPROPERTY() TArray> DebugNodes; UPROPERTY() TObjectPtr FirstNode; UPROPERTY() FGuid FirstNodePinId; #if WITH_EDITORONLY_DATA UPROPERTY() TObjectPtr VoxelGraph; UPROPERTY() TObjectPtr VoxelDebugGraph; FEdGraphPinReference PreviewedPin; #endif UPROPERTY() TObjectPtr PreviewSettings; public: TMap TransientParameters; public: //~ Begin UVoxelGenerator Interface virtual void ApplyParameters(const TMap& Parameters) override; virtual void GetParameters(TArray& OutParameters) const override; virtual TVoxelSharedRef GetTransformableInstance() override; virtual TVoxelSharedRef GetTransformableInstance(const TMap& Parameters) override;; //~ End UVoxelGenerator Interface #if WITH_EDITOR //~ Begin UObject Interface void PostInitProperties() override; void PostLoad() override; void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override; //~ End UObject Interface // Create a new node of NewNodeClass UVoxelNode* ConstructNewNode(UClass* NewNodeClass, const FVector2D& Position, bool bSelectNewNode = true); template T* ConstructNewNode(const FVector2D& Position, bool bSelectNewNode = true) { return CastChecked(ConstructNewNode(T::StaticClass(), Position, bSelectNewNode)); } // Create the basic voxel graph void CreateGraphs(); // Use the EdGraph representation to compile the VoxelNodes void CompileVoxelNodesFromGraphNodes(); #endif #if WITH_EDITORONLY_DATA public: UTexture2D* GetPreviewTexture(); void SetPreviewTexture(const TArray& Colors, int32 Size); private: UPROPERTY(NonTransactional) TArray PreviewTextureSave; UPROPERTY(Transient) TObjectPtr PreviewTexture; #endif private: void UpdateSetterNodes(); void BindUpdateSetterNodes(); };