diff --git a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py index 341d2b107..84d8454ad 100644 --- a/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py +++ b/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py @@ -654,11 +654,16 @@ def manage_material_info(self): for u in range(u_tiles): for v in range(v_tiles): - if u != u_tiles - 1 and v != v_tiles - 1: + # Check if this tile exists + if int("10" + str(v) + str(u+1)) not in tiles: + continue + + # Manage tile limits (inclusive or not), avoiding to have the same vertex in two tiles, if the vertex is on the limit + if int("10" + str(v) + str(u+1+1)) in tiles and int("10" + str(v+1) + str(u+1)) in tiles: indices = np.where((self.dots[uvmap_name + '0'] >= u) & (self.dots[uvmap_name + '0'] < (u + 1)) & (self.dots[uvmap_name + '1'] <= (1-v) ) & (self.dots[uvmap_name + '1'] > 1-(v + 1)))[0] - elif u == u_tiles - 1 and v != v_tiles - 1: + elif int("10" + str(v) + str(u+1+1)) not in tiles and int("10" + str(v+1) + str(u+1)) in tiles: indices = np.where((self.dots[uvmap_name + '0'] >= u) & (self.dots[uvmap_name + '0'] <= (u + 1)) & (self.dots[uvmap_name + '1'] <= (1-v) ) & (self.dots[uvmap_name + '1'] > 1-(v + 1)))[0] - elif u != u_tiles -1 and v == v_tiles - 1: + elif int("10" + str(v) + str(u+1+1)) in tiles and int("10" + str(v+1) + str(u+1)) not in tiles: indices = np.where((self.dots[uvmap_name + '0'] >= u) & (self.dots[uvmap_name + '0'] < (u + 1)) & (self.dots[uvmap_name + '1'] <= (1-v) ) & (self.dots[uvmap_name + '1'] >= 1-(v + 1)))[0] else: indices = np.where((self.dots[uvmap_name + '0'] >= u) & (self.dots[uvmap_name + '0'] <= (u + 1)) & (self.dots[uvmap_name + '1'] <= (1-v) ) & (self.dots[uvmap_name + '1'] >= 1-(v + 1)))[0]