[Bf-blender-cvs] [92c89d7b879] master: UDIM: Move UDIM grid controls to the Overlay panel

Jesse Yurkovich noreply at git.blender.org
Sat Apr 9 06:43:45 CEST 2022


Commit: 92c89d7b879229ac01390da068026d0a11d864f1
Author: Jesse Yurkovich
Date:   Fri Apr 8 21:40:05 2022 -0700
Branches: master
https://developer.blender.org/rB92c89d7b879229ac01390da068026d0a11d864f1

UDIM: Move UDIM grid controls to the Overlay panel

This change moves the grid panel UI from the View tab up into the
Overlay panel.

Reasons to move to the Overlay panel include:
 - Consistency with the grid options in the 3D viewport
 - The grid has been drawn as an Overlay for quite some time already

Additional changes that now make sense to have:
 - The grid responds to the main Overlay show/hide toggle
 - Adds a toggle to show/hide the grid which is consistent with overlays in general

As before, these grid controls are only available for active UV edit
sessions.

Differential Revision: https://developer.blender.org/D11862

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

M	release/scripts/startup/bl_ui/space_image.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/draw/engines/overlay/overlay_grid.c
M	source/blender/editors/space_image/space_image.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 785a841a0e6..1dd50c979e2 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -1453,66 +1453,57 @@ class IMAGE_PT_uv_cursor(Panel):
         col.prop(sima, "cursor_location", text="Location")
 
 
-class IMAGE_PT_udim_grid(Panel):
+class IMAGE_PT_overlay(Panel):
     bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'UI'
-    bl_category = "View"
-    bl_label = "UDIM Grid"
-
-    @classmethod
-    def poll(cls, context):
-        sima = context.space_data
-
-        return sima.show_uvedit
+    bl_region_type = 'HEADER'
+    bl_label = "Overlays"
+    bl_ui_units_x = 13
 
     def draw(self, context):
-        layout = self.layout
-
-        sima = context.space_data
-        uvedit = sima.uv_editor
-
-        layout.use_property_split = True
-        layout.use_property_decorate = False
+        pass
 
-        col = layout.column()
-        col.prop(uvedit, "tile_grid_shape", text="Grid Shape")
 
-class IMAGE_PT_custom_grid(Panel):
+class IMAGE_PT_overlay_guides(Panel):
     bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'UI'
-    bl_category = "View"
-    bl_label = "Custom Grid"
+    bl_region_type = 'HEADER'
+    bl_label = "Guides"
+    bl_parent_id = 'IMAGE_PT_overlay'
 
     @classmethod
     def poll(cls, context):
         sima = context.space_data
-        return sima.show_uvedit
 
-    def draw_header(self, context):
-        sima = context.space_data
-        uvedit = sima.uv_editor
-        self.layout.prop(uvedit, "use_custom_grid", text="")
+        return sima.show_uvedit
 
     def draw(self, context):
         layout = self.layout
 
         sima = context.space_data
+        overlay = sima.overlay
         uvedit = sima.uv_editor
 
-        layout.use_property_split = True
-        layout.use_property_decorate = False
+        layout.active = overlay.show_overlays
 
-        col = layout.column()
-        col.prop(uvedit, "custom_grid_subdivisions", text="Subdivisions")
+        row = layout.row()
+        row_el = row.column()
+        row_el.prop(overlay, "show_grid_background", text="Grid")
 
-class IMAGE_PT_overlay(Panel):
-    bl_space_type = 'IMAGE_EDITOR'
-    bl_region_type = 'HEADER'
-    bl_label = "Overlays"
-    bl_ui_units_x = 13
+        if overlay.show_grid_background:
+            layout.use_property_split = True
+            col = layout.column(align=False, heading="Fixed Subdivisions")
+            col.use_property_decorate = False
 
-    def draw(self, context):
-        pass
+            row = col.row(align=True)
+            sub = row.row(align=True)
+            sub.prop(uvedit, "use_custom_grid", text="")
+            sub = sub.row(align=True)
+            sub.active = uvedit.use_custom_grid
+            sub.prop(uvedit, "custom_grid_subdivisions", text="")
+
+            row = layout.row()
+            row.use_property_split = True
+            row.use_property_decorate = False
+            row.prop(uvedit, "tile_grid_shape", text="Tiles")
 
 
 class IMAGE_PT_overlay_uv_edit(Panel):
@@ -1689,9 +1680,8 @@ classes = (
     IMAGE_PT_scope_sample,
     IMAGE_PT_uv_cursor,
     IMAGE_PT_annotation,
-    IMAGE_PT_udim_grid,
-    IMAGE_PT_custom_grid,
     IMAGE_PT_overlay,
+    IMAGE_PT_overlay_guides,
     IMAGE_PT_overlay_uv_edit,
     IMAGE_PT_overlay_uv_edit_geometry,
     IMAGE_PT_overlay_texture_paint,
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 34f3b9afacd..8a2693f3f6b 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 11
+#define BLENDER_FILE_SUBVERSION 12
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index dd3412d6c83..95851c0e9ff 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -2567,9 +2567,7 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
-  }
 
