[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48150] trunk/blender/source/blender/ makesrna/intern/rna_color.c: Fix for color ramp RNA paths in node trees.

Lukas Toenne lukas.toenne at googlemail.com
Thu Jun 21 09:14:58 CEST 2012


Revision: 48150
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48150
Author:   lukastoenne
Date:     2012-06-21 07:14:39 +0000 (Thu, 21 Jun 2012)
Log Message:
-----------
Fix for color ramp RNA paths in node trees. The path generation for color ramps in nodes was incomplete (not prepending the ID-to-node path), which prevented keyframing color ramp elements. Path lookup for color ramps is still brute-force and slow, but this is a general design problem with nested RNA structs.

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_color.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_color.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_color.c	2012-06-21 06:27:51 UTC (rev 48149)
+++ trunk/blender/source/blender/makesrna/intern/rna_color.c	2012-06-21 07:14:39 UTC (rev 48150)
@@ -135,6 +135,8 @@
 
 static char *rna_ColorRamp_path(PointerRNA *ptr)
 {
+	char *path = NULL;
+	
 	/* handle the cases where a single datablock may have 2 ramp types */
 	if (ptr->id.data) {
 		ID *id = ptr->id.data;
@@ -145,16 +147,47 @@
 				Material *ma = (Material *)id;
 				
 				if (ptr->data == ma->ramp_col)
-					return BLI_strdup("diffuse_ramp");
+					path = BLI_strdup("diffuse_ramp");
 				else if (ptr->data == ma->ramp_spec)
-					return BLI_strdup("specular_ramp");
+					path = BLI_strdup("specular_ramp");
+				break;
 			}
-			break;
+			
+			case ID_NT:
+			{
+				bNodeTree *ntree = (bNodeTree *)id;
+				bNode *node;
+				PointerRNA node_ptr;
+				char *node_path;
+				
+				for (node = ntree->nodes.first; node; node = node->next) {
+					if (ELEM3(node->type, SH_NODE_VALTORGB, CMP_NODE_VALTORGB, TEX_NODE_VALTORGB)) {
+						if (node->storage == ptr->data) {
+							/* all node color ramp properties called 'color_ramp'
+							 * prepend path from ID to the node
+							 */
+							RNA_pointer_create(id, &RNA_Node, node, &node_ptr);
+							node_path = RNA_path_from_ID_to_struct(&node_ptr);
+							path = BLI_sprintfN("%s.color_ramp", node_path);
+							MEM_freeN(node_path);
+						}
+					}
+				}
+				break;
+			}
+			
+			default:
+				/* everything else just uses 'color_ramp' */
+				path = BLI_strdup("color_ramp");
+				break;
 		}
 	}
+	else {
+		/* everything else just uses 'color_ramp' */
+		path = BLI_strdup("color_ramp");
+	}
 	
-	/* everything else just uses 'color_ramp' */
-	return BLI_strdup("color_ramp");
+	return path;
 }
 
 static char *rna_ColorRampElement_path(PointerRNA *ptr)
@@ -204,7 +237,6 @@
 			}
 			break;
 				
-			/* TODO: node trees need special attention */
 			case ID_NT:
 			{
 				bNodeTree *ntree = (bNodeTree *)id;




More information about the Bf-blender-cvs mailing list