From cb836e30f546552076b5a52b233116f17bd0875a Mon Sep 17 00:00:00 2001 From: Swann Date: Mon, 28 Sep 2020 22:50:42 +0200 Subject: [PATCH] fix: empty uv useless update --- multi_user/bl_types/bl_mesh.py | 48 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/multi_user/bl_types/bl_mesh.py b/multi_user/bl_types/bl_mesh.py index 6af2ee6..7ee32d5 100644 --- a/multi_user/bl_types/bl_mesh.py +++ b/multi_user/bl_types/bl_mesh.py @@ -89,24 +89,26 @@ class BlMesh(BlDatablock): np_load_collection(data["polygons"],target.polygons, POLYGON) # UV Layers - for layer in data['uv_layers']: - if layer not in target.uv_layers: - target.uv_layers.new(name=layer) + if 'uv_layers' in data.keys(): + for layer in data['uv_layers']: + if layer not in target.uv_layers: + target.uv_layers.new(name=layer) - np_load_collection_primitives( - target.uv_layers[layer].data, - 'uv', - data["uv_layers"][layer]['data']) + np_load_collection_primitives( + target.uv_layers[layer].data, + 'uv', + data["uv_layers"][layer]['data']) # Vertex color - for color_layer in data['vertex_colors']: - if color_layer not in target.vertex_colors: - target.vertex_colors.new(name=color_layer) + if 'vertex_colors' in data.keys(): + for color_layer in data['vertex_colors']: + if color_layer not in target.vertex_colors: + target.vertex_colors.new(name=color_layer) - np_load_collection_primitives( - target.vertex_colors[color_layer].data, - 'color', - data["vertex_colors"][color_layer]['data']) + np_load_collection_primitives( + target.vertex_colors[color_layer].data, + 'color', + data["vertex_colors"][color_layer]['data']) target.validate() target.update() @@ -147,16 +149,18 @@ class BlMesh(BlDatablock): data["loops"] = np_dump_collection(mesh.loops, LOOP) # UV Layers - data['uv_layers'] = {} - for layer in mesh.uv_layers: - data['uv_layers'][layer.name] = {} - data['uv_layers'][layer.name]['data'] = np_dump_collection_primitive(layer.data, 'uv') + if mesh.uv_layers: + data['uv_layers'] = {} + for layer in mesh.uv_layers: + data['uv_layers'][layer.name] = {} + data['uv_layers'][layer.name]['data'] = np_dump_collection_primitive(layer.data, 'uv') # Vertex color - data['vertex_colors'] = {} - for color_map in mesh.vertex_colors: - data['vertex_colors'][color_map.name] = {} - data['vertex_colors'][color_map.name]['data'] = np_dump_collection_primitive(color_map.data, 'color') + if mesh.vertex_colors: + data['vertex_colors'] = {} + for color_map in mesh.vertex_colors: + data['vertex_colors'][color_map.name] = {} + data['vertex_colors'][color_map.name]['data'] = np_dump_collection_primitive(color_map.data, 'color') # Fix material index m_list = []