Separate bone constraints calculations to before-IK and after-IK parts (more like a multipass constraint concept now) #39962

Closed
opened 2014-04-30 08:16:55 +02:00 by Fazekas Laszlo · 14 comments
Member

Bone constraints now calculated entirely before the IK solver. I'm trying to write a patch for separating the bone constraints into "before IK" and "after IK" parts but first I'd like to ask the developers which way you prefer:

  • the backward compatible way: I can add a flagbit to the existing constraint DNA structure, there is empty place in the flags field so this can be fully backward compatible. In this case the GUI headline of the constraint will get a new toggle button so you can select the constraint as before-IK or after-IK. However, this is a bit ugly: these constraints can be in a mixed order and you must switch them one by one.

  • the nice way: the constraints before the IK constraint will run before IK, and the remainings are after. Of course the middle bones of the IK chain has no IK constraint, so I can add an a new empty "IK placeholder" constraint type to mark the position where the IK calculations separate the two parts. IMHO this is nice, intuitive but not fully backward compatible.

  • or something else?

Bone constraints now calculated entirely before the IK solver. I'm trying to write a patch for separating the bone constraints into "before IK" and "after IK" parts but first I'd like to ask the developers which way you prefer: - the backward compatible way: I can add a flagbit to the existing constraint DNA structure, there is empty place in the flags field so this can be fully backward compatible. In this case the GUI headline of the constraint will get a new toggle button so you can select the constraint as before-IK or after-IK. However, this is a bit ugly: these constraints can be in a mixed order and you must switch them one by one. - the nice way: the constraints before the IK constraint will run before IK, and the remainings are after. Of course the middle bones of the IK chain has no IK constraint, so I can add an a new empty "IK placeholder" constraint type to mark the position where the IK calculations separate the two parts. IMHO this is nice, intuitive but not fully backward compatible. - or something else?
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @totoro-4

Added subscriber: @totoro-4
Member

Added subscriber: @JoshuaLeung

Added subscriber: @JoshuaLeung
Member

I guess I should comment a bit on this as the maintainer of this area.

