Skip to content

Commit 705480c

Browse files
committed
Blender 5.0 compatibility
1 parent 9eb52c3 commit 705480c

25 files changed

+171
-190
lines changed

blender_manifest.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
schema_version = "1.0.0"
22

33
id = "uv_toolkit"
4-
version = "2.1.3"
4+
version = "2.1.4"
55
name = "UVToolkit"
66
tagline = "A collection of UV editing tools for Blender"
77
maintainer = "Ethan Simon-Law <ethan.simon.3d@gmail.com>"
@@ -11,7 +11,7 @@ website = "https://github.com/oRazeD/UVToolkit"
1111

1212
tags = ["UV", "Material"]
1313

14-
blender_version_min = "4.2.0"
14+
blender_version_min = "5.0.0"
1515
blender_version_max = "6.0.0"
1616

1717
license = [
@@ -20,4 +20,3 @@ license = [
2020

2121
# [permissions]
2222
files = "Read/Write Images"
23-

operators/align_uv.py

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ def align_islands(self, context):
3333
me = ob.data
3434
bm = bmesh.from_edit_mesh(me)
3535
uv = bm.loops.layers.uv.verify()
36-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
36+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
3737
bbox = get_bbox(uv, island)
3838
bboxes.append(bbox)
3939

4040
if not bboxes:
4141
return {'CANCELED'}
4242

4343
if self.align_uv == 'MAX_U':
44-
max_u = max([bbox[1][0] for bbox in bboxes])
44+
max_u = max(bbox[1][0] for bbox in bboxes)
4545
for ob in context.objects_in_mode_unique_data:
4646
seams = objects_seams[ob]
4747
me = ob.data
4848
bm = bmesh.from_edit_mesh(me)
4949
uv = bm.loops.layers.uv.verify()
50-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
50+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
5151
bbox = get_bbox(uv, island)
5252
bbox_max_u = bbox[1][0]
5353
distance = max_u - bbox_max_u
@@ -58,14 +58,14 @@ def align_islands(self, context):
5858
l[uv].uv = new_co
5959
bmesh.update_edit_mesh(me)
6060

61-
if self.align_uv == 'MIN_U':
62-
min_u = min([bbox[0][0] for bbox in bboxes])
61+
elif self.align_uv == 'MIN_U':
62+
min_u = min(bbox[0][0] for bbox in bboxes)
6363
for ob in context.objects_in_mode_unique_data:
6464
seams = objects_seams[ob]
6565
me = ob.data
6666
bm = bmesh.from_edit_mesh(me)
6767
uv = bm.loops.layers.uv.verify()
68-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
68+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
6969
bbox = get_bbox(uv, island)
7070
bbox_min_u = bbox[0][0]
7171
distance = bbox_min_u - min_u
@@ -76,14 +76,14 @@ def align_islands(self, context):
7676
l[uv].uv = new_co
7777
bmesh.update_edit_mesh(me)
7878

79-
if self.align_uv == 'MAX_V':
80-
max_v = max([bbox[1][1] for bbox in bboxes])
79+
elif self.align_uv == 'MAX_V':
80+
max_v = max(bbox[1][1] for bbox in bboxes)
8181
for ob in context.objects_in_mode_unique_data:
8282
seams = objects_seams[ob]
8383
me = ob.data
8484
bm = bmesh.from_edit_mesh(me)
8585
uv = bm.loops.layers.uv.verify()
86-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
86+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
8787
bbox = get_bbox(uv, island)
8888
bbox_max_v = bbox[1][1]
8989
distance = max_v - bbox_max_v
@@ -94,14 +94,14 @@ def align_islands(self, context):
9494
l[uv].uv = new_co
9595
bmesh.update_edit_mesh(me)
9696

97-
if self.align_uv == 'MIN_V':
98-
min_v = min([bbox[0][1] for bbox in bboxes])
97+
elif self.align_uv == 'MIN_V':
98+
min_v = min(bbox[0][1] for bbox in bboxes)
9999
for ob in context.objects_in_mode_unique_data:
100100
seams = objects_seams[ob]
101101
me = ob.data
102102
bm = bmesh.from_edit_mesh(me)
103103
uv = bm.loops.layers.uv.verify()
104-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
104+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
105105
bbox = get_bbox(uv, island)
106106
bbox_min_v = bbox[0][1]
107107
distance = bbox_min_v - min_v
@@ -121,10 +121,11 @@ def align_vertices(self, context):
121121
uv = bm.loops.layers.uv.verify()
122122

123123
for f in bm.faces:
124-
if f.select:
125-
for l in f.loops:
126-
if l[uv].select:
127-
coords.append(l[uv].uv[:])
124+
if not f.select:
125+
continue
126+
for l in f.loops:
127+
if l.uv_select_edge:
128+
coords.append(l[uv].uv[:])
128129

129130
if not coords:
130131
return {'CANCELED'}
@@ -135,44 +136,53 @@ def align_vertices(self, context):
135136
uv = bm.loops.layers.uv.verify()
136137

137138
if self.align_uv == 'MAX_U':
138-
u = max([uv[0] for uv in coords])
139+
u = max(uv[0] for uv in coords)
139140
for f in bm.faces:
140-
if f.select:
141-
for l in f.loops:
142-
if l[uv].select:
143-
for l in l.vert.link_loops:
144-
if l[uv].select:
145-
l[uv].uv[0] = u
146-
147-
if self.align_uv == 'MIN_U':
148-
u = min([uv[0] for uv in coords])
141+
if not f.select:
142+
continue
143+
for l in f.loops:
144+
if not l.uv_select_edge:
145+
continue
146+
for l in l.vert.link_loops:
147+
if l.uv_select_edge:
148+
l[uv].uv[0] = u
149+
150+
elif self.align_uv == 'MIN_U':
151+
u = min(uv[0] for uv in coords)
149152
for f in bm.faces:
150-
if f.select:
151-
for l in f.loops:
152-
if l[uv].select:
153-
for l in l.vert.link_loops:
154-
if l[uv].select:
155-
l[uv].uv[0] = u
156-
157-
if self.align_uv == 'MAX_V':
158-
v = max([uv[1] for uv in coords])
153+
if not f.select:
154+
continue
155+
for l in f.loops:
156+
if not l.uv_select_edge:
157+
continue
158+
for l in l.vert.link_loops:
159+
if l.uv_select_edge:
160+
l[uv].uv[0] = u
161+
162+
elif self.align_uv == 'MAX_V':
163+
v = max(uv[1] for uv in coords)
159164
for f in bm.faces:
160-
if f.select:
161-
for l in f.loops:
162-
if l[uv].select:
163-
for l in l.vert.link_loops:
164-
if l[uv].select:
165-
l[uv].uv[1] = v
166-
167-
if self.align_uv == 'MIN_V':
168-
v = min([uv[1] for uv in coords])
165+
if not f.select:
166+
continue
167+
for l in f.loops:
168+
if not l.uv_select_edge:
169+
continue
170+
for l in l.vert.link_loops:
171+
if l.uv_select_edge:
172+
l[uv].uv[1] = v
173+
174+
elif self.align_uv == 'MIN_V':
175+
v = min(uv[1] for uv in coords)
169176
for f in bm.faces:
170-
if f.select:
171-
for l in f.loops:
172-
if l[uv].select:
173-
for l in l.vert.link_loops:
174-
if l[uv].select:
175-
l[uv].uv[1] = v
177+
if not f.select:
178+
continue
179+
for l in f.loops:
180+
if not l.uv_select_edge:
181+
continue
182+
for l in l.vert.link_loops:
183+
if l.uv_select_edge:
184+
l[uv].uv[1] = v
185+
176186
bmesh.update_edit_mesh(me)
177187

178188
def execute(self, context):

operators/distribute.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def execute(self, context):
247247
for f in bm.faces:
248248
if f.select:
249249
for l in f.loops:
250-
if l[uv].select:
250+
if l.uv_select_edge:
251251
loops.add(l)
252252

253253
uv_edge_loops = get_sorted_uv_edge_loops(uv, loops)

operators/find_shattered_islands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class FindShatteredIslands(Operator):
1717
min=1,
1818
default=3
1919
)
20-
20+
2121
pin: BoolProperty(
2222
name="Pin to Corner",
2323
description="Move and pin islands to the top-left corner within UV space\n(handy for testing your workflow under ideal conditions)",
@@ -53,11 +53,11 @@ def execute(self, context):
5353
face.select = True
5454
for loop in face.loops:
5555
if not use_uv_select_sync:
56-
loop[uv_layer].select = True
56+
loop.uv_select_edge_set(True)
5757
if self.pin:
5858
loop[uv_layer].uv = (0, 1)
5959
loop[uv_layer].pin_uv = True
60-
60+
6161
bmesh.update_edit_mesh(ob.data)
6262
bm.free()
6363
return {'FINISHED'}

operators/find_udim_crossing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ def execute(self, context):
4646
bm = bmesh.from_edit_mesh(me)
4747
uv = bm.loops.layers.uv.verify()
4848

49-
deselect_all_loops_uv(uv, bm)
49+
deselect_all_loops_uv(bm)
5050

5151
if uv_sync_status:
5252
select_all_faces(bm)
5353

54-
for island in get_islands(uv, bm, seams):
54+
for island in get_islands(bm, seams):
5555
bbox = get_bbox(uv, island)
5656
bbox_u1, bbox_v1 = bbox[0][0], bbox[0][1]
5757
bbox_u2, bbox_v2 = bbox[1][0], bbox[1][1]
@@ -70,7 +70,7 @@ def execute(self, context):
7070

7171
for f in island:
7272
for l in f.loops:
73-
l[uv].select = True
73+
l.uv_select_edge_set(True)
7474
islands_count += 1
7575

7676
bmesh.update_edit_mesh(me)

operators/fit_to_bounds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def execute(self, context):
5151
bm = bmesh.from_edit_mesh(me)
5252
uv = bm.loops.layers.uv.verify()
5353

54-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
54+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
5555
bbox = get_bbox(uv, island)
5656
bbox_center_u, bbox_center_v = calc_bbox_center(bbox)
5757
bbox_width, bbox_height = get_bbox_size(bbox)

operators/invert_selection.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ def execute(self, context):
5151

5252
me = ob.data
5353
bm = bmesh.from_edit_mesh(me)
54-
uv = bm.loops.layers.uv.verify()
54+
bm.loops.layers.uv.verify()
5555

56-
loops = create_list_of_loops_from_uv_selection(uv, bm.faces)
56+
loops = create_list_of_loops_from_uv_selection(bm.faces)
5757

5858
bpy.ops.uv.select_linked()
5959

6060
for l in loops:
61-
l[uv].select = False
61+
l.uv_select_edge_set(False)
6262

6363
bpy.ops.object.mode_set(mode='OBJECT')
6464
ob.select_set(False)

operators/match_islands.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def execute(self, context):
103103
bm = bmesh.from_edit_mesh(me)
104104
uv = bm.loops.layers.uv.verify()
105105

106-
for target_island in get_islands(uv, bm, seams, has_selected_faces=True):
106+
for target_island in get_islands(bm, seams, has_selected_faces=True):
107107
target_island_found = True
108108
break
109109
if target_island_found:
@@ -139,11 +139,11 @@ def execute(self, context):
139139
bm = bmesh.from_edit_mesh(me)
140140
uv = bm.loops.layers.uv.verify()
141141

142-
for island in get_islands(uv, bm, seams):
142+
for island in get_islands(bm, seams):
143143
island_has_selection = False
144144
for f in island:
145145
for l in f.loops:
146-
if l[uv].select:
146+
if l.uv_select_edge:
147147
island_has_selection = True
148148
if island_has_selection:
149149
break

operators/orient_islands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def execute(self, context):
9393
bm = bmesh.from_edit_mesh(me)
9494
uv = bm.loops.layers.uv.verify()
9595

96-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
96+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
9797
uv_edges_co = self.get_uv_edges_coordinates(uv, island)
9898
uv_edges_angles = self.collect_uv_edges_angles(context, uv_edges_co)
9999
rotation_angle = self.get_rotation_angle(uv_edges_angles)

operators/orient_to_edge.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def execute(self, context):
3737
bm = bmesh.from_edit_mesh(me)
3838
uv = bm.loops.layers.uv.verify()
3939

40-
for island in get_islands(uv, bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
40+
for island in get_islands(bm, seams, has_selected_faces=True, islands_with_hidden_faces=False):
4141
selected_uv_verts_co = {l[uv].uv.copy().freeze()
4242
for f in island
4343
for l in f.loops
44-
if l[uv].select}
44+
if l.uv_select_edge}
4545
if not len(selected_uv_verts_co) >= 2:
4646
continue
4747

0 commit comments

Comments
 (0)