Apply scale on armature breaks position of child elements with relationship 'Bone' #91101

Open
opened 2021-09-01 03:48:42 +02:00 by Astralite Heart · 6 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 471.68

Blender Version
Broken: version: 2.93.1, branch: master, commit date: 2021-06-22 05:57, hash: 1b8d33b18c
Also Broken: blender-2.93.4-candidate+v293.7ec351c0d531-windows.amd64-release
Worked: Never (2.80+)

Short description of error
If I have an armature with non (1,1,1) scale and if I create an object that is parented to one of the armature bones, applying the scale to the armature moves the object.

If I then select my arrow/cube and remove the 'Parent Bone', it is aligned correctly again, if I then put the 'Parent Bone' bone back, the arrow/cube is moved to a completely new position.

I can also see the following error in terminal when I unparent the bone (I don't think this is relevant and clearing the bone always prints this, but just in case)

add_relation(Bone Parent) - Could not find op_from (ComponentKey(OBArmature, BONE))
add_relation(Bone Parent) - Failed, but op_to (ComponentKey(OBEmpty, TRANSFORM)) was ok
ERROR (bke.object): C:\Users\blender\git\blender-v293\blender.git\source\blender\blenkernel\intern\object.c:3330 ob_parbone: Object Empty with Bone parent: bone  doesn't exist

My theory is that Blender is trying to reposition the object without taking the bone parent into consideration.

I've recorded a small video to illustrate: https://www.youtube.com/watch?v=BGNckTOfBQQ

I was also able to create a script that fixes the position by detaching the parent and reattaching with keep_transform (also note the commented out line)

import bpy

print ('Bone fixer')
for obj in bpy.data.objects:
    if (obj.parent_type == 'BONE' and obj.parent_bone):
        bpy.ops.object.select_all(action='DESELECT')
        
        print (f'Parent={obj.parent} parent_={obj.parent_type} parent_bone={obj.parent_bone}')
        print (obj.name, obj.scale, obj.location, obj.rotation_euler)
        
        # obj.parent_bone = obj.parent_bone # This line should not have any effect but it does move the object to a new position

        parent_bone = obj.parent_bone
        obj.parent_bone = '' # We are now correctly positioned but not parented                        

        obj.select_set(state=True)
        obj.parent.select_set(state=True)
        obj.parent.data.bones[parent_bone].select = True
        bpy.ops.object.parent_set(type='BONE', keep_transform=True)

Exact steps for others to reproduce the error
Based on the default startup or an attached .blend file (as simple as possible).

test.blend

  1. Create armature ('Armature') and set a non 1,1,1 scale
  2. Add bones to armature
  3. Create a new object (I tried empty/arrow or cube)
  4. Set relationship on the cube as parent = 'Armature', Parent Type = Bone, Parent Bone = 'Bone.X' (last bone in the sample file)
    (^ Already done in sample file)
  5. Select armature and "Apply scale"

Expected - the empty remains at the 'end' of the bone
Observed - the empty is moved to a new location (I am unsure what is the logic)

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 471.68 **Blender Version** Broken: version: 2.93.1, branch: master, commit date: 2021-06-22 05:57, hash: `1b8d33b18c` Also Broken: blender-2.93.4-candidate+v293.7ec351c0d531-windows.amd64-release Worked: Never (2.80+) **Short description of error** If I have an armature with non (1,1,1) scale and if I create an object that is parented to one of the armature bones, applying the scale to the armature moves the object. If I then select my arrow/cube and remove the 'Parent Bone', it is aligned correctly again, if I then put the 'Parent Bone' bone back, the arrow/cube is moved to a completely new position. I can also see the following error in terminal when I unparent the bone (I don't think this is relevant and clearing the bone always prints this, but just in case) ``` add_relation(Bone Parent) - Could not find op_from (ComponentKey(OBArmature, BONE)) add_relation(Bone Parent) - Failed, but op_to (ComponentKey(OBEmpty, TRANSFORM)) was ok ERROR (bke.object): C:\Users\blender\git\blender-v293\blender.git\source\blender\blenkernel\intern\object.c:3330 ob_parbone: Object Empty with Bone parent: bone doesn't exist ``` My theory is that Blender is trying to reposition the object without taking the bone parent into consideration. I've recorded a small video to illustrate: https://www.youtube.com/watch?v=BGNckTOfBQQ I was also able to create a script that fixes the position by detaching the parent and reattaching with keep_transform (also note the commented out line) ``` import bpy print ('Bone fixer') for obj in bpy.data.objects: if (obj.parent_type == 'BONE' and obj.parent_bone): bpy.ops.object.select_all(action='DESELECT') print (f'Parent={obj.parent} parent_={obj.parent_type} parent_bone={obj.parent_bone}') print (obj.name, obj.scale, obj.location, obj.rotation_euler) # obj.parent_bone = obj.parent_bone # This line should not have any effect but it does move the object to a new position parent_bone = obj.parent_bone obj.parent_bone = '' # We are now correctly positioned but not parented obj.select_set(state=True) obj.parent.select_set(state=True) obj.parent.data.bones[parent_bone].select = True bpy.ops.object.parent_set(type='BONE', keep_transform=True) ``` **Exact steps for others to reproduce the error** Based on the default startup or an attached .blend file (as simple as possible). [test.blend](https://archive.blender.org/developer/F10359147/test.blend) 1. Create armature ('Armature') and set a non 1,1,1 scale 2. Add bones to armature 3. Create a new object (I tried empty/arrow or cube) 4. Set relationship on the cube as parent = 'Armature', Parent Type = Bone, Parent Bone = 'Bone.X' (last bone in the sample file) (^ Already done in sample file) 5. Select armature and "Apply scale" Expected - the empty remains at the 'end' of the bone Observed - the empty is moved to a new location (I am unsure what is the logic)

Added subscriber: @Astralite-Heart

Added subscriber: @Astralite-Heart

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

This issue was referenced by a45dd52cf0

This issue was referenced by a45dd52cf0bbdc0ff362681a4836385c8154c70d
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

I can also see the following error in terminal when I unparent the bone (I don't think this is relevant and clearing the bone always prints this, but just in case)

This should be fixed by D12389: Depsgraph: skip parentbone relation if bone prop is empty

> I can also see the following error in terminal when I unparent the bone (I don't think this is relevant and clearing the bone always prints this, but just in case) This should be fixed by [D12389: Depsgraph: skip parentbone relation if bone prop is empty](https://archive.blender.org/developer/D12389)

This issue was referenced by 235655ee0d

This issue was referenced by 235655ee0d0634db9150b1dc266e3a3b35c491e4
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:35:32 +01:00
Sign in to join this conversation.
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
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#91101
No description provided.