mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 18:59:12 +00:00
UndoCommand: Move struct into implementation where applicable
This commit is contained in:
@@ -84,10 +84,10 @@ void CCloneSelectionCommand::redo()
|
||||
}
|
||||
|
||||
// Clone outgoing links from source object; incoming ones are discarded
|
||||
for (int iNode = 0; iNode < ClonedNodes.size(); iNode++)
|
||||
for (qsizetype iNode = 0; iNode < ClonedNodes.size(); iNode++)
|
||||
{
|
||||
CScriptObject *pSrc = static_cast<CScriptNode*>(ToClone[iNode])->Instance();
|
||||
CScriptObject *pClone = static_cast<CScriptNode*>(ClonedNodes[iNode])->Instance();
|
||||
auto* pSrc = static_cast<CScriptNode*>(ToClone[iNode])->Instance();
|
||||
auto* pClone = static_cast<CScriptNode*>(ClonedNodes[iNode])->Instance();
|
||||
|
||||
for (size_t iLink = 0; iLink < pSrc->NumLinks(ELinkType::Outgoing); iLink++)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
struct CRotateNodeCommand::SNodeRotate
|
||||
{
|
||||
CNodePtr pNode;
|
||||
CVector3f InitialPos;
|
||||
CQuaternion InitialRot;
|
||||
CVector3f NewPos;
|
||||
CQuaternion NewRot;
|
||||
};
|
||||
|
||||
CRotateNodeCommand::CRotateNodeCommand()
|
||||
: IUndoCommand(QCoreApplication::translate("CRotateNodeCommand", "Rotate"))
|
||||
{
|
||||
@@ -58,7 +67,7 @@ bool CRotateNodeCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
|
||||
if (pkOther->id() == (int) EUndoCommand::RotateNodeCmd)
|
||||
{
|
||||
const CRotateNodeCommand *pkCmd = static_cast<const CRotateNodeCommand*>(pkOther);
|
||||
const auto* pkCmd = static_cast<const CRotateNodeCommand*>(pkOther);
|
||||
|
||||
if (pkCmd->mCommandEnded)
|
||||
{
|
||||
@@ -68,7 +77,7 @@ bool CRotateNodeCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
|
||||
if ((mpEditor == pkCmd->mpEditor) && (mNodeList.size() == pkCmd->mNodeList.size()))
|
||||
{
|
||||
for (int iNode = 0; iNode < mNodeList.size(); iNode++)
|
||||
for (qsizetype iNode = 0; iNode < mNodeList.size(); iNode++)
|
||||
{
|
||||
mNodeList[iNode].NewPos = pkCmd->mNodeList[iNode].NewPos;
|
||||
mNodeList[iNode].NewRot = pkCmd->mNodeList[iNode].NewRot;
|
||||
|
||||
@@ -11,14 +11,8 @@ class INodeEditor;
|
||||
|
||||
class CRotateNodeCommand : public IUndoCommand
|
||||
{
|
||||
struct SNodeRotate
|
||||
{
|
||||
CNodePtr pNode;
|
||||
CVector3f InitialPos;
|
||||
CQuaternion InitialRot;
|
||||
CVector3f NewPos;
|
||||
CQuaternion NewRot;
|
||||
};
|
||||
struct SNodeRotate;
|
||||
|
||||
QList<SNodeRotate> mNodeList;
|
||||
INodeEditor *mpEditor = nullptr;
|
||||
bool mCommandEnded = false;
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
struct CScaleNodeCommand::SNodeScale
|
||||
{
|
||||
CNodePtr pNode;
|
||||
CVector3f InitialPos;
|
||||
CVector3f InitialScale;
|
||||
CVector3f NewPos;
|
||||
CVector3f NewScale;
|
||||
};
|
||||
|
||||
CScaleNodeCommand::CScaleNodeCommand()
|
||||
: IUndoCommand(QCoreApplication::translate("CScaleNodeCommand", "Scale"))
|
||||
{
|
||||
@@ -38,9 +47,7 @@ CScaleNodeCommand::CScaleNodeCommand(INodeEditor *pEditor, const QList<CSceneNod
|
||||
mpEditor->NotifySelectionTransformed();
|
||||
}
|
||||
|
||||
CScaleNodeCommand::~CScaleNodeCommand()
|
||||
{
|
||||
}
|
||||
CScaleNodeCommand::~CScaleNodeCommand() = default;
|
||||
|
||||
int CScaleNodeCommand::id() const
|
||||
{
|
||||
@@ -53,7 +60,7 @@ bool CScaleNodeCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
|
||||
if (pkOther->id() == (int) EUndoCommand::ScaleNodeCmd)
|
||||
{
|
||||
const CScaleNodeCommand *pkCmd = static_cast<const CScaleNodeCommand*>(pkOther);
|
||||
const auto* pkCmd = static_cast<const CScaleNodeCommand*>(pkOther);
|
||||
|
||||
if (pkCmd->mCommandEnded)
|
||||
{
|
||||
@@ -63,7 +70,7 @@ bool CScaleNodeCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
|
||||
if ((mpEditor == pkCmd->mpEditor) && (mNodeList.size() == pkCmd->mNodeList.size()))
|
||||
{
|
||||
for (int iNode = 0; iNode < mNodeList.size(); iNode++)
|
||||
for (qsizetype iNode = 0; iNode < mNodeList.size(); iNode++)
|
||||
{
|
||||
mNodeList[iNode].NewPos = pkCmd->mNodeList[iNode].NewPos;
|
||||
mNodeList[iNode].NewScale = pkCmd->mNodeList[iNode].NewScale;
|
||||
|
||||
@@ -11,14 +11,8 @@ class INodeEditor;
|
||||
|
||||
class CScaleNodeCommand : public IUndoCommand
|
||||
{
|
||||
struct SNodeScale
|
||||
{
|
||||
CNodePtr pNode;
|
||||
CVector3f InitialPos;
|
||||
CVector3f InitialScale;
|
||||
CVector3f NewPos;
|
||||
CVector3f NewScale;
|
||||
};
|
||||
struct SNodeScale;
|
||||
|
||||
QList<SNodeScale> mNodeList;
|
||||
INodeEditor *mpEditor = nullptr;
|
||||
bool mCommandEnded = false;
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
struct CTranslateNodeCommand::SNodeTranslate
|
||||
{
|
||||
CNodePtr pNode;
|
||||
CVector3f InitialPos;
|
||||
CVector3f NewPos;
|
||||
};
|
||||
|
||||
CTranslateNodeCommand::CTranslateNodeCommand()
|
||||
: IUndoCommand(QCoreApplication::translate("CTranslateNodeCommand", "Translate"))
|
||||
{
|
||||
@@ -30,6 +37,8 @@ CTranslateNodeCommand::CTranslateNodeCommand(INodeEditor *pEditor, const QList<C
|
||||
mpEditor->NotifySelectionTransformed();
|
||||
}
|
||||
|
||||
CTranslateNodeCommand::~CTranslateNodeCommand() = default;
|
||||
|
||||
int CTranslateNodeCommand::id() const
|
||||
{
|
||||
return (int) EUndoCommand::TranslateNodeCmd;
|
||||
@@ -37,11 +46,12 @@ int CTranslateNodeCommand::id() const
|
||||
|
||||
bool CTranslateNodeCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
{
|
||||
if (mCommandEnded) return false;
|
||||
if (mCommandEnded)
|
||||
return false;
|
||||
|
||||
if (pkOther->id() == (int) EUndoCommand::TranslateNodeCmd)
|
||||
{
|
||||
const CTranslateNodeCommand *pkCmd = static_cast<const CTranslateNodeCommand*>(pkOther);
|
||||
const auto* pkCmd = static_cast<const CTranslateNodeCommand*>(pkOther);
|
||||
|
||||
if (pkCmd->mCommandEnded)
|
||||
{
|
||||
@@ -51,7 +61,7 @@ bool CTranslateNodeCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
|
||||
if ((mpEditor == pkCmd->mpEditor) && (mNodeList.size() == pkCmd->mNodeList.size()))
|
||||
{
|
||||
for (int iNode = 0; iNode < mNodeList.size(); iNode++)
|
||||
for (qsizetype iNode = 0; iNode < mNodeList.size(); iNode++)
|
||||
mNodeList[iNode].NewPos = pkCmd->mNodeList[iNode].NewPos;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -11,12 +11,8 @@ class INodeEditor;
|
||||
|
||||
class CTranslateNodeCommand : public IUndoCommand
|
||||
{
|
||||
struct SNodeTranslate
|
||||
{
|
||||
CNodePtr pNode;
|
||||
CVector3f InitialPos;
|
||||
CVector3f NewPos;
|
||||
};
|
||||
struct SNodeTranslate;
|
||||
|
||||
QList<SNodeTranslate> mNodeList;
|
||||
INodeEditor *mpEditor = nullptr;
|
||||
bool mCommandEnded = false;
|
||||
@@ -24,6 +20,7 @@ class CTranslateNodeCommand : public IUndoCommand
|
||||
public:
|
||||
CTranslateNodeCommand();
|
||||
CTranslateNodeCommand(INodeEditor *pEditor, const QList<CSceneNode*>& rkNodes, const CVector3f& rkDelta, ETransformSpace TransformSpace);
|
||||
~CTranslateNodeCommand() override;
|
||||
|
||||
int id() const override;
|
||||
bool mergeWith(const QUndoCommand *pkOther) override;
|
||||
|
||||
@@ -97,31 +97,31 @@ int IEditPropertyCommand::id() const
|
||||
|
||||
bool IEditPropertyCommand::mergeWith(const QUndoCommand *pkOther)
|
||||
{
|
||||
if (!mCommandEnded)
|
||||
if (mCommandEnded)
|
||||
return false;
|
||||
|
||||
const auto* pkCmd = dynamic_cast<const IEditPropertyCommand*>(pkOther);
|
||||
|
||||
if (pkCmd && pkCmd->mpProperty == mpProperty)
|
||||
{
|
||||
const IEditPropertyCommand* pkCmd = dynamic_cast<const IEditPropertyCommand*>(pkOther);
|
||||
QList<void*> MyPointers;
|
||||
GetObjectDataPointers(MyPointers);
|
||||
|
||||
if (pkCmd && pkCmd->mpProperty == mpProperty)
|
||||
QList<void*> TheirPointers;
|
||||
pkCmd->GetObjectDataPointers(TheirPointers);
|
||||
|
||||
if (TheirPointers.size() == MyPointers.size())
|
||||
{
|
||||
QList<void*> MyPointers;
|
||||
GetObjectDataPointers(MyPointers);
|
||||
|
||||
QList<void*> TheirPointers;
|
||||
pkCmd->GetObjectDataPointers(TheirPointers);
|
||||
|
||||
if (TheirPointers.size() == MyPointers.size())
|
||||
for (qsizetype PtrIdx = 0; PtrIdx < MyPointers.size(); PtrIdx++)
|
||||
{
|
||||
for (int PtrIdx = 0; PtrIdx < MyPointers.size(); PtrIdx++)
|
||||
{
|
||||
if (MyPointers[PtrIdx] != TheirPointers[PtrIdx])
|
||||
return false;
|
||||
}
|
||||
|
||||
// Match
|
||||
mNewData = pkCmd->mNewData;
|
||||
mCommandEnded = pkCmd->mCommandEnded;
|
||||
return true;
|
||||
if (MyPointers[PtrIdx] != TheirPointers[PtrIdx])
|
||||
return false;
|
||||
}
|
||||
|
||||
// Match
|
||||
mNewData = pkCmd->mNewData;
|
||||
mCommandEnded = pkCmd->mCommandEnded;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user