void SocketProxyNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { OutputSocket *outputsocket = this->getOutputSocket(0); InputSocket *inputsocket = this->getInputSocket(0); if (outputsocket->isConnected()) { if (inputsocket->isConnected()) { SocketProxyOperation *operation = new SocketProxyOperation(this->getOutputSocket()->getDataType()); inputsocket->relinkConnections(operation->getInputSocket(0)); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); } else { /* If input is not connected, add a constant value operation instead */ switch (outputsocket->getDataType()) { case COM_DT_VALUE: { SetValueOperation *operation = new SetValueOperation(); bNodeSocketValueFloat *dval = (bNodeSocketValueFloat *)inputsocket->getbNodeSocket()->default_value; operation->setValue(dval->value); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); break; } case COM_DT_COLOR: { SetColorOperation *operation = new SetColorOperation(); bNodeSocketValueRGBA *dval = (bNodeSocketValueRGBA *)inputsocket->getbNodeSocket()->default_value; operation->setChannels(dval->value); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); break; } case COM_DT_VECTOR: { SetVectorOperation *operation = new SetVectorOperation(); bNodeSocketValueVector *dval = (bNodeSocketValueVector *)inputsocket->getbNodeSocket()->default_value; operation->setVector(dval->value); outputsocket->relinkConnections(operation->getOutputSocket(0)); graph->addOperation(operation); break; } } } } }
void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input, NodeInput *node_input) { switch (input->getDataType()) { case COM_DT_VALUE: { float value; if (node_input && node_input->getbNodeSocket()) value = node_input->getEditorValueFloat(); else value = 0.0f; SetValueOperation *op = new SetValueOperation(); op->setValue(value); addOperation(op); addLink(op->getOutputSocket(), input); break; } case COM_DT_COLOR: { float value[4]; if (node_input && node_input->getbNodeSocket()) node_input->getEditorValueColor(value); else zero_v4(value); SetColorOperation *op = new SetColorOperation(); op->setChannels(value); addOperation(op); addLink(op->getOutputSocket(), input); break; } case COM_DT_VECTOR: { float value[3]; if (node_input && node_input->getbNodeSocket()) node_input->getEditorValueVector(value); else zero_v3(value); SetVectorOperation *op = new SetVectorOperation(); op->setVector(value); addOperation(op); addLink(op->getOutputSocket(), input); break; } } }