Integrating up through commit 90f050496
This commit is contained in:
+8
-5
@@ -16,7 +16,7 @@
|
||||
#include "EntityTransformCommand.h"
|
||||
#include <HexEdFramework/FrameworkCore/SelectionMessages.h>
|
||||
#include <HexEd/WorldEditor/ToolsComponents/TransformComponentBus.h>
|
||||
#include "PreemptiveUndoCache.h"
|
||||
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
@@ -31,6 +31,9 @@ namespace AzToolsFramework
|
||||
m_priorTransforms[*it] = current;
|
||||
m_nextTransforms[*it] = current;
|
||||
}
|
||||
|
||||
m_undoCacheInterface = AZ::Interface<UndoSystem::UndoCacheInterface>::Get();
|
||||
AZ_Assert(m_undoCacheInterface, "Could not get UndoCacheInterface on TransformCommand construction.");
|
||||
}
|
||||
|
||||
void TransformCommand::Post()
|
||||
@@ -46,7 +49,7 @@ namespace AzToolsFramework
|
||||
|
||||
for (auto it = m_priorTransforms.begin(); it != m_priorTransforms.end(); ++it)
|
||||
{
|
||||
PreemptiveUndoCache::Get()->UpdateCache(it->first);
|
||||
m_undoCacheInterface->UpdateCache(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +58,7 @@ namespace AzToolsFramework
|
||||
for (auto it = m_priorTransforms.begin(); it != m_priorTransforms.end(); ++it)
|
||||
{
|
||||
EBUS_EVENT_ID(it->first, TransformComponentMessages::Bus, SetLocalSRT, it->second);
|
||||
PreemptiveUndoCache::Get()->UpdateCache(it->first);
|
||||
m_undoCacheInterface->UpdateCache(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +67,7 @@ namespace AzToolsFramework
|
||||
for (auto it = m_nextTransforms.begin(); it != m_nextTransforms.end(); ++it)
|
||||
{
|
||||
EBUS_EVENT_ID(it->first, TransformComponentMessages::Bus, SetLocalSRT, it->second);
|
||||
PreemptiveUndoCache::Get()->UpdateCache(it->first);
|
||||
m_undoCacheInterface->UpdateCache(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,4 +90,4 @@ namespace AzToolsFramework
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
|
||||
namespace AzToolsFramework
|
||||
{
|
||||
namespace UndoSystem
|
||||
{
|
||||
class UndoCacheInterface;
|
||||
}
|
||||
|
||||
typedef AZStd::vector<AZ::EntityId> EntityList;
|
||||
|
||||
// transform command specializes undo to just care about the transform of an entity instead of the entire thing, for performance.
|
||||
@@ -54,9 +59,12 @@ namespace AzToolsFramework
|
||||
|
||||
CapturedTransforms m_priorTransforms;
|
||||
CapturedTransforms m_nextTransforms;
|
||||
|
||||
private:
|
||||
UndoCacheInterface* m_undoCacheInterface;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // disabled
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,11 @@ namespace AzToolsFramework
|
||||
s_cache->m_instance = this;
|
||||
}
|
||||
|
||||
void PreemptiveUndoCache::RegisterToUndoCacheInterface()
|
||||
{
|
||||
AZ::Interface<UndoSystem::UndoCacheInterface>::Register(this);
|
||||
}
|
||||
|
||||
PreemptiveUndoCache::~PreemptiveUndoCache()
|
||||
{
|
||||
if (s_cache)
|
||||
@@ -60,6 +65,11 @@ namespace AzToolsFramework
|
||||
s_cache->m_instance = nullptr;
|
||||
s_cache.Reset();
|
||||
}
|
||||
|
||||
if (AZ::Interface<UndoSystem::UndoCacheInterface>::Get() == this)
|
||||
{
|
||||
AZ::Interface<UndoSystem::UndoCacheInterface>::Unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
PreemptiveUndoCache* PreemptiveUndoCache::Get()
|
||||
@@ -173,4 +183,4 @@ namespace AzToolsFramework
|
||||
return it->second;
|
||||
}
|
||||
|
||||
} // namespace AzToolsFramework
|
||||
} // namespace AzToolsFramework
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <AzCore/std/containers/unordered_map.h>
|
||||
|
||||
#include <AzToolsFramework/Undo/UndoCacheInterface.h>
|
||||
|
||||
// Enable to generate warnings for entity data changes not caught by undo batches.
|
||||
#if defined(AZ_DEBUG_BUILD) && !defined(ENABLE_UNDOCACHE_CONSISTENCY_CHECKS)
|
||||
# define ENABLE_UNDOCACHE_CONSISTENCY_CHECKS
|
||||
@@ -29,6 +31,7 @@ namespace AzToolsFramework
|
||||
// so that the user does not have to inform us before they make a change, only after they make a change
|
||||
// it also allows us to detect errors with change notification and not have to do multiple snapshots (before and after)
|
||||
class PreemptiveUndoCache
|
||||
: UndoSystem::UndoCacheInterface
|
||||
{
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(PreemptiveUndoCache, AZ::SystemAllocator, 0);
|
||||
@@ -37,23 +40,21 @@ namespace AzToolsFramework
|
||||
PreemptiveUndoCache();
|
||||
~PreemptiveUndoCache();
|
||||
|
||||
void RegisterToUndoCacheInterface();
|
||||
|
||||
// UndoCacheInterface...
|
||||
void UpdateCache(const AZ::EntityId& entityId) override;
|
||||
void PurgeCache(const AZ::EntityId& entityId) override;
|
||||
void Clear() override;
|
||||
void Validate(const AZ::EntityId& entityId) override;
|
||||
|
||||
// whenever an entity appears in the world, as an atomic operation (ie, after all of its loading is complete, and the entity is active)
|
||||
// we snapshot it here. then, whenever an entity changes, we have what it used to be.
|
||||
typedef AZStd::vector<AZ::u8> CacheLineType;
|
||||
|
||||
void Validate(const AZ::EntityId& entityId);
|
||||
|
||||
// Store the new entity state or replace the old state
|
||||
void UpdateCache(const AZ::EntityId& entityId);
|
||||
|
||||
// remove the cache line for the entity, if there is one
|
||||
void PurgeCache(const AZ::EntityId& entityId);
|
||||
|
||||
// retrieve the last known state for an entity
|
||||
const CacheLineType& Retrieve(const AZ::EntityId& entityId);
|
||||
|
||||
// clear the entire cache:
|
||||
void Clear();
|
||||
protected:
|
||||
typedef AZStd::unordered_map<AZ::EntityId, CacheLineType> EntityStateMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user