[Bf-blender-cvs] [2bdb872] master: Fix T41067: Muted nodes still do data type conversions.

Lukas Tönne noreply at git.blender.org
Tue Jul 15 11:04:46 CEST 2014


Commit: 2bdb872cfb90feae214088954d243820e4992c3b
Author: Lukas Tönne
Date:   Tue Jul 15 10:55:49 2014 +0200
https://developer.blender.org/rB2bdb872cfb90feae214088954d243820e4992c3b

Fix T41067: Muted nodes still do data type conversions.

Proxy operations from muted nodes would still create conversion
operations where the datatypes don't match, which creates unexpected
behavior. Arguably datatype conversion could still happen even when the
main operation is muted, but this would be a design change and so is
disabled now.

===================================================================

M	source/blender/compositor/intern/COM_NodeConverter.cpp
M	source/blender/compositor/intern/COM_NodeConverter.h
M	source/blender/compositor/intern/COM_NodeGraph.cpp
M	source/blender/compositor/intern/COM_NodeOperation.h
M	source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
M	source/blender/compositor/nodes/COM_SocketProxyNode.cpp
M	source/blender/compositor/nodes/COM_SocketProxyNode.h
M	source/blender/compositor/nodes/COM_SwitchNode.cpp
M	source/blender/compositor/operations/COM_SocketProxyOperation.cpp
M	source/blender/compositor/operations/COM_SocketProxyOperation.h

===================================================================

diff --git a/source/blender/compositor/intern/COM_NodeConverter.cpp b/source/blender/compositor/intern/COM_NodeConverter.cpp
index 81a10a5..208a3db 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.cpp
+++ b/source/blender/compositor/intern/COM_NodeConverter.cpp
@@ -83,9 +83,9 @@ NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
 	return operation;
 }
 
-NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input)
+NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input, bool use_conversion)
 {
-	SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType());
+	SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion);
 	m_builder->addOperation(proxy);
 	
 	m_builder->mapInputSocket(input, proxy->getInputSocket(0));
@@ -93,9 +93,9 @@ NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input)
 	return proxy->getOutputSocket();
 }
 
-NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output)
+NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output, bool use_conversion)
 {
-	SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType());
+	SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion);
 	m_builder->addOperation(proxy);
 	
 	m_builder->mapOutputSocket(output, proxy->getOutputSocket());
diff --git a/source/blender/compositor/intern/COM_NodeConverter.h b/source/blender/compositor/intern/COM_NodeConverter.h
index e5e7629..414b4f1 100644
--- a/source/blender/compositor/intern/COM_NodeConverter.h
+++ b/source/blender/compositor/intern/COM_NodeConverter.h
@@ -70,12 +70,12 @@ public:
 	 *  This operation will be removed later and replaced
 	 *  by direct links between the connected operations.
 	 */
-	NodeOperationOutput *addInputProxy(NodeInput *input);
+	NodeOperationOutput *addInputProxy(NodeInput *input, bool use_conversion);
 	/** Create a proxy operation for a node output.
 	 *  This operation will be removed later and replaced
 	 *  by direct links between the connected operations.
 	 */
-	NodeOperationInput *addOutputProxy(NodeOutput *output);
+	NodeOperationInput *addOutputProxy(NodeOutput *output, bool use_conversion);
 	
 	/** Define a constant input value. */
 	void addInputValue(NodeOperationInput *input, float value);
diff --git a/source/blender/compositor/intern/COM_NodeGraph.cpp b/source/blender/compositor/intern/COM_NodeGraph.cpp
index cbe4723..2dcf419 100644
--- a/source/blender/compositor/intern/COM_NodeGraph.cpp
+++ b/source/blender/compositor/intern/COM_NodeGraph.cpp
@@ -202,7 +202,7 @@ void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink
 void NodeGraph::add_proxies_mute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
 {
 	for (bNodeLink *b_link = (bNodeLink *)b_node->internal_links.first; b_link; b_link = b_link->next) {
-		SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock);
+		SocketProxyNode *proxy = new SocketProxyNode(b_node, b_link->fromsock, b_link->tosock, false);
 		add_node(proxy, b_ntree, key, is_active_group);
 	}
 }
@@ -219,7 +219,7 @@ void NodeGraph::add_proxies_skip(bNodeTree *b_ntree, bNode *b_node, bNodeInstanc
 		}
 		
 		if (input) {
-			SocketProxyNode *proxy = new SocketProxyNode(b_node, input, output);
+			SocketProxyNode *proxy = new SocketProxyNode(b_node, input, output, true);
 			add_node(proxy, b_ntree, key, is_active_group);
 		}
 	}
@@ -237,7 +237,7 @@ void NodeGraph::add_proxies_group_inputs(bNode *b_node, bNode *b_node_io)
 	for (bNodeSocket *b_sock_io = (bNodeSocket *)b_node_io->outputs.first; b_sock_io; b_sock_io = b_sock_io->next) {
 		bNodeSocket *b_sock_group = find_b_node_input(b_node, b_sock_io->identifier);
 		if (b_sock_group) {
-			SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_group, b_sock_io);
+			SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_group, b_sock_io, true);
 			add_node(proxy, b_group_tree, key, is_active_group);
 		}
 	}
@@ -260,7 +260,7 @@ void NodeGraph::add_proxies_group_outputs(bNode *b_node, bNode *b_node_io, bool
 				add_node(buffer, b_group_tree, key, is_active_group);
 			}
 			else {
-				SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_io, b_sock_group);
+				SocketProxyNode *proxy = new SocketProxyNode(b_node_io, b_sock_io, b_sock_group, true);
 				add_node(proxy, b_group_tree, key, is_active_group);
 			}
 		}
