diff --git a/src/__init__.py b/src/__init__.py index 1319577..65b5393 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -3,7 +3,7 @@ bl_info = { "author": "iedSoftworks", "description": "", # !VERSION - "blender": (2, 80, 0), + "blender": (2, 92, 0), "category": "Object" } diff --git a/src/properties/bake_to_id.py b/src/properties/bake_to_id.py index 77978eb..019941a 100644 --- a/src/properties/bake_to_id.py +++ b/src/properties/bake_to_id.py @@ -16,7 +16,7 @@ class BakeToIDProperties(PropertyGroup): items=get_targets_enum(), name="Target", description="To where should the IDs should be baked to", - default="VERTEX_COLORS" + default=get_targets_enum()[0][0] ) source_materials_remove_all : BoolProperty( diff --git a/src/types/targets/vertex_colors.py b/src/types/targets/vertex_colors.py index 6b6340d..f77a718 100644 --- a/src/types/targets/vertex_colors.py +++ b/src/types/targets/vertex_colors.py @@ -1,6 +1,6 @@ -target_id = 'VERTEX_COLORS' -name = 'Vertex Colors' -description = 'Bakes the ID onto the vertex color' +target_id = 'COLOR_ATTRIBUTE' +name = 'Color Attribute / Vertex Color' +description = 'Bakes the ID onto a color attribute (previously known as Vertex Color)' connected_properties = [ 'target_vertex_color_attribute_name' @@ -8,25 +8,25 @@ connected_properties = [ def paint_targets(props, targets, colors): - sortedTargets = {} + sorted_targets = {} for i in range(len(targets)): target = targets[i] obj = target[0] indecies = target[1] - if obj not in sortedTargets: - sortedTargets[obj] = [] + if obj not in sorted_targets: + sorted_targets[obj] = [] - sortedTargets[obj].append((indecies, colors[i])) + sorted_targets[obj].append((indecies, colors[i])) layer_name = props.target_vertex_color_attribute_name - for mesh in sortedTargets: - if layer_name in mesh.vertex_colors: - mesh.vertex_colors.remove(mesh.vertex_colors[layer_name]) + for mesh in sorted_targets: + if layer_name in mesh.attributes: + mesh.attributes.remove(mesh.attributes[layer_name]) - vertex_color_layer = mesh.vertex_colors.new(name=layer_name) + color_attribute = mesh.attributes.new(name=layer_name, type='FLOAT_COLOR', domain='CORNER') - for (indecies, color) in sortedTargets[mesh]: + for (indecies, color) in sorted_targets[mesh]: for polygon in indecies: for idx in polygon.loop_indices: - vertex_color_layer.data[idx].color = (color[0], color[1], color[2], 1.0) \ No newline at end of file + color_attribute.data[idx].color = (color[0], color[1], color[2], 1.0) \ No newline at end of file