Esempio n. 1
0
static SocketPair node_socket_map_pair(PtrNodeMap& node_map, BL::Node b_node, BL::NodeSocket b_socket)
{
	BL::Node::inputs_iterator b_input;
	BL::Node::outputs_iterator b_output;
	string name = b_socket.name();
	bool found = false;
	int counter = 0, total = 0;

	/* find in inputs */
	for(b_node.inputs.begin(b_input); b_input != b_node.inputs.end(); ++b_input) {
		if(b_input->name() == name) {
			if(!found)
				counter++;
			total++;
		}

		if(b_input->ptr.data == b_socket.ptr.data)
			found = true;
	}

	if(!found) {
		/* find in outputs */
		found = false;
		counter = 0;
		total = 0;

		for(b_node.outputs.begin(b_output); b_output != b_node.outputs.end(); ++b_output) {
			if(b_output->name() == name) {
				if(!found)
					counter++;
				total++;
			}

			if(b_output->ptr.data == b_socket.ptr.data)
				found = true;
		}
	}

	/* rename if needed */
	if(name == "Shader")
		name = "Closure";

	if(total > 1)
		name = string_printf("%s%d", name.c_str(), counter);

	return SocketPair(node_map[b_node.ptr.data], name);
}
Esempio n. 2
0
static ShaderSocketType convert_osl_socket_type(OSL::OSLQuery& query,
                                                BL::NodeSocket& b_socket)
{
	ShaderSocketType socket_type = convert_socket_type(b_socket);
	if(socket_type == SHADER_SOCKET_VECTOR) {
		/* TODO(sergey): Do we need compatible_name() here? */
		const OSL::OSLQuery::Parameter *param = query.getparam(b_socket.name());
		assert(param != NULL);
		if(param != NULL) {
			if(param->type.vecsemantics == TypeDesc::POINT) {
				socket_type = SHADER_SOCKET_POINT;
			}
			else if(param->type.vecsemantics == TypeDesc::NORMAL) {
				socket_type = SHADER_SOCKET_NORMAL;
			}
		}
	}

	return socket_type;
}