2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
2011-02-27 20:40:57 +00:00
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <math.h>
|
2018-06-17 17:05:51 +02:00
|
|
|
#include <stddef.h>
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2020-09-10 11:02:42 +02:00
|
|
|
/* Allow using deprecated functionality for .blend file I/O. */
|
|
|
|
#define DNA_DEPRECATED_ALLOW
|
|
|
|
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
#include "DNA_anim_types.h"
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
#include "DNA_armature_types.h"
|
|
|
|
#include "DNA_constraint_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_scene_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_blenlib.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_ghash.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_math.h"
|
2020-08-03 17:17:57 +02:00
|
|
|
#include "BLI_session_uuid.h"
|
2017-01-16 17:33:34 +01:00
|
|
|
#include "BLI_string_utils.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
#include "BKE_action.h"
|
2020-09-25 11:07:32 +02:00
|
|
|
#include "BKE_anim_data.h"
|
2020-04-03 11:35:04 +02:00
|
|
|
#include "BKE_anim_visualization.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BKE_animsys.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_armature.h"
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
#include "BKE_constraint.h"
|
2013-11-17 04:30:36 +11:00
|
|
|
#include "BKE_deform.h"
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
#include "BKE_fcurve.h"
|
2021-02-04 14:17:50 +01:00
|
|
|
#include "BKE_icons.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BKE_idprop.h"
|
2020-03-06 16:35:23 +01:00
|
|
|
#include "BKE_idtype.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2020-05-18 18:43:11 +02:00
|
|
|
#include "BKE_lib_query.h"
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_object.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2020-11-06 17:58:12 +01:00
|
|
|
#include "DEG_depsgraph.h"
|
2017-04-06 16:11:50 +02:00
|
|
|
#include "DEG_depsgraph_build.h"
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
#include "BIK_api.h"
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
|
2009-04-15 12:59:49 +00:00
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2020-09-10 11:02:42 +02:00
|
|
|
#include "BLO_read_write.h"
|
|
|
|
|
2019-02-01 12:44:19 +11:00
|
|
|
#include "CLG_log.h"
|
|
|
|
|
|
|
|
static CLG_LogRef LOG = {"bke.action"};
|
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* *********************** NOTE ON POSE AND ACTION **********************
|
2012-03-03 20:19:11 +00:00
|
|
|
*
|
|
|
|
* - Pose is the local (object level) component of armature. The current
|
|
|
|
* object pose is saved in files, and (will be) is presorted for dependency
|
|
|
|
* - Actions have fewer (or other) channels, and write data to a Pose
|
2012-05-05 16:03:57 +00:00
|
|
|
* - Currently ob->pose data is controlled in BKE_pose_where_is only. The (recalc)
|
2012-03-03 20:19:11 +00:00
|
|
|
* event system takes care of calling that
|
|
|
|
* - The NLA system (here too) uses Poses as interpolation format for Actions
|
|
|
|
* - Therefore we assume poses to be static, and duplicates of poses have channels in
|
|
|
|
* same order, for quick interpolation reasons
|
|
|
|
*
|
|
|
|
* ****************************** (ton) ************************************ */
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
/**************************** Action Datablock ******************************/
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
/*********************** Armature Datablock ***********************/
|
2011-06-29 04:34:20 +00:00
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
/**
|
2019-04-27 12:07:07 +10:00
|
|
|
* Only copy internal data of Action ID from source
|
|
|
|
* to already allocated/initialized destination.
|
|
|
|
* You probably never want to use that directly,
|
|
|
|
* use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
*
|
|
|
|
* WARNING! This function will not handle ID user count!
|
|
|
|
*
|
2020-02-10 12:58:59 +01:00
|
|
|
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
*/
|
2021-02-04 14:17:50 +01:00
|
|
|
static void action_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, const int flag)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
2020-03-06 16:35:23 +01:00
|
|
|
bAction *action_dst = (bAction *)id_dst;
|
|
|
|
const bAction *action_src = (const bAction *)id_src;
|
|
|
|
|
|
|
|
bActionGroup *group_dst, *group_src;
|
|
|
|
FCurve *fcurve_dst, *fcurve_src;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
/* Duplicate the lists of groups and markers. */
|
|
|
|
BLI_duplicatelist(&action_dst->groups, &action_src->groups);
|
|
|
|
BLI_duplicatelist(&action_dst->markers, &action_src->markers);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
/* Copy F-Curves, fixing up the links as we go. */
|
|
|
|
BLI_listbase_clear(&action_dst->curves);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
for (fcurve_src = action_src->curves.first; fcurve_src; fcurve_src = fcurve_src->next) {
|
|
|
|
/* Duplicate F-Curve. */
|
2019-04-27 12:07:07 +10:00
|
|
|
|
|
|
|
/* XXX TODO pass subdata flag?
|
|
|
|
* But surprisingly does not seem to be doing any ID refcounting... */
|
2020-06-05 09:30:15 +02:00
|
|
|
fcurve_dst = BKE_fcurve_copy(fcurve_src);
|
2019-04-27 12:07:07 +10:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
BLI_addtail(&action_dst->curves, fcurve_dst);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
/* Fix group links (kindof bad list-in-list search, but this is the most reliable way). */
|
|
|
|
for (group_dst = action_dst->groups.first, group_src = action_src->groups.first;
|
|
|
|
group_dst && group_src;
|
|
|
|
group_dst = group_dst->next, group_src = group_src->next) {
|
|
|
|
if (fcurve_src->grp == group_src) {
|
|
|
|
fcurve_dst->grp = group_dst;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
if (group_dst->channels.first == fcurve_src) {
|
|
|
|
group_dst->channels.first = fcurve_dst;
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
}
|
2020-03-06 16:35:23 +01:00
|
|
|
if (group_dst->channels.last == fcurve_src) {
|
|
|
|
group_dst->channels.last = fcurve_dst;
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
}
|
2009-04-13 11:15:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-02-04 14:17:50 +01:00
|
|
|
|
|
|
|
if (flag & LIB_ID_COPY_NO_PREVIEW) {
|
|
|
|
action_dst->preview = NULL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_previewimg_id_copy(&action_dst->id, &action_src->id);
|
|
|
|
}
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
}
|
2015-01-09 09:52:51 +01:00
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
/** Free (or release) any data used by this action (does not free the action itself). */
|
|
|
|
static void action_free_data(struct ID *id)
|
|
|
|
{
|
|
|
|
bAction *action = (bAction *)id;
|
|
|
|
/* No animdata here. */
|
|
|
|
|
|
|
|
/* Free F-Curves. */
|
2020-06-05 09:30:15 +02:00
|
|
|
BKE_fcurves_free(&action->curves);
|
2020-03-06 16:35:23 +01:00
|
|
|
|
|
|
|
/* Free groups. */
|
|
|
|
BLI_freelistN(&action->groups);
|
|
|
|
|
|
|
|
/* Free pose-references (aka local markers). */
|
|
|
|
BLI_freelistN(&action->markers);
|
2021-02-04 14:17:50 +01:00
|
|
|
|
|
|
|
BKE_previewimg_free(&action->preview);
|
2020-03-06 16:35:23 +01:00
|
|
|
}
|
|
|
|
|
2020-05-18 18:43:11 +02:00
|
|
|
static void action_foreach_id(ID *id, LibraryForeachIDData *data)
|
|
|
|
{
|
|
|
|
bAction *act = (bAction *)id;
|
|
|
|
|
2020-05-26 11:53:00 +02:00
|
|
|
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
|
|
|
|
BKE_fcurve_foreach_id(fcu, data);
|
|
|
|
}
|
|
|
|
|
2020-05-18 18:43:11 +02:00
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
|
|
|
|
BKE_LIB_FOREACHID_PROCESS(data, marker->camera, IDWALK_CB_NOP);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-10 11:02:42 +02:00
|
|
|
static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
|
|
|
{
|
|
|
|
bAction *act = (bAction *)id;
|
|
|
|
if (act->id.us > 0 || BLO_write_is_undo(writer)) {
|
|
|
|
BLO_write_id_struct(writer, bAction, id_address, &act->id);
|
|
|
|
BKE_id_blend_write(writer, &act->id);
|
|
|
|
|
|
|
|
BKE_fcurve_blend_write(writer, &act->curves);
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bActionGroup *, grp, &act->groups) {
|
|
|
|
BLO_write_struct(writer, bActionGroup, grp);
|
|
|
|
}
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
|
|
|
|
BLO_write_struct(writer, TimeMarker, marker);
|
|
|
|
}
|
2021-02-04 14:17:50 +01:00
|
|
|
|
|
|
|
BKE_previewimg_blend_write(writer, act->preview);
|
2020-09-10 11:02:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void action_blend_read_data(BlendDataReader *reader, ID *id)
|
|
|
|
{
|
|
|
|
bAction *act = (bAction *)id;
|
|
|
|
|
|
|
|
BLO_read_list(reader, &act->curves);
|
|
|
|
BLO_read_list(reader, &act->chanbase); /* XXX deprecated - old animation system */
|
|
|
|
BLO_read_list(reader, &act->groups);
|
|
|
|
BLO_read_list(reader, &act->markers);
|
|
|
|
|
|
|
|
/* XXX deprecated - old animation system <<< */
|
|
|
|
LISTBASE_FOREACH (bActionChannel *, achan, &act->chanbase) {
|
|
|
|
BLO_read_data_address(reader, &achan->grp);
|
|
|
|
|
|
|
|
BLO_read_list(reader, &achan->constraintChannels);
|
|
|
|
}
|
|
|
|
/* >>> XXX deprecated - old animation system */
|
|
|
|
|
|
|
|
BKE_fcurve_blend_read_data(reader, &act->curves);
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) {
|
|
|
|
BLO_read_data_address(reader, &agrp->channels.first);
|
|
|
|
BLO_read_data_address(reader, &agrp->channels.last);
|
|
|
|
}
|
2021-02-04 14:17:50 +01:00
|
|
|
|
|
|
|
BLO_read_data_address(reader, &act->preview);
|
|
|
|
BKE_previewimg_blend_read(reader, act->preview);
|
2020-09-10 11:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_read_lib_constraint_channels(BlendLibReader *reader, ID *id, ListBase *chanbase)
|
|
|
|
{
|
|
|
|
LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
|
|
|
|
BLO_read_id_address(reader, id->lib, &chan->ipo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void action_blend_read_lib(BlendLibReader *reader, ID *id)
|
|
|
|
{
|
|
|
|
bAction *act = (bAction *)id;
|
|
|
|
|
|
|
|
/* XXX deprecated - old animation system <<< */
|
|
|
|
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
|
|
|
|
BLO_read_id_address(reader, act->id.lib, &chan->ipo);
|
|
|
|
blend_read_lib_constraint_channels(reader, &act->id, &chan->constraintChannels);
|
|
|
|
}
|
|
|
|
/* >>> XXX deprecated - old animation system */
|
|
|
|
|
|
|
|
BKE_fcurve_blend_read_lib(reader, &act->id, &act->curves);
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
|
|
|
|
if (marker->camera) {
|
|
|
|
BLO_read_id_address(reader, act->id.lib, &marker->camera);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void blend_read_expand_constraint_channels(BlendExpander *expander, ListBase *chanbase)
|
|
|
|
{
|
|
|
|
LISTBASE_FOREACH (bConstraintChannel *, chan, chanbase) {
|
|
|
|
BLO_expand(expander, chan->ipo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void action_blend_read_expand(BlendExpander *expander, ID *id)
|
|
|
|
{
|
|
|
|
bAction *act = (bAction *)id;
|
|
|
|
|
|
|
|
/* XXX deprecated - old animation system -------------- */
|
|
|
|
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
|
|
|
|
BLO_expand(expander, chan->ipo);
|
|
|
|
blend_read_expand_constraint_channels(expander, &chan->constraintChannels);
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------- */
|
|
|
|
|
|
|
|
/* F-Curves in Action */
|
|
|
|
BKE_fcurve_blend_read_expand(expander, &act->curves);
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
|
|
|
|
if (marker->camera) {
|
|
|
|
BLO_expand(expander, marker->camera);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 16:35:23 +01:00
|
|
|
IDTypeInfo IDType_ID_AC = {
|
|
|
|
.id_code = ID_AC,
|
|
|
|
.id_filter = FILTER_ID_AC,
|
|
|
|
.main_listbase_index = INDEX_ID_AC,
|
|
|
|
.struct_size = sizeof(bAction),
|
|
|
|
.name = "Action",
|
|
|
|
.name_plural = "actions",
|
|
|
|
.translation_context = BLT_I18NCONTEXT_ID_ACTION,
|
2020-10-07 12:35:58 +02:00
|
|
|
.flags = IDTYPE_FLAGS_NO_ANIMDATA,
|
2020-03-06 16:35:23 +01:00
|
|
|
|
|
|
|
.init_data = NULL,
|
|
|
|
.copy_data = action_copy_data,
|
|
|
|
.free_data = action_free_data,
|
|
|
|
.make_local = NULL,
|
2020-05-18 18:43:11 +02:00
|
|
|
.foreach_id = action_foreach_id,
|
2020-08-28 13:05:48 +02:00
|
|
|
.foreach_cache = NULL,
|
2021-02-25 10:17:31 +01:00
|
|
|
.owner_get = NULL,
|
2020-08-28 13:05:48 +02:00
|
|
|
|
2020-09-10 11:02:42 +02:00
|
|
|
.blend_write = action_blend_write,
|
|
|
|
.blend_read_data = action_blend_read_data,
|
|
|
|
.blend_read_lib = action_blend_read_lib,
|
|
|
|
.blend_read_expand = action_blend_read_expand,
|
2020-11-03 11:39:36 +01:00
|
|
|
|
|
|
|
.blend_read_undo_preserve = NULL,
|
2021-01-22 14:52:50 +01:00
|
|
|
|
|
|
|
.lib_override_apply_post = NULL,
|
2020-03-06 16:35:23 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ***************** Library data level operations on action ************** */
|
|
|
|
|
|
|
|
bAction *BKE_action_add(Main *bmain, const char name[])
|
|
|
|
{
|
|
|
|
bAction *act;
|
|
|
|
|
2020-10-08 12:50:04 +02:00
|
|
|
act = BKE_id_new(bmain, ID_AC, name);
|
2020-03-06 16:35:23 +01:00
|
|
|
|
|
|
|
return act;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* .................................. */
|
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* *************** Action Groups *************** */
|
2004-11-11 15:31:44 +00:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
/* Get the active action-group for an Action */
|
2012-05-06 15:15:33 +00:00
|
|
|
bActionGroup *get_active_actiongroup(bAction *act)
|
2009-02-09 10:04:11 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
bActionGroup *agrp = NULL;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-10-21 05:46:41 +00:00
|
|
|
if (act && act->groups.first) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (agrp->flag & AGRP_ACTIVE) {
|
2009-02-09 10:04:11 +00:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
return agrp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make the given Action-Group the active one */
|
2012-04-29 17:11:40 +00:00
|
|
|
void set_active_action_group(bAction *act, bActionGroup *agrp, short select)
|
2009-02-09 10:04:11 +00:00
|
|
|
{
|
|
|
|
bActionGroup *grp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (act == NULL) {
|
2009-02-09 10:04:11 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-09-24 17:27:41 +02:00
|
|
|
/* Deactivate all others */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (grp = act->groups.first; grp; grp = grp->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((grp == agrp) && (select)) {
|
2009-02-09 10:04:11 +00:00
|
|
|
grp->flag |= AGRP_ACTIVE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2009-02-09 10:04:11 +00:00
|
|
|
grp->flag &= ~AGRP_ACTIVE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-01 13:54:44 +00:00
|
|
|
/* Sync colors used for action/bone group with theme settings */
|
2012-07-03 01:15:03 +00:00
|
|
|
void action_group_colors_sync(bActionGroup *grp, const bActionGroup *ref_grp)
|
2012-06-01 13:54:44 +00:00
|
|
|
{
|
|
|
|
/* only do color copying if using a custom color (i.e. not default color) */
|
|
|
|
if (grp->customCol) {
|
|
|
|
if (grp->customCol > 0) {
|
|
|
|
/* copy theme colors on-to group's custom color in case user tries to edit color */
|
|
|
|
bTheme *btheme = U.themes.first;
|
|
|
|
ThemeWireColor *col_set = &btheme->tarm[(grp->customCol - 1)];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-06-01 13:54:44 +00:00
|
|
|
memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
|
|
|
|
}
|
|
|
|
else {
|
2012-07-03 01:15:03 +00:00
|
|
|
/* if a reference group is provided, use the custom color from there... */
|
|
|
|
if (ref_grp) {
|
|
|
|
/* assumption: reference group has a color set */
|
|
|
|
memcpy(&grp->cs, &ref_grp->cs, sizeof(ThemeWireColor));
|
|
|
|
}
|
|
|
|
/* otherwise, init custom color with a generic/placeholder color set if
|
|
|
|
* no previous theme color was used that we can just keep using
|
|
|
|
*/
|
|
|
|
else if (grp->cs.solid[0] == 0) {
|
2012-06-01 13:54:44 +00:00
|
|
|
/* define for setting colors in theme below */
|
2019-08-06 04:20:17 +10:00
|
|
|
rgba_uchar_args_set(grp->cs.solid, 0xff, 0x00, 0x00, 255);
|
|
|
|
rgba_uchar_args_set(grp->cs.select, 0x81, 0xe6, 0x14, 255);
|
|
|
|
rgba_uchar_args_set(grp->cs.active, 0x18, 0xb6, 0xe0, 255);
|
2012-06-01 13:54:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* Add a new action group with the given name to the action */
|
2012-05-06 15:15:33 +00:00
|
|
|
bActionGroup *action_groups_add_new(bAction *act, const char name[])
|
2010-04-01 06:26:41 +00:00
|
|
|
{
|
|
|
|
bActionGroup *agrp;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* sanity check: must have action and name */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, name)) {
|
2010-04-01 06:26:41 +00:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* allocate a new one */
|
|
|
|
agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* make it selected, with default name */
|
|
|
|
agrp->flag = AGRP_SELECTED;
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* add to action, and validate */
|
|
|
|
BLI_addtail(&act->groups, agrp);
|
2013-03-25 08:29:06 +00:00
|
|
|
BLI_uniquename(
|
|
|
|
&act->groups, agrp, DATA_("Group"), '.', offsetof(bActionGroup, name), sizeof(agrp->name));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-04-01 06:26:41 +00:00
|
|
|
/* return the new group */
|
|
|
|
return agrp;
|
|
|
|
}
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* Add given channel into (active) group
|
2018-11-14 12:53:15 +11:00
|
|
|
* - assumes that channel is not linked to anything anymore
|
|
|
|
* - always adds at the end of the group
|
2009-02-09 10:04:11 +00:00
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
|
2018-06-17 17:05:51 +02:00
|
|
|
{
|
2009-02-09 10:04:11 +00:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, agrp, fcurve)) {
|
2009-02-09 10:04:11 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-18 11:55:18 +00:00
|
|
|
/* if no channels anywhere, just add to two lists at the same time */
|
2014-02-08 06:07:10 +11:00
|
|
|
if (BLI_listbase_is_empty(&act->curves)) {
|
2009-02-09 10:04:11 +00:00
|
|
|
fcurve->next = fcurve->prev = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
agrp->channels.first = agrp->channels.last = fcurve;
|
|
|
|
act->curves.first = act->curves.last = fcurve;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* if the group already has channels, the F-Curve can simply be added to the list
|
2009-12-18 11:55:18 +00:00
|
|
|
* (i.e. as the last channel in the group)
|
|
|
|
*/
|
|
|
|
else if (agrp->channels.first) {
|
2018-06-17 17:05:51 +02:00
|
|
|
/* if the group's last F-Curve is the action's last F-Curve too,
|
2009-12-18 11:55:18 +00:00
|
|
|
* then set the F-Curve as the last for the action first so that
|
|
|
|
* the lists will be in sync after linking
|
|
|
|
*/
|
2019-04-22 09:39:35 +10:00
|
|
|
if (agrp->channels.last == act->curves.last) {
|
2012-05-06 15:15:33 +00:00
|
|
|
act->curves.last = fcurve;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-18 11:55:18 +00:00
|
|
|
/* link in the given F-Curve after the last F-Curve in the group,
|
|
|
|
* which means that it should be able to fit in with the rest of the
|
|
|
|
* list seamlessly
|
|
|
|
*/
|
|
|
|
BLI_insertlinkafter(&agrp->channels, agrp->channels.last, fcurve);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-18 11:55:18 +00:00
|
|
|
/* otherwise, need to find the nearest F-Curve in group before/after current to link with */
|
|
|
|
else {
|
|
|
|
bActionGroup *grp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-18 11:55:18 +00:00
|
|
|
/* firstly, link this F-Curve to the group */
|
|
|
|
agrp->channels.first = agrp->channels.last = fcurve;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* Step through the groups preceding this one,
|
|
|
|
* finding the F-Curve there to attach this one after. */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (grp = agrp->prev; grp; grp = grp->prev) {
|
2019-04-27 12:07:07 +10:00
|
|
|
/* if this group has F-Curves, we want weave the given one in right after the last channel
|
|
|
|
* there, but via the Action's list not this group's list
|
2018-11-14 12:53:15 +11:00
|
|
|
* - this is so that the F-Curve is in the right place in the Action,
|
2019-04-27 12:07:07 +10:00
|
|
|
* but won't be included in the previous group.
|
2009-12-18 11:55:18 +00:00
|
|
|
*/
|
|
|
|
if (grp->channels.last) {
|
|
|
|
/* once we've added, break here since we don't need to search any further... */
|
|
|
|
BLI_insertlinkafter(&act->curves, grp->channels.last, fcurve);
|
2009-02-09 10:04:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* If grp is NULL, that means we fell through, and this F-Curve should be added as the new
|
|
|
|
* first since group is (effectively) the first group. Thus, the existing first F-Curve becomes
|
|
|
|
* the second in the chain, etc. etc.
|
2009-12-18 11:55:18 +00:00
|
|
|
*/
|
2019-04-22 09:39:35 +10:00
|
|
|
if (grp == NULL) {
|
2009-12-18 11:55:18 +00:00
|
|
|
BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-12-18 11:55:18 +00:00
|
|
|
/* set the F-Curve's new group */
|
2012-05-06 15:15:33 +00:00
|
|
|
fcurve->grp = agrp;
|
2018-06-17 17:05:51 +02:00
|
|
|
}
|
2009-02-09 10:04:11 +00:00
|
|
|
|
2019-12-17 15:20:11 +01:00
|
|
|
/* Reconstruct group channel pointers.
|
|
|
|
* Assumes that the channels are still in the proper order, i.e. that channels of the same group
|
|
|
|
* are adjacent in the act->channels list. It also assumes that the groups
|
|
|
|
* referred to by the FCurves are already in act->groups.
|
|
|
|
*/
|
|
|
|
void BKE_action_groups_reconstruct(bAction *act)
|
|
|
|
{
|
|
|
|
/* Sanity check. */
|
|
|
|
if (ELEM(NULL, act, act->groups.first)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear out all group channels. Channels that are actually in use are
|
|
|
|
* reconstructed below; this step is necessary to clear out unused groups. */
|
|
|
|
LISTBASE_FOREACH (bActionGroup *, group, &act->groups) {
|
|
|
|
BLI_listbase_clear(&group->channels);
|
|
|
|
}
|
|
|
|
|
|
|
|
bActionGroup *grp;
|
|
|
|
bActionGroup *last_grp = NULL;
|
|
|
|
LISTBASE_FOREACH (FCurve *, fcurve, &act->curves) {
|
|
|
|
if (fcurve->grp == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
grp = fcurve->grp;
|
|
|
|
if (last_grp != grp) {
|
|
|
|
/* If this is the first time we see this group, this must be the first channel. */
|
|
|
|
grp->channels.first = fcurve;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the last channel, until it's overwritten by a later iteration. */
|
|
|
|
grp->channels.last = fcurve;
|
|
|
|
last_grp = grp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
/* Remove the given channel from all groups */
|
2012-04-29 17:11:40 +00:00
|
|
|
void action_groups_remove_channel(bAction *act, FCurve *fcu)
|
2009-02-09 10:04:11 +00:00
|
|
|
{
|
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, fcu)) {
|
2009-02-09 10:04:11 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
/* check if any group used this directly */
|
|
|
|
if (fcu->grp) {
|
2012-05-06 15:15:33 +00:00
|
|
|
bActionGroup *agrp = fcu->grp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
if (agrp->channels.first == agrp->channels.last) {
|
|
|
|
if (agrp->channels.first == fcu) {
|
2014-02-08 06:07:10 +11:00
|
|
|
BLI_listbase_clear(&agrp->channels);
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (agrp->channels.first == fcu) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((fcu->next) && (fcu->next->grp == agrp)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
agrp->channels.first = fcu->next;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
agrp->channels.first = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
|
|
|
else if (agrp->channels.last == fcu) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((fcu->prev) && (fcu->prev->grp == agrp)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
agrp->channels.last = fcu->prev;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
agrp->channels.last = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
fcu->grp = NULL;
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
/* now just remove from list */
|
|
|
|
BLI_remlink(&act->curves, fcu);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find a group with the given name */
|
2012-05-06 15:15:33 +00:00
|
|
|
bActionGroup *BKE_action_group_find_name(bAction *act, const char name[])
|
2009-02-09 10:04:11 +00:00
|
|
|
{
|
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, act->groups.first, name) || (name[0] == 0)) {
|
2009-02-09 10:04:11 +00:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-02-09 10:04:11 +00:00
|
|
|
/* do string comparisons */
|
2010-08-22 14:15:28 +00:00
|
|
|
return BLI_findstring(&act->groups, name, offsetof(bActionGroup, name));
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-12-29 11:51:53 +00:00
|
|
|
/* Clear all 'temp' flags on all groups */
|
2012-04-29 17:11:40 +00:00
|
|
|
void action_groups_clear_tempflags(bAction *act)
|
2010-12-29 11:51:53 +00:00
|
|
|
{
|
|
|
|
bActionGroup *agrp;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-12-29 11:51:53 +00:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, act->groups.first)) {
|
2010-12-29 11:51:53 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2010-12-29 11:51:53 +00:00
|
|
|
/* flag clearing loop */
|
2019-04-22 09:39:35 +10:00
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2010-12-29 11:51:53 +00:00
|
|
|
agrp->flag &= ~AGRP_TEMP;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-12-29 11:51:53 +00:00
|
|
|
}
|
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* *************** Pose channels *************** */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2020-08-03 17:17:57 +02:00
|
|
|
void BKE_pose_channel_session_uuid_generate(bPoseChannel *pchan)
|
|
|
|
{
|
|
|
|
pchan->runtime.session_uuid = BLI_session_uuid_generate();
|
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Return a pointer to the pose channel of the given name
|
|
|
|
* from this pose.
|
|
|
|
*/
|
2012-05-05 16:03:57 +00:00
|
|
|
bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name)
|
2004-01-02 20:57:43 +00:00
|
|
|
{
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, pose, name) || (name[0] == '\0')) {
|
2009-08-21 10:47:27 +00:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose->chanhash) {
|
2015-01-01 23:26:03 +11:00
|
|
|
return BLI_ghash_lookup(pose->chanhash, (const void *)name);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-11-25 11:19:14 +01:00
|
|
|
return BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Looks to see if the channel with the given name
|
|
|
|
* already exists in this pose - if not a new one is
|
|
|
|
* allocated and initialized.
|
|
|
|
*
|
|
|
|
* \note Use with care, not on Armature poses but for temporal ones.
|
|
|
|
* \note (currently used for action constraints and in rebuild_pose).
|
|
|
|
*/
|
2021-04-30 15:30:41 +10:00
|
|
|
bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name)
|
2004-01-02 20:57:43 +00:00
|
|
|
{
|
2002-10-12 11:37:38 +00:00
|
|
|
bPoseChannel *chan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose == NULL) {
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-01-18 10:41:45 +00:00
|
|
|
/* See if this channel exists */
|
2018-06-11 20:26:29 +02:00
|
|
|
chan = BKE_pose_channel_find_name(pose, name);
|
2012-03-24 06:18:31 +00:00
|
|
|
if (chan) {
|
2011-05-01 06:34:40 +00:00
|
|
|
return chan;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2011-05-01 06:34:40 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* If not, create it and add it */
|
|
|
|
chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2020-08-03 17:17:57 +02:00
|
|
|
BKE_pose_channel_session_uuid_generate(chan);
|
|
|
|
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(chan->name, name, sizeof(chan->name));
|
2015-09-21 23:49:58 +10:00
|
|
|
|
2021-05-11 11:22:41 +02:00
|
|
|
copy_v3_fl(chan->custom_scale_xyz, 1.0f);
|
|
|
|
zero_v3(chan->custom_translation);
|
|
|
|
zero_v3(chan->custom_rotation_euler);
|
2015-09-21 23:49:58 +10:00
|
|
|
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* init vars to prevent math errors */
|
2011-02-02 00:40:55 +00:00
|
|
|
unit_qt(chan->quat);
|
|
|
|
unit_axis_angle(chan->rotAxis, &chan->rotAngle);
|
2009-01-18 10:41:45 +00:00
|
|
|
chan->size[0] = chan->size[1] = chan->size[2] = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
2020-12-11 19:17:39 +03:00
|
|
|
copy_v3_fl(chan->scale_in, 1.0f);
|
|
|
|
copy_v3_fl(chan->scale_out, 1.0f);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-11-16 11:09:02 +13:00
|
|
|
chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -M_PI;
|
|
|
|
chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = M_PI;
|
2012-05-06 15:15:33 +00:00
|
|
|
chan->stiffness[0] = chan->stiffness[1] = chan->stiffness[2] = 0.0f;
|
2009-09-24 21:22:24 +00:00
|
|
|
chan->ikrotweight = chan->iklinweight = 0.0f;
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m4(chan->constinv);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
BLI_addtail(&pose->chanbase, chan);
|
2018-06-11 20:26:29 +02:00
|
|
|
if (pose->chanhash) {
|
|
|
|
BLI_ghash_insert(pose->chanhash, chan->name, chan);
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
return chan;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-10-01 13:28:59 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
bool BKE_pose_channels_is_valid(const bPose *pose)
|
|
|
|
{
|
|
|
|
if (pose->chanhash) {
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
if (BLI_ghash_lookup(pose->chanhash, pchan->name) != pchan) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-01 13:28:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2013-10-26 03:56:32 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-25 01:14:39 +11:00
|
|
|
* Find the active pose-channel for an object
|
|
|
|
* (we can't just use pose, as layer info is in armature)
|
2013-10-26 03:56:32 +00:00
|
|
|
*
|
2019-11-25 01:14:39 +11:00
|
|
|
* \note #Object, not #bPose is used here, as we need layer info from Armature.
|
2013-10-26 03:56:32 +00:00
|
|
|
*/
|
2012-05-06 15:15:33 +00:00
|
|
|
bPoseChannel *BKE_pose_channel_active(Object *ob)
|
2008-12-21 10:33:24 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
bArmature *arm = (ob) ? ob->data : NULL;
|
2008-12-21 10:33:24 +00:00
|
|
|
bPoseChannel *pchan;
|
2012-03-25 22:35:18 +00:00
|
|
|
|
2014-07-20 01:30:29 +10:00
|
|
|
if (ELEM(NULL, ob, ob->pose, arm)) {
|
2008-12-21 10:33:24 +00:00
|
|
|
return NULL;
|
2012-03-25 22:35:18 +00:00
|
|
|
}
|
|
|
|
|
2008-12-21 10:33:24 +00:00
|
|
|
/* find active */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer)) {
|
2008-12-21 10:33:24 +00:00
|
|
|
return pchan;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-12-21 10:33:24 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-12-21 10:33:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-07-18 18:45:56 +10:00
|
|
|
/**
|
|
|
|
* Use this when detecting the "other selected bone",
|
|
|
|
* when we have multiple armatures in pose mode.
|
|
|
|
*
|
|
|
|
* In this case the active-selected is an obvious choice when finding the target for a
|
|
|
|
* constraint for eg. however from the users perspective the active pose bone of the
|
|
|
|
* active object is the _real_ active bone, so any other non-active selected bone
|
|
|
|
* is a candidate for being the other selected bone, see: T58447.
|
|
|
|
*/
|
|
|
|
bPoseChannel *BKE_pose_channel_active_or_first_selected(struct Object *ob)
|
|
|
|
{
|
|
|
|
bArmature *arm = (ob) ? ob->data : NULL;
|
|
|
|
|
|
|
|
if (ELEM(NULL, ob, ob->pose, arm)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bPoseChannel *pchan = BKE_pose_channel_active(ob);
|
|
|
|
if (pchan && (pchan->bone->flag & BONE_SELECTED) && PBONE_VISIBLE(arm, pchan->bone)) {
|
|
|
|
return pchan;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
if (pchan->bone != NULL) {
|
|
|
|
if ((pchan->bone->flag & BONE_SELECTED) && PBONE_VISIBLE(arm, pchan->bone)) {
|
|
|
|
return pchan;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-17 04:30:36 +11:00
|
|
|
/**
|
2018-04-15 11:45:51 +02:00
|
|
|
* \see #ED_armature_ebone_get_mirrored (edit-mode, matching function)
|
2013-11-17 04:30:36 +11:00
|
|
|
*/
|
|
|
|
bPoseChannel *BKE_pose_channel_get_mirrored(const bPose *pose, const char *name)
|
|
|
|
{
|
|
|
|
char name_flip[MAXBONENAME];
|
|
|
|
|
2017-01-16 20:34:13 +01:00
|
|
|
BLI_string_flip_side_name(name_flip, name, false, sizeof(name_flip));
|
2013-11-17 04:30:36 +11:00
|
|
|
|
|
|
|
if (!STREQ(name_flip, name)) {
|
|
|
|
return BKE_pose_channel_find_name(pose, name_flip);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
const char *BKE_pose_ikparam_get_name(bPose *pose)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
if (pose) {
|
|
|
|
switch (pose->iksolver) {
|
2012-11-24 00:18:34 +00:00
|
|
|
case IKSOLVER_STANDARD:
|
2012-05-06 15:15:33 +00:00
|
|
|
return NULL;
|
|
|
|
case IKSOLVER_ITASC:
|
|
|
|
return "bItasc";
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-26 03:56:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a new pose on the heap, and copy the src pose and its channels
|
|
|
|
* into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL.
|
|
|
|
*
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param dst: Should be freed already, makes entire duplicate.
|
2013-10-26 03:56:32 +00:00
|
|
|
*/
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
void BKE_pose_copy_data_ex(bPose **dst,
|
|
|
|
const bPose *src,
|
|
|
|
const int flag,
|
|
|
|
const bool copy_constraints)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
|
|
|
bPose *outPose;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
bPoseChannel *pchan;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
ListBase listb;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
if (!src) {
|
2012-05-06 15:15:33 +00:00
|
|
|
*dst = NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
2008-06-13 02:20:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
outPose = MEM_callocN(sizeof(bPose), "pose");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-12-19 11:45:46 +00:00
|
|
|
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
/* Rebuild ghash here too, so that name lookups below won't be too bad...
|
|
|
|
* BUT this will have the penalty that the ghash will be built twice
|
|
|
|
* if BKE_pose_rebuild() gets called after this...
|
|
|
|
*/
|
|
|
|
if (outPose->chanbase.first != outPose->chanbase.last) {
|
|
|
|
outPose->chanhash = NULL;
|
2021-04-30 15:28:13 +10:00
|
|
|
BKE_pose_channels_hash_ensure(outPose);
|
2016-05-20 19:08:48 +12:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
outPose->iksolver = src->iksolver;
|
|
|
|
outPose->ikdata = NULL;
|
|
|
|
outPose->ikparam = MEM_dupallocN(src->ikparam);
|
2012-10-03 08:51:05 +00:00
|
|
|
outPose->avs = src->avs;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
|
|
|
id_us_plus((ID *)pchan->custom);
|
2014-05-01 05:57:01 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-03 17:17:57 +02:00
|
|
|
if ((flag & LIB_ID_CREATE_NO_MAIN) == 0) {
|
|
|
|
BKE_pose_channel_session_uuid_generate(pchan);
|
|
|
|
}
|
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
/* warning, O(n2) here, if done without the hash, but these are rarely used features. */
|
2014-05-01 06:05:35 +10:00
|
|
|
if (pchan->custom_tx) {
|
|
|
|
pchan->custom_tx = BKE_pose_channel_find_name(outPose, pchan->custom_tx->name);
|
|
|
|
}
|
2016-05-20 19:08:48 +12:00
|
|
|
if (pchan->bbone_prev) {
|
|
|
|
pchan->bbone_prev = BKE_pose_channel_find_name(outPose, pchan->bbone_prev->name);
|
|
|
|
}
|
|
|
|
if (pchan->bbone_next) {
|
|
|
|
pchan->bbone_next = BKE_pose_channel_find_name(outPose, pchan->bbone_next->name);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
if (copy_constraints) {
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
BKE_constraints_copy_ex(
|
|
|
|
&listb, &pchan->constraints, flag, true); /* BKE_constraints_copy NULLs listb */
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->constraints = listb;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* XXX: This is needed for motionpath drawing to work.
|
|
|
|
* Dunno why it was setting to null before... */
|
2018-06-01 16:38:21 +02:00
|
|
|
pchan->mpath = animviz_copy_motionpath(pchan->mpath);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pchan->prop) {
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
pchan->prop = IDP_CopyProperty_ex(pchan->prop, flag);
|
2009-11-23 13:35:21 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-04 01:32:16 +10:00
|
|
|
pchan->draw_data = NULL; /* Drawing cache, no need to copy. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-22 13:38:03 +03:00
|
|
|
/* Runtime data, no need to copy. */
|
2020-08-03 17:17:57 +02:00
|
|
|
BKE_pose_channel_runtime_reset_on_copy(&pchan->runtime);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 13:35:21 +00:00
|
|
|
/* for now, duplicate Bone Groups too when doing this */
|
2013-10-26 03:56:32 +00:00
|
|
|
if (copy_constraints) {
|
2009-11-23 13:35:21 +00:00
|
|
|
BLI_duplicatelist(&outPose->agroups, &src->agroups);
|
2013-10-26 03:56:32 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
*dst = outPose;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
void BKE_pose_copy_data(bPose **dst, const bPose *src, const bool copy_constraints)
|
|
|
|
{
|
|
|
|
BKE_pose_copy_data_ex(dst, src, 0, copy_constraints);
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_itasc_init(bItasc *itasc)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
if (itasc) {
|
|
|
|
itasc->iksolver = IKSOLVER_ITASC;
|
|
|
|
itasc->minstep = 0.01f;
|
|
|
|
itasc->maxstep = 0.06f;
|
|
|
|
itasc->numiter = 100;
|
|
|
|
itasc->numstep = 4;
|
|
|
|
itasc->precision = 0.005f;
|
2012-05-06 15:15:33 +00:00
|
|
|
itasc->flag = ITASC_AUTO_STEP | ITASC_INITIAL_REITERATION;
|
2012-04-11 08:15:13 +00:00
|
|
|
itasc->feedback = 20.0f;
|
|
|
|
itasc->maxvel = 50.0f;
|
2009-09-24 21:22:24 +00:00
|
|
|
itasc->solver = ITASC_SOLVER_SDLS;
|
|
|
|
itasc->dampmax = 0.5;
|
|
|
|
itasc->dampeps = 0.15;
|
|
|
|
}
|
|
|
|
}
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_ikparam_init(bPose *pose)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
|
|
|
bItasc *itasc;
|
|
|
|
switch (pose->iksolver) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case IKSOLVER_ITASC:
|
|
|
|
itasc = MEM_callocN(sizeof(bItasc), "itasc");
|
|
|
|
BKE_pose_itasc_init(itasc);
|
|
|
|
pose->ikparam = itasc;
|
|
|
|
break;
|
2012-11-24 00:18:34 +00:00
|
|
|
case IKSOLVER_STANDARD:
|
2012-05-06 15:15:33 +00:00
|
|
|
default:
|
|
|
|
pose->ikparam = NULL;
|
|
|
|
break;
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 03:03:46 +00:00
|
|
|
/* only for real IK, not for auto-IK */
|
|
|
|
static bool pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level)
|
|
|
|
{
|
|
|
|
bConstraint *con;
|
|
|
|
Bone *bone;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-09-13 03:03:46 +00:00
|
|
|
/* No need to check if constraint is active (has influence),
|
|
|
|
* since all constraints with CONSTRAINT_IK_AUTO are active */
|
|
|
|
for (con = pchan->constraints.first; con; con = con->next) {
|
|
|
|
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
|
|
|
|
bKinematicConstraint *data = con->data;
|
|
|
|
if ((data->rootbone == 0) || (data->rootbone > level)) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((data->flag & CONSTRAINT_IK_AUTO) == 0) {
|
2013-09-13 03:03:46 +00:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-09-13 03:03:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (bone = pchan->bone->childbase.first; bone; bone = bone->next) {
|
|
|
|
pchan = BKE_pose_channel_find_name(ob->pose, bone->name);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) {
|
2013-09-13 03:03:46 +00:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-09-13 03:03:46 +00:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
|
|
|
|
{
|
|
|
|
return pose_channel_in_IK_chain(ob, pchan, 0);
|
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Removes the hash for quick lookup of channels, must
|
|
|
|
* be done when adding/removing channels.
|
|
|
|
*/
|
2021-04-30 15:28:13 +10:00
|
|
|
void BKE_pose_channels_hash_ensure(bPose *pose)
|
2010-03-26 10:33:53 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (!pose->chanhash) {
|
2010-03-26 10:33:53 +00:00
|
|
|
bPoseChannel *pchan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-16 00:51:36 +00:00
|
|
|
pose->chanhash = BLI_ghash_str_new("make_pose_chan gh");
|
2019-04-22 09:39:35 +10:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2010-03-26 10:33:53 +00:00
|
|
|
BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2010-03-26 10:33:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
void BKE_pose_channels_hash_free(bPose *pose)
|
2010-03-26 10:33:53 +00:00
|
|
|
{
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pose->chanhash) {
|
2010-03-26 10:33:53 +00:00
|
|
|
BLI_ghash_free(pose->chanhash, NULL, NULL);
|
2012-05-06 15:15:33 +00:00
|
|
|
pose->chanhash = NULL;
|
2010-03-26 10:33:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-15 15:13:33 +02:00
|
|
|
static void pose_channels_remove_internal_links(Object *ob, bPoseChannel *unlinked_pchan)
|
|
|
|
{
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) {
|
|
|
|
if (pchan->bbone_prev == unlinked_pchan) {
|
|
|
|
pchan->bbone_prev = NULL;
|
|
|
|
}
|
|
|
|
if (pchan->bbone_next == unlinked_pchan) {
|
|
|
|
pchan->bbone_next = NULL;
|
|
|
|
}
|
|
|
|
if (pchan->custom_tx == unlinked_pchan) {
|
|
|
|
pchan->custom_tx = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-13 03:20:07 +10:00
|
|
|
/**
|
|
|
|
* Selectively remove pose channels.
|
|
|
|
*/
|
|
|
|
void BKE_pose_channels_remove(Object *ob,
|
|
|
|
bool (*filter_fn)(const char *bone_name, void *user_data),
|
|
|
|
void *user_data)
|
|
|
|
{
|
2016-05-20 19:08:48 +12:00
|
|
|
/* Erase any associated pose channel, along with any references to them */
|
2015-06-13 03:20:07 +10:00
|
|
|
if (ob->pose) {
|
|
|
|
bPoseChannel *pchan, *pchan_next;
|
|
|
|
bConstraint *con;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-13 03:20:07 +10:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan_next) {
|
|
|
|
pchan_next = pchan->next;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-13 03:20:07 +10:00
|
|
|
if (filter_fn(pchan->name, user_data)) {
|
2016-05-20 19:08:48 +12:00
|
|
|
/* Bone itself is being removed */
|
2015-06-13 03:20:07 +10:00
|
|
|
BKE_pose_channel_free(pchan);
|
2019-07-15 15:13:33 +02:00
|
|
|
pose_channels_remove_internal_links(ob, pchan);
|
2015-06-13 03:20:07 +10:00
|
|
|
if (ob->pose->chanhash) {
|
|
|
|
BLI_ghash_remove(ob->pose->chanhash, pchan->name, NULL, NULL);
|
|
|
|
}
|
|
|
|
BLI_freelinkN(&ob->pose->chanbase, pchan);
|
|
|
|
}
|
|
|
|
else {
|
2016-05-20 19:08:48 +12:00
|
|
|
/* Maybe something the bone references is being removed instead? */
|
2015-06-13 03:20:07 +10:00
|
|
|
for (con = pchan->constraints.first; con; con = con->next) {
|
|
|
|
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
|
|
|
ListBase targets = {NULL, NULL};
|
|
|
|
bConstraintTarget *ct;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-13 03:20:07 +10:00
|
|
|
if (cti && cti->get_constraint_targets) {
|
|
|
|
cti->get_constraint_targets(con, &targets);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-06-13 03:20:07 +10:00
|
|
|
for (ct = targets.first; ct; ct = ct->next) {
|
|
|
|
if (ct->tar == ob) {
|
|
|
|
if (ct->subtarget[0]) {
|
|
|
|
if (filter_fn(ct->subtarget, user_data)) {
|
|
|
|
con->flag |= CONSTRAINT_DISABLE;
|
|
|
|
ct->subtarget[0] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (cti->flush_constraint_targets) {
|
2015-06-13 03:20:07 +10:00
|
|
|
cti->flush_constraint_targets(con, &targets, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2015-06-13 03:20:07 +10:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
if (pchan->bbone_prev) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (filter_fn(pchan->bbone_prev->name, user_data)) {
|
2016-05-20 19:08:48 +12:00
|
|
|
pchan->bbone_prev = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-20 19:08:48 +12:00
|
|
|
}
|
|
|
|
if (pchan->bbone_next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (filter_fn(pchan->bbone_next->name, user_data)) {
|
2016-05-20 19:08:48 +12:00
|
|
|
pchan->bbone_next = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-20 19:08:48 +12:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
if (pchan->custom_tx) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (filter_fn(pchan->custom_tx->name, user_data)) {
|
2016-05-20 19:08:48 +12:00
|
|
|
pchan->custom_tx = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-20 19:08:48 +12:00
|
|
|
}
|
2015-06-13 03:20:07 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Deallocates a pose channel.
|
|
|
|
* Does not free the pose channel itself.
|
|
|
|
*/
|
2013-12-25 16:43:26 +06:00
|
|
|
void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
|
2009-11-21 11:26:09 +00:00
|
|
|
{
|
2013-08-07 15:23:09 +00:00
|
|
|
if (pchan->custom) {
|
2013-12-25 16:43:26 +06:00
|
|
|
if (do_id_user) {
|
|
|
|
id_us_min(&pchan->custom->id);
|
|
|
|
}
|
2013-08-07 15:23:09 +00:00
|
|
|
pchan->custom = NULL;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
if (pchan->mpath) {
|
|
|
|
animviz_free_motionpath(pchan->mpath);
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->mpath = NULL;
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-03-06 15:21:01 +05:00
|
|
|
BKE_constraints_free_ex(&pchan->constraints, do_id_user);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cleanup of MotionPaths+Ghosts (AnimViz) - Part 1
This commit sets up some of the groundwork necessary to extend the animation visualisation capabilities, previously only available for bones in PoseMode, to Objects as well. Also, some of the other goals of this refactor is to make future visualisation goodies (i.e. editable paths) more feasible...
(There's really nothing to see here yet. The following log notes are really just for my own reference to keep track of things.)
Currently, the following things have been done:
* New datastructures + settings have been tidied up, ready for usage
* Added these new types into the Object and PoseBone code as necessary, with freeing/adding/copying accounted for
* File IO code for the new data, including version patching to convert the old system to the new one.
* Set up the drawing system for motionpaths based on the old armature path drawing code. Armatures still draw using the old system, since the two systems use different storage systems.
* Started setting up the motionpath 'baking' code, but the core of this still needs to be coded...
Next Steps (after some semi-urgent Durian Driver changes):
* Port the ghosting/onionskinning code over too
* Finish motionpath baking code
* RNA wrapping for the new types
* Hooking up all the new code into the operators, etc.
2010-01-01 12:24:16 +00:00
|
|
|
if (pchan->prop) {
|
2020-07-01 14:42:24 +03:00
|
|
|
IDP_FreeProperty_ex(pchan->prop, do_id_user);
|
2020-04-07 13:50:57 +02:00
|
|
|
pchan->prop = NULL;
|
2009-11-21 11:26:09 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-05-04 01:32:16 +10:00
|
|
|
/* Cached data, for new draw manager rendering code. */
|
2017-05-03 16:10:25 +02:00
|
|
|
MEM_SAFE_FREE(pchan->draw_data);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-18 21:19:57 +03:00
|
|
|
/* Cached B-Bone shape and other data. */
|
|
|
|
BKE_pose_channel_runtime_free(&pchan->runtime);
|
2018-11-22 13:38:03 +03:00
|
|
|
}
|
|
|
|
|
2019-04-18 21:19:57 +03:00
|
|
|
/** Clears the runtime cache of a pose channel without free. */
|
|
|
|
void BKE_pose_channel_runtime_reset(bPoseChannel_Runtime *runtime)
|
2018-11-22 13:38:03 +03:00
|
|
|
{
|
2019-04-18 21:19:57 +03:00
|
|
|
memset(runtime, 0, sizeof(*runtime));
|
|
|
|
}
|
2018-11-22 13:38:03 +03:00
|
|
|
|
2020-08-03 17:17:57 +02:00
|
|
|
/* Reset all non-persistent fields. */
|
|
|
|
void BKE_pose_channel_runtime_reset_on_copy(bPoseChannel_Runtime *runtime)
|
|
|
|
{
|
|
|
|
const SessionUUID uuid = runtime->session_uuid;
|
|
|
|
memset(runtime, 0, sizeof(*runtime));
|
|
|
|
runtime->session_uuid = uuid;
|
|
|
|
}
|
|
|
|
|
2019-04-18 21:19:57 +03:00
|
|
|
/** Deallocates runtime cache of a pose channel */
|
|
|
|
void BKE_pose_channel_runtime_free(bPoseChannel_Runtime *runtime)
|
|
|
|
{
|
|
|
|
BKE_pose_channel_free_bbone_cache(runtime);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Deallocates runtime cache of a pose channel's B-Bone shape. */
|
|
|
|
void BKE_pose_channel_free_bbone_cache(bPoseChannel_Runtime *runtime)
|
|
|
|
{
|
2018-11-22 13:38:03 +03:00
|
|
|
runtime->bbone_segments = 0;
|
|
|
|
MEM_SAFE_FREE(runtime->bbone_rest_mats);
|
|
|
|
MEM_SAFE_FREE(runtime->bbone_pose_mats);
|
|
|
|
MEM_SAFE_FREE(runtime->bbone_deform_mats);
|
|
|
|
MEM_SAFE_FREE(runtime->bbone_dual_quats);
|
2009-11-21 11:26:09 +00:00
|
|
|
}
|
|
|
|
|
2013-12-25 16:43:26 +06:00
|
|
|
void BKE_pose_channel_free(bPoseChannel *pchan)
|
|
|
|
{
|
|
|
|
BKE_pose_channel_free_ex(pchan, true);
|
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Removes and deallocates all channels from a pose.
|
|
|
|
* Does not free the pose itself.
|
|
|
|
*/
|
2013-12-25 16:43:26 +06:00
|
|
|
void BKE_pose_channels_free_ex(bPose *pose, bool do_id_user)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
2005-10-23 10:08:19 +00:00
|
|
|
bPoseChannel *pchan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
== Bone Groups ==
I'm committing some work-in-progress code for "bone groups" now, as I there have been are some major bugs caused by the timeoffset stuff (some of my test files were not loading, and other files were showing all sorts of weird problems).
Anyway, in this commit, the following things for "bone groups" have been done:
* Bone groups are stored per armature (internally, this is per bPose block)
* Added controls for editing bone-groups per armature - "add", "remove", "rename". These can be found in the "Links and Materials" panel in PoseMode, beside the settings for PoseLib.
* Reorganised buttons for editing selected bones in PoseMode. I've replaced the "dist" and "weight" buttons (they existed in EditMode anyway) with a menu to choose the bone-group and the custom-shape-ob field. In the place of the old custom-shape-ob field, I've restored the "Hide" button. This might break muscle-memory a bit, but there isn't a lot of space to play with there.
Some stuff I'd been originally planning to do before committing:
* When adding keyframes for bones, an action-group with the same name as the bone's group will be added to the action, and the action-channel will be made a member of that.
* New action/bone groups have unique names (renaming/adding new should check if name exists before assigning it)
* There's a setting under Bone-Groups stuff which sets which custom-colour set is used to colour that group's bones. Currently, this is non-functional, as the necessary drawing code for armatures is not in place yet.
2008-01-20 02:55:35 +00:00
|
|
|
if (pose->chanbase.first) {
|
2019-04-22 09:39:35 +10:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2013-12-25 16:43:26 +06:00
|
|
|
BKE_pose_channel_free_ex(pchan, do_id_user);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-03-16 03:51:00 +00:00
|
|
|
BLI_freelistN(&pose->chanbase);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-03-26 10:33:53 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_channels_hash_free(pose);
|
2019-04-14 21:53:03 +03:00
|
|
|
|
|
|
|
MEM_SAFE_FREE(pose->chan_array);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2013-12-25 16:43:26 +06:00
|
|
|
void BKE_pose_channels_free(bPose *pose)
|
|
|
|
{
|
|
|
|
BKE_pose_channels_free_ex(pose, true);
|
|
|
|
}
|
|
|
|
|
2016-05-10 16:45:27 +02:00
|
|
|
void BKE_pose_free_data_ex(bPose *pose, bool do_id_user)
|
|
|
|
{
|
|
|
|
/* free pose-channels */
|
|
|
|
BKE_pose_channels_free_ex(pose, do_id_user);
|
|
|
|
|
|
|
|
/* free pose-groups */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose->agroups.first) {
|
2016-05-10 16:45:27 +02:00
|
|
|
BLI_freelistN(&pose->agroups);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-10 16:45:27 +02:00
|
|
|
|
|
|
|
/* free IK solver state */
|
|
|
|
BIK_clear_data(pose);
|
|
|
|
|
|
|
|
/* free IK solver param */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose->ikparam) {
|
2016-05-10 16:45:27 +02:00
|
|
|
MEM_freeN(pose->ikparam);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-10 16:45:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_pose_free_data(bPose *pose)
|
|
|
|
{
|
|
|
|
BKE_pose_free_data_ex(pose, true);
|
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Removes and deallocates all data from a pose, and also frees the pose.
|
|
|
|
*/
|
2013-12-25 16:43:26 +06:00
|
|
|
void BKE_pose_free_ex(bPose *pose, bool do_id_user)
|
== Bone Groups ==
I'm committing some work-in-progress code for "bone groups" now, as I there have been are some major bugs caused by the timeoffset stuff (some of my test files were not loading, and other files were showing all sorts of weird problems).
Anyway, in this commit, the following things for "bone groups" have been done:
* Bone groups are stored per armature (internally, this is per bPose block)
* Added controls for editing bone-groups per armature - "add", "remove", "rename". These can be found in the "Links and Materials" panel in PoseMode, beside the settings for PoseLib.
* Reorganised buttons for editing selected bones in PoseMode. I've replaced the "dist" and "weight" buttons (they existed in EditMode anyway) with a menu to choose the bone-group and the custom-shape-ob field. In the place of the old custom-shape-ob field, I've restored the "Hide" button. This might break muscle-memory a bit, but there isn't a lot of space to play with there.
Some stuff I'd been originally planning to do before committing:
* When adding keyframes for bones, an action-group with the same name as the bone's group will be added to the action, and the action-channel will be made a member of that.
* New action/bone groups have unique names (renaming/adding new should check if name exists before assigning it)
* There's a setting under Bone-Groups stuff which sets which custom-colour set is used to colour that group's bones. Currently, this is non-functional, as the necessary drawing code for armatures is not in place yet.
2008-01-20 02:55:35 +00:00
|
|
|
{
|
|
|
|
if (pose) {
|
2016-05-10 16:45:27 +02:00
|
|
|
BKE_pose_free_data_ex(pose, do_id_user);
|
2009-09-24 21:22:24 +00:00
|
|
|
/* free pose */
|
2008-09-17 01:29:54 +00:00
|
|
|
MEM_freeN(pose);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-25 16:43:26 +06:00
|
|
|
void BKE_pose_free(bPose *pose)
|
|
|
|
{
|
|
|
|
BKE_pose_free_ex(pose, true);
|
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Copy the internal members of each pose channel including constraints
|
|
|
|
* and ID-Props, used when duplicating bones in editmode.
|
2016-05-20 19:08:48 +12:00
|
|
|
* (unlike copy_pose_channel_data which only does posing-related stuff).
|
2013-10-26 03:56:32 +00:00
|
|
|
*
|
2021-04-30 15:30:41 +10:00
|
|
|
* \note use when copying bones in editmode (on returned value from #BKE_pose_channel_ensure)
|
2013-10-26 03:56:32 +00:00
|
|
|
*/
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from)
|
2009-11-23 23:03:04 +00:00
|
|
|
{
|
|
|
|
/* copy transform locks */
|
|
|
|
pchan->protectflag = pchan_from->protectflag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 23:03:04 +00:00
|
|
|
/* copy rotation mode */
|
|
|
|
pchan->rotmode = pchan_from->rotmode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 23:03:04 +00:00
|
|
|
/* copy bone group */
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->agrp_index = pchan_from->agrp_index;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 23:03:04 +00:00
|
|
|
/* ik (dof) settings */
|
|
|
|
pchan->ikflag = pchan_from->ikflag;
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(pchan->limitmin, pchan_from->limitmin);
|
|
|
|
copy_v3_v3(pchan->limitmax, pchan_from->limitmax);
|
|
|
|
copy_v3_v3(pchan->stiffness, pchan_from->stiffness);
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->ikstretch = pchan_from->ikstretch;
|
|
|
|
pchan->ikrotweight = pchan_from->ikrotweight;
|
|
|
|
pchan->iklinweight = pchan_from->iklinweight;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
/* bbone settings (typically not animated) */
|
|
|
|
pchan->bbone_next = pchan_from->bbone_next;
|
|
|
|
pchan->bbone_prev = pchan_from->bbone_prev;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 23:03:04 +00:00
|
|
|
/* constraints */
|
2014-04-11 11:47:07 +10:00
|
|
|
BKE_constraints_copy(&pchan->constraints, &pchan_from->constraints, true);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 23:03:04 +00:00
|
|
|
/* id-properties */
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pchan->prop) {
|
2009-11-23 23:03:04 +00:00
|
|
|
/* unlikely but possible it exists */
|
|
|
|
IDP_FreeProperty(pchan->prop);
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->prop = NULL;
|
2009-11-23 23:03:04 +00:00
|
|
|
}
|
2012-03-24 06:18:31 +00:00
|
|
|
if (pchan_from->prop) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->prop = IDP_CopyProperty(pchan_from->prop);
|
2009-11-23 23:03:04 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-11-23 23:03:04 +00:00
|
|
|
/* custom shape */
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->custom = pchan_from->custom;
|
2013-08-12 13:52:13 +00:00
|
|
|
if (pchan->custom) {
|
|
|
|
id_us_plus(&pchan->custom->id);
|
|
|
|
}
|
2021-05-11 11:22:41 +02:00
|
|
|
copy_v3_v3(pchan->custom_scale_xyz, pchan_from->custom_scale_xyz);
|
|
|
|
copy_v3_v3(pchan->custom_translation, pchan_from->custom_translation);
|
|
|
|
copy_v3_v3(pchan->custom_rotation_euler, pchan_from->custom_rotation_euler);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-14 22:35:07 +02:00
|
|
|
pchan->drawflag = pchan_from->drawflag;
|
2009-11-23 23:03:04 +00:00
|
|
|
}
|
|
|
|
|
2009-11-01 11:29:40 +00:00
|
|
|
/* checks for IK constraint, Spline IK, and also for Follow-Path constraint.
|
2018-06-01 18:19:39 +02:00
|
|
|
* can do more constraints flags later
|
2008-03-25 05:32:04 +00:00
|
|
|
*/
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* pose should be entirely OK */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_update_constraint_flags(bPose *pose)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
bPoseChannel *pchan, *parchan;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
bConstraint *con;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* clear */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
pchan->constflag = 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2008-03-25 05:32:04 +00:00
|
|
|
pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* detect */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
for (con = pchan->constraints.first; con; con = con->next) {
|
|
|
|
if (con->type == CONSTRAINT_TYPE_KINEMATIC) {
|
|
|
|
bKinematicConstraint *data = (bKinematicConstraint *)con->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
pchan->constflag |= PCHAN_HAS_IK;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
|
2005-10-30 13:50:42 +00:00
|
|
|
pchan->constflag |= PCHAN_HAS_TARGET;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
/* negative rootbone = recalc rootbone index. used in do_versions */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (data->rootbone < 0) {
|
|
|
|
data->rootbone = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (data->flag & CONSTRAINT_IK_TIP) {
|
2012-05-06 15:15:33 +00:00
|
|
|
parchan = pchan;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
parchan = pchan->parent;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:18:31 +00:00
|
|
|
while (parchan) {
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
data->rootbone++;
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((parchan->bone->flag & BONE_CONNECTED) == 0) {
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
parchan = parchan->parent;
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
}
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2008-03-25 05:32:04 +00:00
|
|
|
else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
|
2012-05-06 15:15:33 +00:00
|
|
|
bFollowPathConstraint *data = (bFollowPathConstraint *)con->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-03-25 05:32:04 +00:00
|
|
|
/* for drawing constraint colors when color set allows this */
|
|
|
|
pchan->constflag |= PCHAN_HAS_CONST;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2008-03-25 05:32:04 +00:00
|
|
|
/* if we have a valid target, make sure that this will get updated on frame-change
|
|
|
|
* (needed for when there is no anim-data for this pose)
|
|
|
|
*/
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((data->tar) && (data->tar->type == OB_CURVE)) {
|
2008-03-25 05:32:04 +00:00
|
|
|
pose->flag |= POSE_CONSTRAINTS_TIMEDEPEND;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2008-03-25 05:32:04 +00:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
|
2009-11-01 11:29:40 +00:00
|
|
|
pchan->constflag |= PCHAN_HAS_SPLINEIK;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2008-03-25 05:32:04 +00:00
|
|
|
pchan->constflag |= PCHAN_HAS_CONST;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2015-03-19 18:28:49 +05:00
|
|
|
pose->flag &= ~POSE_CONSTRAINTS_NEED_UPDATE_FLAGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_pose_tag_update_constraint_flags(bPose *pose)
|
|
|
|
{
|
|
|
|
pose->flag |= POSE_CONSTRAINTS_NEED_UPDATE_FLAGS;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-07-21 10:18:08 +00:00
|
|
|
/* ************************** Bone Groups ************************** */
|
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
/* Adds a new bone-group (name may be NULL) */
|
|
|
|
bActionGroup *BKE_pose_add_group(bPose *pose, const char *name)
|
2009-07-21 10:18:08 +00:00
|
|
|
{
|
|
|
|
bActionGroup *grp;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
if (!name) {
|
|
|
|
name = DATA_("Group");
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup");
|
2014-07-09 10:27:31 +02:00
|
|
|
BLI_strncpy(grp->name, name, sizeof(grp->name));
|
2009-07-21 10:18:08 +00:00
|
|
|
BLI_addtail(&pose->agroups, grp);
|
2014-07-09 10:27:31 +02:00
|
|
|
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-11-16 13:57:58 +01:00
|
|
|
pose->active_group = BLI_listbase_count(&pose->agroups);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
return grp;
|
2009-07-21 10:18:08 +00:00
|
|
|
}
|
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
/* Remove the given bone-group (expects 'virtual' index (+1 one, used by active_group etc.))
|
|
|
|
* index might be invalid ( < 1), in which case it will be find from grp. */
|
|
|
|
void BKE_pose_remove_group(bPose *pose, bActionGroup *grp, const int index)
|
2009-07-21 10:18:08 +00:00
|
|
|
{
|
|
|
|
bPoseChannel *pchan;
|
2014-07-09 10:27:31 +02:00
|
|
|
int idx = index;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
if (idx < 1) {
|
|
|
|
idx = BLI_findindex(&pose->agroups, grp) + 1;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
BLI_assert(idx > 0);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
/* adjust group references (the trouble of using indices!):
|
2018-11-14 12:53:15 +11:00
|
|
|
* - firstly, make sure nothing references it
|
|
|
|
* - also, make sure that those after this item get corrected
|
2014-07-09 10:27:31 +02:00
|
|
|
*/
|
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pchan->agrp_index == idx) {
|
2014-07-09 10:27:31 +02:00
|
|
|
pchan->agrp_index = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (pchan->agrp_index > idx) {
|
2014-07-09 10:27:31 +02:00
|
|
|
pchan->agrp_index--;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2014-07-09 10:27:31 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
/* now, remove it from the pose */
|
|
|
|
BLI_freelinkN(&pose->agroups, grp);
|
|
|
|
if (pose->active_group >= idx) {
|
2015-01-23 16:59:16 +05:00
|
|
|
const bool has_groups = !BLI_listbase_is_empty(&pose->agroups);
|
2011-05-18 08:16:33 +00:00
|
|
|
pose->active_group--;
|
2015-01-23 16:59:16 +05:00
|
|
|
if (pose->active_group == 0 && has_groups) {
|
|
|
|
pose->active_group = 1;
|
|
|
|
}
|
|
|
|
else if (pose->active_group < 0 || !has_groups) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pose->active_group = 0;
|
2011-05-18 08:16:33 +00:00
|
|
|
}
|
2009-07-21 10:18:08 +00:00
|
|
|
}
|
|
|
|
}
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
/* Remove the indexed bone-group (expects 'virtual' index (+1 one, used by active_group etc.)) */
|
|
|
|
void BKE_pose_remove_group_index(bPose *pose, const int index)
|
|
|
|
{
|
|
|
|
bActionGroup *grp = NULL;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-07-09 10:27:31 +02:00
|
|
|
/* get group to remove */
|
|
|
|
grp = BLI_findlink(&pose->agroups, index - 1);
|
|
|
|
if (grp) {
|
|
|
|
BKE_pose_remove_group(pose, grp, index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* ************** F-Curve Utilities for Actions ****************** */
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
/* Check if the given action has any keyframes */
|
2014-02-03 18:55:59 +11:00
|
|
|
bool action_has_motion(const bAction *act)
|
2009-05-23 09:36:18 +00:00
|
|
|
{
|
|
|
|
FCurve *fcu;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
/* return on the first F-Curve that has some keyframes/samples defined */
|
|
|
|
if (act) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fcu->totvert) {
|
2014-12-01 17:11:18 +01:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-05-23 09:36:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-05-23 09:36:18 +00:00
|
|
|
/* nothing found */
|
2014-12-01 17:11:18 +01:00
|
|
|
return false;
|
2009-05-23 09:36:18 +00:00
|
|
|
}
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
|
|
|
|
/* Calculate the extents of given action */
|
2009-08-25 01:46:05 +00:00
|
|
|
void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers)
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
{
|
2009-04-14 10:18:48 +00:00
|
|
|
FCurve *fcu;
|
2012-05-06 15:15:33 +00:00
|
|
|
float min = 999999999.0f, max = -999999999.0f;
|
|
|
|
short foundvert = 0, foundmod = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
if (act) {
|
2012-05-06 15:15:33 +00:00
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
2009-08-25 01:46:05 +00:00
|
|
|
/* if curve has keyframes, consider them first */
|
2009-04-14 10:18:48 +00:00
|
|
|
if (fcu->totvert) {
|
|
|
|
float nmin, nmax;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-09-12 12:35:04 +12:00
|
|
|
/* get extents for this curve
|
|
|
|
* - no "selected only", since this is often used in the backend
|
|
|
|
* - no "minimum length" (we will apply this later), otherwise
|
|
|
|
* single-keyframe curves will increase the overall length by
|
|
|
|
* a phantom frame (T50354)
|
|
|
|
*/
|
2020-06-05 09:30:15 +02:00
|
|
|
BKE_fcurve_calc_range(fcu, &nmin, &nmax, false, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-14 10:18:48 +00:00
|
|
|
/* compare to the running tally */
|
2012-10-23 16:21:55 +00:00
|
|
|
min = min_ff(min, nmin);
|
|
|
|
max = max_ff(max, nmax);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
foundvert = 1;
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-25 01:46:05 +00:00
|
|
|
/* if incl_modifiers is enabled, need to consider modifiers too
|
2018-11-14 12:53:15 +11:00
|
|
|
* - only really care about the last modifier
|
2009-08-25 01:46:05 +00:00
|
|
|
*/
|
|
|
|
if ((incl_modifiers) && (fcu->modifiers.last)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
FModifier *fcm = fcu->modifiers.last;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-25 01:46:05 +00:00
|
|
|
/* only use the maximum sensible limits of the modifiers if they are more extreme */
|
|
|
|
switch (fcm->type) {
|
|
|
|
case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
FMod_Limits *fmd = (FMod_Limits *)fcm->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-25 01:46:05 +00:00
|
|
|
if (fmd->flag & FCM_LIMIT_XMIN) {
|
2012-10-23 16:21:55 +00:00
|
|
|
min = min_ff(min, fmd->rect.xmin);
|
2009-08-25 01:46:05 +00:00
|
|
|
}
|
|
|
|
if (fmd->flag & FCM_LIMIT_XMAX) {
|
2012-10-23 16:21:55 +00:00
|
|
|
max = max_ff(max, fmd->rect.xmax);
|
2009-08-25 01:46:05 +00:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-08-25 01:46:05 +00:00
|
|
|
}
|
|
|
|
case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */
|
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
FMod_Cycles *fmd = (FMod_Cycles *)fcm->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) {
|
2012-05-06 15:15:33 +00:00
|
|
|
min = MINAFRAMEF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) {
|
2012-05-06 15:15:33 +00:00
|
|
|
max = MAXFRAMEF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2013-07-19 15:23:42 +00:00
|
|
|
break;
|
2009-08-25 01:46:05 +00:00
|
|
|
}
|
2012-07-06 23:56:59 +00:00
|
|
|
/* TODO: function modifier may need some special limits */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-25 01:46:05 +00:00
|
|
|
default: /* all other standard modifiers are on the infinite range... */
|
2012-05-06 15:15:33 +00:00
|
|
|
min = MINAFRAMEF;
|
|
|
|
max = MAXFRAMEF;
|
2009-08-25 01:46:05 +00:00
|
|
|
break;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
foundmod = 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-08-25 01:46:05 +00:00
|
|
|
}
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-08-25 01:46:05 +00:00
|
|
|
if (foundvert || foundmod) {
|
2017-09-12 12:35:04 +12:00
|
|
|
/* ensure that action is at least 1 frame long (for NLA strips to have a valid length) */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (min == max) {
|
2012-05-06 15:15:33 +00:00
|
|
|
max += 1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
*start = min;
|
|
|
|
*end = max;
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
*start = 0.0f;
|
|
|
|
*end = 1.0f;
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* Return flags indicating which transforms the given object/posechannel has
|
2018-11-14 12:53:15 +11:00
|
|
|
* - if 'curves' is provided, a list of links to these curves are also returned
|
2009-09-17 10:14:56 +00:00
|
|
|
*/
|
2012-04-29 17:11:40 +00:00
|
|
|
short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, ListBase *curves)
|
2009-09-17 10:14:56 +00:00
|
|
|
{
|
|
|
|
PointerRNA ptr;
|
|
|
|
FCurve *fcu;
|
2012-05-06 15:15:33 +00:00
|
|
|
char *basePath = NULL;
|
|
|
|
short flags = 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* build PointerRNA from provided data to obtain the paths to use */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pchan) {
|
2009-11-18 11:40:55 +00:00
|
|
|
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (ob) {
|
2009-09-17 10:14:56 +00:00
|
|
|
RNA_id_pointer_create((ID *)ob, &ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2009-09-17 10:14:56 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* get the basic path to the properties of interest */
|
2012-05-06 15:15:33 +00:00
|
|
|
basePath = RNA_path_from_ID_to_struct(&ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (basePath == NULL) {
|
2009-09-17 10:14:56 +00:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* search F-Curves for the given properties
|
2018-11-14 12:53:15 +11:00
|
|
|
* - we cannot use the groups, since they may not be grouped in that way...
|
2009-09-17 10:14:56 +00:00
|
|
|
*/
|
2012-05-06 15:15:33 +00:00
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
2014-04-27 00:20:13 +10:00
|
|
|
const char *bPtr = NULL, *pPtr = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-27 12:07:07 +10:00
|
|
|
/* If enough flags have been found,
|
|
|
|
* we can stop checking unless we're also getting the curves. */
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((flags == ACT_TRANS_ALL) && (curves == NULL)) {
|
2009-09-17 10:14:56 +00:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* just in case... */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fcu->rna_path == NULL) {
|
2009-09-17 10:14:56 +00:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* step 1: check for matching base path */
|
2012-05-06 15:15:33 +00:00
|
|
|
bPtr = strstr(fcu->rna_path, basePath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
if (bPtr) {
|
2018-06-17 17:05:51 +02:00
|
|
|
/* we must add len(basePath) bytes to the match so that we are at the end of the
|
2011-03-13 12:22:57 +00:00
|
|
|
* base path so that we don't get false positives with these strings in the names
|
|
|
|
*/
|
|
|
|
bPtr += strlen(basePath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* step 2: check for some property with transforms
|
2018-11-14 12:53:15 +11:00
|
|
|
* - to speed things up, only check for the ones not yet found
|
|
|
|
* unless we're getting the curves too
|
|
|
|
* - if we're getting the curves, the BLI_genericNodeN() creates a LinkData
|
|
|
|
* node wrapping the F-Curve, which then gets added to the list
|
|
|
|
* - once a match has been found, the curve cannot possibly be any other one
|
2009-09-17 10:14:56 +00:00
|
|
|
*/
|
|
|
|
if ((curves) || (flags & ACT_TRANS_LOC) == 0) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pPtr = strstr(bPtr, "location");
|
2011-03-13 12:22:57 +00:00
|
|
|
if (pPtr) {
|
2009-09-17 10:14:56 +00:00
|
|
|
flags |= ACT_TRANS_LOC;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2009-09-17 10:14:56 +00:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
if ((curves) || (flags & ACT_TRANS_SCALE) == 0) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pPtr = strstr(bPtr, "scale");
|
2011-03-13 12:22:57 +00:00
|
|
|
if (pPtr) {
|
2009-09-17 10:14:56 +00:00
|
|
|
flags |= ACT_TRANS_SCALE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2009-09-17 10:14:56 +00:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
if ((curves) || (flags & ACT_TRANS_ROT) == 0) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pPtr = strstr(bPtr, "rotation");
|
2011-03-13 12:22:57 +00:00
|
|
|
if (pPtr) {
|
2009-09-17 10:14:56 +00:00
|
|
|
flags |= ACT_TRANS_ROT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2009-09-17 10:14:56 +00:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
if ((curves) || (flags & ACT_TRANS_BBONE) == 0) {
|
|
|
|
/* bbone shape properties */
|
|
|
|
pPtr = strstr(bPtr, "bbone_");
|
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_BBONE;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2016-05-18 03:19:06 +12:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-18 03:19:06 +12:00
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-05-18 03:19:06 +12:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-03-13 12:22:57 +00:00
|
|
|
if ((curves) || (flags & ACT_TRANS_PROP) == 0) {
|
|
|
|
/* custom properties only */
|
2019-08-15 01:05:15 +10:00
|
|
|
pPtr = strstr(bPtr, "[\"");
|
2011-03-13 12:22:57 +00:00
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_PROP;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2011-03-13 12:22:57 +00:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2011-03-13 12:22:57 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2009-09-17 10:14:56 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* free basePath */
|
|
|
|
MEM_freeN(basePath);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-09-17 10:14:56 +00:00
|
|
|
/* return flags found */
|
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************** Pose Management Tools ****************** */
|
|
|
|
|
2020-07-21 09:51:27 -04:00
|
|
|
/**
|
|
|
|
* Zero the pose transforms for the entire pose or only for selected bones.
|
|
|
|
*/
|
|
|
|
void BKE_pose_rest(bPose *pose, bool selected_bones_only)
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
{
|
|
|
|
bPoseChannel *pchan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!pose) {
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
|
|
|
|
memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2020-07-21 09:51:27 -04:00
|
|
|
if (selected_bones_only && pchan->bone != NULL && (pchan->bone->flag & BONE_SELECTED) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-02-02 00:40:55 +00:00
|
|
|
zero_v3(pchan->loc);
|
|
|
|
zero_v3(pchan->eul);
|
|
|
|
unit_qt(pchan->quat);
|
|
|
|
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
pchan->roll1 = pchan->roll2 = 0.0f;
|
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
2020-12-11 19:17:39 +03:00
|
|
|
pchan->curve_in_x = pchan->curve_in_z = 0.0f;
|
|
|
|
pchan->curve_out_x = pchan->curve_out_z = 0.0f;
|
2017-11-01 13:38:51 +13:00
|
|
|
pchan->ease1 = pchan->ease2 = 0.0f;
|
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
2020-12-11 19:17:39 +03:00
|
|
|
|
|
|
|
copy_v3_fl(pchan->scale_in, 1.0f);
|
|
|
|
copy_v3_fl(pchan->scale_out, 1.0f);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-20 19:08:48 +12:00
|
|
|
pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE);
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-14 10:45:35 +02:00
|
|
|
void BKE_pose_copy_pchan_result(bPoseChannel *pchanto, const bPoseChannel *pchanfrom)
|
2018-07-31 13:23:01 +02:00
|
|
|
{
|
|
|
|
copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
|
|
|
|
copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 13:23:01 +02:00
|
|
|
/* used for local constraints */
|
|
|
|
copy_v3_v3(pchanto->loc, pchanfrom->loc);
|
|
|
|
copy_qt_qt(pchanto->quat, pchanfrom->quat);
|
|
|
|
copy_v3_v3(pchanto->eul, pchanfrom->eul);
|
|
|
|
copy_v3_v3(pchanto->size, pchanfrom->size);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 13:23:01 +02:00
|
|
|
copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head);
|
|
|
|
copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 13:23:01 +02:00
|
|
|
pchanto->roll1 = pchanfrom->roll1;
|
|
|
|
pchanto->roll2 = pchanfrom->roll2;
|
2019-04-23 13:15:30 +03:00
|
|
|
pchanto->curve_in_x = pchanfrom->curve_in_x;
|
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
2020-12-11 19:17:39 +03:00
|
|
|
pchanto->curve_in_z = pchanfrom->curve_in_z;
|
2019-04-23 13:15:30 +03:00
|
|
|
pchanto->curve_out_x = pchanfrom->curve_out_x;
|
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
2020-12-11 19:17:39 +03:00
|
|
|
pchanto->curve_out_z = pchanfrom->curve_out_z;
|
2018-07-31 13:23:01 +02:00
|
|
|
pchanto->ease1 = pchanfrom->ease1;
|
|
|
|
pchanto->ease2 = pchanfrom->ease2;
|
Armature: add B-Bone Y scale channel and extra flag fields to DNA.
In addition to the base bone transformation itself, B-Bones have
controls that affect transformation of its segments. For rotation
the features are quite complete, allowing to both reorient the
Bezier handles via properties, and to control them using custom
handle bones. However for scaling there are two deficiencies.
First, there are only X and Y scale factors (actually X and Z),
while lengthwise all segments have the same scaling. The ease
option merely affects the shape of the curve, and does not cause
actual scaling.
Second, scaling can only be controlled via properties, thus
requiring up to 6 drivers per joint between B-Bones to transfer
scaling factors from the handle bone. This is very inefficient.
Finally, the Z channels are confusingly called Y.
This commit adds a B-Bone Y Scale channel and extra B-Bone flag
fields to DNA with appropriate versioning (including for F-Curves
and drivers) in preparation to addressing these limitations.
Functionality is not changed, so the new fields are not used
until the following commits.
Differential Revision: https://developer.blender.org/D9870
2020-12-11 19:17:39 +03:00
|
|
|
|
|
|
|
copy_v3_v3(pchanto->scale_in, pchanfrom->scale_in);
|
|
|
|
copy_v3_v3(pchanto->scale_out, pchanfrom->scale_out);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-31 13:23:01 +02:00
|
|
|
pchanto->rotmode = pchanfrom->rotmode;
|
|
|
|
pchanto->flag = pchanfrom->flag;
|
|
|
|
pchanto->protectflag = pchanfrom->protectflag;
|
|
|
|
}
|
|
|
|
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
/* both poses should be in sync */
|
2013-01-24 14:48:08 +00:00
|
|
|
bool BKE_pose_copy_result(bPose *to, bPose *from)
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
{
|
|
|
|
bPoseChannel *pchanto, *pchanfrom;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (to == NULL || from == NULL) {
|
2019-02-01 12:44:19 +11:00
|
|
|
CLOG_ERROR(
|
|
|
|
&LOG, "Pose copy error, pose to:%p from:%p", (void *)to, (void *)from); /* debug temp */
|
2013-01-24 14:48:08 +00:00
|
|
|
return false;
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (to == from) {
|
2019-02-01 12:44:19 +11:00
|
|
|
CLOG_ERROR(&LOG, "source and target are the same");
|
2013-01-24 14:48:08 +00:00
|
|
|
return false;
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (pchanfrom = from->chanbase.first; pchanfrom; pchanfrom = pchanfrom->next) {
|
|
|
|
pchanto = BKE_pose_channel_find_name(to, pchanfrom->name);
|
2018-07-31 13:23:01 +02:00
|
|
|
if (pchanto != NULL) {
|
2019-10-14 10:45:35 +02:00
|
|
|
BKE_pose_copy_pchan_result(pchanto, pchanfrom);
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
|
|
|
}
|
2013-01-24 14:48:08 +00:00
|
|
|
return true;
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
}
|
|
|
|
|
2015-05-12 13:13:36 +05:00
|
|
|
/* Tag pose for recalc. Also tag all related data to be recalc. */
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
void BKE_pose_tag_recalc(Main *bmain, bPose *pose)
|
2015-05-12 13:13:36 +05:00
|
|
|
{
|
|
|
|
pose->flag |= POSE_RECALC;
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* Depsgraph components depends on actual pose state,
|
|
|
|
* if pose was changed depsgraph is to be updated as well.
|
|
|
|
*/
|
2017-04-06 16:11:50 +02:00
|
|
|
DEG_relations_tag_update(bmain);
|
2015-05-12 13:13:36 +05:00
|
|
|
}
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* For the calculation of the effects of an Action at the given frame on an object
|
2018-06-01 18:19:39 +02:00
|
|
|
* This is currently only used for the Action Constraint
|
2009-01-29 11:22:34 +00:00
|
|
|
*/
|
T77086 Animation: Passing Dependency Graph to Drivers
Custom driver functions need access to the dependency graph that is
triggering the evaluation of the driver. This patch passes the
dependency graph pointer through all the animation-related calls.
Instead of passing the evaluation time to functions, the code now passes
an `AnimationEvalContext` pointer:
```
typedef struct AnimationEvalContext {
struct Depsgraph *const depsgraph;
const float eval_time;
} AnimationEvalContext;
```
These structs are read-only, meaning that the code cannot change the
evaluation time. Note that the `depsgraph` pointer itself is const, but
it points to a non-const depsgraph.
FCurves and Drivers can be evaluated at a different time than the
current scene time, for example when evaluating NLA strips. This means
that, even though the current time is stored in the dependency graph, we
need an explicit evaluation time.
There are two functions that allow creation of `AnimationEvalContext`
objects:
- `BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float
eval_time)`, which creates a new context object from scratch, and
- `BKE_animsys_eval_context_construct_at(AnimationEvalContext
*anim_eval_context, float eval_time)`, which can be used to create a
`AnimationEvalContext` with the same depsgraph, but at a different
time. This makes it possible to later add fields without changing any
of the code that just want to change the eval time.
This also provides a fix for T75553, although it does require a change
to the custom driver function. The driver should call
`custom_function(depsgraph)`, and the function should use that depsgraph
instead of information from `bpy.context`.
Reviewed By: brecht, sergey
Differential Revision: https://developer.blender.org/D8047
2020-07-17 17:38:09 +02:00
|
|
|
void what_does_obaction(Object *ob,
|
|
|
|
Object *workob,
|
|
|
|
bPose *pose,
|
|
|
|
bAction *act,
|
|
|
|
char groupname[],
|
|
|
|
const AnimationEvalContext *anim_eval_context)
|
2009-01-29 11:22:34 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
bActionGroup *agrp = BKE_action_group_find_name(act, groupname);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-15 12:59:49 +00:00
|
|
|
/* clear workob */
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_workob_clear(workob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-29 11:22:34 +00:00
|
|
|
/* init workob */
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(workob->obmat, ob->obmat);
|
|
|
|
copy_m4_m4(workob->parentinv, ob->parentinv);
|
|
|
|
copy_m4_m4(workob->constinv, ob->constinv);
|
2012-05-06 15:15:33 +00:00
|
|
|
workob->parent = ob->parent;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
workob->rotmode = ob->rotmode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
workob->trackflag = ob->trackflag;
|
|
|
|
workob->upflag = ob->upflag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
workob->partype = ob->partype;
|
|
|
|
workob->par1 = ob->par1;
|
|
|
|
workob->par2 = ob->par2;
|
|
|
|
workob->par3 = ob->par3;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-01-29 11:22:34 +00:00
|
|
|
workob->constraints.first = ob->constraints.first;
|
|
|
|
workob->constraints.last = ob->constraints.last;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-07-02 22:17:22 +10:00
|
|
|
/* Need to set pose too, since this is used for both types of Action Constraint. */
|
|
|
|
workob->pose = pose;
|
2016-04-26 14:11:03 +02:00
|
|
|
if (pose) {
|
2016-05-10 16:45:27 +02:00
|
|
|
/* This function is most likely to be used with a temporary pose with a single bone in there.
|
|
|
|
* For such cases it makes no sense to create hash since it'll only waste CPU ticks on memory
|
|
|
|
* allocation and also will make lookup slower.
|
|
|
|
*/
|
|
|
|
if (pose->chanbase.first != pose->chanbase.last) {
|
2021-04-30 15:28:13 +10:00
|
|
|
BKE_pose_channels_hash_ensure(pose);
|
2016-05-10 16:45:27 +02:00
|
|
|
}
|
2016-04-26 14:11:03 +02:00
|
|
|
if (pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
|
|
|
|
BKE_pose_update_constraint_flags(pose);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2016-04-26 14:11:03 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr));
|
2019-04-27 12:07:07 +10:00
|
|
|
|
|
|
|
/* we don't use real object name, otherwise RNA screws with the real thing */
|
|
|
|
BLI_strncpy(workob->id.name, "OB<ConstrWorkOb>", sizeof(workob->id.name));
|
|
|
|
|
|
|
|
/* If we're given a group to use, it's likely to be more efficient
|
|
|
|
* (though a bit more dangerous). */
|
2009-04-15 12:59:49 +00:00
|
|
|
if (agrp) {
|
|
|
|
/* specifically evaluate this group only */
|
|
|
|
PointerRNA id_ptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-15 12:59:49 +00:00
|
|
|
/* get RNA-pointer for the workob's ID */
|
|
|
|
RNA_id_pointer_create(&workob->id, &id_ptr);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-15 12:59:49 +00:00
|
|
|
/* execute action for this group only */
|
T77086 Animation: Passing Dependency Graph to Drivers
Custom driver functions need access to the dependency graph that is
triggering the evaluation of the driver. This patch passes the
dependency graph pointer through all the animation-related calls.
Instead of passing the evaluation time to functions, the code now passes
an `AnimationEvalContext` pointer:
```
typedef struct AnimationEvalContext {
struct Depsgraph *const depsgraph;
const float eval_time;
} AnimationEvalContext;
```
These structs are read-only, meaning that the code cannot change the
evaluation time. Note that the `depsgraph` pointer itself is const, but
it points to a non-const depsgraph.
FCurves and Drivers can be evaluated at a different time than the
current scene time, for example when evaluating NLA strips. This means
that, even though the current time is stored in the dependency graph, we
need an explicit evaluation time.
There are two functions that allow creation of `AnimationEvalContext`
objects:
- `BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float
eval_time)`, which creates a new context object from scratch, and
- `BKE_animsys_eval_context_construct_at(AnimationEvalContext
*anim_eval_context, float eval_time)`, which can be used to create a
`AnimationEvalContext` with the same depsgraph, but at a different
time. This makes it possible to later add fields without changing any
of the code that just want to change the eval time.
This also provides a fix for T75553, although it does require a change
to the custom driver function. The driver should call
`custom_function(depsgraph)`, and the function should use that depsgraph
instead of information from `bpy.context`.
Reviewed By: brecht, sergey
Differential Revision: https://developer.blender.org/D8047
2020-07-17 17:38:09 +02:00
|
|
|
animsys_evaluate_action_group(&id_ptr, act, agrp, anim_eval_context);
|
2009-04-15 12:59:49 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
AnimData adt = {NULL};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-15 12:59:49 +00:00
|
|
|
/* init animdata, and attach to workob */
|
2012-05-06 15:15:33 +00:00
|
|
|
workob->adt = &adt;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
adt.action = act;
|
2020-09-25 11:07:32 +02:00
|
|
|
BKE_animdata_action_ensure_idroot(&workob->id, act);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2009-04-15 12:59:49 +00:00
|
|
|
/* execute effects of Action on to workob (or its PoseChannels) */
|
T77086 Animation: Passing Dependency Graph to Drivers
Custom driver functions need access to the dependency graph that is
triggering the evaluation of the driver. This patch passes the
dependency graph pointer through all the animation-related calls.
Instead of passing the evaluation time to functions, the code now passes
an `AnimationEvalContext` pointer:
```
typedef struct AnimationEvalContext {
struct Depsgraph *const depsgraph;
const float eval_time;
} AnimationEvalContext;
```
These structs are read-only, meaning that the code cannot change the
evaluation time. Note that the `depsgraph` pointer itself is const, but
it points to a non-const depsgraph.
FCurves and Drivers can be evaluated at a different time than the
current scene time, for example when evaluating NLA strips. This means
that, even though the current time is stored in the dependency graph, we
need an explicit evaluation time.
There are two functions that allow creation of `AnimationEvalContext`
objects:
- `BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float
eval_time)`, which creates a new context object from scratch, and
- `BKE_animsys_eval_context_construct_at(AnimationEvalContext
*anim_eval_context, float eval_time)`, which can be used to create a
`AnimationEvalContext` with the same depsgraph, but at a different
time. This makes it possible to later add fields without changing any
of the code that just want to change the eval time.
This also provides a fix for T75553, although it does require a change
to the custom driver function. The driver should call
`custom_function(depsgraph)`, and the function should use that depsgraph
instead of information from `bpy.context`.
Reviewed By: brecht, sergey
Differential Revision: https://developer.blender.org/D8047
2020-07-17 17:38:09 +02:00
|
|
|
BKE_animsys_evaluate_animdata(&workob->id, &adt, anim_eval_context, ADT_RECALC_ANIM, false);
|
2009-04-15 12:59:49 +00:00
|
|
|
}
|
2009-01-29 11:22:34 +00:00
|
|
|
}
|
2020-08-03 17:17:57 +02:00
|
|
|
|
|
|
|
void BKE_pose_check_uuids_unique_and_report(const bPose *pose)
|
|
|
|
{
|
|
|
|
if (pose == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GSet *used_uuids = BLI_gset_new(
|
|
|
|
BLI_session_uuid_ghash_hash, BLI_session_uuid_ghash_compare, "sequencer used uuids");
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
|
|
|
|
const SessionUUID *session_uuid = &pchan->runtime.session_uuid;
|
|
|
|
if (!BLI_session_uuid_is_generated(session_uuid)) {
|
|
|
|
printf("Pose channel %s does not have UUID generated.\n", pchan->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BLI_gset_lookup(used_uuids, session_uuid) != NULL) {
|
|
|
|
printf("Pose channel %s has duplicate UUID generated.\n", pchan->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_gset_insert(used_uuids, (void *)session_uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_gset_free(used_uuids, NULL);
|
|
|
|
}
|
2020-11-06 17:58:12 +01:00
|
|
|
|
|
|
|
void BKE_pose_blend_write(BlendWriter *writer, bPose *pose, bArmature *arm)
|
|
|
|
{
|
|
|
|
/* Write each channel */
|
|
|
|
if (pose == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_assert(arm != NULL);
|
|
|
|
|
|
|
|
/* Write channels */
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
|
|
|
|
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
|
|
|
|
* of library blocks that implement this.*/
|
|
|
|
if (chan->prop) {
|
|
|
|
IDP_BlendWrite(writer, chan->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_constraint_blend_write(writer, &chan->constraints);
|
|
|
|
|
|
|
|
animviz_motionpath_blend_write(writer, chan->mpath);
|
|
|
|
|
|
|
|
/* Prevent crashes with autosave,
|
|
|
|
* when a bone duplicated in edit-mode has not yet been assigned to its pose-channel.
|
|
|
|
* Also needed with memundo, in some cases we can store a step before pose has been
|
|
|
|
* properly rebuilt from previous undo step. */
|
|
|
|
Bone *bone = (pose->flag & POSE_RECALC) ? BKE_armature_find_bone_name(arm, chan->name) :
|
|
|
|
chan->bone;
|
|
|
|
if (bone != NULL) {
|
|
|
|
/* gets restored on read, for library armatures */
|
|
|
|
chan->selectflag = bone->flag & BONE_SELECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLO_write_struct(writer, bPoseChannel, chan);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write groups */
|
|
|
|
LISTBASE_FOREACH (bActionGroup *, grp, &pose->agroups) {
|
|
|
|
BLO_write_struct(writer, bActionGroup, grp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write IK param */
|
|
|
|
if (pose->ikparam) {
|
|
|
|
const char *structname = BKE_pose_ikparam_get_name(pose);
|
|
|
|
if (structname) {
|
|
|
|
BLO_write_struct_by_name(writer, structname, pose->ikparam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write this pose */
|
|
|
|
BLO_write_struct(writer, bPose, pose);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_pose_blend_read_data(BlendDataReader *reader, bPose *pose)
|
|
|
|
{
|
|
|
|
if (!pose) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLO_read_list(reader, &pose->chanbase);
|
|
|
|
BLO_read_list(reader, &pose->agroups);
|
|
|
|
|
|
|
|
pose->chanhash = NULL;
|
|
|
|
pose->chan_array = NULL;
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
|
|
|
|
BKE_pose_channel_runtime_reset(&pchan->runtime);
|
|
|
|
BKE_pose_channel_session_uuid_generate(pchan);
|
|
|
|
|
|
|
|
pchan->bone = NULL;
|
|
|
|
BLO_read_data_address(reader, &pchan->parent);
|
|
|
|
BLO_read_data_address(reader, &pchan->child);
|
|
|
|
BLO_read_data_address(reader, &pchan->custom_tx);
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &pchan->bbone_prev);
|
|
|
|
BLO_read_data_address(reader, &pchan->bbone_next);
|
|
|
|
|
|
|
|
BKE_constraint_blend_read_data(reader, &pchan->constraints);
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &pchan->prop);
|
|
|
|
IDP_BlendDataRead(reader, &pchan->prop);
|
|
|
|
|
|
|
|
BLO_read_data_address(reader, &pchan->mpath);
|
|
|
|
if (pchan->mpath) {
|
|
|
|
animviz_motionpath_blend_read_data(reader, pchan->mpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_listbase_clear(&pchan->iktree);
|
|
|
|
BLI_listbase_clear(&pchan->siktree);
|
|
|
|
|
|
|
|
/* in case this value changes in future, clamp else we get undefined behavior */
|
|
|
|
CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
|
|
|
|
|
|
|
|
pchan->draw_data = NULL;
|
|
|
|
}
|
|
|
|
pose->ikdata = NULL;
|
|
|
|
if (pose->ikparam != NULL) {
|
|
|
|
BLO_read_data_address(reader, &pose->ikparam);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_pose_blend_read_lib(BlendLibReader *reader, Object *ob, bPose *pose)
|
|
|
|
{
|
|
|
|
bArmature *arm = ob->data;
|
|
|
|
|
|
|
|
if (!pose || !arm) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always rebuild to match proxy or lib changes, but on Undo */
|
|
|
|
bool rebuild = false;
|
|
|
|
|
|
|
|
if (!BLO_read_lib_is_undo(reader)) {
|
|
|
|
if (ob->proxy || ob->id.lib != arm->id.lib) {
|
|
|
|
rebuild = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ob->proxy) {
|
|
|
|
/* sync proxy layer */
|
|
|
|
if (pose->proxy_layer) {
|
|
|
|
arm->layer = pose->proxy_layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sync proxy active bone */
|
|
|
|
if (pose->proxy_act_bone[0]) {
|
|
|
|
Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone);
|
|
|
|
if (bone) {
|
|
|
|
arm->act_bone = bone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, pchan, &pose->chanbase) {
|
|
|
|
BKE_constraint_blend_read_lib(reader, (ID *)ob, &pchan->constraints);
|
|
|
|
|
|
|
|
pchan->bone = BKE_armature_find_bone_name(arm, pchan->name);
|
|
|
|
|
|
|
|
IDP_BlendReadLib(reader, pchan->prop);
|
|
|
|
|
2021-03-02 12:37:44 +01:00
|
|
|
BLO_read_id_address(reader, ob->id.lib, &pchan->custom);
|
2020-11-06 17:58:12 +01:00
|
|
|
if (UNLIKELY(pchan->bone == NULL)) {
|
|
|
|
rebuild = true;
|
|
|
|
}
|
|
|
|
else if ((ob->id.lib == NULL) && arm->id.lib) {
|
|
|
|
/* local pose selection copied to armature, bit hackish */
|
|
|
|
pchan->bone->flag &= ~BONE_SELECTED;
|
|
|
|
pchan->bone->flag |= pchan->selectflag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rebuild) {
|
|
|
|
Main *bmain = BLO_read_lib_get_main(reader);
|
|
|
|
DEG_id_tag_update_ex(
|
|
|
|
bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION);
|
|
|
|
BKE_pose_tag_recalc(bmain, pose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_pose_blend_read_expand(BlendExpander *expander, bPose *pose)
|
|
|
|
{
|
|
|
|
if (!pose) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LISTBASE_FOREACH (bPoseChannel *, chan, &pose->chanbase) {
|
|
|
|
BKE_constraint_blend_read_expand(expander, &chan->constraints);
|
|
|
|
IDP_BlendReadExpand(expander, chan->prop);
|
|
|
|
BLO_expand(expander, chan->custom);
|
|
|
|
}
|
|
|
|
}
|