Files
o3de/Gems/WhiteBox/Code/Source/Asset/WhiteBoxMeshAssetUndoCommand.cpp
T
Steve Pham 38261d0800 Shorten copyright headers by splitting into 2 lines (#2213)
* Updated all copyright headers to split the longer original copyright line into 2 shorter lines

Signed-off-by: Steve Pham <spham@amazon.com>
2021-07-16 15:25:48 -07:00

59 lines
1.8 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "WhiteBox_precompiled.h"
#include "Asset/WhiteBoxMeshAssetBus.h"
#include "WhiteBoxMeshAssetUndoCommand.h"
namespace WhiteBox
{
AZ_CLASS_ALLOCATOR_IMPL(WhiteBoxMeshAssetUndoCommand, AZ::SystemAllocator, 0);
WhiteBoxMeshAssetUndoCommand::WhiteBoxMeshAssetUndoCommand()
: AzToolsFramework::UndoSystem::URSequencePoint("WhiteBoxMeshAssetUndoCommand")
{
}
void WhiteBoxMeshAssetUndoCommand::SetAsset(AZ::Data::Asset<Pipeline::WhiteBoxMeshAsset> asset)
{
m_asset = asset;
}
void WhiteBoxMeshAssetUndoCommand::SetUndoState(const Api::WhiteBoxMeshStream& undoState)
{
m_undoState = undoState;
}
void WhiteBoxMeshAssetUndoCommand::SetRedoState(const Api::WhiteBoxMeshStream& redoState)
{
m_redoState = redoState;
}
void WhiteBoxMeshAssetUndoCommand::Undo()
{
Api::ReadMesh(*m_asset->GetMesh(), m_undoState);
m_asset->SetWhiteBoxData(m_undoState);
WhiteBoxMeshAssetNotificationBus::Event(
m_asset.GetId(), &WhiteBoxMeshAssetNotificationBus::Events::OnWhiteBoxMeshAssetModified, m_asset);
}
void WhiteBoxMeshAssetUndoCommand::Redo()
{
Api::ReadMesh(*m_asset->GetMesh(), m_redoState);
m_asset->SetWhiteBoxData(m_redoState);
WhiteBoxMeshAssetNotificationBus::Event(
m_asset.GetId(), &WhiteBoxMeshAssetNotificationBus::Events::OnWhiteBoxMeshAssetModified, m_asset);
}
bool WhiteBoxMeshAssetUndoCommand::Changed() const
{
return m_undoState != m_redoState;
}
} // namespace WhiteBox