@@ -294,6 +294,6 @@ void NodeGraph::add_proxies_group(const CompositorContext &context, bNode *b_nod
 
 void NodeGraph::add_proxies_reroute(bNodeTree *b_ntree, bNode *b_node, bNodeInstanceKey key, bool is_active_group)
 {
-	SocketProxyNode *proxy = new SocketProxyNode(b_node, (bNodeSocket *)b_node->inputs.first, (bNodeSocket *)b_node->outputs.first);
+	SocketProxyNode *proxy = new SocketProxyNode(b_node, (bNodeSocket *)b_node->inputs.first, (bNodeSocket *)b_node->outputs.first, false);
 	add_node(proxy, b_ntree, key, is_active_group);
 }
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h
index 3f636df..b2b8f03 100644
--- a/source/blender/compositor/intern/COM_NodeOperation.h
+++ b/source/blender/compositor/intern/COM_NodeOperation.h
@@ -288,6 +288,8 @@ public:
 	virtual bool isFileOutputOperation() const { return false; }
 	virtual bool isProxyOperation() const { return false; }
 	
+	virtual bool useDatatypeConversion() const { return true; }
+	
 	inline bool isBreaked() const {
 		return this->m_btree->test_break(this->m_btree->tbh);
 	}
diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
index 6554926..0c8c3ed 100644
--- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
+++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cpp
@@ -269,6 +269,13 @@ void NodeOperationBuilder::add_datatype_conversions()
 	Links convert_links;
 	for (Links::const_iterator it = m_links.begin(); it != m_links.end(); ++it) {
 		const Link &link = *it;
+		
+		/* proxy operations can skip data type conversion */
+		NodeOperation *from_op = &link.from()->getOperation();
+		NodeOperation *to_op = &link.to()->getOperation();
+		if (!from_op->useDatatypeConversion() || !to_op->useDatatypeConversion())
+			continue;
+		
 		if (link.from()->getDataType() != link.to()->getDataType())
 			convert_links.push_back(link);
 	}
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
index f750a44..48c8acf 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.cpp
@@ -29,7 +29,9 @@
 #include "COM_WriteBufferOperation.h"
 #include "COM_ReadBufferOperation.h"
 
-SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput) : Node(editorNode, false)
+SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool use_conversion) :
+    Node(editorNode, false),
+    m_use_conversion(use_conversion)
 {
 	DataType dt;
 
@@ -46,7 +48,7 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bN
 
 void SocketProxyNode::convertToOperations(NodeConverter &converter, const CompositorContext &context) const
 {
-	NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0));
+	NodeOperationOutput *proxy_output = converter.addInputProxy(getInputSocket(0), m_use_conversion);
 	converter.mapOutputSocket(getOutputSocket(), proxy_output);
 }
 
diff --git a/source/blender/compositor/nodes/COM_SocketProxyNode.h b/source/blender/compositor/nodes/COM_SocketProxyNode.h
index 2fbaa71..5dbf393 100644
--- a/source/blender/compositor/nodes/COM_SocketProxyNode.h
+++ b/source/blender/compositor/nodes/COM_SocketProxyNode.h
@@ -31,8 +31,15 @@
  */
 class SocketProxyNode : public Node {
 public:
-	SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput);
+	SocketProxyNode(bNode *editorNode, bNodeSocket *editorInput, bNodeSocket *editorOutput, bool use_conversion);
 	void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+	
+	bool getUseConversion() const { return m_use_conversion; }
+	void setUseConversion(bool use_conversion) { m_use_conversion = use_conversion; }
+	
+private:
+	/** If true, the proxy will convert input and output data to/from the proxy socket types. */
+	bool m_use_conversion;
 };
 
 
diff --git a/source/blender/compositor/nodes/COM_SwitchNode.cpp b/source/blender/compositor/nodes/COM_SwitchNode.cpp
index 692b8d7..10f0ee3 100644
--- a/source/blender/compositor/nodes/COM_SwitchNode.cpp
+++ b/source/blender/compositor/nodes/COM_SwitchNode.cpp
@@ -33,9 +33,9 @@ void SwitchNode::convertToOperations(NodeConverter &converter, const CompositorC
 	
 	NodeOperationOutput *result;
 	if (!condition)
-		result = converter.addInputProxy(getInputSocket(0));
+		result = converter.addInputProxy(getInputSocket(0), false);
 	else
-		result = converter.addInputProxy(getInputSocket(1));
+		result = converter.addInputProxy(getInputSocket(1), false);
 	
 	converter.mapOutputSocket(getOutputSocket(0), result);
 }
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
index da345b2..21d2f28 100644
--- a/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
+++ b/source/blender/compositor/operations/COM_SocketProxyOperation.cpp
@@ -22,7 +22,9 @@
 
 #include "COM_SocketProxyOperation.h"
 
-SocketProxyOperation::SocketProxyOperation(DataType type) : NodeOperation()
+SocketProxyOperation::SocketProxyOperation(DataType type, bool use_conversion) :
+    NodeOperation(),
+    m_use_conversion(use_conversion)
 {
 	this->addInputSocket(type);
 	this->addOutputSocket(type);
diff --git a/source/blender/compositor/operations/COM_SocketProxyOperation.h b/source/blender/compositor/operations/COM_SocketProxyOperation.h
index 9733a1f..c9d6cb6 100644
--- a/source/blender/compositor/operations/COM_SocketPro

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list