[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50341] trunk/blender/intern/cycles/render : Replaced dynamic_casts for node type checks by simple 'special type' identifiers.

Lukas Toenne lukas.toenne at googlemail.com
Mon Sep 3 13:38:15 CEST 2012


Revision: 50341
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50341
Author:   lukastoenne
Date:     2012-09-03 11:38:15 +0000 (Mon, 03 Sep 2012)
Log Message:
-----------
Replaced dynamic_casts for node type checks by simple 'special type' identifiers. RTTI has to be disabled in cycles for OSL.

Modified Paths:
--------------
    trunk/blender/intern/cycles/render/graph.cpp
    trunk/blender/intern/cycles/render/graph.h
    trunk/blender/intern/cycles/render/nodes.cpp

Modified: trunk/blender/intern/cycles/render/graph.cpp
===================================================================
--- trunk/blender/intern/cycles/render/graph.cpp	2012-09-03 11:26:04 UTC (rev 50340)
+++ trunk/blender/intern/cycles/render/graph.cpp	2012-09-03 11:38:15 UTC (rev 50341)
@@ -55,6 +55,7 @@
 	name = name_;
 	id = -1;
 	bump = SHADER_BUMP_NONE;
+	special_type = SHADER_SPECIAL_TYPE_NONE;
 }
 
 ShaderNode::~ShaderNode()
@@ -298,8 +299,8 @@
 void ShaderGraph::remove_proxy_nodes(vector<bool>& removed)
 {
 	foreach(ShaderNode *node, nodes) {
-		ProxyNode *proxy = dynamic_cast<ProxyNode*>(node);
-		if (proxy) {
+		if (node->special_type == SHADER_SPECIAL_TYPE_PROXY) {
+			ProxyNode *proxy = static_cast<ProxyNode*>(node);
 			ShaderInput *input = proxy->inputs[0];
 			ShaderOutput *output = proxy->outputs[0];
 			
@@ -330,9 +331,8 @@
 		}
 
 		/* remove useless mix closures nodes */
-		MixClosureNode *mix = dynamic_cast<MixClosureNode*>(node);
-
-		if(mix) {
+		if(node->special_type == SHADER_SPECIAL_TYPE_MIX_CLOSURE) {
+			MixClosureNode *mix = static_cast<MixClosureNode*>(node);
 			if(mix->outputs[0]->links.size() && mix->inputs[1]->link == mix->inputs[2]->link) {
 				ShaderOutput *output = mix->inputs[1]->link;
 				vector<ShaderInput*> inputs = mix->outputs[0]->links;

Modified: trunk/blender/intern/cycles/render/graph.h
===================================================================
--- trunk/blender/intern/cycles/render/graph.h	2012-09-03 11:26:04 UTC (rev 50340)
+++ trunk/blender/intern/cycles/render/graph.h	2012-09-03 11:38:15 UTC (rev 50341)
@@ -63,6 +63,17 @@
 	SHADER_BUMP_DY
 };
 
+/* Identifiers for some special node types.
+ *
+ * The graph needs to identify these in the clean function.
+ * Cannot use dynamic_cast, as this is disabled for OSL. */
+
+enum ShaderNodeSpecialType {
+	SHADER_SPECIAL_TYPE_NONE,
+	SHADER_SPECIAL_TYPE_PROXY,
+	SHADER_SPECIAL_TYPE_MIX_CLOSURE
+};
+
 /* Enum
  *
  * Utility class for enum values. */
@@ -167,6 +178,8 @@
 	ustring name; /* name, not required to be unique */
 	int id; /* index in graph node array */
 	ShaderBump bump; /* for bump mapping utility */
+	
+	ShaderNodeSpecialType special_type;	/* special node type */
 };
 
 

Modified: trunk/blender/intern/cycles/render/nodes.cpp
===================================================================
--- trunk/blender/intern/cycles/render/nodes.cpp	2012-09-03 11:26:04 UTC (rev 50340)
+++ trunk/blender/intern/cycles/render/nodes.cpp	2012-09-03 11:38:15 UTC (rev 50341)
@@ -1036,6 +1036,7 @@
 {
 	from = from_;
 	to = to_;
+	special_type = SHADER_SPECIAL_TYPE_PROXY;
 
 	add_input("Input", from);
 	add_output("Output", to);
@@ -1971,6 +1972,8 @@
 MixClosureNode::MixClosureNode()
 : ShaderNode("mix_closure")
 {
+	special_type = SHADER_SPECIAL_TYPE_MIX_CLOSURE;
+	
 	add_input("Fac", SHADER_SOCKET_FLOAT, 0.5f);
 	add_input("Closure1", SHADER_SOCKET_CLOSURE);
 	add_input("Closure2", SHADER_SOCKET_CLOSURE);




More information about the Bf-blender-cvs mailing list