UV Editor: Grid and snapping improvements

Implements T89789, T89792, custom grid (described as dynamic grid in
T78389) and UV grid snapping (T78391)
Replaces the default UV editor grid with 2 new types of grid :

* Custom grid: Allows the user to create an NxN grid, where the value
  of N is specified by the user.
* Subdividing grid: Subdivides the UV editor grid when the user
  zooms in the viewport and vice versa when zooming out.

UV snapping improvements :
* Increment snapping: Increment values for snapping are calculated based
  on which grid type is being used in the UV editor
  (subdividing or custom). In general the increment value is equal to
  the distance between 2 visible grid lines.
* Absolute grid snap: New toggle added to increment snapping option in
  the UV editor, allows UV grid snapping during translation.

Reviewed By: campbellbarton

Ref D12684
This commit is contained in:
Siddhartha Jejurkar
2021-09-29 17:47:32 +10:00
committed by Campbell Barton
parent 008ae26712
commit bf06f76be6
17 changed files with 218 additions and 38 deletions

View File

@@ -934,6 +934,10 @@ class IMAGE_PT_snapping(Panel):
row = col.row(align=True)
row.prop(tool_settings, "snap_target", expand=True)
col.separator()
if 'INCREMENT' in tool_settings.snap_uv_element:
col.prop(tool_settings, "use_snap_uv_grid_absolute")
col.label(text="Affect")
row = col.row(align=True)
row.prop(tool_settings, "use_snap_translate", text="Move", toggle=True)
@@ -1467,6 +1471,33 @@ class IMAGE_PT_udim_grid(Panel):
col = layout.column()
col.prop(uvedit, "tile_grid_shape", text="Grid Shape")
class IMAGE_PT_custom_grid(Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = 'UI'
bl_category = "View"
bl_label = "Custom Grid"
@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="")
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
col = layout.column()
col.prop(uvedit, "custom_grid_subdivisions", text="Subdivisions")
class IMAGE_PT_overlay(Panel):
bl_space_type = 'IMAGE_EDITOR'
@@ -1652,6 +1683,7 @@ classes = (
IMAGE_PT_uv_cursor,
IMAGE_PT_annotation,
IMAGE_PT_udim_grid,
IMAGE_PT_custom_grid,
IMAGE_PT_overlay,
IMAGE_PT_overlay_uv_edit,
IMAGE_PT_overlay_uv_edit_geometry,