diff --git a/src/operators/bake_to_id_map.py b/src/operators/bake_to_id_map.py index a4462e7..06f3051 100644 --- a/src/operators/bake_to_id_map.py +++ b/src/operators/bake_to_id_map.py @@ -3,7 +3,8 @@ import math import bpy -from .. types import (get_source, get_target) +from .. types.sources import get_source +from .. types.targets import get_target class BakeToIDMapOperator(bpy.types.Operator): diff --git a/src/panels/panel_info.py b/src/panels/panel_info.py index ebcfa70..808a5bc 100644 --- a/src/panels/panel_info.py +++ b/src/panels/panel_info.py @@ -1,7 +1,6 @@ import bpy -from .. operators.bake_to_id_map import BakeToIDMapOperator -from ..types import get_source +from .. types.sources import get_source class BakeToIDInfoPanel(bpy.types.Panel): diff --git a/src/panels/panel_options.py b/src/panels/panel_options.py index 0042ba6..0da5b42 100644 --- a/src/panels/panel_options.py +++ b/src/panels/panel_options.py @@ -2,7 +2,8 @@ import textwrap import bpy -from src.types import get_source, get_target +from .. types.sources import get_source +from .. types.targets import get_target class BakeToIDOptionsPanel(bpy.types.Panel): @@ -22,14 +23,17 @@ class BakeToIDOptionsPanel(bpy.types.Panel): layout.prop(props, "source") source = get_source(props.source) - source_settings_box = layout.box() - for setting in source.connected_properties: - source_settings_box.prop(props, setting) + + if len(source.connected_properties) > 0: + source_settings_box = layout.box() + for setting in source.connected_properties: + source_settings_box.prop(props, setting) layout.separator() layout.prop(props, "target") target = get_target(props.target) - target_settings_box = layout.box() - for setting in target.connected_properties: - target_settings_box.prop(props, setting) + if len(target.connected_properties) > 0: + target_settings_box = layout.box() + for setting in target.connected_properties: + target_settings_box.prop(props, setting) diff --git a/src/properties/bake_to_id.py b/src/properties/bake_to_id.py index bab3b6d..b777c0f 100644 --- a/src/properties/bake_to_id.py +++ b/src/properties/bake_to_id.py @@ -1,7 +1,8 @@ from bpy.types import (PropertyGroup) from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty) -from src.types import get_source_enum, get_targets_enum +from src.types.sources import get_source_enum +from src.types.targets import get_targets_enum class BakeToIDProperties(PropertyGroup): @@ -21,8 +22,8 @@ class BakeToIDProperties(PropertyGroup): name="Source", description="From where should the IDs be taken", default="MATERIAL_INDEX" - ) + target: EnumProperty( items=get_targets_enum(), name="Target", @@ -30,7 +31,7 @@ class BakeToIDProperties(PropertyGroup): default=get_targets_enum()[0][0] ) - source_materials_remove_all : BoolProperty( + source_materials_remove_all: BoolProperty( name="Remove all source materials", default=False, description="Removes every material except the first one." diff --git a/src/types/__init__.py b/src/types/__init__.py index 58a175e..e69de29 100644 --- a/src/types/__init__.py +++ b/src/types/__init__.py @@ -1,45 +0,0 @@ -from . sources import material_index as source_mat_index -from . sources import object as source_object - -from . targets import vertex_colors as target_vertex_colors - -_sources = [ - source_mat_index, - source_object -] - -_targets = [ - target_vertex_colors -] - -def get_source(id): - for source in _sources: - if source.source_id == id: - return source - - raise Exception("Source not found: " + id) - -def get_target(id): - for target in _targets: - if target.target_id == id: - return target - - raise Exception("Target not found: " + id) - -def get_source_enum(): - enumList = [] - i = 0 - for source in _sources: - enumList.append((source.source_id, source.name, source.description, i)) - i += 1 - - return enumList - -def get_targets_enum(): - enumList = [] - i = 0 - for target in _targets: - enumList.append((target.target_id, target.name, target.description, i)) - i += 1 - - return enumList diff --git a/src/types/sources/__init__.py b/src/types/sources/__init__.py new file mode 100644 index 0000000..f52c397 --- /dev/null +++ b/src/types/sources/__init__.py @@ -0,0 +1,25 @@ +from . import material_index +from . import object + +_sources = [ + material_index, + object +] + +def get_source(id): + for source in _sources: + if source.source_id == id: + return source + + raise Exception("Source not found: " + id) + + +def get_source_enum(): + enum_list = [] + i = 0 + for source in _sources: + enum_list.append((source.source_id, source.name, source.description, i)) + i += 1 + + return enum_list + diff --git a/src/types/targets/__init__.py b/src/types/targets/__init__.py new file mode 100644 index 0000000..95c7908 --- /dev/null +++ b/src/types/targets/__init__.py @@ -0,0 +1,23 @@ +from . import vertex_colors + +_targets = [ + vertex_colors +] + + +def get_target(id): + for target in _targets: + if target.target_id == id: + return target + + raise Exception("Target not found: " + id) + + +def get_targets_enum(): + enum_list = [] + i = 0 + for target in _targets: + enum_list.append((target.target_id, target.name, target.description, i)) + i += 1 + + return enum_list