!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / CryEngine / CrySchematyc2 / Deprecated / DocGraphNodes / DocGraphBranchNode.cpp
blob0182128e13f6435683de79ba327b5df09e5195d0
1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 #include "StdAfx.h"
4 #include "Deprecated/DocGraphNodes/DocGraphBranchNode.h"
6 #include <CrySchematyc2/ICompiler.h>
7 #include <CrySchematyc2/LibUtils.h>
8 #include <CrySchematyc2/Deprecated/DocUtils.h>
9 #include <CrySchematyc2/Deprecated/IGlobalFunction.h>
11 #include "Deprecated/DocGraphNodes/DocGraphNodeBase.h"
12 #include "Script/ScriptVariableDeclaration.h"
14 namespace Schematyc2
16 //////////////////////////////////////////////////////////////////////////
17 CDocGraphBranchNode::CDocGraphBranchNode(IScriptFile& file, IDocGraph& graph, const SGUID& guid, const SGUID& contextGUID, const SGUID& refGUID, Vec2 pos)
18 : CDocGraphNodeBase(file, graph, guid, "Branch", EScriptGraphNodeType::Branch, contextGUID, refGUID, pos)
19 , m_bValue(false)
21 Refresh(SScriptRefreshParams(EScriptRefreshReason::Other));
24 //////////////////////////////////////////////////////////////////////////
25 IAnyConstPtr CDocGraphBranchNode::GetCustomOutputDefault() const
27 return IAnyConstPtr();
30 //////////////////////////////////////////////////////////////////////////
31 size_t CDocGraphBranchNode::AddCustomOutput(const IAny& value)
33 return INVALID_INDEX;
36 //////////////////////////////////////////////////////////////////////////
37 void CDocGraphBranchNode::EnumerateOptionalOutputs(const ScriptGraphNodeOptionalOutputEnumerator& enumerator) {}
39 //////////////////////////////////////////////////////////////////////////
40 size_t CDocGraphBranchNode::AddOptionalOutput(const char* szName, EScriptGraphPortFlags flags, const CAggregateTypeId& typeId)
42 return INVALID_INDEX;
45 //////////////////////////////////////////////////////////////////////////
46 void CDocGraphBranchNode::RemoveOutput(size_t outputIdx) {}
48 //////////////////////////////////////////////////////////////////////////
49 void CDocGraphBranchNode::Refresh(const SScriptRefreshParams& params)
51 CRY_PROFILE_FUNCTION(PROFILE_LOADING_ONLY);
52 CDocGraphNodeBase::Refresh(params);
53 CDocGraphNodeBase::AddInput("In", EScriptGraphPortFlags::MultiLink | EScriptGraphPortFlags::Execute);
54 CDocGraphNodeBase::AddInput("Value", EScriptGraphPortFlags::None, GetAggregateTypeId<bool>());
55 CDocGraphNodeBase::AddOutput("True", EScriptGraphPortFlags::Execute);
56 CDocGraphNodeBase::AddOutput("False", EScriptGraphPortFlags::Execute);
59 //////////////////////////////////////////////////////////////////////////
60 void CDocGraphBranchNode::Serialize(Serialization::IArchive& archive)
62 CRY_PROFILE_FUNCTION(PROFILE_LOADING_ONLY);
63 CDocGraphNodeBase::Serialize(archive);
64 archive(m_bValue, "value", "Value");
67 //////////////////////////////////////////////////////////////////////////
68 void CDocGraphBranchNode::PreCompileSequence(IDocGraphSequencePreCompiler& preCompiler, size_t outputIdx) const {}
70 //////////////////////////////////////////////////////////////////////////
71 void CDocGraphBranchNode::LinkSequence(IDocGraphSequenceLinker& linker, size_t outputIdx, const LibFunctionId& functionId) const {}
73 //////////////////////////////////////////////////////////////////////////
74 void CDocGraphBranchNode::Compile(IDocGraphNodeCompiler& compiler, EDocGraphSequenceStep sequenceStep, size_t portIdx) const
76 switch(sequenceStep)
78 case EDocGraphSequenceStep::BeginInput:
80 CompileInputs(compiler);
81 break;
83 case EDocGraphSequenceStep::BeginOutput:
85 switch(portIdx)
87 case EOutput::True:
89 CompileTrue(compiler);
90 break;
92 case EOutput::False:
94 CompileFalse(compiler);
95 break;
98 break;
100 case EDocGraphSequenceStep::EndInput:
102 CompileEnd(compiler);
103 break;
108 //////////////////////////////////////////////////////////////////////////
109 void CDocGraphBranchNode::CompileInputs(IDocGraphNodeCompiler& compiler) const
111 compiler.CreateStackFrame(*this, EStackFrame::Value);
112 const size_t stackPos = compiler.FindInputOnStack(*this, EInput::Value);
113 if(stackPos != INVALID_INDEX)
115 if(stackPos != (compiler.GetStackSize() - 1))
117 compiler.Copy(stackPos, INVALID_INDEX, MakeAny(m_bValue), CDocGraphNodeBase::GetGUID(), GetInputName(EInput::Value));
119 else
121 compiler.SetDebugInput(CDocGraphNodeBase::GetGUID(), GetInputName(EInput::Value));
124 else
126 compiler.Push(MakeAny(m_bValue), CDocGraphNodeBase::GetGUID(), GetInputName(EInput::Value));
130 //////////////////////////////////////////////////////////////////////////
131 void CDocGraphBranchNode::CompileTrue(IDocGraphNodeCompiler& compiler) const
133 compiler.BranchIfZero(*this, EMarker::BranchFalse);
134 compiler.CollapseStackFrame(*this, EStackFrame::Value);
135 compiler.CreateStackFrame(*this, EStackFrame::Value);
138 //////////////////////////////////////////////////////////////////////////
139 void CDocGraphBranchNode::CompileFalse(IDocGraphNodeCompiler& compiler) const
141 compiler.Branch(*this, EMarker::BranchEnd);
142 compiler.CreateMarker(*this, EMarker::BranchFalse);
143 compiler.CollapseStackFrame(*this, EStackFrame::Value);
144 compiler.CreateStackFrame(*this, EStackFrame::Value);
147 //////////////////////////////////////////////////////////////////////////
148 void CDocGraphBranchNode::CompileEnd(IDocGraphNodeCompiler& compiler) const
150 compiler.CreateMarker(*this, EMarker::BranchEnd);
151 compiler.CollapseStackFrame(*this, EStackFrame::Value);