Replaced unique instance queue with checks in template to instance mapper
This commit is contained in:
+9
-45
@@ -123,6 +123,15 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
auto findInstancesResult = m_templateInstanceMapperInterface->FindInstancesOwnedByTemplate(instanceTemplateId)->get();
|
||||
|
||||
if (findInstancesResult.find(instanceToUpdate) == findInstancesResult.end())
|
||||
{
|
||||
isUpdateSuccessful = false;
|
||||
m_instancesUpdateQueue.pop();
|
||||
continue;
|
||||
}
|
||||
|
||||
Template& currentTemplate = currentTemplateReference->get();
|
||||
Instance::EntityList newEntities;
|
||||
if (PrefabDomUtils::LoadInstanceFromPrefabDom(*instanceToUpdate, newEntities, currentTemplate.GetPrefabDom()))
|
||||
@@ -173,50 +182,5 @@ namespace AzToolsFramework
|
||||
|
||||
return isUpdateSuccessful;
|
||||
}
|
||||
|
||||
Instance* InstanceUpdateExecutor::UniqueInstanceQueue::front()
|
||||
{
|
||||
return m_instancesQueue.front();
|
||||
}
|
||||
|
||||
void InstanceUpdateExecutor::UniqueInstanceQueue::pop()
|
||||
{
|
||||
m_instancesSet.erase(m_instancesQueue.front());
|
||||
m_instancesQueue.pop();
|
||||
}
|
||||
|
||||
void InstanceUpdateExecutor::UniqueInstanceQueue::emplace(Instance* instance)
|
||||
{
|
||||
Instance* ancestorInstance = instance;
|
||||
|
||||
while (ancestorInstance != nullptr)
|
||||
{
|
||||
if (m_instancesSet.contains(ancestorInstance))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto parent = ancestorInstance->GetParentInstance();
|
||||
if (parent.has_value())
|
||||
{
|
||||
ancestorInstance = &(parent->get());
|
||||
}
|
||||
else
|
||||
{
|
||||
ancestorInstance = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO - remove child instances too?
|
||||
// Optimization.
|
||||
|
||||
m_instancesQueue.emplace(instance);
|
||||
m_instancesSet.emplace(instance);
|
||||
}
|
||||
|
||||
size_t InstanceUpdateExecutor::UniqueInstanceQueue::size()
|
||||
{
|
||||
return m_instancesQueue.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-14
@@ -15,7 +15,6 @@
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzCore/Serialization/Json/JsonSerialization.h>
|
||||
#include <AzCore/std/containers/queue.h>
|
||||
#include <AzCore/std/containers/set.h>
|
||||
#include <AzToolsFramework/Prefab/Instance/InstanceUpdateExecutorInterface.h>
|
||||
#include <AzToolsFramework/Prefab/PrefabIdTypes.h>
|
||||
|
||||
@@ -46,19 +45,6 @@ namespace AzToolsFramework
|
||||
PrefabSystemComponentInterface* m_prefabSystemComponentInterface = nullptr;
|
||||
TemplateInstanceMapperInterface* m_templateInstanceMapperInterface = nullptr;
|
||||
int m_instanceCountToUpdateInBatch = 0;
|
||||
|
||||
class UniqueInstanceQueue
|
||||
{
|
||||
public:
|
||||
Instance* front();
|
||||
void pop();
|
||||
void emplace(Instance* instance);
|
||||
size_t size();
|
||||
private:
|
||||
AZStd::queue<Instance*> m_instancesQueue;
|
||||
AZStd::unordered_set<Instance*> m_instancesSet;
|
||||
};
|
||||
//UniqueInstanceQueue m_instancesUpdateQueue;
|
||||
AZStd::queue<Instance*> m_instancesUpdateQueue;
|
||||
bool m_updatingTemplateInstancesInQueue { false };
|
||||
};
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace AzToolsFramework
|
||||
// Create Undo node on entities if they belong to an instance
|
||||
InstanceOptionalReference instanceOptionalReference = m_instanceEntityMapperInterface->FindOwningInstance(entityId);
|
||||
|
||||
if (instanceOptionalReference.has_value() && !IsInstanceContainerEntity(entityId))
|
||||
if (instanceOptionalReference.has_value())
|
||||
{
|
||||
PrefabDom afterState;
|
||||
AZ::Entity* entity = GetEntityById(entityId);
|
||||
|
||||
@@ -144,7 +144,6 @@ namespace AzToolsFramework
|
||||
|
||||
void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId)
|
||||
{
|
||||
UpdatePrefabInstances(templateId);
|
||||
auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId);
|
||||
if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end())
|
||||
{
|
||||
@@ -155,6 +154,10 @@ namespace AzToolsFramework
|
||||
templateIdToLinkIdsIterator->second.end()));
|
||||
UpdateLinkedInstances(linkIdsToUpdateQueue);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePrefabInstances(templateId);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefabSystemComponent::UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom)
|
||||
|
||||
Reference in New Issue
Block a user