Commit: fcadf47a917988527641a49f30ceb90c9f0f8bb7
Author: Antony Riakiotakis
Date:   Fri Nov 14 13:50:10 2014 +0100
Branches: master
https://developer.blender.org/rBfcadf47a917988527641a49f30ceb90c9f0f8bb7

Fix T42561 (semi feature request/comeback) UVs in image editor can get
too crowded.

UVs in the same layer can be used for many images. It used to be
possible to filter UV faces based on the image, but this is impossible
now due to the way the system works, so I added an option to allow
filtering UVs based on active material index.

Rationale on using option and not being smart here (options are bad tm)
is that for some workflows, such as preserving image space by using the
same image for many materials, people might want to turn this off.

===================================================================

M       release/scripts/startup/bl_ui/space_image.py
M       source/blender/editors/space_image/space_image.c
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/makesdna/DNA_space_types.h
M       source/blender/makesrna/intern/rna_object.c
M       source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_image.py 
b/release/scripts/startup/bl_ui/space_image.py
index bdb0ca7..1e3a743 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -82,6 +82,7 @@ class IMAGE_MT_view(Menu):
         layout.prop(uv, "show_other_objects")
         if paint.brush and (context.image_paint_object or sima.mode == 
'PAINT'):
             layout.prop(uv, "show_texpaint")
+            layout.prop(uv, "texpaint_filter_mat")
 
         layout.separator()
 
diff --git a/source/blender/editors/space_image/space_image.c 
b/source/blender/editors/space_image/space_image.c
index 42c1b92..770582f 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -791,7 +791,7 @@ static void image_main_area_draw(const bContext *C, ARegion 
*ar)
 #endif
 }
 
-static void image_main_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), 
ARegion *ar, wmNotifier *wmn)
+static void image_main_area_listener(bScreen *UNUSED(sc), ScrArea *sa, ARegion 
*ar, wmNotifier *wmn)
 {
        /* context changes */
        switch (wmn->category) {
@@ -803,6 +803,14 @@ static void image_main_area_listener(bScreen *UNUSED(sc), 
ScrArea *UNUSED(sa), A
                        if (wmn->action == NA_PAINTING)
                                ED_region_tag_redraw(ar);
                        break;
+               case NC_MATERIAL:
+                       if (wmn->data == ND_SHADING_LINKS) {
+                               SpaceImage *sima = sa->spacedata.first;
+
+                               if (sima->flag & SI_TEXPAINT_FILTER_MATERIAL)
+                                       ED_region_tag_redraw(ar);
+                       }
+                       break;
        }
 }
 
diff --git a/source/blender/editors/uvedit/uvedit_draw.c 
b/source/blender/editors/uvedit/uvedit_draw.c
index 525cedb..7b674e7 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -506,6 +506,8 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene 
*scene, Object *ob)
                mloopuv_base = mloopuv;
 
                for (a = me->totpoly; a > 0; a--, mpoly++) {
+                       if ((sima->flag & SI_TEXPAINT_FILTER_MATERIAL) && 
mpoly->mat_nr != ob->actcol - 1)
+                               continue;
                        glBegin(GL_LINE_LOOP);
 
                        mloopuv = mloopuv_base + mpoly->loopstart;
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index a267217..41b302e 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -809,7 +809,9 @@ typedef enum eSpaceImage_Flag {
 
        SI_COLOR_CORRECTION   = (1 << 24),
 
-       SI_NO_DRAW_TEXPAINT   = (1 << 25)
+       SI_NO_DRAW_TEXPAINT   = (1 << 25),
+       /* filter texpaint uvs based on active material */
+       SI_TEXPAINT_FILTER_MATERIAL   = (1 << 26)
 } eSpaceImage_Flag;
 
 /* Text Editor ============================================ */
diff --git a/source/blender/makesrna/intern/rna_object.c 
b/source/blender/makesrna/intern/rna_object.c
index 690468a..b57c368 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -941,6 +941,7 @@ static void rna_MaterialSlot_name_get(PointerRNA *ptr, char 
*str)
 static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
        rna_Object_internal_update(bmain, scene, ptr);
+
        WM_main_add_notifier(NC_OBJECT | ND_OB_SHADING, ptr->id.data);
        WM_main_add_notifier(NC_MATERIAL | ND_SHADING_LINKS, NULL);
 }
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 68173eb..8788a72 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1523,6 +1523,11 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Draw Texture Paint UVs", "Draw overlay 
of texture paint uv layer");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
 
+       prop = RNA_def_property(srna, "texpaint_filter_mat", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
SI_TEXPAINT_FILTER_MATERIAL);
+       RNA_def_property_ui_text(prop, "Same Material UVs", "Only draw UVs of 
faces with active material");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+
        prop = RNA_def_property(srna, "show_normalized_coords", PROP_BOOLEAN, 
PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_COORDFLOATS);
        RNA_def_property_ui_text(prop, "Normalized Coordinates",

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to