Firstly, I think you need to be aware that this part of the code is something that is slated for some radical changes in the depsgraph refactor. Therefore, it is unlikely that any changes here will be accepted to the main repo before then. You are of course free to tinker with this (that's the beauty of open source :) though

One of the things I wonder a bit with this is what the intended use cases of this are. For instance, when would it be useful that some constraints are able to run after/on top of the IK results, perhaps in the middle of the IK chain even? What would be the implications of this on the final result, given that some constraints may have made the original IK solution point to the wrong places now?

Regarding your original questions:

  • I don't think this necessarily needs to be an "either or" situation. For example, one way this could work is that you would have a new flag that goes on the IK constraints to say whether they should be evaluated after the stack (i.e. when flag is not set => backwards compatability for old files) vs "in place" (i.e. when the flag is set => perhaps the default for new files, if this makes sense that is).

  • You may be interested to know that we have a "null" constraint type. This basically does nothing, and is used to represent any constraint a version of Blender knows nothing about (e.g. if the constraint came from a newer version). While versions from 2.5 onwards don't show this anymore, it has always existed in the codebase.

Hopefully this doesn't come off sounding too harsh :)

I guess I should comment a bit on this as the maintainer of this area. Firstly, I think you need to be aware that this part of the code is something that is slated for some radical changes in the depsgraph refactor. Therefore, it is unlikely that any changes here will be accepted to the main repo before then. You are of course free to tinker with this (that's the beauty of open source :) though One of the things I wonder a bit with this is what the intended use cases of this are. For instance, when would it be useful that some constraints are able to run after/on top of the IK results, perhaps in the middle of the IK chain even? What would be the implications of this on the final result, given that some constraints may have made the original IK solution point to the wrong places now? Regarding your original questions: - I don't think this necessarily needs to be an "either or" situation. For example, one way this could work is that you would have a new flag that goes on the IK constraints to say whether they should be evaluated after the stack (i.e. when flag is not set => backwards compatability for old files) vs "in place" (i.e. when the flag is set => perhaps the default for new files, if this makes sense that is). - You may be interested to know that we have a "null" constraint type. This basically does nothing, and is used to represent any constraint a version of Blender knows nothing about (e.g. if the constraint came from a newer version). While versions from 2.5 onwards don't show this anymore, it has always existed in the codebase. Hopefully this doesn't come off sounding too harsh :)
Joshua Leung self-assigned this 2014-04-30 16:36:57 +02:00
Author
Member

Hello @JoshuaLeung,

Sometimes I make complex armatures, specially with stretched bones where volume must be preserved or the bone's X/Z scales must not change. In these cases the possibility to modify a bone after the IK calculations could be more than useful. Now the only solution for these to use additional copy bones, just like rigify does. It is not nice, hard to build, hard to modify, hard to debug. And perhaps - I cannot check yet:) - it is slower to calculate in real time.

Currently, if you put a constraint after the IK on the GUI list, it seems it is "after" the IK solver, but really is not. I don't fully understand yet how it works but it seems that all other constraint calculations are done right before the IK solver (in iksolver_execute_tree).

I want to keep this, but finish the BKE_pose_where_is() at the first KINEMATIC constraint/IK marker (I'm talking about my second solution). After calling the IK solver, it goes through the bPoseChannels again, and execute the remaining constraints. I don't see yet what modifications needed in the depsgraph but surely will be some.

The null constraint sounds perfect. I assume it is just a simple bConstraint struct. What is the conventional way to define its sub-type? Is it enough if I set its name- [ ] to something specific like "IK placeholder"?

Hello @JoshuaLeung, Sometimes I make complex armatures, specially with stretched bones where volume must be preserved or the bone's X/Z scales must not change. In these cases the possibility to modify a bone after the IK calculations could be more than useful. Now the only solution for these to use additional copy bones, just like rigify does. It is not nice, hard to build, hard to modify, hard to debug. And perhaps - I cannot check yet:) - it is slower to calculate in real time. Currently, if you put a constraint after the IK on the GUI list, it seems it is "after" the IK solver, but really is not. I don't fully understand yet how it works but it seems that all other constraint calculations are done right before the IK solver (in iksolver_execute_tree). I want to keep this, but finish the BKE_pose_where_is() at the first KINEMATIC constraint/IK marker (I'm talking about my second solution). After calling the IK solver, it goes through the bPoseChannels again, and execute the remaining constraints. I don't see yet what modifications needed in the depsgraph but surely will be some. The null constraint sounds perfect. I assume it is just a simple bConstraint struct. What is the conventional way to define its sub-type? Is it enough if I set its name- [ ] to something specific like "IK placeholder"?
Member

Regarding the depsgraph:
The plan is that we're going to break up the hardcoded/monolithic pose eval code with a network of operation nodes. Bone transforms, individual constraints, IK solver steps, and init/cleanup steps for bones/constraint stacks/armature eval will all become separate operation nodes, allowing more possibilities for interleaving the evaluation of bones/constraints with drivers and other objects/geometry.

Regarding null constraints:
For your purposes, I think a name based method will do initially

Regarding the depsgraph: The plan is that we're going to break up the hardcoded/monolithic pose eval code with a network of operation nodes. Bone transforms, individual constraints, IK solver steps, and init/cleanup steps for bones/constraint stacks/armature eval will all become separate operation nodes, allowing more possibilities for interleaving the evaluation of bones/constraints with drivers and other objects/geometry. Regarding null constraints: For your purposes, I think a name based method will do initially
Author
Member

Aw, the depsgraph sounds good, will it be accessible through the node editor too? Is there already a fork to try?

I decided to make the second method anyway (no flagbit) maybe with some file loader code to rearrange the order of constraints in old files (put the kinematic to the end). This way it remains backward compatible. The separator will listen to the first two characters ('IK') of the null constraint.

Aw, the depsgraph sounds good, will it be accessible through the node editor too? Is there already a fork to try? I decided to make the second method anyway (no flagbit) maybe with some file loader code to rearrange the order of constraints in old files (put the kinematic to the end). This way it remains backward compatible. The separator will listen to the first two characters ('IK') of the null constraint.
Author
Member

The null constraint is not good (used and filtered at many places in the program) so I've made a new constraint type. Now I have a new concept: the whole thing is not related to IK but it is a general pass separator. The passes can contain separate IK-s too or you can repeat a constraint in the different passes if required. I can't see all the possibilities now, but there are many. The new constraint contains a numeric field to split the constraint calculations into independent passes.

The null constraint is not good (used and filtered at many places in the program) so I've made a new constraint type. Now I have a new concept: the whole thing is not related to IK but it is a general pass separator. The passes can contain separate IK-s too or you can repeat a constraint in the different passes if required. I can't see all the possibilities now, but there are many. The new constraint contains a numeric field to split the constraint calculations into independent passes.
Fazekas Laszlo changed title from Separate bone constraints calculations to before-IK and after-IK parts to Separate bone constraints calculations to before-IK and after-IK parts (more like a multipass constraint concept now) 2014-05-02 06:33:46 +02:00
Author
Member

Sooo... it is not as easy as I thought. Constraints are often recalculated for individual objects in the code everywhere. This means it is nearly impossible to make a multi-object-multi-pass solution (I don't want a heavy caching for every passes). No sense to make this for objects, only for bones within an armature.

I'm really curious now about the new depsgraph.

Sooo... it is not as easy as I thought. Constraints are often recalculated for individual objects in the code everywhere. This means it is nearly impossible to make a multi-object-multi-pass solution (I don't want a heavy caching for every passes). No sense to make this for objects, only for bones within an armature. I'm really curious now about the new depsgraph.
Author
Member

This is the first version. I made this as harmless as can be and fully backward compatible with everything.

Basically it is a new constraint type for bones. Always processed after the IK solver and changes only the bone's x and z scaling. Very similar to the maintain volume or stretch to constraints. The bone's head are tail are never changed.

The sample .blend file contains a simple armature modifying a cylinder mesh. You can move the upmost bone as an IK target and the other two bones are using IK with scaling. Try to change the new Post IK constraints at the lower bones to see the difference.

post_ik_constraint.diff

post_ik.blend

This is the first version. I made this as harmless as can be and fully backward compatible with everything. Basically it is a new constraint type for bones. Always processed after the IK solver and changes only the bone's x and z scaling. Very similar to the maintain volume or stretch to constraints. The bone's head are tail are never changed. The sample .blend file contains a simple armature modifying a cylinder mesh. You can move the upmost bone as an IK target and the other two bones are using IK with scaling. Try to change the new Post IK constraints at the lower bones to see the difference. [post_ik_constraint.diff](https://archive.blender.org/developer/F86920/post_ik_constraint.diff) [post_ik.blend](https://archive.blender.org/developer/F86921/post_ik.blend)
Author
Member

postik.png

![postik.png](https://archive.blender.org/developer/F86922/postik.png)

Added subscriber: @dfelinto

Added subscriber: @dfelinto

Changed status from 'Confirmed' to: 'Archived'

Changed status from 'Confirmed' to: 'Archived'

Hi, thanks for your patch.

We are undergoing a Tracker Curfew where we are automatically closing old patches.

If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.

Hi, thanks for your patch. We are undergoing a [Tracker Curfew ](https://code.blender.org/?p=3861) where we are automatically closing old patches. If you think the patch is still relevant please update and re-submit it. For new features make sure there is a clear design from the user level perspective.
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
3 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#39962
No description provided.