changes code to use attributes instead of vertex_colors
this also bump the blender requirement to 2.92
This commit is contained in:
parent
bc6734a349
commit
b14c7a19db
3 changed files with 15 additions and 15 deletions
|
|
@ -3,7 +3,7 @@ bl_info = {
|
|||
"author": "iedSoftworks",
|
||||
"description": "",
|
||||
# !VERSION
|
||||
"blender": (2, 80, 0),
|
||||
"blender": (2, 92, 0),
|
||||
"category": "Object"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
color_attribute.data[idx].color = (color[0], color[1], color[2], 1.0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue