processOrSkipNodeOnMatrix method

bool processOrSkipNodeOnMatrix(
  1. NodeOutput item,
  2. State state
)

Implementation

bool processOrSkipNodeOnMatrix(NodeOutput item, State state) {
  var mtx = state.mtx;
  var queue = state.queue;
  if (item.passedIncomes.length != 0) {
    state.y = centred
        ? this.getCenterYAmongIncomes(item, mtx)
        : this.getLowestYAmongIncomes(item, mtx);
  }
  bool hasLoops = this.hasLoops(item);
  List<LoopNode> loopNodes = [];
  if (hasLoops) {
    loopNodes = this.handleLoopEdges(item, state);
  }
  bool needsLoopSkip = hasLoops && loopNodes.length == 0;
  if (mtx.hasVerticalCollision(state.x, state.y) || needsLoopSkip) {
    queue.push(item);
    return false;
  }
  this.insertNodeOnMatrix(item, state, false);

  if (loopNodes.length != 0) {
    loopNodes
        .sort((a, b) => a.isSelfLoop ? -1 : 1); // process self-loop first
    insertLoopEdges(item, state, loopNodes);
  }
  return true;
}