UV Export: add option to export UV tiles #104940
@ -60,9 +60,9 @@ class ExportUVLayout(bpy.types.Operator):
|
||||
('NONE', "None",
|
||||
"Export only UVs in the [0, 1] range"),
|
||||
('UDIM', "UDIM",
|
||||
"Export tiles in the UDIM notation: 1001 + u-tile + 10*v-tile"),
|
||||
('UV', "UV Tiles",
|
||||
"Export tiles in the UV notation: u(u-tile + 1)_v(v-tile + 1)"),
|
||||
"Export tiles in the UDIM numbering scheme: 1001 + u-tile + 10*v-tile"),
|
||||
('UV', "UVTILE",
|
||||
"Export tiles in the UVTILE numbering scheme: u(u-tile + 1)_v(v-tile + 1)"),
|
||||
),
|
||||
description="Choose whether to export only the [0, 1 range], or all UV tiles",
|
||||
default='NONE',
|
||||
@ -165,7 +165,7 @@ class ExportUVLayout(bpy.types.Operator):
|
||||
if match:
|
||||
filename = match.groups()[0]
|
||||
|
||||
for tile in tiles:
|
||||
for tile in sorted(tiles):
|
||||
filepath = os.path.join(dirname, filename)
|
||||
if self.export_tiles == 'UDIM':
|
||||
filepath += f".{1001 + tile[0] + tile[1] * 10:04}"
|
||||
@ -210,7 +210,16 @@ class ExportUVLayout(bpy.types.Operator):
|
||||
tiles = set()
|
||||
for poly in polygon_data:
|
||||
for uv in poly[0]:
|
||||
tiles.add((floor(uv[0]), floor(uv[1])))
|
||||
# Ignore UVs at corners - precisely touching the right or upper edge
|
||||
# of a tile should not load its right/upper neighbor as well.
|
||||
# From intern/cycles/scene/attribute.cpp
|
||||
u, v = (uv[0], uv[1])
|
||||
x, y = (floor(u), floor(v))
|
||||
if (x > 0 and (u < x + 1e-6)):
|
||||
x -= 1
|
||||
if (y > 0 and (v < y + 1e-6)):
|
||||
y -= 1
|
||||
tiles.add((x, y))
|
||||
return tiles
|
||||
|
||||
@staticmethod
|
||||
|
Loading…
Reference in New Issue
Block a user