use of org.terasology.engine.rendering.dag.dependencyConnections.FboConnection in project Terasology by MovingBlocks.
the class RenderGraph method reconnectAllConnectedInputsTo.
/**
* Insert node's connection after a specific node's connection and reconnect the other previously connected nodes's connections
* to the new one. Simple approach, maintain structure 1 to N. For M to N output do manually.
*/
public void reconnectAllConnectedInputsTo(DependencyConnection connectionToReplace, DependencyConnection newOutputConnection) {
Node fromNode = findNode(connectionToReplace.getParentNode());
ConnectionType connectionType;
if (newOutputConnection instanceof FboConnection) {
connectionType = ConnectionType.FBO;
} else if (newOutputConnection instanceof BufferPairConnection) {
connectionType = ConnectionType.BUFFER_PAIR;
} else {
logger.error("Unknown connection type: " + newOutputConnection + " .\n");
throw new RuntimeException("Unknown connection type: " + newOutputConnection + " .\n");
}
if (!connectionToReplace.getConnectedConnections().isEmpty()) {
// Hard to deal with concurency problems, iterate copy, edit original
final Map<String, DependencyConnection> connectedConnections = connectionToReplace.getConnectedConnections();
final Map<String, DependencyConnection> connectedConnectionsCopy = Maps.newHashMap(connectionToReplace.getConnectedConnections());
for (DependencyConnection connectedConnectionCopy : connectedConnectionsCopy.values()) {
DependencyConnection toConnection = connectedConnections.get(connectedConnectionCopy.getName());
if (!toConnection.getParentNode().equals(fromNode.getUri())) {
// TODO potteintionally harmful ID guesswork
reconnectInputToOutput(findNode(toConnection.getParentNode()), DependencyConnection.getIdFromConnectionName(toConnection.getName()), newOutputConnection, connectionType, true);
// Node toNode = findNode(toConnection.getParentNode());
// if (!areConnected(fromNode, toNode)) {
// connect(fromNode, toNode);
// }
}
}
}
}
use of org.terasology.engine.rendering.dag.dependencyConnections.FboConnection in project Terasology by MovingBlocks.
the class AbstractNode method addOutputFboConnection.
/**
* TODO do something if could not insert
* @param id
* @param fboData
* @return true if inserted, false otherwise
*/
protected boolean addOutputFboConnection(int id, FBO fboData) {
boolean success = false;
String connectionUri = FboConnection.getConnectionName(id, this.nodeUri);
if (outputConnections.containsKey(connectionUri)) {
FboConnection fboConnection = (FboConnection) outputConnections.get(connectionUri);
if (fboConnection.getData() != null) {
logger.warn("Adding output fbo data to slot id " + id + " of " + this.nodeUri + "node overwrites data of existing connection: " + fboConnection.toString());
}
fboConnection.setData(fboData);
// set data for all connected connections
if (!fboConnection.getConnectedConnections().isEmpty()) {
logger.info("Propagating fbo data to all connected connections of " + fboConnection + ": ");
fboConnection.getConnectedConnections().forEach((k, v) -> {
logger.info("setting data for: " + v.toString() + " ,");
v.setData(fboData);
});
logger.info("data propagated.\n");
}
success = true;
} else {
DependencyConnection fboConnection = new FboConnection(FboConnection.getConnectionName(id, this.nodeUri), DependencyConnection.Type.OUTPUT, fboData, this.getUri());
success = addOutputConnection(fboConnection);
}
return success;
}
use of org.terasology.engine.rendering.dag.dependencyConnections.FboConnection in project Terasology by MovingBlocks.
the class AbstractNode method addInputFboConnection.
/**
* @param id
* @param from
* @return true if inserted, false otherwise
*/
protected boolean addInputFboConnection(int id, FboConnection from) {
DependencyConnection fboConnection = new FboConnection(FboConnection.getConnectionName(id, this.nodeUri), DependencyConnection.Type.INPUT, from.getData(), this.getUri());
// must remember where I'm connected from
fboConnection.setConnectedConnection(from);
return addInputConnection(fboConnection);
}
Aggregations