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",
|
"author": "iedSoftworks",
|
||||||
"description": "",
|
"description": "",
|
||||||
# !VERSION
|
# !VERSION
|
||||||
"blender": (2, 80, 0),
|
"blender": (2, 92, 0),
|
||||||
"category": "Object"
|
"category": "Object"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class BakeToIDProperties(PropertyGroup):
|
||||||
items=get_targets_enum(),
|
items=get_targets_enum(),
|
||||||
name="Target",
|
name="Target",
|
||||||
description="To where should the IDs should be baked to",
|
description="To where should the IDs should be baked to",
|
||||||
default="VERTEX_COLORS"
|
default=get_targets_enum()[0][0]
|
||||||
)
|
)
|
||||||
|
|
||||||
source_materials_remove_all : BoolProperty(
|
source_materials_remove_all : BoolProperty(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
target_id = 'VERTEX_COLORS'
|
target_id = 'COLOR_ATTRIBUTE'
|
||||||
name = 'Vertex Colors'
|
name = 'Color Attribute / Vertex Color'
|
||||||
description = 'Bakes the ID onto the vertex color'
|
description = 'Bakes the ID onto a color attribute (previously known as Vertex Color)'
|
||||||
|
|
||||||
connected_properties = [
|
connected_properties = [
|
||||||
'target_vertex_color_attribute_name'
|
'target_vertex_color_attribute_name'
|
||||||
|
|
@ -8,25 +8,25 @@ connected_properties = [
|
||||||
|
|
||||||
|
|
||||||
def paint_targets(props, targets, colors):
|
def paint_targets(props, targets, colors):
|
||||||
sortedTargets = {}
|
sorted_targets = {}
|
||||||
for i in range(len(targets)):
|
for i in range(len(targets)):
|
||||||
target = targets[i]
|
target = targets[i]
|
||||||
obj = target[0]
|
obj = target[0]
|
||||||
indecies = target[1]
|
indecies = target[1]
|
||||||
|
|
||||||
if obj not in sortedTargets:
|
if obj not in sorted_targets:
|
||||||
sortedTargets[obj] = []
|
sorted_targets[obj] = []
|
||||||
|
|
||||||
sortedTargets[obj].append((indecies, colors[i]))
|
sorted_targets[obj].append((indecies, colors[i]))
|
||||||
|
|
||||||
layer_name = props.target_vertex_color_attribute_name
|
layer_name = props.target_vertex_color_attribute_name
|
||||||
for mesh in sortedTargets:
|
for mesh in sorted_targets:
|
||||||
if layer_name in mesh.vertex_colors:
|
if layer_name in mesh.attributes:
|
||||||
mesh.vertex_colors.remove(mesh.vertex_colors[layer_name])
|
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 polygon in indecies:
|
||||||
for idx in polygon.loop_indices:
|
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