Bugfix #32975
authorTon Roosendaal <ton@blender.org>
Fri, 26 Oct 2012 11:29:30 +0000 (11:29 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 26 Oct 2012 11:29:30 +0000 (11:29 +0000)
Shader nodes didn't redraw correct on preview-type changes.
Also made shader node previews draw nicely, without flashing empty images.

source/blender/blenkernel/intern/node.c
source/blender/makesrna/intern/rna_material.c

index 5613f25fca429f1d533f555c39c420d5cb8912f6..3f30da7f349a03913442e1b2bfb692f094000e89 100644 (file)
@@ -403,7 +403,13 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node)
        
        node->new_node = nnode;
        nnode->new_node = NULL;
-       nnode->preview = NULL;
+       
+       /* only shader nodes get pleasant preview updating this way, compo uses own system */
+       if (node->preview && ntree->type == NTREE_SHADER) {
+               nnode->preview = MEM_dupallocN(node->preview);
+               if (node->preview->rect)
+                       nnode->preview->rect = MEM_dupallocN(node->preview->rect);
+       }
        
        if (ntree)
                ntree->update |= NTREE_UPDATE_NODES;
index 6c3270c8e99adf9c86572e130edf7ec938875651..5e8dda7c0654711cbc4737699c24e7dcf89235fd 100644 (file)
@@ -107,6 +107,17 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *p
        }
 }
 
+static void rna_Material_update_previews(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+       Material *ma = ptr->id.data;
+       
+       if (ma->nodetree)
+               ntreeClearPreview(ma->nodetree);
+               
+       rna_Material_update(bmain, scene, ptr);
+}
+
+
 static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr)
 {
        Material *ma = ptr->id.data;
@@ -1757,7 +1768,7 @@ void RNA_def_material(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "pr_type");
        RNA_def_property_enum_items(prop, preview_type_items);
        RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render");
-       RNA_def_property_update(prop, 0, "rna_Material_update");
+       RNA_def_property_update(prop, 0, "rna_Material_update_previews");
        
        prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR);
        RNA_def_property_float_sdna(prop, NULL, "amb");