From 9d782f5a4cf769f84722a62f1b5979b668be064e Mon Sep 17 00:00:00 2001 From: parax0 Date: Mon, 21 Mar 2016 16:01:14 -0600 Subject: [PATCH] Fixed rotation arrow rendering bug, fixed waypoint path bounding boxes not updating when the waypoints are transformed, fixed clone selection and paste nodes commands not properly notifying linked instances of their links being modified --- src/Core/Scene/CScriptNode.cpp | 3 +++ src/Core/ScriptExtra/CWaypointExtra.cpp | 11 ++++++++++ src/Core/ScriptExtra/CWaypointExtra.h | 1 + src/Editor/Undo/CCloneSelectionCommand.cpp | 24 ++++++++++++++-------- src/Editor/Undo/CCloneSelectionCommand.h | 1 + src/Editor/Undo/CPasteNodesCommand.cpp | 7 +++++++ src/Editor/Undo/CPasteNodesCommand.h | 1 + 7 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/Core/Scene/CScriptNode.cpp b/src/Core/Scene/CScriptNode.cpp index 345c1d65..54638319 100644 --- a/src/Core/Scene/CScriptNode.cpp +++ b/src/Core/Scene/CScriptNode.cpp @@ -247,6 +247,9 @@ void CScriptNode::DrawSelection() CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f(); CGraphics::UpdateMVPBlock(); + CGraphics::sPixelBlock.TintColor = CColor::skWhite; + CGraphics::UpdatePixelBlock(); + DrawRotationArrow(); } diff --git a/src/Core/ScriptExtra/CWaypointExtra.cpp b/src/Core/ScriptExtra/CWaypointExtra.cpp index b7ff464a..2e29a9c3 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.cpp +++ b/src/Core/ScriptExtra/CWaypointExtra.cpp @@ -138,6 +138,17 @@ void CWaypointExtra::GetLinkedWaypoints(std::list& rOut) } } +void CWaypointExtra::OnTransformed() +{ + for (u32 iLink = 0; iLink < mLinks.size(); iLink++) + { + SWaypointLink& rLink = mLinks[iLink]; + rLink.LineAABB = CAABox::skInfinite; + rLink.LineAABB.ExpandBounds(AbsolutePosition()); + rLink.LineAABB.ExpandBounds(rLink.pWaypoint->AbsolutePosition()); + } +} + void CWaypointExtra::LinksModified() { BuildLinks(); diff --git a/src/Core/ScriptExtra/CWaypointExtra.h b/src/Core/ScriptExtra/CWaypointExtra.h index 4cbaecee..0b2c2e92 100644 --- a/src/Core/ScriptExtra/CWaypointExtra.h +++ b/src/Core/ScriptExtra/CWaypointExtra.h @@ -29,6 +29,7 @@ public: bool IsPathLink(CLink *pLink); void GetLinkedWaypoints(std::list& rOut); + void OnTransformed(); void LinksModified(); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); diff --git a/src/Editor/Undo/CCloneSelectionCommand.cpp b/src/Editor/Undo/CCloneSelectionCommand.cpp index bae0a1b1..ea064868 100644 --- a/src/Editor/Undo/CCloneSelectionCommand.cpp +++ b/src/Editor/Undo/CCloneSelectionCommand.cpp @@ -10,7 +10,21 @@ CCloneSelectionCommand::CCloneSelectionCommand(INodeEditor *pEditor) for (CSelectionIterator It(mpEditor->Selection()); It; ++It) { if (It->NodeType() == eScriptNode) + { mNodesToClone << *It; + + // Fetch linked objects + CScriptNode *pScript = static_cast(*It); + CScriptObject *pInst = pScript->Object(); + + for (u32 iLink = 0; iLink < pInst->NumLinks(eOutgoing); iLink++) + { + CScriptNode *pNode = mpEditor->Scene()->NodeForObject(pInst->Link(eOutgoing, iLink)->Receiver()); + + if (!pNode->IsSelected()) + mLinkedInstances << pNode->Object(); + } + } } } @@ -30,6 +44,7 @@ void CCloneSelectionCommand::undo() } mClonedNodes.clear(); + mpEditor->OnLinksModified(mLinkedInstances.DereferenceList()); mpEditor->Selection()->SetSelectedNodes(mOriginalSelection.DereferenceList()); } @@ -65,8 +80,6 @@ void CCloneSelectionCommand::redo() } // Clone outgoing links from source object; incoming ones are discarded - QList LinkedInstances; - for (int iNode = 0; iNode < ClonedNodes.size(); iNode++) { CScriptObject *pSrc = static_cast(ToClone[iNode])->Object(); @@ -84,11 +97,6 @@ void CCloneSelectionCommand::redo() CLink *pCloneLink = new CLink(pSrcLink->Area(), pSrcLink->State(), pSrcLink->Message(), pClone->InstanceID(), ReceiverID); pCloneLink->Sender()->AddLink(eOutgoing, pCloneLink); pCloneLink->Receiver()->AddLink(eIncoming, pCloneLink); - - if (!LinkedInstances.contains(pCloneLink->Sender())) - LinkedInstances << pCloneLink->Sender(); - if (!LinkedInstances.contains(pCloneLink->Receiver())) - LinkedInstances << pCloneLink->Receiver(); } } @@ -96,6 +104,6 @@ void CCloneSelectionCommand::redo() foreach (CSceneNode *pNode, ClonedNodes) pNode->OnLoadFinished(); - mpEditor->OnLinksModified(LinkedInstances); + mpEditor->OnLinksModified(mLinkedInstances.DereferenceList()); mpEditor->Selection()->SetSelectedNodes(mClonedNodes.DereferenceList()); } diff --git a/src/Editor/Undo/CCloneSelectionCommand.h b/src/Editor/Undo/CCloneSelectionCommand.h index 8bb12891..dc2aa2b9 100644 --- a/src/Editor/Undo/CCloneSelectionCommand.h +++ b/src/Editor/Undo/CCloneSelectionCommand.h @@ -11,6 +11,7 @@ class CCloneSelectionCommand : public IUndoCommand CNodePtrList mOriginalSelection; CNodePtrList mNodesToClone; CNodePtrList mClonedNodes; + CInstancePtrList mLinkedInstances; public: CCloneSelectionCommand(INodeEditor *pEditor); diff --git a/src/Editor/Undo/CPasteNodesCommand.cpp b/src/Editor/Undo/CPasteNodesCommand.cpp index bcf3f73c..e735285a 100644 --- a/src/Editor/Undo/CPasteNodesCommand.cpp +++ b/src/Editor/Undo/CPasteNodesCommand.cpp @@ -34,6 +34,8 @@ void CPasteNodesCommand::undo() mpEditor->NotifyNodeDeleted(); } + mpEditor->OnLinksModified(mLinkedInstances.DereferenceList()); + mLinkedInstances.clear(); mPastedNodes.clear(); } @@ -112,6 +114,9 @@ void CPasteNodesCommand::redo() delete pLink; iLink--; } + + else + mLinkedInstances << pLink->Receiver(); } } } @@ -123,5 +128,7 @@ void CPasteNodesCommand::redo() pNode->OnLoadFinished(); mpEditor->Selection()->SetSelectedNodes(PastedNodes); + + mpEditor->OnLinksModified(mLinkedInstances.DereferenceList()); mPastedNodes = PastedNodes; } diff --git a/src/Editor/Undo/CPasteNodesCommand.h b/src/Editor/Undo/CPasteNodesCommand.h index 027066e1..3cdc0afb 100644 --- a/src/Editor/Undo/CPasteNodesCommand.h +++ b/src/Editor/Undo/CPasteNodesCommand.h @@ -15,6 +15,7 @@ class CPasteNodesCommand : public IUndoCommand CNodeCopyMimeData *mpMimeData; CNodePtrList mPastedNodes; CNodePtrList mOriginalSelection; + CInstancePtrList mLinkedInstances; public: CPasteNodesCommand(CWorldEditor *pEditor, CScriptLayer *pLayer, CVector3f PastePoint);