Merge branch 'development' into chore/rename-Graph-EditorGraph-Match

This commit is contained in:
Luis Sempé
2022-01-18 12:35:58 -08:00
committed by GitHub
1346 changed files with 38972 additions and 26851 deletions
@@ -100,12 +100,18 @@ namespace ScriptCanvas
{
RuntimeAsset* runtimeAsset = asset.GetAs<RuntimeAsset>();
AZ_Assert(runtimeAsset, "This should be a Script Canvas runtime asset, as this is the only type we process!");
if (runtimeAsset && m_serializeContext)
{
stream->Seek(0U, AZ::IO::GenericStream::ST_SEEK_BEGIN);
bool loadSuccess = AZ::Utils::LoadObjectFromStreamInPlace(*stream, runtimeAsset->m_runtimeData, m_serializeContext, AZ::ObjectStream::FilterDescriptor(assetLoadFilterCB));
const bool loadSuccess = AZ::Utils::LoadObjectFromStreamInPlace(*stream, runtimeAsset->m_runtimeData
, m_serializeContext, AZ::ObjectStream::FilterDescriptor(assetLoadFilterCB));
AZ_Error("ScriptCanvas", loadSuccess, "ScriptCanvas failed to load runtime asset: %s - %s"
, asset.GetHint().c_str(), asset.GetId().ToString<AZStd::string>().c_str());
return loadSuccess ? AZ::Data::AssetHandler::LoadResult::LoadComplete : AZ::Data::AssetHandler::LoadResult::Error;
}
return AZ::Data::AssetHandler::LoadResult::Error;
}
@@ -2577,11 +2577,11 @@ namespace ScriptCanvas
}
}
bool Node::ConvertSlotToReference(const SlotId& slotId)
bool Node::ConvertSlotToReference(const SlotId& slotId, bool isNewSlot)
{
Slot* slot = GetSlot(slotId);
if (slot && slot->ConvertToReference())
if (slot && slot->ConvertToReference(isNewSlot))
{
InitializeVariableReference((*slot), {});
return true;
@@ -498,7 +498,7 @@ namespace ScriptCanvas
void SanityCheckDynamicDisplay();
void SanityCheckDynamicDisplay(ExploredDynamicGroupCache& exploredGroupCache);
bool ConvertSlotToReference(const SlotId& slotId);
bool ConvertSlotToReference(const SlotId& slotId, bool isNewSlot = false);
bool ConvertSlotToValue(const SlotId& slotId);
NamedEndpoint CreateNamedEndpoint(SlotId slotId) const;
@@ -460,14 +460,14 @@ namespace ScriptCanvas
&& GetDataType() != Data::Type::BehaviorContextObject(GraphScopedVariableId::TYPEINFO_Uuid());
}
bool Slot::CanConvertToReference() const
{
return !m_isUserAdded && CanConvertTypes() && !m_isVariableReference && !m_node->HasConnectedNodes((*this));
bool Slot::CanConvertToReference(bool isNewSlot) const
{
return (!m_isUserAdded || isNewSlot) && CanConvertTypes() && !m_isVariableReference && !m_node->HasConnectedNodes((*this));
}
bool Slot::ConvertToReference()
bool Slot::ConvertToReference(bool isNewSlot)
{
if (CanConvertToReference())
if (CanConvertToReference(isNewSlot))
{
m_isVariableReference = true;
@@ -147,8 +147,8 @@ namespace ScriptCanvas
bool CanConvertToValue() const;
bool ConvertToValue();
bool CanConvertToReference() const;
bool ConvertToReference();
bool CanConvertToReference(bool isNewSlot = false) const;
bool ConvertToReference(bool isNewSlot = false);
void SetVariableReference(const VariableId& variableId);
const VariableId& GetVariableReference() const;
GraphVariable* GetVariable() const;
@@ -240,7 +240,6 @@ namespace ScriptCanvas
// #functions2 slot<->variable consider getting all variables from the UX variable manager, or from the ACM and looking them up in the variable manager for ordering
m_sourceVariableByDatum.insert(AZStd::make_pair(datum, &variablePair.second));
}
}
for (auto& sourceVariable : sortedVariables)
@@ -1714,6 +1713,7 @@ namespace ScriptCanvas
auto iter = m_inputVariableByNodelingInSlot.find(input);
if (iter != m_inputVariableByNodelingInSlot.end())
{
// #sc_user_slot_variable_ux don't add variable name if not necessary
VariablePtr variable = iter->second;
const Slot* slot = iter->first;
variable->m_name = call->ModScope()->AddVariableName(slot->GetName());
@@ -4644,35 +4644,59 @@ namespace ScriptCanvas
void AbstractCodeModel::ParseNodelingVariables(const Node& node, NodelingType nodelingType)
{
// #functions2 slot<->variable adjust once datums are more coordinated
auto createVariablesSlots = [&](AZStd::unordered_map<const Slot*, VariablePtr>& variablesBySlots, const AZStd::vector<const Slot*>& slots, bool slotHasDatum)
// This function accounts for all the ways users have been able to introduce input/output data in their SC function definitions.
// They have been able to create slots, variables, or both. This function reads the datums to create the correct ACM
// variable per required SC user variable. It uses slots as the key, and checks datums in the SC variable list for possible
// matches.
auto createVariablesSlots = [&](AZStd::unordered_map<const Slot*, VariablePtr>& variablesBySlots, const AZStd::vector<const Slot*>& slots, bool errorOnMissingDatum)
{
for (const auto& slot : slots)
{
auto variable = AZStd::make_shared<Variable>();
auto variableDatum = slot->FindDatum();
bool initializeDatum = true;
if (slotHasDatum)
if (variableDatum)
{
auto variableDatum = slot->FindDatum();
if (!variableDatum)
{
AddError(nullptr, aznew Internal::ParseError(node.GetEntityId(), AZStd::string::format("Datum missing from Slot %s on Node %s", slot->GetName().data(), node.GetNodeName().c_str())));
return;
}
initializeDatum = false;
}
else if (errorOnMissingDatum)
{
AddError(nullptr, aznew Internal::ParseError(node.GetEntityId(), AZStd::string::format("Datum missing from Slot %s on Node %s", slot->GetName().data(), node.GetNodeName().c_str())));
return;
}
// #functions2 slot<->variable consider getting all variables from the UX variable manager, or from the ACM and looking them up in the variable manager for ordering
// auto iter = m_sourceVariableByDatum.find(variableDatum);
// if (iter == m_sourceVariableByDatum.end())
// {
// AddError(nullptr, aznew Internal::ParseError(node.GetEntityId(), AZStd::string::format("Datum missing from Slot %s on Node %s", slot->GetName().data(), node.GetNodeName().c_str())));
// return;
// }
// variable->m_sourceVariableId = iter->second->GetVariableId();
// find the other variable
auto iter = m_sourceVariableByDatum.find(variableDatum);
if (iter != m_sourceVariableByDatum.end())
{
initializeDatum = false;
}
else if (!variableDatum && errorOnMissingDatum)
{
AddError(nullptr, aznew Internal::ParseError(node.GetEntityId(), AZStd::string::format("Datum missing from Slot %s on Node %s", slot->GetName().data(), node.GetNodeName().c_str())));
return;
}
VariablePtr premadeVariable = iter != m_sourceVariableByDatum.end()
? AZStd::const_pointer_cast<Variable>(FindVariable(iter->second->GetVariableId()))
: VariablePtr();
if (premadeVariable)
{
initializeDatum = false;
variable = premadeVariable;
}
variable->m_sourceSlotId = slot->GetId();
if (!premadeVariable && variableDatum)
{
variable->m_datum = *variableDatum;
}
else
if (initializeDatum)
{
// make a new datum and a source slot id and all that
variable->m_datum.SetType(slot->GetDataType());
}
@@ -4680,7 +4704,11 @@ namespace ScriptCanvas
variable->m_sourceSlotId = slot->GetId();
variable->m_isFromFunctionDefinitionSlot = true;
variablesBySlots.insert({ slot, variable });
m_variables.push_back(variable);
if (!premadeVariable)
{
m_variables.push_back(variable);
}
}
};
@@ -220,7 +220,6 @@ namespace ScriptCanvas
return AZ::Success(newId);
}
// #functions2 slot<->variable add this to the graph, using the old datum
AZ::Outcome<VariableId, AZStd::string> GraphVariableManagerComponent::AddVariable(AZStd::string_view name, const Datum& value, bool functionScope)
{
if (FindVariable(name))