Modifying Basis shape key .co via script in Object mode desyncs from mesh vertices causing new from_mix=False shape keys to revert script changes #98890
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#98890
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 471.11
Blender Version
Broken: 2.79.0, 2.80.75, 2.93.7, 3.0.0, 3.2.0, 3.3.0 Alpha (branch: master, commit date: 2022-06-07 18:08, hash:
173a15bcda
) (I have not tested any versions older than 2.79.0)Worked:
Short description of error
Modifying the Basis shape key of a mesh via script in Object mode does not update the mesh vertices to match the changes to the Basis shape key.
When creating a new shape key with
from_mix=False
, the newly created shape key matches the positions of the mesh vertices instead of the Basis shape key, making the new shape key effectively undo the modifications via script.This is confusing because there is no way to tell through the UI that the mesh vertices and Basis shape key have become desynchronised due to a script.
Fixing the desynchronised state is at least fairly simple, going into Edit mode and back out to Object mode will cause the mesh vertices to update to match the basis shape key, fixing the desync (of course, the script could also be modified to propagate the changes to the mesh vertices too).
I'm unsure if the issue here should be considered the desync between basis shape key and mesh vertices, the behaviour of creating new shape keys with
from_mix=False
or a fault with the script for not also updating the mesh vertices, causing the desync in the first place.Exact steps for others to reproduce the error
bpy.context.object.data.shape_keys.reference_key.data- [x].co.x += 1
from_mix=False
(either the UI, the operator used by the UI or the shape_key_add method of the Cube Object)Alternative steps to reproduce only the desync without creating a new shape key with
from_mix=False
:bpy.context.object.data.shape_keys.reference_key.data- [x].co.x += 1
Modifying the Basis shape's .co via foreach_set('co', my_co_array) has the same issues, but note that it does not update the visuals of the cube in the 3D view immediately so it can appear as if it has done nothing until something else causes the visuals to update e.g.
for data1, data2 in zip(shape_data_or_vertices1, shape_data_or_vertices2):
if data1.co != data2.co:
return False
return True
bpy.ops.object.shape_key_remove(all=True)
assert v.co == b.co
print("Basis shape key matches mesh vertices")
print("Basis shape key does not match mesh vertices, there is desync!")
print("from_mix=True matches basis shape key")
print("from_mix=True does not match basis shape key!")
if cos_equal(me.vertices, new_shape_from_mix.data):
print(" from_mix=True matches mesh vertices")
else:
print(" from_mix=True does not match mesh vertices")
print("from_mix=False matches basis shape key")
print("from_mix=False does not match basis shape key!")
if cos_equal(me.vertices, new_shape.data):
print(" from_mix=False matches mesh vertices")
else:
print(" from_mix=False does not match mesh vertices")
Example script output in the System console:
from_mix=False matches mesh vertices```
Added subscriber: @Mysteryem-2
blender/blender-addons#102452 was marked as duplicate of this issue
Two clips that follow along the reproduction steps:
Reproduction with creating a new shape key with
from_mix=False
ReproductionWithNewFromMixFalseShape.mp4
Reproduction with only the Basis shape key
ReproductionWithoutNewFromMixFalseShape.mp4
I've realised you can reproduce the desync issue without requiring any scripting:
Starting from a default cube:
bpy.context.object.data.shape_keys.reference_key
) and the mesh vertices are now desynced until you enter and exit Edit mode.Added subscriber: @OmarEmaraDev
Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'
It seems
shape_key_add
just creates the new shape key from the mesh itself, not from the reference key. But I am not sure how the reference key relates to the mesh itself, so tagging the module for more information.If it's deemed that keeping the mesh vertices and reference key in sync is completely down to the script author, then I think it may be best for the steps in my previous comment, to cause a desync without using any scripts, to go into their own separate bug report.
The FBX exporter provided with Blender, for example, exports the mesh's vertex positions. Users could be unaware that the mesh vertices and reference key are desynced due to Blender visibly displaying the reference key, export as FBX and then find their exported mesh does not match what was shown in Blender.
Added subscriber: @halfblue3