2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
#include "GraphEditorCommon.h"
|
|
|
|
|
#include "SGraphNodeMaterialResult.h"
|
2014-09-11 08:13:08 -04:00
|
|
|
#include "TutorialMetaData.h"
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// SGraphNodeMaterialResult
|
|
|
|
|
|
|
|
|
|
void SGraphNodeMaterialResult::Construct(const FArguments& InArgs, UMaterialGraphNode_Root* InNode)
|
|
|
|
|
{
|
|
|
|
|
this->GraphNode = InNode;
|
|
|
|
|
this->RootNode = InNode;
|
|
|
|
|
|
|
|
|
|
this->SetCursor(EMouseCursor::CardinalCross);
|
|
|
|
|
|
|
|
|
|
this->UpdateGraphNode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SGraphNodeMaterialResult::CreatePinWidgets()
|
|
|
|
|
{
|
|
|
|
|
// Create Pin widgets for each of the pins.
|
|
|
|
|
for( int32 PinIndex=0; PinIndex < GraphNode->Pins.Num(); ++PinIndex )
|
|
|
|
|
{
|
|
|
|
|
UEdGraphPin* CurPin = GraphNode->Pins[PinIndex];
|
|
|
|
|
|
|
|
|
|
bool bHideNoConnectionPins = false;
|
|
|
|
|
|
|
|
|
|
if (OwnerGraphPanelPtr.IsValid())
|
|
|
|
|
{
|
|
|
|
|
bHideNoConnectionPins = OwnerGraphPanelPtr.Pin()->GetPinVisibility() == SGraphEditor::Pin_HideNoConnection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool bPinHasConections = CurPin->LinkedTo.Num() > 0;
|
|
|
|
|
|
|
|
|
|
//const bool bPinDesiresToBeHidden = CurPin->bHidden || (bHideNoConnectionPins && !bPinHasConections);
|
|
|
|
|
|
|
|
|
|
UMaterialGraph* MaterialGraph = CastChecked<UMaterialGraph>(GraphNode->GetGraph());
|
2014-10-08 15:27:19 -04:00
|
|
|
|
|
|
|
|
check(PinIndex < MaterialGraph->MaterialInputs.Num());
|
|
|
|
|
|
|
|
|
|
const bool bPinDesiresToBeHidden = !MaterialGraph->MaterialInputs[PinIndex].IsVisiblePin(MaterialGraph->Material) || (bHideNoConnectionPins && !bPinHasConections);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
if (!bPinDesiresToBeHidden)
|
|
|
|
|
{
|
|
|
|
|
TSharedPtr<SGraphPin> NewPin = CreatePinWidget(CurPin);
|
|
|
|
|
check(NewPin.IsValid());
|
|
|
|
|
NewPin->SetIsEditable(IsEditable);
|
|
|
|
|
|
|
|
|
|
this->AddPin(NewPin.ToSharedRef());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-06 04:45:44 -04:00
|
|
|
void SGraphNodeMaterialResult::MoveTo(const FVector2D& NewPosition, FNodeSet& NodeFilter)
|
2014-03-14 14:13:41 -04:00
|
|
|
{
|
2014-05-06 04:45:44 -04:00
|
|
|
SGraphNode::MoveTo(NewPosition, NodeFilter);
|
2014-03-14 14:13:41 -04:00
|
|
|
|
|
|
|
|
RootNode->Material->EditorX = RootNode->NodePosX;
|
|
|
|
|
RootNode->Material->EditorY = RootNode->NodePosY;
|
|
|
|
|
RootNode->Material->MarkPackageDirty();
|
|
|
|
|
RootNode->Material->MaterialGraph->MaterialDirtyDelegate.ExecuteIfBound();
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-11 08:13:08 -04:00
|
|
|
|
|
|
|
|
void SGraphNodeMaterialResult::PopulateMetaTag(FGraphNodeMetaData* TagMeta) const
|
|
|
|
|
{
|
|
|
|
|
if( (GraphNode != nullptr) && (RootNode != nullptr) )
|
|
|
|
|
{
|
|
|
|
|
UMaterialGraph* OuterGraph = RootNode->GetTypedOuter<UMaterialGraph>();
|
|
|
|
|
if (OuterGraph != nullptr)
|
|
|
|
|
{
|
|
|
|
|
TagMeta->OuterName = OuterGraph->OriginalMaterialFullName;
|
|
|
|
|
// There is only one root node - so we dont need a guid.
|
|
|
|
|
TagMeta->Tag = FName(*FString::Printf(TEXT("MaterialResNode_%s"), *TagMeta->OuterName));
|
|
|
|
|
TagMeta->GUID.Invalidate();
|
|
|
|
|
TagMeta->FriendlyName = FString::Printf(TEXT("Material Result node in %s"), *TagMeta->OuterName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|