diff options
author | Damien Picard <dam.pic@free.fr> | 2022-06-14 19:39:09 +0300 |
---|---|---|
committer | Damien Picard <dam.pic@free.fr> | 2022-06-14 19:49:02 +0300 |
commit | 634f0c8c91879aa98cd485526b3742a86d348326 (patch) | |
tree | 0ed8bbb16e24e68394c25d72885d735baa51a337 | |
parent | 470d0257c40ba2ff7dcd34800a771cd3c2229c67 (diff) |
AnimAll: remove vertex colors
Vertex color access through `Mesh.vertex_colors` is deprecated and
will be removed eventually.
https://wiki.blender.org/wiki/Reference/Release_Notes/3.2/Python_API#Deprecation
It is already not entirely functional for AnimAll's workflow: if there
are multiple vertex color layers, the active one cannot be selected
because the interface is no longer exposed. This results in the user
being unable to select which layer they want to animate.
Besides, all functionality is covered by the more generic attributes
system. An operator is provided to upgrade animation curves still
using the old system.
-rw-r--r-- | animation_animall.py | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/animation_animall.py b/animation_animall.py index fe99019c..fdbeff8d 100644 --- a/animation_animall.py +++ b/animation_animall.py @@ -3,7 +3,7 @@ bl_info = { "name": "AnimAll", "author": "Daniel Salazar <zanqdo@gmail.com>", - "version": (0, 9, 0), + "version": (0, 9, 1), "blender": (3, 3, 0), "location": "3D View > Toolbox > Animation tab > AnimAll", "description": "Allows animation of mesh, lattice, curve and surface data", @@ -62,11 +62,6 @@ class AnimallProperties(bpy.types.PropertyGroup): description="Insert keyframes on edge creases", default=False ) - key_vcols: BoolProperty( - name="V-Cols", - description="Insert keyframes on active Vertex Color values", - default=False - ) key_vgroups: BoolProperty( name="V-groups", description="Insert keyframes on active Vertex group values", @@ -172,10 +167,22 @@ class VIEW3D_PT_animall(Panel): row.prop(animall_properties, "key_crease") row.prop(animall_properties, "key_uvs") row = col.row() - row.prop(animall_properties, "key_vcols") - row.prop(animall_properties, "key_vgroups") - row = col.row() row.prop(animall_properties, "key_attribute") + row.prop(animall_properties, "key_vgroups") + + # Vertex group update operator + if (context.active_object is not None + and context.active_object.type == 'MESH' + and context.active_object.data.animation_data is not None + and context.active_object.data.animation_data.action is not None): + for fcurve in context.active_object.data.animation_data.action.fcurves: + if fcurve.data_path.startswith("vertex_colors"): + layout.separator() + row = layout.row() + row.label(text="Object includes old-style vertex colors. Consider updating them.", icon="ERROR") + row = layout.row() + row.operator("anim.update_vertex_color_animation_animall", icon="FILE_REFRESH") + break elif obj.type == 'CURVE': row.prop(animall_properties, "key_points") @@ -338,12 +345,6 @@ class ANIM_OT_insert_keyframe_animall(Operator): if not animall_properties.key_selected or uv.select: insert_key(uv, 'uv', group="UV layer %s" % uv_i) - if animall_properties.key_vcols: - for v_col_layer in data.vertex_colors: - if v_col_layer.active: # only insert in active VCol layer - for v_i, vcol_data in enumerate(v_col_layer.data): - insert_key(vcol_data, 'color', group="Loop %s" % v_i) - if animall_properties.key_attribute: if data.attributes.active is not None: attribute = data.attributes.active @@ -469,12 +470,6 @@ class ANIM_OT_delete_keyframe_animall(Operator): if not animall_properties.key_selected or uv.select: delete_key(uv, 'uv') - if animall_properties.key_vcols: - for v_col_layer in data.vertex_colors: - if v_col_layer.active: # only delete in active VCol layer - for vcol_data in v_col_layer.data: - delete_key(vcol_data, 'color') - if animall_properties.key_attribute: if data.attributes.active is not None: attribute = data.attributes.active @@ -599,6 +594,29 @@ class ANIM_OT_clear_animation_animall(Operator): return {'FINISHED'} +class ANIM_OT_update_vertex_color_animation_animall(Operator): + bl_label = "Update Vertex Color Animation" + bl_idname = "anim.update_vertex_color_animation_animall" + bl_description = "Update old vertex color channel formats from pre-3.3 versions" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(self, context): + if (context.active_object is None + or context.active_object.type != 'MESH' + or context.active_object.data.animation_data is None + or context.active_object.data.animation_data.action is None): + return False + for fcurve in context.active_object.data.animation_data.action.fcurves: + if fcurve.data_path.startswith("vertex_colors"): + return True + + def execute(self, context): + for fcurve in context.active_object.data.animation_data.action.fcurves: + if fcurve.data_path.startswith("vertex_colors"): + fcurve.data_path = fcurve.data_path.replace("vertex_colors", "attributes") + return {'FINISHED'} + # Add-ons Preferences Update Panel # Define Panel classes for updating @@ -651,6 +669,7 @@ def register(): bpy.utils.register_class(ANIM_OT_insert_keyframe_animall) bpy.utils.register_class(ANIM_OT_delete_keyframe_animall) bpy.utils.register_class(ANIM_OT_clear_animation_animall) + bpy.utils.register_class(ANIM_OT_update_vertex_color_animation_animall) bpy.utils.register_class(AnimallAddonPreferences) update_panel(None, bpy.context) @@ -662,6 +681,7 @@ def unregister(): bpy.utils.unregister_class(ANIM_OT_insert_keyframe_animall) bpy.utils.unregister_class(ANIM_OT_delete_keyframe_animall) bpy.utils.unregister_class(ANIM_OT_clear_animation_animall) + bpy.utils.unregister_class(ANIM_OT_update_vertex_color_animation_animall) bpy.utils.unregister_class(AnimallAddonPreferences) if __name__ == "__main__": |