From 9765e28786f96ca662e22f28d33cd16bc32b6cf4 Mon Sep 17 00:00:00 2001 From: Michel Fedde <35878897+Neintonine@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:00:03 +0100 Subject: [PATCH] adds object as source --- build/.version | 2 +- src/operators/bake_to_id_map.py | 3 ++- src/types/__init__.py | 4 +++- src/types/sources/object.py | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 src/types/sources/object.py diff --git a/build/.version b/build/.version index 155f135..d4d0d90 100644 --- a/build/.version +++ b/build/.version @@ -1 +1 @@ -1.0.0+build.18 \ No newline at end of file +1.1.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 dcd6643..5da24f8 100644 --- a/src/operators/bake_to_id_map.py +++ b/src/operators/bake_to_id_map.py @@ -50,4 +50,5 @@ class BakeToIDMapOperator(bpy.types.Operator): target = get_target(props.target) target.paint_targets(props, targets, colors) - source.after_painting(context, props) \ No newline at end of file + if 'after_painting' in dir(source): + source.after_painting(context, props) \ No newline at end of file diff --git a/src/types/__init__.py b/src/types/__init__.py index c814b4c..58a175e 100644 --- a/src/types/__init__.py +++ b/src/types/__init__.py @@ -1,9 +1,11 @@ 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_mat_index, + source_object ] _targets = [ diff --git a/src/types/sources/object.py b/src/types/sources/object.py new file mode 100644 index 0000000..d7e07e0 --- /dev/null +++ b/src/types/sources/object.py @@ -0,0 +1,16 @@ +source_id = 'OBJECT' +name = 'Object ID' +description = 'Uses the object id as basis for the ID mask.' + +connected_properties = [] + +def get_targets(context): + targets = [] + for obj in context.selected_objects: + mesh = obj.data + targets.append((mesh, mesh.polygons)) + + return targets + +def estimate_ids(context, props): + return len(context.selected_objects) \ No newline at end of file