Search in sources :

Example 6 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method getInputConnection.

@Nullable
public DependencyConnection getInputConnection(String name) {
    DependencyConnection connection = inputConnections.get(name);
    if (connection == null) {
        String errorMessage = String.format("Getting input connection named %s returned null." + " No such input connection in %s", name, this.toString());
        logger.error(errorMessage);
    // throw new NullPointerException(errorMessage);
    }
    return connection;
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection) Nullable(javax.annotation.Nullable)

Example 7 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class AbstractNode method isDependentOn.

/**
 * Is {@code thisNode} dependent on {@param anotherNode}?
 * @param anotherNode
 * @return If this node has at least one {@param anotherNode}'s connection on input - true. Otherwise false.
 */
public boolean isDependentOn(Node anotherNode) {
    boolean isDependent = false;
    // for all my input connections
    for (DependencyConnection connection : inputConnections.values()) {
        if (!connection.getConnectedConnections().isEmpty()) {
            Map<String, DependencyConnection> connectedConnections = connection.getConnectedConnections();
            SimpleUri anotherNodeUri = anotherNode.getUri();
            // for all connection's connected connections get parent node and see if it matches anotherNode
            for (DependencyConnection connectedConnection : connectedConnections.values()) {
                if (connectedConnection.getParentNode().equals(anotherNodeUri)) {
                    isDependent = true;
                }
            }
        }
    }
    return isDependent;
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection) SimpleUri(org.terasology.engine.core.SimpleUri)

Example 8 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class RenderGraph method reconnectFbo.

public void reconnectFbo(Node fromNode, int outputId, Node toNode, int inputId) {
    // for each output connection connected to input get it's connected inputs, find us and remove ourselves from its list
    DependencyConnection connectionToReconnect = toNode.getInputFboConnection(inputId);
    // for each output connected to toNode's input fbo connection(inputId) (should be just one)
    if (connectionToReconnect != null) {
        connectionToReconnect.getConnectedConnections().forEach((conUri, outputConnection) -> {
            ((DependencyConnection) outputConnection).getConnectedConnections().remove(connectionToReconnect.getName());
        });
        // connectionToReconnect gets removed and then created again
        toNode.removeFboConnection(inputId, DependencyConnection.Type.INPUT);
    }
    connectFbo(fromNode, outputId, toNode, inputId);
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection)

Example 9 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class RenderGraph method connectBufferPair.

/**
 * @param inputConnectionId Input BufferPairConnection id is a number of the input connection on this node.
 *                   Chosen arbitrarily, integers starting by 1 typically.
 * @param fromConnection BufferPairConnection obtained form another node's output.
 */
// TODO merge with connectFbo()
private void connectBufferPair(Node toNode, int inputConnectionId, DependencyConnection fromConnection) {
    // Is not yet connected?
    if (!fromConnection.getConnectedConnections().isEmpty()) {
        logger.info("Warning, " + fromConnection + "connection is already read somewhere else.");
    }
    // TODO These checks might be redundant
    if (toNode.addInputConnection(inputConnectionId, fromConnection)) {
        DependencyConnection localConnection = toNode.getInputBufferPairConnection(inputConnectionId);
        // Upon successful insertion - save connected connection. If node is already connected, throw an exception.
        localConnection.connectInputToOutput(fromConnection);
    } else {
        // if adding new input failed, it already existed - check for connections
        // TODO update
        logger.info(toNode.getUri() + ".connectFbo(" + inputConnectionId + ", " + fromConnection.getName() + "):" + " Connection already existed. Testing for its connections..");
        DependencyConnection localConnection = toNode.getInputBufferPairConnection(inputConnectionId);
        // if our input is connected
        if (!localConnection.getConnectedConnections().isEmpty()) {
            if (!localConnection.getConnectedConnections().containsKey(fromConnection)) {
                localConnection.connectInputToOutput(fromConnection);
            } else {
                throw new RuntimeException(" Could not connect node " + toNode + ", inputConnection with id " + inputConnectionId + " already connected to " + localConnection.getConnectedConnections());
            }
        }
    }
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection)

Example 10 with DependencyConnection

use of org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection in project Terasology by MovingBlocks.

the class RenderGraph method connectFbo.

/**
 * @param inputFboId Input FBO id is a number of the input connection on this node.
 *                   Chosen arbitrarily, integers starting by 1 typically.
 * @param fromConnection FboConnection obtained form another node's output.
 */
// TODO simpleuri
private void connectFbo(Node toNode, int inputFboId, DependencyConnection fromConnection) {
    // Is not yet connected?
    if (!fromConnection.getConnectedConnections().isEmpty()) {
        logger.warn("Warning, " + fromConnection + "connection is already read somewhere else.");
    }
    // TODO These checks might be redundant
    if (toNode.addInputConnection(inputFboId, fromConnection)) {
        DependencyConnection localConnection = toNode.getInputFboConnection(inputFboId);
        // Upon successful insertion - save connected connection. If node is already connected, throw an exception.
        localConnection.connectInputToOutput(fromConnection);
    } else {
        // if adding new input failed, it already existed - check for connections
        // TODO update
        logger.info(toNode.getUri() + ".connectFbo(" + inputFboId + ", " + fromConnection.getName() + "):" + " Connection already existed. Testing for its connections..");
        DependencyConnection localConnection = toNode.getInputFboConnection(inputFboId);
        // if our input is connected
        if (!localConnection.getConnectedConnections().isEmpty()) {
            localConnection.connectInputToOutput(fromConnection);
        } else {
            throw new RuntimeException(" Could not connect node " + toNode + ", inputConnection with id " + inputFboId + " already connected to " + localConnection.getConnectedConnections());
        }
    }
}
Also used : DependencyConnection(org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection)

Aggregations

DependencyConnection (org.terasology.engine.rendering.dag.dependencyConnections.DependencyConnection)18 BufferPairConnection (org.terasology.engine.rendering.dag.dependencyConnections.BufferPairConnection)4 FboConnection (org.terasology.engine.rendering.dag.dependencyConnections.FboConnection)3 Nullable (javax.annotation.Nullable)2 SimpleUri (org.terasology.engine.core.SimpleUri)1 RunOrderConnection (org.terasology.engine.rendering.dag.dependencyConnections.RunOrderConnection)1