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

This commit is contained in:
parax0 2016-03-21 16:01:14 -06:00
parent 0faa4c3630
commit 9d782f5a4c
7 changed files with 40 additions and 8 deletions

View File

@ -247,6 +247,9 @@ void CScriptNode::DrawSelection()
CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f(); CGraphics::sMVPBlock.ModelMatrix = Transform.ToMatrix4f();
CGraphics::UpdateMVPBlock(); CGraphics::UpdateMVPBlock();
CGraphics::sPixelBlock.TintColor = CColor::skWhite;
CGraphics::UpdatePixelBlock();
DrawRotationArrow(); DrawRotationArrow();
} }

View File

@ -138,6 +138,17 @@ void CWaypointExtra::GetLinkedWaypoints(std::list<CWaypointExtra*>& 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() void CWaypointExtra::LinksModified()
{ {
BuildLinks(); BuildLinks();

View File

@ -29,6 +29,7 @@ public:
bool IsPathLink(CLink *pLink); bool IsPathLink(CLink *pLink);
void GetLinkedWaypoints(std::list<CWaypointExtra*>& rOut); void GetLinkedWaypoints(std::list<CWaypointExtra*>& rOut);
void OnTransformed();
void LinksModified(); void LinksModified();
void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo); void AddToRenderer(CRenderer *pRenderer, const SViewInfo& ViewInfo);
void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo); void Draw(FRenderOptions Options, int ComponentIndex, const SViewInfo& ViewInfo);

View File

@ -10,7 +10,21 @@ CCloneSelectionCommand::CCloneSelectionCommand(INodeEditor *pEditor)
for (CSelectionIterator It(mpEditor->Selection()); It; ++It) for (CSelectionIterator It(mpEditor->Selection()); It; ++It)
{ {
if (It->NodeType() == eScriptNode) if (It->NodeType() == eScriptNode)
{
mNodesToClone << *It; mNodesToClone << *It;
// Fetch linked objects
CScriptNode *pScript = static_cast<CScriptNode*>(*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(); mClonedNodes.clear();
mpEditor->OnLinksModified(mLinkedInstances.DereferenceList());
mpEditor->Selection()->SetSelectedNodes(mOriginalSelection.DereferenceList()); mpEditor->Selection()->SetSelectedNodes(mOriginalSelection.DereferenceList());
} }
@ -65,8 +80,6 @@ void CCloneSelectionCommand::redo()
} }
// Clone outgoing links from source object; incoming ones are discarded // Clone outgoing links from source object; incoming ones are discarded
QList<CScriptObject*> LinkedInstances;
for (int iNode = 0; iNode < ClonedNodes.size(); iNode++) for (int iNode = 0; iNode < ClonedNodes.size(); iNode++)
{ {
CScriptObject *pSrc = static_cast<CScriptNode*>(ToClone[iNode])->Object(); CScriptObject *pSrc = static_cast<CScriptNode*>(ToClone[iNode])->Object();
@ -84,11 +97,6 @@ void CCloneSelectionCommand::redo()
CLink *pCloneLink = new CLink(pSrcLink->Area(), pSrcLink->State(), pSrcLink->Message(), pClone->InstanceID(), ReceiverID); CLink *pCloneLink = new CLink(pSrcLink->Area(), pSrcLink->State(), pSrcLink->Message(), pClone->InstanceID(), ReceiverID);
pCloneLink->Sender()->AddLink(eOutgoing, pCloneLink); pCloneLink->Sender()->AddLink(eOutgoing, pCloneLink);
pCloneLink->Receiver()->AddLink(eIncoming, 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) foreach (CSceneNode *pNode, ClonedNodes)
pNode->OnLoadFinished(); pNode->OnLoadFinished();
mpEditor->OnLinksModified(LinkedInstances); mpEditor->OnLinksModified(mLinkedInstances.DereferenceList());
mpEditor->Selection()->SetSelectedNodes(mClonedNodes.DereferenceList()); mpEditor->Selection()->SetSelectedNodes(mClonedNodes.DereferenceList());
} }

View File

@ -11,6 +11,7 @@ class CCloneSelectionCommand : public IUndoCommand
CNodePtrList mOriginalSelection; CNodePtrList mOriginalSelection;
CNodePtrList mNodesToClone; CNodePtrList mNodesToClone;
CNodePtrList mClonedNodes; CNodePtrList mClonedNodes;
CInstancePtrList mLinkedInstances;
public: public:
CCloneSelectionCommand(INodeEditor *pEditor); CCloneSelectionCommand(INodeEditor *pEditor);

View File

@ -34,6 +34,8 @@ void CPasteNodesCommand::undo()
mpEditor->NotifyNodeDeleted(); mpEditor->NotifyNodeDeleted();
} }
mpEditor->OnLinksModified(mLinkedInstances.DereferenceList());
mLinkedInstances.clear();
mPastedNodes.clear(); mPastedNodes.clear();
} }
@ -112,6 +114,9 @@ void CPasteNodesCommand::redo()
delete pLink; delete pLink;
iLink--; iLink--;
} }
else
mLinkedInstances << pLink->Receiver();
} }
} }
} }
@ -123,5 +128,7 @@ void CPasteNodesCommand::redo()
pNode->OnLoadFinished(); pNode->OnLoadFinished();
mpEditor->Selection()->SetSelectedNodes(PastedNodes); mpEditor->Selection()->SetSelectedNodes(PastedNodes);
mpEditor->OnLinksModified(mLinkedInstances.DereferenceList());
mPastedNodes = PastedNodes; mPastedNodes = PastedNodes;
} }

View File

@ -15,6 +15,7 @@ class CPasteNodesCommand : public IUndoCommand
CNodeCopyMimeData *mpMimeData; CNodeCopyMimeData *mpMimeData;
CNodePtrList mPastedNodes; CNodePtrList mPastedNodes;
CNodePtrList mOriginalSelection; CNodePtrList mOriginalSelection;
CInstancePtrList mLinkedInstances;
public: public:
CPasteNodesCommand(CWorldEditor *pEditor, CScriptLayer *pLayer, CVector3f PastePoint); CPasteNodesCommand(CWorldEditor *pEditor, CScriptLayer *pLayer, CVector3f PastePoint);