2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-11-12 04:18:54 -05:00
|
|
|
#include "K2Node_CallParentFunction.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
|
|
|
|
|
#include "EdGraph/EdGraphPin.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "EdGraphSchema_K2.h"
|
|
|
|
|
#include "Editor.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
#include "Engine/Blueprint.h"
|
|
|
|
|
#include "Engine/MemberReference.h"
|
|
|
|
|
#include "GraphEditorSettings.h"
|
2023-12-14 06:34:39 -05:00
|
|
|
#include "FindInBlueprintManager.h"
|
|
|
|
|
#include "FindInBlueprints.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
#include "HAL/PlatformMath.h"
|
|
|
|
|
#include "Internationalization/Internationalization.h"
|
|
|
|
|
#include "K2Node.h"
|
|
|
|
|
#include "Misc/Guid.h"
|
2024-06-27 20:20:20 -04:00
|
|
|
#include "ObjectTools.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
#include "Settings/EditorStyleSettings.h"
|
2022-08-30 23:04:40 -04:00
|
|
|
#include "Templates/Casts.h"
|
2022-08-30 23:03:03 -04:00
|
|
|
#include "UObject/Class.h"
|
|
|
|
|
#include "UObject/NameTypes.h"
|
|
|
|
|
#include "UObject/Script.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "K2Node"
|
|
|
|
|
|
2014-10-14 10:29:11 -04:00
|
|
|
UK2Node_CallParentFunction::UK2Node_CallParentFunction(const FObjectInitializer& ObjectInitializer)
|
|
|
|
|
: Super(ObjectInitializer)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-23 18:30:37 -04:00
|
|
|
FText UK2Node_CallParentFunction::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2015-03-12 14:17:48 -04:00
|
|
|
UFunction* Function = FunctionReference.ResolveMember<UFunction>(GetBlueprintClassFromNode());
|
2015-03-27 12:54:58 -04:00
|
|
|
FText FunctionName;
|
2014-04-23 18:30:37 -04:00
|
|
|
|
2015-03-27 12:54:58 -04:00
|
|
|
if (Function)
|
2014-04-23 18:30:37 -04:00
|
|
|
{
|
2024-06-27 20:20:20 -04:00
|
|
|
FunctionName = ObjectTools::GetUserFacingFunctionName( Function );
|
2015-03-27 12:54:58 -04:00
|
|
|
}
|
|
|
|
|
else if ( GEditor && GetDefault<UEditorStyleSettings>()->bShowFriendlyNames )
|
|
|
|
|
{
|
|
|
|
|
FunctionName = FText::FromString(FName::NameToDisplayString(FunctionReference.GetMemberName().ToString(), false));
|
2014-04-23 18:30:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FFormatNamedArguments Args;
|
2015-03-27 12:54:58 -04:00
|
|
|
Args.Add(TEXT("FunctionName"), FunctionName);
|
2014-04-23 18:30:37 -04:00
|
|
|
return FText::Format( LOCTEXT( "CallSuperFunction", "Parent: {FunctionName}" ), Args);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
FLinearColor UK2Node_CallParentFunction::GetNodeTitleColor() const
|
|
|
|
|
{
|
2014-05-20 19:00:53 -04:00
|
|
|
return GetDefault<UGraphEditorSettings>()->ParentFunctionCallNodeTitleColor;
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UK2Node_CallParentFunction::AllocateDefaultPins()
|
|
|
|
|
{
|
|
|
|
|
Super::AllocateDefaultPins();
|
|
|
|
|
|
|
|
|
|
const UEdGraphSchema_K2* Schema = GetDefault<UEdGraphSchema_K2>();
|
|
|
|
|
UEdGraphPin* SelfPin = Schema->FindSelfPin(*this, EGPD_Input);
|
|
|
|
|
if( SelfPin )
|
|
|
|
|
{
|
|
|
|
|
SelfPin->bHidden = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UK2Node_CallParentFunction::SetFromFunction(const UFunction* Function)
|
|
|
|
|
{
|
UE-196156 - Add exec toggle for pure nodes
Blueprint pure nodes were initially intended to be similar to "functional pure". In other words, they're deterministic and produce no side effects (eg: doesn't mutate state). However, pure nodes have violated both conditions for a while now.
Instead, pure nodes are simply function nodes with output values and no visible exec pins. While this can be convenient, they come with a downside: the pure node is evaluated for each connected output. This can lead to unexpected performance issues if the node is expensive to evaluate. In the case of non-deterministic nodes, this can lead to unexpected behavior. In both cases, the user often needs to cull multiple outputs of a pure node and cache the result manually.
The solution here is to add support for toggling purity at the call site. When a function node is placed, right-clicking on it and selecting either "Hide Exec pins" or "Show Exec Pins" will toggle purity. Additionally, the meaning of BlueprintPure and the "Pure" check box changes slightly: it now means that the function node _defaults_ to a pure state when placed in a graph. However, it can be toggled to show its exec pins.
In future changes, we'll also reevaluate which common library functions should continue to default as pure.
#jira UE-196156
#rb dan.oconnor, jodon.karlik, ben.zeigler
[CL 35309072 by dave jones2 in ue5-main branch]
2024-08-05 11:58:15 -04:00
|
|
|
if (Function != nullptr)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
UE-196156 - Add exec toggle for pure nodes
Blueprint pure nodes were initially intended to be similar to "functional pure". In other words, they're deterministic and produce no side effects (eg: doesn't mutate state). However, pure nodes have violated both conditions for a while now.
Instead, pure nodes are simply function nodes with output values and no visible exec pins. While this can be convenient, they come with a downside: the pure node is evaluated for each connected output. This can lead to unexpected performance issues if the node is expensive to evaluate. In the case of non-deterministic nodes, this can lead to unexpected behavior. In both cases, the user often needs to cull multiple outputs of a pure node and cache the result manually.
The solution here is to add support for toggling purity at the call site. When a function node is placed, right-clicking on it and selecting either "Hide Exec pins" or "Show Exec Pins" will toggle purity. Additionally, the meaning of BlueprintPure and the "Pure" check box changes slightly: it now means that the function node _defaults_ to a pure state when placed in a graph. However, it can be toggled to show its exec pins.
In future changes, we'll also reevaluate which common library functions should continue to default as pure.
#jira UE-196156
#rb dan.oconnor, jodon.karlik, ben.zeigler
[CL 35309072 by dave jones2 in ue5-main branch]
2024-08-05 11:58:15 -04:00
|
|
|
bDefaultsToPureFunc = Function->HasAnyFunctionFlags(FUNC_BlueprintPure);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
2014-09-24 14:15:01 -04:00
|
|
|
UClass* OwnerClass = Function->GetOwnerClass();
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
FGuid FunctionGuid;
|
2014-09-24 14:15:01 -04:00
|
|
|
if (OwnerClass != nullptr)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-09-24 14:15:01 -04:00
|
|
|
OwnerClass = OwnerClass->GetAuthoritativeClass();
|
|
|
|
|
UBlueprint::GetGuidFromClassByFieldName<UFunction>(OwnerClass, Function->GetFName(), FunctionGuid);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
|
UE-196156 - Add exec toggle for pure nodes
Blueprint pure nodes were initially intended to be similar to "functional pure". In other words, they're deterministic and produce no side effects (eg: doesn't mutate state). However, pure nodes have violated both conditions for a while now.
Instead, pure nodes are simply function nodes with output values and no visible exec pins. While this can be convenient, they come with a downside: the pure node is evaluated for each connected output. This can lead to unexpected performance issues if the node is expensive to evaluate. In the case of non-deterministic nodes, this can lead to unexpected behavior. In both cases, the user often needs to cull multiple outputs of a pure node and cache the result manually.
The solution here is to add support for toggling purity at the call site. When a function node is placed, right-clicking on it and selecting either "Hide Exec pins" or "Show Exec Pins" will toggle purity. Additionally, the meaning of BlueprintPure and the "Pure" check box changes slightly: it now means that the function node _defaults_ to a pure state when placed in a graph. However, it can be toggled to show its exec pins.
In future changes, we'll also reevaluate which common library functions should continue to default as pure.
#jira UE-196156
#rb dan.oconnor, jodon.karlik, ben.zeigler
[CL 35309072 by dave jones2 in ue5-main branch]
2024-08-05 11:58:15 -04:00
|
|
|
const bool bIsConsideredSelfContext = false;
|
|
|
|
|
FunctionReference.SetDirect(Function->GetFName(), FunctionGuid, OwnerClass, bIsConsideredSelfContext);
|
2014-03-14 14:13:41 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
void UK2Node_CallParentFunction::FixupSelfMemberContext()
|
|
|
|
|
{
|
|
|
|
|
// Do nothing. We want the context to continue to be our parent class.
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
void UK2Node_CallParentFunction::PostPlacedNewNode()
|
|
|
|
|
{
|
|
|
|
|
// We don't want to check if our function exists in the current scope
|
|
|
|
|
|
|
|
|
|
UK2Node::PostPlacedNewNode();
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-14 06:34:39 -05:00
|
|
|
void UK2Node_CallParentFunction::AddSearchMetaDataInfo(TArray<struct FSearchTagDataPair>& OutTaggedMetaData) const
|
|
|
|
|
{
|
|
|
|
|
Super::AddSearchMetaDataInfo(OutTaggedMetaData);
|
|
|
|
|
|
|
|
|
|
// CallParentFunction nodes will always target the direct parent class, unlike CallFunction nodes.
|
|
|
|
|
// However, we still want the function to be searchable using the ancestor class or interface that declares it.
|
|
|
|
|
// Therefore, index a FuncOriginClass metadata value and don't rely on the target pin's type.
|
|
|
|
|
if (const UClass* FuncOriginClass = FindInBlueprintsHelpers::GetFunctionOriginClass(GetTargetFunction()))
|
|
|
|
|
{
|
|
|
|
|
const FString FuncOriginClassName = FuncOriginClass->GetPathName();
|
|
|
|
|
OutTaggedMetaData.Add(FSearchTagDataPair(FFindInBlueprintSearchTags::FiB_FuncOriginClass, FText::FromString(FuncOriginClassName)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-14 14:13:41 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|