Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Toenne <lukas.toenne@googlemail.com>2012-06-21 11:14:39 +0400
committerLukas Toenne <lukas.toenne@googlemail.com>2012-06-21 11:14:39 +0400
commit27aa2174b7544e97eae2a27e871609e74e0a5107 (patch)
treec842633ca6236c46e83ba91e85cbf184d743446b /source/blender/makesrna/intern
parent7ef54879ed8bb157046e305da554cae907adf6e8 (diff)
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.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r--source/blender/makesrna/intern/rna_color.c44
1 files changed, 38 insertions, 6 deletions
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index ecdfe1505c8..15fdce09d83 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -135,6 +135,8 @@ static void rna_CurveMapping_clipmaxy_range(PointerRNA *ptr, float *min, float *
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 @@ static char *rna_ColorRamp_path(PointerRNA *ptr)
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 @@ static char *rna_ColorRampElement_path(PointerRNA *ptr)
}
break;
- /* TODO: node trees need special attention */
case ID_NT:
{
bNodeTree *ntree = (bNodeTree *)id;