Commit: c2d0832c6ee11e1575744ab18233e41a9e7c2730
Author: Sergey Sharybin
Date:   Mon Oct 17 14:28:16 2016 +0200
Branches: master
https://developer.blender.org/rBc2d0832c6ee11e1575744ab18233e41a9e7c2730

UV Editor: Add filter option to control what is visible when Draw Other Objects 
is enabled

Previously the editor will always try to only show UV faces with the same exact 
active
image or image texture, which is quite difficult to control on a production 
shaders, where
each material can have multiple objects assigned.

The idea of this commit is to bring option which allows to easily control what 
to display
when "Draw Other Objects" is enabled, so currently we can have old behavior 
("Same Image")
or tell editor to show everything ("All"). In the future we can extend it with 
such filters
as "Same Material" and things like that.

Hopefully this will help @eyecandy's workflow of texturing.

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

M       release/scripts/startup/bl_ui/space_image.py
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/makesdna/DNA_space_types.h
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 bf6df05..b608718 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -687,6 +687,12 @@ class IMAGE_PT_view_properties(Panel):
             sub.active = uvedit.show_stretch
             sub.row().prop(uvedit, "draw_stretch_type", expand=True)
 
+            col = layout.column()
+            col.prop(uvedit, "show_other_objects")
+            row = col.row()
+            row.active = uvedit.show_other_objects
+            row.prop(uvedit, "other_uv_filter", text="Filter")
+
         if show_render and ima:
             layout.separator()
             render_slot = ima.render_slots.active
diff --git a/source/blender/editors/uvedit/uvedit_draw.c 
b/source/blender/editors/uvedit/uvedit_draw.c
index 94d69a0..5c5e84e 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -377,7 +377,7 @@ static void draw_uvs_lineloop_mpoly(Mesh *me, MPoly *mpoly)
        glEnd();
 }
 
-static void draw_uvs_other_mesh_texface(Object *ob, const Image *curimage)
+static void draw_uvs_other_mesh_texface(Object *ob, const Image *curimage, 
const int other_uv_filter)
 {
        Mesh *me = ob->data;
        MPoly *mpoly = me->mpoly;
@@ -389,14 +389,19 @@ static void draw_uvs_other_mesh_texface(Object *ob, const 
Image *curimage)
        }
 
        for (a = me->totpoly; a != 0; a--, mpoly++, mtpoly++) {
-               if (mtpoly->tpage != curimage) {
-                       continue;
+               if (other_uv_filter == SI_FILTER_ALL) {
+                       /* Nothing to compare, all UV faces are visible. */
+               }
+               else if (other_uv_filter == SI_FILTER_SAME_IMAGE) {
+                       if (mtpoly->tpage != curimage) {
+                               continue;
+                       }
                }
 
                draw_uvs_lineloop_mpoly(me, mpoly);
        }
 }
-static void draw_uvs_other_mesh_new_shading(Object *ob, const Image *curimage)
+static void draw_uvs_other_mesh_new_shading(Object *ob, const Image *curimage, 
const int other_uv_filter)
 {
        Mesh *me = ob->data;
        MPoly *mpoly = me->mpoly;
@@ -436,27 +441,34 @@ static void draw_uvs_other_mesh_new_shading(Object *ob, 
const Image *curimage)
        }
 
        for (a = me->totpoly; a != 0; a--, mpoly++) {
-               const int mat_nr = mpoly->mat_nr;
-               if ((mat_nr >= totcol) ||
-                   (BLI_BITMAP_TEST(mat_test_array, mat_nr)) == 0)
-               {
-                       continue;
+               if (other_uv_filter == SI_FILTER_ALL) {
+                       /* Nothing to compare, all UV faces are visible. */
+               }
+               else if (other_uv_filter == SI_FILTER_SAME_IMAGE) {
+                       const int mat_nr = mpoly->mat_nr;
+                       if ((mat_nr >= totcol) ||
+                           (BLI_BITMAP_TEST(mat_test_array, mat_nr)) == 0)
+                       {
+                               continue;
+                       }
                }
 
                draw_uvs_lineloop_mpoly(me, mpoly);
        }
 }
