fix: bevel and crease mesh attribute replication

This commit is contained in:
Swann 2024-03-25 23:32:54 +01:00
parent 4f71e41436
commit 9452dc010d
2 changed files with 39 additions and 7 deletions

View File

@ -19,9 +19,9 @@
bl_info = { bl_info = {
"name": "Multi-User", "name": "Multi-User",
"author": "Swann Martinez", "author": "Swann Martinez",
"version": (0, 5, 8), "version": (0, 6, 0),
"description": "Enable real-time collaborative workflow inside blender", "description": "Enable real-time collaborative workflow inside blender",
"blender": (2, 82, 0), "blender": (4, 0, 0),
"location": "3D View > Sidebar > Multi-User tab", "location": "3D View > Sidebar > Multi-User tab",
"warning": "Unstable addon, use it at your own risks", "warning": "Unstable addon, use it at your own risks",
"category": "Collaboration", "category": "Collaboration",

View File

@ -52,6 +52,18 @@ POLYGON = [
'material_index', 'material_index',
] ]
GENERIC_ATTRIBUTES =[
'crease_vert',
'crease_edge',
'bevel_weight_vert',
'bevel_weight_edge'
]
GENERIC_ATTRIBUTES_ENSURE = {
'crease_vert': 'vertex_crease_ensure',
'crease_edge': 'edge_crease_ensure'
}
class BlMesh(ReplicatedDatablock): class BlMesh(ReplicatedDatablock):
use_delta = True use_delta = True
@ -116,7 +128,17 @@ class BlMesh(ReplicatedDatablock):
datablock.vertex_colors[color_layer].data, datablock.vertex_colors[color_layer].data,
'color', 'color',
data["vertex_colors"][color_layer]['data']) data["vertex_colors"][color_layer]['data'])
# Generic attibutes
for attribute_name, attribute_data_type, attribute_domain, attribute_data in data["attributes"]:
if attribute_name not in datablock.attributes:
datablock.attributes.new(
attribute_name,
attribute_data_type,
attribute_domain
)
np_load_collection(attribute_data, datablock.attributes[attribute_name].data ,['value'])
datablock.validate() datablock.validate()
datablock.update() datablock.update()
@ -133,7 +155,6 @@ class BlMesh(ReplicatedDatablock):
'use_auto_smooth', 'use_auto_smooth',
'auto_smooth_angle', 'auto_smooth_angle',
'use_customdata_edge_bevel', 'use_customdata_edge_bevel',
'use_customdata_edge_crease'
] ]
data = dumper.dump(mesh) data = dumper.dump(mesh)
@ -148,10 +169,21 @@ class BlMesh(ReplicatedDatablock):
data["egdes_count"] = len(mesh.edges) data["egdes_count"] = len(mesh.edges)
data["edges"] = np_dump_collection(mesh.edges, EDGE) data["edges"] = np_dump_collection(mesh.edges, EDGE)
# TODO 4.0: use bevel_weight_vertex, bevel_weight_edge, crease_edge, crease_vert # ATTIBUTES
# https://developer.blender.org/docs/release_notes/4.0/python_api/ data["attributes"] = []
# ex: C.object.data.attributes['crease_edge'].data[1].value = 0.5 for attribute_name in GENERIC_ATTRIBUTES:
if attribute_name in datablock.attributes:
attribute_data = datablock.attributes.get(attribute_name)
dumped_attr_data = np_dump_collection(attribute_data.data, ['value'])
data["attributes"].append(
(
attribute_name,
attribute_data.data_type,
attribute_data.domain,
dumped_attr_data
)
)
# POLYGONS # POLYGONS
data["poly_count"] = len(mesh.polygons) data["poly_count"] = len(mesh.polygons)
data["polygons"] = np_dump_collection(mesh.polygons, POLYGON) data["polygons"] = np_dump_collection(mesh.polygons, POLYGON)