diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2014-07-21 14:02:05 +0400 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2014-07-21 14:02:05 +0400 |
commit | f745564e4ee791e4faf804b09ce975b882f4f8d9 (patch) | |
tree | 90ebbe363ccd925cedc652c9bb018ce552b5a2ab /source/blender/makesrna/intern/rna_material.c | |
parent | 8489b94e07f9e73bd3c9c3e4f6a91f1f0a259827 (diff) |
GSOC 2013 paint
Yep, at last it's here!
There are a few minor issues remaining but development can go on in
master after discussion at blender institute.
For full list of features see:
http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.72/Painting
Thanks to Sergey and Campbell for the extensive review and to the
countless artists that have given their input and reported issues during
development.
Diffstat (limited to 'source/blender/makesrna/intern/rna_material.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 0a4799937cd..3c9eaf3c5db 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -82,6 +82,8 @@ EnumPropertyItem ramp_blend_items[] = { #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_screen_types.h" +#include "DNA_space_types.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -92,6 +94,8 @@ EnumPropertyItem ramp_blend_items[] = { #include "BKE_paint.h" #include "ED_node.h" +#include "ED_image.h" +#include "BKE_scene.h" static void rna_Material_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { @@ -165,6 +169,50 @@ static void rna_Material_mtex_begin(CollectionPropertyIterator *iter, PointerRNA rna_iterator_array_begin(iter, (void *)ma->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL); } +static void rna_Material_texpaint_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Material *ma = (Material *)ptr->data; + rna_iterator_array_begin(iter, (void *)ma->texpaintslot, sizeof(TexPaintSlot), ma->tot_slots, 0, NULL); +} + + +static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bScreen *sc; + Material *ma = ptr->id.data; + + + if (ma->use_nodes && ma->nodetree && BKE_scene_use_new_shading_nodes(scene)) { + struct bNode *node; + int index = 0; + for (node = ma->nodetree->nodes.first; node; node = node->next) { + if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { + if (index++ == ma->paint_active_slot) { + break; + } + } + } + if (node) + nodeSetActive(ma->nodetree, node); + } + + for (sc = bmain->screen.first; sc; sc = sc->id.next) { + ScrArea *sa; + for (sa = sc->areabase.first; sa; sa = sa->next) { + SpaceLink *sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *)sl; + ED_space_image_set(sima, scene, scene->obedit, ma->texpaintslot[ma->paint_active_slot].ima); + } + } + } + } + + DAG_id_tag_update(&ma->id, 0); + WM_main_add_notifier(NC_MATERIAL | ND_SHADING, ma); +} + static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr) { Material *ma = (Material *)ptr->data; @@ -2059,6 +2107,8 @@ void RNA_def_material(BlenderRNA *brna) "rna_Material_active_texture_set", "rna_Material_active_texture_editable", "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update", "rna_Material_update"); + rna_def_mtex_texpaint(srna); + /* only material has this one */ prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1); @@ -2147,4 +2197,27 @@ void rna_def_mtex_common(BlenderRNA *brna, StructRNA *srna, const char *begin, RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, update_index); } +void rna_def_mtex_texpaint(StructRNA *srna) +{ + PropertyRNA *prop; + + /* mtex */ + prop = RNA_def_property(srna, "texture_paint_slots", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_Material_texpaint_begin", "rna_iterator_array_next", "rna_iterator_array_end", + "rna_iterator_array_dereference_get", NULL, NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "Image"); + RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures"); + + prop = RNA_def_property(srna, "paint_active_slot", PROP_INT, PROP_UNSIGNED); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Active Paint Texture Index", "Index of active texture paint slot"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_Material_active_paint_texture_index_update"); + + prop = RNA_def_property(srna, "paint_clone_slot", PROP_INT, PROP_UNSIGNED); + RNA_def_property_range(prop, 0, INT_MAX); + RNA_def_property_ui_text(prop, "Clone Paint Texture Index", "Index of clone texture paint slot"); + RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL); +} + + #endif |