-static void draw_uvs_other_mesh(Object *ob, const Image *curimage, const bool 
new_shading_nodes)
+static void draw_uvs_other_mesh(Object *ob, const Image *curimage, const bool 
new_shading_nodes,
+                                const int other_uv_filter)
 {
        if (new_shading_nodes) {
-               draw_uvs_other_mesh_new_shading(ob, curimage);
+               draw_uvs_other_mesh_new_shading(ob, curimage, other_uv_filter);
        }
        else {
-               draw_uvs_other_mesh_texface(ob, curimage);
+               draw_uvs_other_mesh_texface(ob, curimage, other_uv_filter);
        }
 }
 
-static void draw_uvs_other(Scene *scene, Object *obedit, const Image 
*curimage, const bool new_shading_nodes)
+static void draw_uvs_other(Scene *scene, Object *obedit, const Image 
*curimage, const bool new_shading_nodes,
+                           const int other_uv_filter)
 {
        Base *base;
 
@@ -470,7 +482,7 @@ static void draw_uvs_other(Scene *scene, Object *obedit, 
const Image *curimage,
                if (ob->restrictflag & OB_RESTRICT_VIEW) continue;
 
                if ((ob->type == OB_MESH) && (ob != obedit) && ((Mesh 
*)ob->data)->mloopuv) {
-                       draw_uvs_other_mesh(ob, curimage, new_shading_nodes);
+                       draw_uvs_other_mesh(ob, curimage, new_shading_nodes, 
other_uv_filter);
                }
        }
 }
@@ -483,7 +495,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene 
*scene, Object *ob)
        Material *ma;
 
        if (sima->flag & SI_DRAW_OTHER) {
-               draw_uvs_other(scene, ob, curimage, new_shading_nodes);
+               draw_uvs_other(scene, ob, curimage, new_shading_nodes, 
sima->other_uv_filter);
        }
 
        UI_ThemeColor(TH_UV_SHADOW);
@@ -586,7 +598,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object 
*obedit)
                        curimage = (activetf) ? activetf->tpage : ima;
                }
 
-               draw_uvs_other(scene, obedit, curimage, new_shading_nodes);
+               draw_uvs_other(scene, obedit, curimage, new_shading_nodes, 
sima->other_uv_filter);
        }
 
        /* 1. draw shadow mesh */
diff --git a/source/blender/makesdna/DNA_space_types.h 
b/source/blender/makesdna/DNA_space_types.h
index 41188c2..5e01554 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -898,6 +898,10 @@ typedef struct SpaceImage {
        char dt_uvstretch;
        char around;
 
+       /* Filter settings when editor shows other object's UVs. */
+       int other_uv_filter;
+       int pad2;
+
        MaskSpaceInfo mask_info;
 } SpaceImage;
 
@@ -976,6 +980,12 @@ typedef enum eSpaceImage_Flag {
        SI_SHOW_B             = (1 << 29),
 } eSpaceImage_Flag;
 
+/* SpaceImage->other_uv_filter */
+typedef enum eSpaceImage_OtherUVFilter {
+       SI_FILTER_SAME_IMAGE    = 0,
+       SI_FILTER_ALL           = 1,
+} eSpaceImage_OtherUVFilter;
+
 /* Text Editor ============================================ */
 
 /* Text Editor */
diff --git a/source/blender/makesrna/intern/rna_space.c 
b/source/blender/makesrna/intern/rna_space.c
index 8fb9970..ffcf12e 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1977,6 +1977,13 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
+       static EnumPropertyItem other_uv_filter_items[] = {
+               {SI_FILTER_ALL, "ALL", 0, "All", "No filter, show all islands 
from other objects"},
+               {SI_FILTER_SAME_IMAGE, "SAME_IMAGE", ICON_IMAGE_DATA, "Same 
Image",
+                "Only show others' UV islads who's active image matches image 
of the active face"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        srna = RNA_def_struct(brna, "SpaceUVEditor", NULL);
        RNA_def_struct_sdna(srna, "SpaceImage");
        RNA_def_struct_nested(brna, srna, "SpaceImageEditor");
@@ -2064,6 +2071,13 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Live Unwrap",
                                 "Continuously unwrap the selected UV island 
while transforming pinned vertices");
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+
+       /* Other UV filtering */
+       prop = RNA_def_property(srna, "other_uv_filter", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, other_uv_filter_items);
+       RNA_def_property_ui_text(prop, "Other UV filter",
+                                "Filter applied on the other object's UV to 
limit displayed");
+       RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
 }
 
 static void rna_def_space_outliner(BlenderRNA *brna)

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to