-  if (!MAIN_VERSION_ATLEAST(bmain, 302, 10)) {
     /* While vertex-colors were experimental the smear tool became corrupt due
      * to bugs in the wm_toolsystem API (auto-creation of sculpt brushes
      * was broken).  Go through and reset all smear brushes. */
@@ -2637,17 +2635,18 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
-  /**
-   * Versioning code until next subversion bump goes here.
-   *
-   * \note Be sure to check when bumping the version:
-   * - "versioning_userdef.c", #blo_do_versions_userdef
-   * - "versioning_userdef.c", #do_versions_theme
-   *
-   * \note Keep this message at the bottom of the function.
-   */
-  {
-    /* Keep this block, even when empty. */
+  if (!MAIN_VERSION_ATLEAST(bmain, 302, 12)) {
+    /* UV/Image show background grid option. */
+    LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
+          if (space->spacetype == SPACE_IMAGE) {
+            SpaceImage *sima = (SpaceImage *)space;
+            sima->overlay.flag |= SI_OVERLAY_SHOW_GRID_BACKGROUND;
+          }
+        }
+      }
+    }
 
     /* Add node storage for the merge by distance node. */
     FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
@@ -2666,4 +2665,17 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
     FOREACH_NODETREE_END;
   }
+
+  /**
+   * Versioning code until next subversion bump goes here.
+   *
+   * \note Be sure to check when bumping the version:
+   * - "versioning_userdef.c", #blo_do_versions_userdef
+   * - "versioning_userdef.c", #do_versions_theme
+   *
+   * \note Keep this message at the bottom of the function.
+   */
+  {
+    /* Keep this block, even when empty. */
+  }
 }
diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.c
index 20403f156a1..ed6db459696 100644
--- a/source/blender/draw/engines/overlay/overlay_grid.c
+++ b/source/blender/draw/engines/overlay/overlay_grid.c
@@ -49,20 +49,29 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata)
   if (pd->space_type == SPACE_IMAGE) {
     SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
     View2D *v2d = &draw_ctx->region->v2d;
-    if (sima->mode == SI_MODE_UV || !ED_space_image_has_buffer(sima)) {
-      shd->grid_flag = GRID_BACK | PLANE_IMAGE | SHOW_GRID;
-    }
-    else {
-      shd->grid_flag = 0;
+
+    /* Only UV Edit mode has the various Overlay options for now. */
+    const bool is_uv_edit = sima->mode == SI_MODE_UV;
+
+    const bool background_enabled = is_uv_edit ? (!pd->hide_overlays &&
+                                                  (sima->overlay.flag &
+                                                   SI_OVERLAY_SHOW_GRID_BACKGROUND) != 0) :
+                                                 true;
+    if (background_enabled) {
+      shd->grid_flag = GRID_BACK | PLANE_IMAGE;
     }
 
-    if (sima->flag & SI_CUSTOM_GRID) {
-      shd->grid_flag |= CUSTOM_GRID;
+    const bool draw_grid = is_uv_edit || !ED_space_image_has_buffer(sima);
+    if (background_enabled && draw_grid) {
+      shd->grid_flag |= SHOW_GRID;
+      if (is_uv_edit && (sima->flag & SI_CUSTOM_GRID) != 0) {
+        shd->grid_flag |= CUSTOM_GRID;
+      }
     }
 
     shd->grid_distance = 1.0f;
     copy_v3_fl3(shd->grid_size, 1.0f, 1.0f, 1.0f);
-    if (sima->mode == SI_MODE_UV) {
+    if (is_uv_edit) {
       shd->grid_size[0] = (float)sima->tile_grid_shape[0];
       shd->grid_size[1] = (float)sima->tile_grid_shape[1];
     }
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 03ec018fbe8..bc047a00ae1 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -100,7 +100,7 @@ static SpaceLink *image_create(const ScrArea *UNUSED(area), const Scene *UNUSED(
   simage->lock = true;
   simage->flag = SI_SHOW_GPENCIL | SI_USE_ALPHA | SI_COORDFLOATS;
   simage->uv_opacity = 1.0f;
-  simage->overlay.flag = SI_OVERLAY_SHOW_OVERLAYS;
+  simage->overlay.flag = SI_OVERLAY_SHOW_OVERLAYS | SI_OVERLAY_SHOW_GRID_BACKGROUND;
 
   BKE_imageuser_default(&simage->iuser);
   simage->iuser.flag = IMA_SHOW_STEREO | IMA_ANIM_ALWAYS | IMA_SHOW_MAX_RESOLUTION;
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 806c989100d..bcf54ee47a0 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -1318,6 +1318,7 @@ typedef enum eSpaceImage_Flag {
 
 typedef enum eSpaceImageOverlay_Flag {
   SI_OVERLAY_SHOW_OVERLAYS = (1 << 0),
+  SI_OVERLAY_SHOW_GRID_BACKGROUND = (1 << 1),
 } eSpaceImageOverlay_Flag;
 
 /** Keep in sync with `STEPS_LEN` in `grid_frag.glsl`. */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index a74019f9569..d2b8eb203aa 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3497,7 +3497,7 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Display Faces", "Display faces over the image");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
 
-  prop = RNA_def_property(srna, "tile_grid_shape", PROP_INT, PROP_NONE);
+  prop = RNA_def_property(srna, "tile_grid_shape", PROP_INT, PROP_XYZ);
   RNA_def_property_int_sdna(prop, NULL, "tile_grid_shape");
   RNA_def_property_array(prop, 2);
   RNA_def_property_int_default(prop, 1);
@@ -5264,6 +5264,11 @@ static void rna_def_space_image_overlay(BlenderRNA *brna)
   prop = RNA_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list