Regression: Copy of eval mesh may keep shape keys #109327
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
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109327
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.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41
Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-06-19 17:26, hash:
cedec09d0594
Worked: sort of 2.79 (the API was a bit different). And in 2.90.1, only the first buggy scenario (see below) is present
Short description of error
Calling
Object.to_mesh()
on an evaluated mesh keeps the shape keys in some circumstances, even though the shape keys and modifiers have been applied to the mesh.There are two buggy scenarios this can create:
from_mix=False
and exporting with most exporters that support exporting shape keys (#98890).Object.data.copy()
.In both cases, simply removing all the shape keys will restore the meshes to their expected states because both the shape keys and modifiers have been applied to the mesh vertices as expected.
It's not clear which of
Object.to_mesh()
orMesh.copy()
is at fault for not removing the shape keys.The API in 2.79 is a little different to 2.80+, since there is no depsgraph, you choose with the function arguments whether or not to apply modifiers:
When using apply_modifiers=True, the new mesh has no shape keys as expected.
When using apply_modifiers=False, the new mesh retains its shape keys as expected.
Additionally, in 2.79,
Object.to_mesh()
creates a new Mesh data-block in bpy.data.meshes rather than creating a temporary Mesh owned by the Object.Exact steps for others to reproduce the error
Scenario 1 (mesh vertex positions do not match reference shape key positions)
Using the attached .blend:
Step-by-step:
depsgraph = C.evaluated_depsgraph_get()
obj_eval = C.object.evaluated_get(depsgraph)
temp_mesh = obj_eval.to_mesh(preserve_all_data_layers=True, depsgraph=depsgraph)
new_mesh = temp_mesh.copy()
C.object.data = new_mesh
Scenario 2 (number of mesh vertices does not match number of shape key 'vertices'/data)
Using the attached .blend:
Step-by-step:
depsgraph = C.evaluated_depsgraph_get()
obj_eval = C.object.evaluated_get(depsgraph)
temp_mesh = obj_eval.to_mesh(preserve_all_data_layers=False, depsgraph=depsgraph)
# Note: False this timenew_mesh = temp_mesh.copy()
C.object.data = new_mesh
Attached is a .blend (authored in 2.80) that has a script and three Objects that go over different cases (has modifiers/no modifiers/has modifiers but they're disabled) or creating meshes from evaluated Objects with
Object.to_mesh
as well as comparing the behaviour of the similarBlendDataMeshes.new_from_object
function andMesh.copy()
These are the results of running the script in the attached .blend in 4.0.0a:
`Object.to_mesh().copy()` may keep shape keys of meshes created from evaluated Objectsto Regression: Copy of eval mesh may keep shape keysThis is definitely gonna be a problem.
I'm not sure but maybe we could combine the discussion in here with #109313.