Merge branch 'development' of https://github.com/o3de/o3de into TerrainMaterialsFix
This commit is contained in:
@@ -73,7 +73,7 @@ namespace AzToolsFramework
|
||||
settings.m_keepDefaults = true;
|
||||
}
|
||||
|
||||
if ((flags & StoreFlags::StoreLinkIds) != StoreFlags::None)
|
||||
if ((flags & StoreFlags::StripLinkIds) != StoreFlags::StripLinkIds)
|
||||
{
|
||||
settings.m_metadata.Create<LinkIdMetadata>();
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace AzToolsFramework
|
||||
|
||||
//! We do not save linkIds to file. However when loading a level we want to temporarily save
|
||||
//! linkIds to instance dom so any nested prefabs will have linkIds correctly set.
|
||||
StoreLinkIds = 1 << 1
|
||||
StripLinkIds = 1 << 1
|
||||
};
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(StoreFlags);
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace AzToolsFramework::Prefab
|
||||
SetInstanceContainersOpenState(m_rootAliasFocusPath, false);
|
||||
|
||||
const RootAliasPath previousContainerRootAliasPath = m_rootAliasFocusPath;
|
||||
const InstanceOptionalConstReference previousFocusedInstance = GetInstanceReference(previousContainerRootAliasPath);
|
||||
const InstanceOptionalReference previousFocusedInstance = GetInstanceReference(previousContainerRootAliasPath);
|
||||
|
||||
m_rootAliasFocusPath = focusedInstance->get().GetAbsoluteInstanceAliasPath();
|
||||
m_focusedTemplateId = focusedInstance->get().GetTemplateId();
|
||||
@@ -277,7 +277,7 @@ namespace AzToolsFramework::Prefab
|
||||
|
||||
AZ::EntityId PrefabFocusHandler::GetFocusedPrefabContainerEntityId([[maybe_unused]] AzFramework::EntityContextId entityContextId) const
|
||||
{
|
||||
if (const InstanceOptionalConstReference instance = GetInstanceReference(m_rootAliasFocusPath); instance.has_value())
|
||||
if (const InstanceOptionalReference instance = GetInstanceReference(m_rootAliasFocusPath); instance.has_value())
|
||||
{
|
||||
return instance->get().GetContainerEntityId();
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace AzToolsFramework
|
||||
}
|
||||
|
||||
PrefabDom storedPrefabDom(&loadedTemplateDom->get().GetAllocator());
|
||||
if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom, PrefabDomUtils::StoreFlags::StoreLinkIds))
|
||||
if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ namespace AzToolsFramework
|
||||
|
||||
PrefabDom storedPrefabDom(&savingTemplateDom->get().GetAllocator());
|
||||
if (!PrefabDomUtils::StoreInstanceInPrefabDom(savingPrefabInstance, storedPrefabDom,
|
||||
PrefabDomUtils::StoreFlags::StripDefaultValues))
|
||||
PrefabDomUtils::StoreFlags::StripDefaultValues | PrefabDomUtils::StoreFlags::StripLinkIds))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace AzToolsFramework
|
||||
|
||||
// Update the template of the instance since the entities are modified since the template creation.
|
||||
Prefab::PrefabDom serializedInstance;
|
||||
if (Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(instanceToCreate->get(), serializedInstance))
|
||||
if (m_instanceToTemplateInterface->GenerateDomForInstance(serializedInstance, instanceToCreate->get()))
|
||||
{
|
||||
m_prefabSystemComponentInterface->UpdatePrefabTemplate(instanceToCreate->get().GetTemplateId(), serializedInstance);
|
||||
}
|
||||
|
||||
@@ -163,17 +163,21 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalConstReference instanceToExclude)
|
||||
{
|
||||
auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId);
|
||||
if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end())
|
||||
TemplateReference findTemplateResult = FindTemplate(templateId);
|
||||
if (findTemplateResult.has_value())
|
||||
{
|
||||
// We need to initialize a queue here because once all linked instances of a template are updated,
|
||||
// we will find all the linkIds corresponding to the updated template and add them to this queue again.
|
||||
AZStd::queue<LinkIds> linkIdsToUpdateQueue;
|
||||
linkIdsToUpdateQueue.push(LinkIds(templateIdToLinkIdsIterator->second.begin(),
|
||||
templateIdToLinkIdsIterator->second.end()));
|
||||
UpdateLinkedInstances(linkIdsToUpdateQueue);
|
||||
auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId);
|
||||
if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end())
|
||||
{
|
||||
// We need to initialize a queue here because once all linked instances of a template are updated,
|
||||
// we will find all the linkIds corresponding to the updated template and add them to this queue again.
|
||||
AZStd::queue<LinkIds> linkIdsToUpdateQueue;
|
||||
linkIdsToUpdateQueue.push(
|
||||
LinkIds(templateIdToLinkIdsIterator->second.begin(), templateIdToLinkIdsIterator->second.end()));
|
||||
UpdateLinkedInstances(linkIdsToUpdateQueue);
|
||||
}
|
||||
UpdatePrefabInstances(templateId, instanceToExclude);
|
||||
}
|
||||
UpdatePrefabInstances(templateId, instanceToExclude);
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom)
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace AzToolsFramework
|
||||
return;
|
||||
}
|
||||
|
||||
PrefabDomReference sourceDom = sourceTemplate->get().GetPrefabDom();
|
||||
PrefabDom& sourceDom = sourceTemplate->get().GetPrefabDom();
|
||||
|
||||
//use instance pointer to reach position
|
||||
PrefabDomValueReference instanceDomRef = link->get().GetLinkedInstanceDom();
|
||||
@@ -274,16 +274,14 @@ namespace AzToolsFramework
|
||||
(result.GetOutcome() != AZ::JsonSerializationResult::Outcomes::PartialSkip),
|
||||
"Some of the patches are not successfully applied.");
|
||||
|
||||
//remove the link id placed into the instance
|
||||
auto linkIdIter = instanceDom.FindMember(PrefabDomUtils::LinkIdName);
|
||||
if (linkIdIter != instanceDom.MemberEnd())
|
||||
{
|
||||
instanceDom.RemoveMember(PrefabDomUtils::LinkIdName);
|
||||
}
|
||||
// Remove the link ids if present in the doms. We don't want any overrides to be created on top of linkIds because
|
||||
// linkIds are not persistent and will be created dynamically when prefabs are loaded into the editor.
|
||||
instanceDom.RemoveMember(PrefabDomUtils::LinkIdName);
|
||||
sourceDom.RemoveMember(PrefabDomUtils::LinkIdName);
|
||||
|
||||
//we use this to diff our copy against the vanilla template (source template)
|
||||
PrefabDom patchLink;
|
||||
m_instanceToTemplateInterface->GeneratePatch(patchLink, sourceDom->get(), instanceDom);
|
||||
m_instanceToTemplateInterface->GeneratePatch(patchLink, sourceDom, instanceDom);
|
||||
|
||||
// Create a copy of patchLink by providing the allocator of m_linkDomNext so that the patch doesn't become invalid when
|
||||
// the patch goes out of scope in this function.
|
||||
|
||||
+9
-5
@@ -29,7 +29,7 @@
|
||||
#include <AzToolsFramework/ContainerEntity/ContainerEntityInterface.h>
|
||||
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
|
||||
#include <AzToolsFramework/Entity/ReadOnly/ReadOnlyEntityInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabPublicInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabFocusPublicInterface.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentBus.h>
|
||||
#include <AzToolsFramework/ToolsComponents/TransformComponentSerializer.h>
|
||||
#include <AzToolsFramework/ToolsComponents/EditorInspectorComponentBus.h>
|
||||
@@ -963,18 +963,22 @@ namespace AzToolsFramework
|
||||
|
||||
if (!m_parentEntityId.IsValid())
|
||||
{
|
||||
// If Prefabs are enabled, reroute the invalid id to the level root
|
||||
// If Prefabs are enabled, reroute the invalid id to the focused prefab container entity id
|
||||
bool isPrefabSystemEnabled = false;
|
||||
AzFramework::ApplicationRequests::Bus::BroadcastResult(
|
||||
isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled);
|
||||
|
||||
if (isPrefabSystemEnabled)
|
||||
{
|
||||
auto prefabPublicInterface = AZ::Interface<Prefab::PrefabPublicInterface>::Get();
|
||||
auto prefabFocusPublicInterface = AZ::Interface<Prefab::PrefabFocusPublicInterface>::Get();
|
||||
|
||||
if (prefabPublicInterface)
|
||||
if (prefabFocusPublicInterface)
|
||||
{
|
||||
m_parentEntityId = prefabPublicInterface->GetLevelInstanceContainerEntityId();
|
||||
auto editorEntityContextId = AzFramework::EntityContextId::CreateNull();
|
||||
EditorEntityContextRequestBus::BroadcastResult(
|
||||
editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId);
|
||||
|
||||
m_parentEntityId = prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(editorEntityContextId);
|
||||
refreshLevel = AZ::Edit::PropertyRefreshLevels::ValuesOnly;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user