def apply( self, attribute: T.Mesh, parent: T.BlendDataMeshes, key: Union[int, str], delta: Delta, context: Context, to_blender: bool = True, ) -> MeshProxy: """ Apply delta to this proxy and optionally to the Blender attribute its manages. Args: attribute: the Mesh datablock to update parent: the attribute that contains attribute (e.g. a bpy.data.meshes) key: the key that identifies attribute in parent. delta: the delta to apply context: proxy and visit state to_blender: update the managed Blender attribute in addition to this Proxy """ struct_update = delta.value if isinstance(delta, DeltaReplace): self.copy_data(struct_update) if to_blender: attribute.clear_geometry() # WARNING ensure that parent is not queried for key, which would fail with libraries and duplicate names self.save(attribute, parent, key, context) else: # vertex groups are always replaced as a whole vertex_groups_arrays = struct_update._arrays.get( "vertex_groups", None) if vertex_groups_arrays is not None: self._arrays["vertex_groups"] = vertex_groups_arrays # collection resizing will be done in AosProxy.apply() for k, member_delta in struct_update._data.items(): current_value = self._data.get(k) try: self._data[k] = apply_attribute(attribute, k, current_value, member_delta, context, to_blender) except Exception as e: logger.warning( f"Struct.apply(). Processing {member_delta}") logger.warning(f"... for {attribute}.{k}") logger.warning(f"... Exception: {e!r}") logger.warning("... Update ignored") continue # If a face is removed from a cube, the vertices array is unchanged but the polygon array is changed. # We expect to receive soa updates for arrays that have been modified, but not for unmodified arrays. # however unmodified arrays must be reloaded if clear_geometry was called return self
def clear_geom(mesh: Mesh): mesh.clear_geometry()