Translation operator moves Child-Of constrained bones in the parent space instead of world #42256

Closed
opened 2014-10-16 13:06:01 +02:00 by Lukas Tönne · 8 comments
Member

Test file child_constraint_problem.blend

Select the top bone with the child-of constraint, press G to move it with the transform operator, observe the movement direction.

Bone with a child-of constraint to another bone. Moving the bone with the translation operator or the manipulators interprets the offset in the constraint target's ("parent") space instead of world space. Changing the world transform with a python script, however, works fine:

import bpy
from mathutils import *

ob = "Armature"
bone = "head"

def translate_world(obname, bonename, offset):
    scene = bpy.context.scene
    ob = scene.objects[obname]
    bone = ob.pose.bones[bonename]
    
    mat = Matrix.Translation(Vector(offset))
    bone.matrix = ob.matrix_world.inverted() * mat * bone.matrix

translate_world(ob, bone, (3,0,0))
Test file [child_constraint_problem.blend](https://archive.blender.org/developer/F117669/child_constraint_problem.blend) Select the top bone with the child-of constraint, press G to move it with the transform operator, observe the movement direction. Bone with a child-of constraint to another bone. Moving the bone with the translation operator or the manipulators interprets the offset in the constraint target's ("parent") space instead of world space. Changing the world transform with a python script, however, works fine: ``` import bpy from mathutils import * ob = "Armature" bone = "head" def translate_world(obname, bonename, offset): scene = bpy.context.scene ob = scene.objects[obname] bone = ob.pose.bones[bonename] mat = Matrix.Translation(Vector(offset)) bone.matrix = ob.matrix_world.inverted() * mat * bone.matrix translate_world(ob, bone, (3,0,0)) ```
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Bastien Montagne was assigned by Lukas Tönne 2014-10-16 13:06:01 +02:00
Author
Member

Added subscriber: @LukasTonne

Added subscriber: @LukasTonne
Author
Member

The problem seems to be related to translation offset, disabling these 3 lines fixes the directions (but breaks gives wrong translation from rotational part):
https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/constraint.c$814

Disabling inverse matrix for transform operator also seems to "fix" the effect:
https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/transform/transform_conversions.c$4774

The problem seems to be related to translation offset, disabling these 3 lines fixes the directions (but breaks gives wrong translation from rotational part): https://developer.blender.org/diffusion/B/browse/master/source/blender/blenkernel/intern/constraint.c$814 Disabling inverse matrix for transform operator also seems to "fix" the effect: https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/transform/transform_conversions.c$4774

So, could reproduce the same issue with mere objects - as soon as you do not use all parent's transform, and do rotate the parent, transform is broken.

child_constraint_noloc_transform_issue.blend

This has clearly to see with constinv and the hack done at the end of childof_evaluate() (first link by Lukas in above comment). Still digging…

So, could reproduce the same issue with mere objects - as soon as you do not use all parent's transform, and do rotate the parent, transform is broken. [child_constraint_noloc_transform_issue.blend](https://archive.blender.org/developer/F117687/child_constraint_noloc_transform_issue.blend) This has clearly to see with constinv and the hack done at the end of `childof_evaluate()` (first link by Lukas in above comment). Still digging…
Member

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung

This issue was referenced by 61d1477415

This issue was referenced by 61d14774150662a8cbcf439c7e93959fd3c74834

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 61d1477415.

Closed by commit 61d1477415.
Sign in to join this conversation.
4 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: blender/blender#42256
No description provided.