diff --git a/build/.version b/build/.version index d4d0d90..a2eca58 100644 --- a/build/.version +++ b/build/.version @@ -1 +1 @@ -1.1.0+build.1 \ No newline at end of file +1.2.0+build.1 \ No newline at end of file diff --git a/src/operators/bake_to_id_map.py b/src/operators/bake_to_id_map.py index 6751d5b..8446d06 100644 --- a/src/operators/bake_to_id_map.py +++ b/src/operators/bake_to_id_map.py @@ -47,7 +47,8 @@ class BakeToIDMapOperator(bpy.types.Operator): return source.get_targets([context.active_object]) if props.selection_mode == 'MULTIPLE_COMBINED': - return source.get_targets(context.selected_objects) + filtered_object = filter(lambda x: x.type == 'MESH', context.selected_objects) + return source.get_targets(list(filtered_object)) if props.selection_mode == 'MULTIPLE_SEPARATE': result = [] diff --git a/src/panels/panel_options.py b/src/panels/panel_options.py index bc92db5..f219d08 100644 --- a/src/panels/panel_options.py +++ b/src/panels/panel_options.py @@ -2,6 +2,7 @@ import textwrap import bpy +from ..types.colors import get_color from .. types.sources import get_source from .. types.targets import get_target @@ -23,21 +24,33 @@ class BakeToIDOptionsPanel(bpy.types.Panel): layout.prop(props, "source") source = get_source(props.source) - - if len(source.connected_properties) > 0: - source_settings_box = layout.box() - for setting in source.connected_properties: - source_settings_box.prop(props, setting) + self.draw_options(context, layout, props, source) layout.separator() layout.prop(props, "target") target = get_target(props.target) - if len(target.connected_properties) > 0: - target_settings_box = layout.box() - for setting in target.connected_properties: - target_settings_box.prop(props, setting) + self.draw_options(context, layout, props, target) layout.separator() layout.prop(props, "colors") + color = get_color(props.colors) + self.draw_options(context, layout, props, color) + + def draw_options(self, context, layout, props, element): + + has_render_ui = 'render_ui' in dir(element) + has_connected_properties = 'connected_properties' in dir(element) and len(element.connected_properties) > 0 + + if not has_render_ui and not has_connected_properties: + return + + object_box = layout.box() + + if has_render_ui: + element.render_ui(context, object_box, props) + return + + for setting in element.connected_properties: + object_box.prop(props, setting) \ No newline at end of file diff --git a/src/properties/bake_to_id.py b/src/properties/bake_to_id.py index 813c9d0..4b9d030 100644 --- a/src/properties/bake_to_id.py +++ b/src/properties/bake_to_id.py @@ -1,5 +1,5 @@ -from bpy.types import (PropertyGroup) -from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty) +from bpy.types import (PropertyGroup, Palette) +from bpy.props import (EnumProperty, BoolProperty, IntProperty, StringProperty, PointerProperty) from src.types.colors import get_color_enum from src.types.sources import get_source_enum @@ -55,23 +55,8 @@ class BakeToIDProperties(PropertyGroup): description="If set true, the attribute will be deleted and recreated, if it already exists. If set false, the data will just be overwritten." ) - adv_total_hues: IntProperty( - name="Total Hues", - default=10, - min=1, - soft_max=360, - ) - - adv_total_satuations: IntProperty( - name="Total Satuations", - default=10, - min=1, - soft_max=100, - ) - - adv_total_brightnesses: IntProperty( - name="Total Brightnesses", - default=10, - min=1, - soft_max=100, + colors_color_palette_palette: PointerProperty( + type=Palette, + name='Color Palette', + description="The Color Palette used for colors" ) \ No newline at end of file diff --git a/src/types/colors/__init__.py b/src/types/colors/__init__.py index 81f5434..82e0530 100644 --- a/src/types/colors/__init__.py +++ b/src/types/colors/__init__.py @@ -1,7 +1,8 @@ -from . import generated +from . import generated, color_palette _colors = [ - generated + generated, + color_palette ] diff --git a/src/types/colors/color_palette.py b/src/types/colors/color_palette.py new file mode 100644 index 0000000..078078a --- /dev/null +++ b/src/types/colors/color_palette.py @@ -0,0 +1,25 @@ +color_id = 'COLOR_PALETTE' +name = 'Palette' +description = "The color palette is specified by the user" + + +def get_colors(props): + if not props.colors_color_palette_palette: + return [] + + return list(map(lambda x: x.color, props.colors_color_palette_palette.colors)) + + +def get_count(props): + if not props.colors_color_palette_palette: + return 0 + + return len(props.colors_color_palette_palette.colors) + + +def render_ui(context, layout, props): + layout.template_ID(props, "colors_color_palette_palette") + if props.colors_color_palette_palette: + row = layout.column() + row.enabled = False + row.template_palette(props, "colors_color_palette_palette", color=True) diff --git a/src/types/colors/generated.py b/src/types/colors/generated.py index 91e7134..11488e6 100644 --- a/src/types/colors/generated.py +++ b/src/types/colors/generated.py @@ -1,5 +1,4 @@ import colorsys -import math color_id = 'GENERATED' name = 'Generated'