code tweaks and clean up --BigRoy's comment

This commit is contained in:
Kayla Man 2024-05-28 20:08:11 +08:00
parent 9f09b750e1
commit 0ebda1d45c
3 changed files with 42 additions and 49 deletions

View file

@ -13,43 +13,6 @@ import substance_painter.export
from qtpy import QtGui, QtWidgets, QtCore
def get_channel_map_enum():
"""Function to get channel map items value.
For backward compatibility only. Will be removed after
client addon migration
"""
return {
"BaseColor": "Base Color",
"Metallic": "Metallic",
"Roughness": "Roughness",
"SpecularEdgeColor": "Specular Edge Color",
"Emissive": "Emissive",
"Opacity": "Opacity",
"Displacement": "Displacement",
"Glossiness": "Glossiness",
"Anisotropylevel": "Anisotropy Level",
"AO": "Ambient Occulsion",
"Anisotropyangle": "Anisotropy Angle",
"Transmissive": "Transmissive",
"Reflection": "Reflection",
"Diffuse": "Diffuse",
"Ior": "Index of Refraction",
"Specularlevel": "Specular Level",
"BlendingMask": "Blending Mask",
"Translucency": "Translucency",
"Scattering": "Scattering",
"ScatterColor": "Scatter Color",
"SheenOpacity": "Sheen Opacity",
"SheenRoughness": "Sheen Roughness",
"SheenColor": "Sheen Color",
"CoatOpacity": "Coat Opacity",
"CoatColor": "Coat Color",
"CoatRoughness": "Coat Roughness",
"CoatSpecularLevel": "Coat Specular Level",
"CoatNormal": "Coat Normal",
}
def get_export_presets():
"""Return Export Preset resource URLs for all available Export Presets.
@ -731,8 +694,9 @@ def set_layer_stack_opacity(node_ids, channel_types):
"""Function to set the opacity of the layer stack during
context
Args:
node_ids (list): A list of substance painter node ids
channel_types (list): A list of channel types
node_ids (list[int]): Substance painter root layer node ids
channel_types (list[str]): Channel type names as defined as
attributes in `substance_painter.textureset.ChannelType`
"""
# Do nothing
if not node_ids or not channel_types:
@ -747,8 +711,11 @@ def set_layer_stack_opacity(node_ids, channel_types):
for node_id in node_ids:
node = substance_painter.layerstack.get_node_by_uid(int(node_id))
all_selected_nodes.append(node)
excluded_nodes = {node for node in stack_root_layers
if node not in all_selected_nodes}
node_ids = set(node_ids) # lookup
excluded_nodes = [
node for node in stack_root_layers
if node.uid() not in node_ids
]
original_opacity_values = []
for node in excluded_nodes:

View file

@ -15,8 +15,7 @@ from ayon_core.hosts.substancepainter.api.pipeline import (
remove_instance
)
from ayon_core.hosts.substancepainter.api.lib import (
get_export_presets,
get_channel_map_enum
get_export_presets
)
import substance_painter
@ -113,7 +112,36 @@ class CreateTextures(Creator):
for item in self.channel_mapping
}
else:
export_channel_enum = get_channel_map_enum()
export_channel_enum = {
"BaseColor": "Base Color",
"Metallic": "Metallic",
"Roughness": "Roughness",
"SpecularEdgeColor": "Specular Edge Color",
"Emissive": "Emissive",
"Opacity": "Opacity",
"Displacement": "Displacement",
"Glossiness": "Glossiness",
"Anisotropylevel": "Anisotropy Level",
"AO": "Ambient Occulsion",
"Anisotropyangle": "Anisotropy Angle",
"Transmissive": "Transmissive",
"Reflection": "Reflection",
"Diffuse": "Diffuse",
"Ior": "Index of Refraction",
"Specularlevel": "Specular Level",
"BlendingMask": "Blending Mask",
"Translucency": "Translucency",
"Scattering": "Scattering",
"ScatterColor": "Scatter Color",
"SheenOpacity": "Sheen Opacity",
"SheenRoughness": "Sheen Roughness",
"SheenColor": "Sheen Color",
"CoatOpacity": "Coat Opacity",
"CoatColor": "Coat Color",
"CoatRoughness": "Coat Roughness",
"CoatSpecularLevel": "Coat Specular Level",
"CoatNormal": "Coat Normal",
}
return [
EnumDef("exportChannel",

View file

@ -114,7 +114,6 @@ class ValidateOutputMaps(pyblish.api.InstancePlugin):
title="Missing output maps"
)
def get_invalid_channels(self, instance, config):
"""Function to get invalid channel(s) from export channel
filtering
@ -144,12 +143,11 @@ class ValidateOutputMaps(pyblish.api.InstancePlugin):
map_names = [channel_map["fileName"] for channel_map
in export_preset["maps"]]
for channel in tmp_export_channel:
found = False
# Check if channel is found in at least one map
for map_name in map_names:
if channel in map_name:
found = True
break # Exit the inner loop once a match is found
if not found:
break
else:
invalid_channel.append(channel)
return invalid_channel