Got images working
- does not do UVs yet - is able to pack images using a split algorithm. I think I broke the size finding though for the output canvas. - does not combine materials after packing
This commit is contained in:
+25
-17
@@ -6,13 +6,18 @@ from bpy.utils import register_class
|
||||
|
||||
|
||||
class material_list_bool:
|
||||
old_list: list[Material] = []
|
||||
bool_material_list_expand: bool = False
|
||||
#For the love that is holy do not ever touch these. If this was java I would make these private
|
||||
#They should only be accessed via context.scene.texture_atlas_Has_Mat_List_Shown
|
||||
#This is so we know if the materials are up to date. messing with these variables directly will make the thing blow up.
|
||||
|
||||
#The only exception to this is the ExpandSection_Materials operator which populates this with new data once the materials have changed and need reloading.
|
||||
old_list: dict[str,list[Material]] = {}
|
||||
bool_material_list_expand: dict[str,bool] = {}
|
||||
|
||||
def set_bool(self, value: bool) -> None:
|
||||
material_list_bool.bool_material_list_expand = value
|
||||
material_list_bool.bool_material_list_expand[bpy.context.scene.name] = value
|
||||
if value == False:
|
||||
material_list_bool.old_list = []
|
||||
material_list_bool.old_list[bpy.context.scene.name] = []
|
||||
|
||||
def get_bool(self) -> bool:
|
||||
newlist: list[Material] = []
|
||||
@@ -24,18 +29,20 @@ class material_list_bool:
|
||||
newlist.append(mat_slot.material)
|
||||
|
||||
still_the_same: bool = True
|
||||
for item in newlist:
|
||||
if item not in material_list_bool.old_list:
|
||||
still_the_same = False
|
||||
break
|
||||
for item in material_list_bool.old_list:
|
||||
if item not in newlist:
|
||||
still_the_same = False
|
||||
break
|
||||
|
||||
material_list_bool.bool_material_list_expand = still_the_same
|
||||
if bpy.context.scene.name in material_list_bool.old_list:
|
||||
for item in newlist:
|
||||
if item not in material_list_bool.old_list[bpy.context.scene.name]:
|
||||
still_the_same = False
|
||||
break
|
||||
for item in material_list_bool.old_list[bpy.context.scene.name]:
|
||||
if item not in newlist:
|
||||
still_the_same = False
|
||||
break
|
||||
else:
|
||||
still_the_same = False
|
||||
material_list_bool.bool_material_list_expand[bpy.context.scene.name] = still_the_same
|
||||
|
||||
return material_list_bool.bool_material_list_expand
|
||||
return material_list_bool.bool_material_list_expand[bpy.context.scene.name]
|
||||
|
||||
class SceneMatClass(PropertyGroup):
|
||||
mat: PointerProperty(type=Material)
|
||||
@@ -48,7 +55,7 @@ def register_properties():
|
||||
#happy with how compressed this get_texture_node_list method is - @989onan
|
||||
def get_texture_node_list(self: Material, context: Context) -> list[set[3]]:
|
||||
if self.use_nodes:
|
||||
Object.Enum = [(i.name+"_image",(i.image.name if i.image else "node with no image..."),i.name,index+1) for index,i in enumerate(self.node_tree.nodes) if i.bl_idname == "ShaderNodeTexImage"]
|
||||
Object.Enum = [((i.image.name if i.image else i.name+"_image"),(i.image.name if i.image else "node with no image..."),(i.image.name if i.image else i.name),index+1) for index,i in enumerate(self.node_tree.nodes) if i.bl_idname == "ShaderNodeTexImage"]
|
||||
if not len(Object.Enum):
|
||||
Object.Enum = [("ERROR", "THIS MATERIAL HAS NO IMAGES!", "ERROR", 0)]
|
||||
else:
|
||||
@@ -57,8 +64,9 @@ def register_properties():
|
||||
return Object.Enum
|
||||
|
||||
|
||||
Material.texture_atlas_normal = EnumProperty(name="Normal", description="The texture that will be used for the normal map atlas", default=0, items=get_texture_node_list)
|
||||
|
||||
Material.texture_atlas_albedo = EnumProperty(name="Albedo", description="The texture that will be used for the albedo map atlas", default=0, items=get_texture_node_list)
|
||||
Material.texture_atlas_normal = EnumProperty(name="Normal", description="The texture that will be used for the normal map atlas", default=0, items=get_texture_node_list)
|
||||
Material.texture_atlas_emission = EnumProperty(name="Emission", description="The texture that will be used for the emission map atlas", default=0, items=get_texture_node_list)
|
||||
Material.texture_atlas_ambient_occlusion = EnumProperty(name="Ambient Occlusion", description="The texture that will be used for the ambient occlusion map atlas", default=0, items=get_texture_node_list)
|
||||
Material.texture_atlas_height = EnumProperty(name="Height", description="The texture that will be used for the height map atlas", default=0, items=get_texture_node_list)
|
||||
|
||||
Reference in New Issue
Block a user