3
11

io_scene_3ds: cleanup texture handling #10

Merged
Sebastian Sille merged 5 commits from :main into main 2023-02-28 18:43:57 +01:00
Showing only changes of commit cf96645043 - Show all commits

View File

@ -323,7 +323,7 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SE
contextMesh_smooth = None
contextMeshUV = None
TEXTURE_DICT = {}
#TEXTURE_DICT = {}
MATDICT = {}
# Localspace variable names, faster.
@ -379,23 +379,19 @@ def process_next_chunk(context, file, previous_chunk, imported_objects, IMAGE_SE
else:
bmat = MATDICT.get(matName)
# in rare cases no materials defined.
if bmat:
img = TEXTURE_DICT.get(bmat.name)
else:
print(" warning: material %r not defined!" % matName)
bmat = MATDICT[matName] = bpy.data.materials.new(matName)
img = None
bmesh.materials.append(bmat) # can be None
for fidx in faces:
bmesh.polygons[fidx].material_index = mat_idx
if uv_faces and img:
for fidx in faces:
bmesh.polygons[fidx].material_index = mat_idx
# TODO: How to restore this?
# uv_faces[fidx].image = img
else:
for fidx in faces:
bmesh.polygons[fidx].material_index = mat_idx
# if uv_faces and img:
# for fidx in faces:
# bmesh.polygons[fidx].material_index = mat_idx
# # TODO: How to restore this?
# # uv_faces[fidx].image = img
# else:
# for fidx in faces:
# bmesh.polygons[fidx].material_index = mat_idx
if uv_faces:
uvl = bmesh.uv_layers.active.data[:]