mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-24 00:53:47 +00:00
bug fix
deleteSelection when an output node had multiple connections only the first one was deleted, needed a new function to return a vector of connections that are now looped and deleted at the end of delete selection. few other minor additions and fixes.
This commit is contained in:
parent
dbbd9383e7
commit
d9c4269d8b
8 changed files with 137 additions and 32 deletions
|
|
@ -23,6 +23,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "gui/shaderEditor/guiShaderEditor.h"
|
||||
#include "gui/shaderEditor/nodes/materialOutputNode.h"
|
||||
#include "gui/shaderEditor/nodes/mathNode.h"
|
||||
|
||||
#include "core/frameAllocator.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
|
|
@ -62,7 +63,8 @@ GuiShaderEditor::GuiShaderEditor()
|
|||
mTempConnection = NULL;
|
||||
mNodeSize = 10;
|
||||
// test
|
||||
addNode(new MaterialOutputNode());
|
||||
addNode(new BRDFOutputNode());
|
||||
addNode(new MathAddNode());
|
||||
addNode(new GuiShaderNode());
|
||||
}
|
||||
|
||||
|
|
@ -648,31 +650,23 @@ void GuiShaderEditor::deleteSelection()
|
|||
{
|
||||
mTrash->addObject(node);
|
||||
|
||||
Vector<NodeConnection*> connVec;
|
||||
for (NodeInput* input : node->mInputNodes)
|
||||
{
|
||||
NodeConnection* conn;
|
||||
if (hasConnection(input, conn))
|
||||
{
|
||||
// selecting one node, push it to the front of the mcurrnodes stack so its rendered on top.
|
||||
Vector< NodeConnection* >::iterator i = T3D::find(mCurrConnections.begin(), mCurrConnections.end(), conn);
|
||||
if (i != mCurrConnections.end())
|
||||
{
|
||||
mCurrConnections.erase(i);
|
||||
}
|
||||
}
|
||||
hasConnection(input, connVec);
|
||||
}
|
||||
|
||||
for (NodeOutput* output : node->mOutputNodes)
|
||||
{
|
||||
NodeConnection* conn;
|
||||
if (hasConnection(output, conn))
|
||||
hasConnection(output, connVec);
|
||||
}
|
||||
|
||||
for (NodeConnection* conn : connVec)
|
||||
{
|
||||
Vector< NodeConnection* >::iterator i = T3D::find(mCurrConnections.begin(), mCurrConnections.end(), conn);
|
||||
if (i != mCurrConnections.end())
|
||||
{
|
||||
// selecting one node, push it to the front of the mcurrnodes stack so its rendered on top.
|
||||
Vector< NodeConnection* >::iterator i = T3D::find(mCurrConnections.begin(), mCurrConnections.end(), conn);
|
||||
if (i != mCurrConnections.end())
|
||||
{
|
||||
mCurrConnections.erase(i);
|
||||
}
|
||||
mCurrConnections.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -857,7 +851,6 @@ U32 GuiShaderEditor::finishConnection(const Point2I& pt)
|
|||
NodeConnection* conn;
|
||||
if(hasConnection(inNode, conn))
|
||||
{
|
||||
// selecting one node, push it to the front of the mcurrnodes stack so its rendered on top.
|
||||
Vector< NodeConnection* >::iterator i = T3D::find(mCurrConnections.begin(), mCurrConnections.end(), conn);
|
||||
if (i != mCurrConnections.end())
|
||||
{
|
||||
|
|
@ -886,7 +879,6 @@ U32 GuiShaderEditor::finishConnection(const Point2I& pt)
|
|||
NodeConnection* conn;
|
||||
if (hasConnection(mTempConnection->inSocket, conn))
|
||||
{
|
||||
// selecting one node, push it to the front of the mcurrnodes stack so its rendered on top.
|
||||
Vector< NodeConnection* >::iterator i = T3D::find(mCurrConnections.begin(), mCurrConnections.end(), conn);
|
||||
if (i != mCurrConnections.end())
|
||||
{
|
||||
|
|
@ -916,6 +908,22 @@ bool GuiShaderEditor::hasConnection(NodeSocket* inSocket)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool GuiShaderEditor::hasConnection(NodeSocket* inSocket, Vector<NodeConnection*>& conn)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
for (NodeConnection* con : mCurrConnections)
|
||||
{
|
||||
if (con->inSocket == dynamic_cast<NodeInput*>(inSocket) || con->outSocket == dynamic_cast<NodeOutput*>(inSocket))
|
||||
{
|
||||
conn.push_back(con);
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GuiShaderEditor::hasConnection(NodeSocket* inSocket, NodeConnection*& conn)
|
||||
{
|
||||
for (NodeConnection* con : mCurrConnections)
|
||||
|
|
@ -924,11 +932,9 @@ bool GuiShaderEditor::hasConnection(NodeSocket* inSocket, NodeConnection*& conn)
|
|||
{
|
||||
if (conn != nullptr)
|
||||
conn = con;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue