MCPcopy Create free account
hub / github.com/MrKepzie/Natron / computeHashInternal

Method computeHashInternal

Engine/Node.cpp:1506–1602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1504}
1505
1506bool
1507Node::computeHashInternal()
1508{
1509 if (!_imp->effect) {
1510 return false;
1511 }
1512 ///Always called in the main thread
1513 assert( QThread::currentThread() == qApp->thread() );
1514 if (!_imp->inputsInitialized) {
1515 qDebug() << "Node::computeHash(): inputs not initialized";
1516 }
1517
1518 U64 oldHash, newHash;
1519 {
1520 QWriteLocker l(&_imp->knobsAgeMutex);
1521
1522 oldHash = _imp->hash.value();
1523
1524 ///reset the hash value
1525 _imp->hash.reset();
1526
1527 ///append the effect's own age
1528 _imp->hash.append(_imp->knobsAge);
1529
1530 ///append all inputs hash
1531 boost::shared_ptr<RotoDrawableItem> attachedStroke = _imp->paintStroke.lock();
1532 NodePtr attachedStrokeContextNode;
1533 if (attachedStroke) {
1534 attachedStrokeContextNode = attachedStroke->getContext()->getNode();
1535 }
1536 {
1537 ViewerInstance* isViewer = dynamic_cast<ViewerInstance*>( _imp->effect.get() );
1538
1539 if (isViewer) {
1540 int activeInput[2];
1541 isViewer->getActiveInputs(activeInput[0], activeInput[1]);
1542
1543 for (int i = 0; i < 2; ++i) {
1544 NodePtr input = getInput(activeInput[i]);
1545 if (input) {
1546 _imp->hash.append( input->getHashValue() );
1547 }
1548 }
1549 } else {
1550 for (U32 i = 0; i < _imp->inputs.size(); ++i) {
1551 NodePtr input = getInput(i);
1552 if (input) {
1553 //Since the rotopaint node is connected to the internal nodes of the tree, don't change their hash
1554 if ( attachedStroke && (input == attachedStrokeContextNode) ) {
1555 continue;
1556 }
1557 ///Add the index of the input to its hash.
1558 ///Explanation: if we didn't add this, just switching inputs would produce a similar
1559 ///hash.
1560 _imp->hash.append(input->getHashValue() + i);
1561 }
1562 }
1563 }

Callers

nothing calls this directly

Calls 15

Hash64_appendQStringFunction · 0.85
getAppFunction · 0.85
appendMethod · 0.80
getHashValueMethod · 0.80
getProjectMethod · 0.80
onNodeHashChangedMethod · 0.80
isProjectClosingMethod · 0.80
valueMethod · 0.45
resetMethod · 0.45
lockMethod · 0.45
getNodeMethod · 0.45

Tested by

no test coverage detected