| 525 | } |
| 526 | |
| 527 | bool RenderGraphUI::addLink( |
| 528 | const std::string& srcPass, |
| 529 | const std::string& dstPass, |
| 530 | const std::string& srcField, |
| 531 | const std::string& dstField, |
| 532 | uint32_t& color |
| 533 | ) |
| 534 | { |
| 535 | // outputs warning if edge could not be created |
| 536 | std::string srcString = srcPass + (srcField[0] == '#' ? "" : ".") + srcField; |
| 537 | std::string dstString = dstPass + (dstField[0] == '#' ? "" : ".") + dstField; |
| 538 | bool canCreateEdge = (mpRenderGraph->getEdge(srcString, dstString) == ((uint32_t)-1)); |
| 539 | if (!canCreateEdge) |
| 540 | return canCreateEdge; |
| 541 | |
| 542 | // update the ui to reflect the connections. This data is used for removal |
| 543 | RenderPassUI& srcRenderPassUI = mRenderPassUI[srcPass]; |
| 544 | RenderPassUI& dstRenderPassUI = mRenderPassUI[dstPass]; |
| 545 | const auto outputIt = srcRenderPassUI.mNameToIndexOutput.find(srcField); |
| 546 | const auto inputIt = dstRenderPassUI.mNameToIndexInput.find(dstField); |
| 547 | // if one filed is empty, check that the other is as well |
| 548 | if ((dstField[0] == '#') || (srcField[0] == '#')) |
| 549 | canCreateEdge &= (srcField[0] == '#') && (dstField[0] == '#'); |
| 550 | // check that link could exist |
| 551 | canCreateEdge &= (outputIt != srcRenderPassUI.mNameToIndexOutput.end()) && (inputIt != dstRenderPassUI.mNameToIndexInput.end()); |
| 552 | // check that the input is not already connected |
| 553 | canCreateEdge &= (mInputPinStringToLinkID.find(dstString) == mInputPinStringToLinkID.end()); |
| 554 | |
| 555 | if (canCreateEdge) |
| 556 | { |
| 557 | uint32_t srcPinIndex = outputIt->second; |
| 558 | uint32_t dstPinIndex = inputIt->second; |
| 559 | srcRenderPassUI.mOutputPins[srcPinIndex].mConnectedPinName = dstField; |
| 560 | srcRenderPassUI.mOutputPins[srcPinIndex].mConnectedNodeName = dstPass; |
| 561 | dstRenderPassUI.mInputPins[dstPinIndex].mConnectedPinName = srcField; |
| 562 | dstRenderPassUI.mInputPins[dstPinIndex].mConnectedNodeName = srcPass; |
| 563 | |
| 564 | if (!(dstField[0] == '#')) |
| 565 | { |
| 566 | color = kEdgesColor; |
| 567 | |
| 568 | // TODO: Auto-resolve is not fully working and will be removed (see #1275). |
| 569 | // RenderPassReflection srcReflection = mpRenderGraph->mNodeData[mpRenderGraph->getPassIndex(srcPass)].pPass->reflect({}); |
| 570 | // RenderPassReflection dstReflection = mpRenderGraph->mNodeData[mpRenderGraph->getPassIndex(dstPass)].pPass->reflect({}); |
| 571 | // |
| 572 | // bool canAutoResolve = mpRenderGraph->canAutoResolve(srcReflection.getField(srcField), dstReflection.getField(dstField)); |
| 573 | // if (canAutoResolve && mDisplayAutoResolvePopup) canCreateEdge = autoResolveWarning(srcString, dstString); |
| 574 | // color = canAutoResolve ? kAutoResolveEdgesColor : kEdgesColor; |
| 575 | } |
| 576 | |
| 577 | if (canCreateEdge) |
| 578 | { |
| 579 | mShouldUpdate = true; |
| 580 | |
| 581 | if (dstField[0] == '#') |
| 582 | { |
| 583 | // rebuilds data to avoid repeated code |
| 584 | mRebuildDisplayData = true; |