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 <string.h>
|
|
|
|
#include <math.h>
|
2009-07-21 10:18:08 +00:00
|
|
|
#include <stdlib.h>
|
2018-06-17 17:05:51 +02:00
|
|
|
#include <stddef.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
#include "MEM_guardedalloc.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 "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"
|
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_math.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"
|
|
|
|
#include "BLI_ghash.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"
|
2019-07-18 18:45:56 +10: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_anim.h"
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BKE_animsys.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"
|
2013-03-25 08:29:06 +00:00
|
|
|
#include "BKE_idprop.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_library.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
|
|
|
|
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"
|
|
|
|
|
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
|
|
|
|
|
|
|
/* ***************** Library data level operations on action ************** */
|
|
|
|
|
2018-01-11 09:55:41 +11:00
|
|
|
bAction *BKE_action_add(Main *bmain, const char name[])
|
2008-12-29 01:19:25 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bAction *act;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
act = BKE_libblock_alloc(bmain, ID_AC, name, 0);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return act;
|
2018-06-17 17:05:51 +02:00
|
|
|
}
|
2008-12-29 01:19:25 +00:00
|
|
|
|
2011-06-29 04:34:20 +00:00
|
|
|
/* .................................. */
|
|
|
|
|
2016-07-10 17:07:27 +02:00
|
|
|
// does copy_fcurve...
|
2016-07-20 19:49:45 +02:00
|
|
|
void BKE_action_make_local(Main *bmain, bAction *act, const bool lib_local)
|
2011-06-29 04:34:20 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_id_make_local_generic(bmain, &act->id, true, lib_local);
|
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-06-29 04:34:20 +00:00
|
|
|
/* .................................. */
|
|
|
|
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
/** Free (or release) any data used by this action (does not free the action itself). */
|
2012-05-05 14:03:12 +00:00
|
|
|
void BKE_action_free(bAction *act)
|
2018-06-17 17:05:51 +02:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* No animdata here. */
|
ID-Remap - Step one: core work (cleanup and rework of generic ID datablock handling).
This commit changes a lot of how IDs are handled internally, especially the unlinking/freeing
processes. So far, this was very fuzy, to summarize cleanly deleting or replacing a datablock
was pretty much impossible, except for a few special cases.
Also, unlinking was handled by each datatype, in a rather messy and prone-to-errors way (quite
a few ID usages were missed or wrongly handled that way).
One of the main goal of id-remap branch was to cleanup this, and fatorize ID links handling
by using library_query utils to allow generic handling of those, which is now the case
(now, generic ID links handling is only "knwon" from readfile.c and library_query.c).
This commit also adds backends to allow live replacement and deletion of datablocks in Blender
(so-called 'remapping' process, where we replace all usages of a given ID pointer by a new one,
or NULL one in case of unlinking).
This will allow nice new features, like ability to easily reload or relocate libraries, real immediate
deletion of datablocks in blender, replacement of one datablock by another, etc.
Some of those are for next commits.
A word of warning: this commit is highly risky, because it affects potentially a lot in Blender core.
Though it was tested rather deeply, being totally impossible to check all possible ID usage cases,
it's likely there are some remaining issues and bugs in new code... Please report them! ;)
Review task: D2027 (https://developer.blender.org/D2027).
Reviewed by campbellbarton, thanks a bunch.
2016-06-22 17:29:38 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Free F-Curves */
|
|
|
|
free_fcurves(&act->curves);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Free groups */
|
|
|
|
BLI_freelistN(&act->groups);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Free pose-references (aka local markers) */
|
|
|
|
BLI_freelistN(&act->markers);
|
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-11-25 12:02:15 +00:00
|
|
|
|
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!
|
|
|
|
*
|
2018-12-12 12:50:58 +11:00
|
|
|
* \param flag: Copying options (see BKE_library.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
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_action_copy_data(Main *UNUSED(bmain),
|
|
|
|
bAction *act_dst,
|
|
|
|
const bAction *act_src,
|
|
|
|
const int UNUSED(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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *grp_dst, *grp_src;
|
|
|
|
FCurve *fcu_dst, *fcu_src;
|
|
|
|
|
|
|
|
/* duplicate the lists of groups and markers */
|
|
|
|
BLI_duplicatelist(&act_dst->groups, &act_src->groups);
|
|
|
|
BLI_duplicatelist(&act_dst->markers, &act_src->markers);
|
|
|
|
|
|
|
|
/* copy F-Curves, fixing up the links as we go */
|
|
|
|
BLI_listbase_clear(&act_dst->curves);
|
|
|
|
|
|
|
|
for (fcu_src = act_src->curves.first; fcu_src; fcu_src = fcu_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... */
|
|
|
|
fcu_dst = copy_fcurve(fcu_src);
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(&act_dst->curves, fcu_dst);
|
|
|
|
|
|
|
|
/* fix group links (kindof bad list-in-list search, but this is the most reliable way) */
|
|
|
|
for (grp_dst = act_dst->groups.first, grp_src = act_src->groups.first; grp_dst && grp_src;
|
|
|
|
grp_dst = grp_dst->next, grp_src = grp_src->next) {
|
|
|
|
if (fcu_src->grp == grp_src) {
|
|
|
|
fcu_dst->grp = grp_dst;
|
|
|
|
|
|
|
|
if (grp_dst->channels.first == fcu_src) {
|
|
|
|
grp_dst->channels.first = fcu_dst;
|
|
|
|
}
|
|
|
|
if (grp_dst->channels.last == fcu_src) {
|
|
|
|
grp_dst->channels.last = fcu_dst;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
bAction *BKE_action_copy(Main *bmain, const bAction *act_src)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bAction *act_copy;
|
|
|
|
BKE_id_copy(bmain, &act_src->id, (ID **)&act_copy);
|
|
|
|
return act_copy;
|
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
|
|
|
}
|
2004-11-11 15:31:44 +00:00
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *agrp = NULL;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (act && act->groups.first) {
|
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (agrp->flag & AGRP_ACTIVE) {
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return agrp;
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *grp;
|
|
|
|
|
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (act == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* Deactivate all others */
|
|
|
|
for (grp = act->groups.first; grp; grp = grp->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((grp == agrp) && (select)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
grp->flag |= AGRP_ACTIVE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
grp->flag &= ~AGRP_ACTIVE;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
{
|
2019-04-17 06:17:24 +02: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)];
|
|
|
|
|
|
|
|
memcpy(&grp->cs, col_set, sizeof(ThemeWireColor));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* 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) {
|
|
|
|
/* 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);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *agrp;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity check: must have action and name */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, name)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* allocate a new one */
|
|
|
|
agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup");
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* make it selected, with default name */
|
|
|
|
agrp->flag = AGRP_SELECTED;
|
|
|
|
BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* add to action, and validate */
|
|
|
|
BLI_addtail(&act->groups, agrp);
|
|
|
|
BLI_uniquename(
|
|
|
|
&act->groups, agrp, DATA_("Group"), '.', offsetof(bActionGroup, name), sizeof(agrp->name));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* return the new group */
|
|
|
|
return agrp;
|
2010-04-01 06:26:41 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, agrp, fcurve)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* if no channels anywhere, just add to two lists at the same time */
|
|
|
|
if (BLI_listbase_is_empty(&act->curves)) {
|
|
|
|
fcurve->next = fcurve->prev = NULL;
|
|
|
|
|
|
|
|
agrp->channels.first = agrp->channels.last = fcurve;
|
|
|
|
act->curves.first = act->curves.last = fcurve;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the group already has channels, the F-Curve can simply be added to the list
|
|
|
|
* (i.e. as the last channel in the group)
|
|
|
|
*/
|
|
|
|
else if (agrp->channels.first) {
|
|
|
|
/* if the group's last F-Curve is the action's last F-Curve too,
|
|
|
|
* 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) {
|
2019-04-17 06:17:24 +02:00
|
|
|
act->curves.last = fcurve;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* otherwise, need to find the nearest F-Curve in group before/after current to link with */
|
|
|
|
else {
|
|
|
|
bActionGroup *grp;
|
|
|
|
|
|
|
|
/* firstly, link this F-Curve to the group */
|
|
|
|
agrp->channels.first = agrp->channels.last = fcurve;
|
|
|
|
|
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. */
|
2019-04-17 06:17:24 +02: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
|
2019-04-17 06:17:24 +02: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.
|
2019-04-17 06:17:24 +02: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);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
2019-04-17 06:17:24 +02:00
|
|
|
*/
|
2019-04-22 09:39:35 +10:00
|
|
|
if (grp == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_insertlinkbefore(&act->curves, act->curves.first, fcurve);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set the F-Curve's new group */
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, fcu)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* check if any group used this directly */
|
|
|
|
if (fcu->grp) {
|
|
|
|
bActionGroup *agrp = fcu->grp;
|
|
|
|
|
|
|
|
if (agrp->channels.first == agrp->channels.last) {
|
|
|
|
if (agrp->channels.first == fcu) {
|
|
|
|
BLI_listbase_clear(&agrp->channels);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (agrp->channels.first == fcu) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((fcu->next) && (fcu->next->grp == agrp)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
agrp->channels.first = fcu->next;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
agrp->channels.first = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else if (agrp->channels.last == fcu) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((fcu->prev) && (fcu->prev->grp == agrp)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
agrp->channels.last = fcu->prev;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
agrp->channels.last = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fcu->grp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now just remove from list */
|
|
|
|
BLI_remlink(&act->curves, fcu);
|
2009-02-09 10:04:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, act->groups.first, name) || (name[0] == 0)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* do string comparisons */
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *agrp;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* sanity checks */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (ELEM(NULL, act, act->groups.first)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* flag clearing loop */
|
2019-04-22 09:39:35 +10:00
|
|
|
for (agrp = act->groups.first; agrp; agrp = agrp->next) {
|
2019-04-17 06:17:24 +02: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
|
|
|
|
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')) {
|
2019-04-17 06:17:24 +02: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) {
|
2019-04-17 06:17:24 +02: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return BLI_findstring(&((const bPose *)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).
|
|
|
|
*/
|
2012-05-05 16:03:57 +00:00
|
|
|
bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name)
|
2004-01-02 20:57:43 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPoseChannel *chan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* See if this channel exists */
|
|
|
|
chan = BKE_pose_channel_find_name(pose, name);
|
|
|
|
if (chan) {
|
|
|
|
return chan;
|
|
|
|
}
|
2011-05-01 06:34:40 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* If not, create it and add it */
|
|
|
|
chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel");
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_strncpy(chan->name, name, sizeof(chan->name));
|
2015-09-21 23:49:58 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
chan->custom_scale = 1.0f;
|
2015-09-21 23:49:58 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* init vars to prevent math errors */
|
|
|
|
unit_qt(chan->quat);
|
|
|
|
unit_axis_angle(chan->rotAxis, &chan->rotAngle);
|
|
|
|
chan->size[0] = chan->size[1] = chan->size[2] = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-20 18:06:31 +03:00
|
|
|
chan->scale_in_x = chan->scale_in_y = 1.0f;
|
|
|
|
chan->scale_out_x = chan->scale_out_y = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -M_PI;
|
|
|
|
chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = M_PI;
|
|
|
|
chan->stiffness[0] = chan->stiffness[1] = chan->stiffness[2] = 0.0f;
|
|
|
|
chan->ikrotweight = chan->iklinweight = 0.0f;
|
|
|
|
unit_m4(chan->constinv);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(&pose->chanbase, chan);
|
|
|
|
if (pose->chanhash) {
|
|
|
|
BLI_ghash_insert(pose->chanhash, chan->name, chan);
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2013-10-01 13:28:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bArmature *arm = (ob) ? ob->data : NULL;
|
|
|
|
bPoseChannel *pchan;
|
2012-03-25 22:35:18 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ELEM(NULL, ob, ob->pose, arm)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-03-25 22:35:18 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* find active */
|
|
|
|
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)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return pchan;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2008-12-21 10:33:24 +00:00
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
char name_flip[MAXBONENAME];
|
2013-11-17 04:30:36 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_string_flip_side_name(name_flip, name, false, sizeof(name_flip));
|
2013-11-17 04:30:36 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!STREQ(name_flip, name)) {
|
|
|
|
return BKE_pose_channel_find_name(pose, name_flip);
|
|
|
|
}
|
2013-11-17 04:30:36 +11:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return NULL;
|
2013-11-17 04:30:36 +11:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pose) {
|
|
|
|
switch (pose->iksolver) {
|
|
|
|
case IKSOLVER_STANDARD:
|
|
|
|
return NULL;
|
|
|
|
case IKSOLVER_ITASC:
|
|
|
|
return "bItasc";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
2013-10-26 03:56:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocate a new pose on the heap, and copy the src pose and it's 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
|
|
|
*/
|
2019-04-17 06:17:24 +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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPose *outPose;
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
ListBase listb;
|
|
|
|
|
|
|
|
if (!src) {
|
|
|
|
*dst = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
outPose = MEM_callocN(sizeof(bPose), "pose");
|
|
|
|
|
|
|
|
BLI_duplicatelist(&outPose->chanbase, &src->chanbase);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
BKE_pose_channels_hash_make(outPose);
|
|
|
|
}
|
|
|
|
|
|
|
|
outPose->iksolver = src->iksolver;
|
|
|
|
outPose->ikdata = NULL;
|
|
|
|
outPose->ikparam = MEM_dupallocN(src->ikparam);
|
|
|
|
outPose->avs = src->avs;
|
|
|
|
|
|
|
|
for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
|
|
|
id_us_plus((ID *)pchan->custom);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* warning, O(n2) here, if done without the hash, but these are rarely used features. */
|
|
|
|
if (pchan->custom_tx) {
|
|
|
|
pchan->custom_tx = BKE_pose_channel_find_name(outPose, pchan->custom_tx->name);
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (copy_constraints) {
|
|
|
|
BKE_constraints_copy_ex(
|
|
|
|
&listb, &pchan->constraints, flag, true); // BKE_constraints_copy NULLs listb
|
|
|
|
pchan->constraints = listb;
|
|
|
|
|
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... */
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->mpath = animviz_copy_motionpath(pchan->mpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pchan->prop) {
|
|
|
|
pchan->prop = IDP_CopyProperty_ex(pchan->prop, flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
pchan->draw_data = NULL; /* Drawing cache, no need to copy. */
|
|
|
|
|
|
|
|
/* Runtime data, no need to copy. */
|
|
|
|
memset(&pchan->runtime, 0, sizeof(pchan->runtime));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* for now, duplicate Bone Groups too when doing this */
|
|
|
|
if (copy_constraints) {
|
|
|
|
BLI_duplicatelist(&outPose->agroups, &src->agroups);
|
|
|
|
}
|
|
|
|
|
|
|
|
*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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pose_copy_data_ex(dst, src, 0, 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
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_itasc_init(bItasc *itasc)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02: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;
|
|
|
|
itasc->flag = ITASC_AUTO_STEP | ITASC_INITIAL_REITERATION;
|
|
|
|
itasc->feedback = 20.0f;
|
|
|
|
itasc->maxvel = 50.0f;
|
|
|
|
itasc->solver = ITASC_SOLVER_SDLS;
|
|
|
|
itasc->dampmax = 0.5;
|
|
|
|
itasc->dampeps = 0.15;
|
|
|
|
}
|
2009-09-24 21:22:24 +00:00
|
|
|
}
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_ikparam_init(bPose *pose)
|
2009-09-24 21:22:24 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bItasc *itasc;
|
|
|
|
switch (pose->iksolver) {
|
|
|
|
case IKSOLVER_ITASC:
|
|
|
|
itasc = MEM_callocN(sizeof(bItasc), "itasc");
|
|
|
|
BKE_pose_itasc_init(itasc);
|
|
|
|
pose->ikparam = itasc;
|
|
|
|
break;
|
|
|
|
case IKSOLVER_STANDARD:
|
|
|
|
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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bConstraint *con;
|
|
|
|
Bone *bone;
|
|
|
|
|
|
|
|
/* 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) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
return false;
|
2013-09-13 03:03:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BKE_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return pose_channel_in_IK_chain(ob, pchan, 0);
|
2013-09-13 03:03:46 +00:00
|
|
|
}
|
|
|
|
|
2013-10-26 03:56:32 +00:00
|
|
|
/**
|
|
|
|
* Removes the hash for quick lookup of channels, must
|
|
|
|
* be done when adding/removing channels.
|
|
|
|
*/
|
2018-06-17 17:05:51 +02:00
|
|
|
void BKE_pose_channels_hash_make(bPose *pose)
|
2010-03-26 10:33:53 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!pose->chanhash) {
|
|
|
|
bPoseChannel *pchan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02: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) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_ghash_insert(pose->chanhash, pchan->name, pchan);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pose->chanhash) {
|
|
|
|
BLI_ghash_free(pose->chanhash, NULL, NULL);
|
|
|
|
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.
|
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
void BKE_pose_channels_remove(Object *ob,
|
|
|
|
bool (*filter_fn)(const char *bone_name, void *user_data),
|
|
|
|
void *user_data)
|
2015-06-13 03:20:07 +10:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* Erase any associated pose channel, along with any references to them */
|
|
|
|
if (ob->pose) {
|
|
|
|
bPoseChannel *pchan, *pchan_next;
|
|
|
|
bConstraint *con;
|
|
|
|
|
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan_next) {
|
|
|
|
pchan_next = pchan->next;
|
|
|
|
|
|
|
|
if (filter_fn(pchan->name, user_data)) {
|
|
|
|
/* Bone itself is being removed */
|
|
|
|
BKE_pose_channel_free(pchan);
|
2019-07-15 15:13:33 +02:00
|
|
|
pose_channels_remove_internal_links(ob, pchan);
|
2019-04-17 06:17:24 +02:00
|
|
|
if (ob->pose->chanhash) {
|
|
|
|
BLI_ghash_remove(ob->pose->chanhash, pchan->name, NULL, NULL);
|
|
|
|
}
|
|
|
|
BLI_freelinkN(&ob->pose->chanbase, pchan);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Maybe something the bone references is being removed instead? */
|
|
|
|
for (con = pchan->constraints.first; con; con = con->next) {
|
|
|
|
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
|
|
|
ListBase targets = {NULL, NULL};
|
|
|
|
bConstraintTarget *ct;
|
|
|
|
|
|
|
|
if (cti && cti->get_constraint_targets) {
|
|
|
|
cti->get_constraint_targets(con, &targets);
|
|
|
|
|
|
|
|
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-22 09:39:35 +10:00
|
|
|
if (cti->flush_constraint_targets) {
|
2019-04-17 06:17:24 +02:00
|
|
|
cti->flush_constraint_targets(con, &targets, 0);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pchan->bbone_prev) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (filter_fn(pchan->bbone_prev->name, user_data)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->bbone_prev = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
if (pchan->bbone_next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (filter_fn(pchan->bbone_next->name, user_data)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->bbone_next = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pchan->custom_tx) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (filter_fn(pchan->custom_tx->name, user_data)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->custom_tx = NULL;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pchan->custom) {
|
|
|
|
if (do_id_user) {
|
|
|
|
id_us_min(&pchan->custom->id);
|
|
|
|
}
|
|
|
|
pchan->custom = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pchan->mpath) {
|
|
|
|
animviz_free_motionpath(pchan->mpath);
|
|
|
|
pchan->mpath = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BKE_constraints_free_ex(&pchan->constraints, do_id_user);
|
|
|
|
|
|
|
|
if (pchan->prop) {
|
|
|
|
IDP_FreeProperty(pchan->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cached data, for new draw manager rendering code. */
|
|
|
|
MEM_SAFE_FREE(pchan->draw_data);
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02: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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pose_channel_free_ex(pchan, true);
|
2013-12-25 16:43:26 +06:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPoseChannel *pchan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pose->chanbase.first) {
|
2019-04-22 09:39:35 +10:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2019-04-17 06:17:24 +02: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_freelistN(&pose->chanbase);
|
|
|
|
}
|
2010-03-26 10:33:53 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pose_channels_hash_free(pose);
|
2019-04-14 21:53:03 +03:00
|
|
|
|
2019-04-17 06:17:24 +02: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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pose_channels_free_ex(pose, true);
|
2013-12-25 16:43:26 +06:00
|
|
|
}
|
|
|
|
|
2016-05-10 16:45:27 +02:00
|
|
|
void BKE_pose_free_data_ex(bPose *pose, bool do_id_user)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* free pose-channels */
|
|
|
|
BKE_pose_channels_free_ex(pose, do_id_user);
|
2016-05-10 16:45:27 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* free pose-groups */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose->agroups.first) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_freelistN(&pose->agroups);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2016-05-10 16:45:27 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* free IK solver state */
|
|
|
|
BIK_clear_data(pose);
|
2016-05-10 16:45:27 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* free IK solver param */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pose->ikparam) {
|
2019-04-17 06:17:24 +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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pose_free_data_ex(pose, true);
|
2016-05-10 16:45:27 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pose) {
|
|
|
|
BKE_pose_free_data_ex(pose, do_id_user);
|
|
|
|
/* free pose */
|
|
|
|
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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
BKE_pose_free_ex(pose, true);
|
2013-12-25 16:43:26 +06:00
|
|
|
}
|
|
|
|
|
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
|
|
|
*
|
|
|
|
* \note use when copying bones in editmode (on returned value from #BKE_pose_channel_verify)
|
|
|
|
*/
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
/* copy transform locks */
|
|
|
|
pchan->protectflag = pchan_from->protectflag;
|
|
|
|
|
|
|
|
/* copy rotation mode */
|
|
|
|
pchan->rotmode = pchan_from->rotmode;
|
|
|
|
|
|
|
|
/* copy bone group */
|
|
|
|
pchan->agrp_index = pchan_from->agrp_index;
|
|
|
|
|
|
|
|
/* ik (dof) settings */
|
|
|
|
pchan->ikflag = pchan_from->ikflag;
|
|
|
|
copy_v3_v3(pchan->limitmin, pchan_from->limitmin);
|
|
|
|
copy_v3_v3(pchan->limitmax, pchan_from->limitmax);
|
|
|
|
copy_v3_v3(pchan->stiffness, pchan_from->stiffness);
|
|
|
|
pchan->ikstretch = pchan_from->ikstretch;
|
|
|
|
pchan->ikrotweight = pchan_from->ikrotweight;
|
|
|
|
pchan->iklinweight = pchan_from->iklinweight;
|
|
|
|
|
|
|
|
/* bbone settings (typically not animated) */
|
|
|
|
pchan->bbone_next = pchan_from->bbone_next;
|
|
|
|
pchan->bbone_prev = pchan_from->bbone_prev;
|
|
|
|
|
|
|
|
/* constraints */
|
|
|
|
BKE_constraints_copy(&pchan->constraints, &pchan_from->constraints, true);
|
|
|
|
|
|
|
|
/* id-properties */
|
|
|
|
if (pchan->prop) {
|
|
|
|
/* unlikely but possible it exists */
|
|
|
|
IDP_FreeProperty(pchan->prop);
|
|
|
|
pchan->prop = NULL;
|
|
|
|
}
|
|
|
|
if (pchan_from->prop) {
|
|
|
|
pchan->prop = IDP_CopyProperty(pchan_from->prop);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* custom shape */
|
|
|
|
pchan->custom = pchan_from->custom;
|
|
|
|
if (pchan->custom) {
|
|
|
|
id_us_plus(&pchan->custom->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
pchan->custom_scale = pchan_from->custom_scale;
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPoseChannel *pchan, *parchan;
|
|
|
|
bConstraint *con;
|
|
|
|
|
|
|
|
/* clear */
|
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
pchan->constflag = 0;
|
|
|
|
}
|
|
|
|
pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND;
|
|
|
|
|
|
|
|
/* detect */
|
|
|
|
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;
|
|
|
|
|
|
|
|
pchan->constflag |= PCHAN_HAS_IK;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->constflag |= PCHAN_HAS_TARGET;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* negative rootbone = recalc rootbone index. used in do_versions */
|
|
|
|
if (data->rootbone < 0) {
|
|
|
|
data->rootbone = 0;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (data->flag & CONSTRAINT_IK_TIP) {
|
2019-04-17 06:17:24 +02:00
|
|
|
parchan = pchan;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
parchan = pchan->parent;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
while (parchan) {
|
|
|
|
data->rootbone++;
|
2019-04-22 09:39:35 +10:00
|
|
|
if ((parchan->bone->flag & BONE_CONNECTED) == 0) {
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
parchan = parchan->parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) {
|
|
|
|
bFollowPathConstraint *data = (bFollowPathConstraint *)con->data;
|
|
|
|
|
|
|
|
/* for drawing constraint colors when color set allows this */
|
|
|
|
pchan->constflag |= PCHAN_HAS_CONST;
|
|
|
|
|
|
|
|
/* 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)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pose->flag |= POSE_CONSTRAINTS_TIMEDEPEND;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-04-22 09:39:35 +10:00
|
|
|
else if (con->type == CONSTRAINT_TYPE_SPLINEIK) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->constflag |= PCHAN_HAS_SPLINEIK;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->constflag |= PCHAN_HAS_CONST;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pose->flag &= ~POSE_CONSTRAINTS_NEED_UPDATE_FLAGS;
|
2015-03-19 18:28:49 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void BKE_pose_tag_update_constraint_flags(bPose *pose)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
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
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* Clears all BONE_UNKEYED flags for every pose channel in every pose
|
2007-09-25 05:04:34 +00:00
|
|
|
* This should only be called on frame changing, when it is acceptable to
|
|
|
|
* do this. Otherwise, these flags should not get cleared as poses may get lost.
|
|
|
|
*/
|
2018-05-04 14:57:31 +02:00
|
|
|
void framechange_poses_clear_unkeyed(Main *bmain)
|
2007-09-25 05:04:34 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
Object *ob;
|
|
|
|
bPose *pose;
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
|
|
|
/* This needs to be done for each object that has a pose */
|
|
|
|
/* TODO: proxies may/may not be correctly handled here... (this needs checking) */
|
|
|
|
for (ob = bmain->objects.first; ob; ob = ob->id.next) {
|
|
|
|
/* we only need to do this on objects with a pose */
|
|
|
|
if ((pose = ob->pose)) {
|
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pchan->bone) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->bone->flag &= ~BONE_UNKEYED;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-25 05:04:34 +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
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *grp;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!name) {
|
|
|
|
name = DATA_("Group");
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup");
|
|
|
|
BLI_strncpy(grp->name, name, sizeof(grp->name));
|
|
|
|
BLI_addtail(&pose->agroups, grp);
|
|
|
|
BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name));
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
pose->active_group = BLI_listbase_count(&pose->agroups);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPoseChannel *pchan;
|
|
|
|
int idx = index;
|
|
|
|
|
|
|
|
if (idx < 1) {
|
|
|
|
idx = BLI_findindex(&pose->agroups, grp) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLI_assert(idx > 0);
|
|
|
|
|
|
|
|
/* adjust group references (the trouble of using indices!):
|
|
|
|
* - firstly, make sure nothing references it
|
|
|
|
* - also, make sure that those after this item get corrected
|
|
|
|
*/
|
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pchan->agrp_index == idx) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->agrp_index = 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (pchan->agrp_index > idx) {
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->agrp_index--;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* now, remove it from the pose */
|
|
|
|
BLI_freelinkN(&pose->agroups, grp);
|
|
|
|
if (pose->active_group >= idx) {
|
|
|
|
const bool has_groups = !BLI_listbase_is_empty(&pose->agroups);
|
|
|
|
pose->active_group--;
|
|
|
|
if (pose->active_group == 0 && has_groups) {
|
|
|
|
pose->active_group = 1;
|
|
|
|
}
|
|
|
|
else if (pose->active_group < 0 || !has_groups) {
|
|
|
|
pose->active_group = 0;
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *grp = NULL;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* get group to remove */
|
|
|
|
grp = BLI_findlink(&pose->agroups, index - 1);
|
|
|
|
if (grp) {
|
|
|
|
BKE_pose_remove_group(pose, grp, index);
|
|
|
|
}
|
2014-07-09 10:27:31 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
FCurve *fcu;
|
|
|
|
|
|
|
|
/* return on the first F-Curve that has some keyframes/samples defined */
|
|
|
|
if (act) {
|
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fcu->totvert) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nothing found */
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
FCurve *fcu;
|
|
|
|
float min = 999999999.0f, max = -999999999.0f;
|
|
|
|
short foundvert = 0, foundmod = 0;
|
|
|
|
|
|
|
|
if (act) {
|
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
|
|
|
/* if curve has keyframes, consider them first */
|
|
|
|
if (fcu->totvert) {
|
|
|
|
float nmin, nmax;
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
*/
|
|
|
|
calc_fcurve_range(fcu, &nmin, &nmax, false, false);
|
|
|
|
|
|
|
|
/* compare to the running tally */
|
|
|
|
min = min_ff(min, nmin);
|
|
|
|
max = max_ff(max, nmax);
|
|
|
|
|
|
|
|
foundvert = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if incl_modifiers is enabled, need to consider modifiers too
|
|
|
|
* - only really care about the last modifier
|
|
|
|
*/
|
|
|
|
if ((incl_modifiers) && (fcu->modifiers.last)) {
|
|
|
|
FModifier *fcm = fcu->modifiers.last;
|
|
|
|
|
|
|
|
/* only use the maximum sensible limits of the modifiers if they are more extreme */
|
|
|
|
switch (fcm->type) {
|
|
|
|
case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */
|
|
|
|
{
|
|
|
|
FMod_Limits *fmd = (FMod_Limits *)fcm->data;
|
|
|
|
|
|
|
|
if (fmd->flag & FCM_LIMIT_XMIN) {
|
|
|
|
min = min_ff(min, fmd->rect.xmin);
|
|
|
|
}
|
|
|
|
if (fmd->flag & FCM_LIMIT_XMAX) {
|
|
|
|
max = max_ff(max, fmd->rect.xmax);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */
|
|
|
|
{
|
|
|
|
FMod_Cycles *fmd = (FMod_Cycles *)fcm->data;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) {
|
2019-04-17 06:17:24 +02:00
|
|
|
min = MINAFRAMEF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) {
|
2019-04-17 06:17:24 +02:00
|
|
|
max = MAXFRAMEF;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* TODO: function modifier may need some special limits */
|
|
|
|
|
|
|
|
default: /* all other standard modifiers are on the infinite range... */
|
|
|
|
min = MINAFRAMEF;
|
|
|
|
max = MAXFRAMEF;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
foundmod = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (foundvert || foundmod) {
|
|
|
|
/* 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) {
|
2019-04-17 06:17:24 +02:00
|
|
|
max += 1.0f;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
*start = min;
|
|
|
|
*end = max;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
PointerRNA ptr;
|
|
|
|
FCurve *fcu;
|
|
|
|
char *basePath = NULL;
|
|
|
|
short flags = 0;
|
|
|
|
|
|
|
|
/* build PointerRNA from provided data to obtain the paths to use */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (pchan) {
|
2019-04-17 06:17:24 +02:00
|
|
|
RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else if (ob) {
|
2019-04-17 06:17:24 +02:00
|
|
|
RNA_id_pointer_create((ID *)ob, &ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* get the basic path to the properties of interest */
|
|
|
|
basePath = RNA_path_from_ID_to_struct(&ptr);
|
2019-04-22 09:39:35 +10:00
|
|
|
if (basePath == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return 0;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* search F-Curves for the given properties
|
|
|
|
* - we cannot use the groups, since they may not be grouped in that way...
|
|
|
|
*/
|
|
|
|
for (fcu = act->curves.first; fcu; fcu = fcu->next) {
|
|
|
|
const char *bPtr = NULL, *pPtr = NULL;
|
|
|
|
|
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)) {
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* just in case... */
|
2019-04-22 09:39:35 +10:00
|
|
|
if (fcu->rna_path == NULL) {
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
/* step 1: check for matching base path */
|
|
|
|
bPtr = strstr(fcu->rna_path, basePath);
|
|
|
|
|
|
|
|
if (bPtr) {
|
|
|
|
/* we must add len(basePath) bytes to the match so that we are at the end of the
|
|
|
|
* base path so that we don't get false positives with these strings in the names
|
|
|
|
*/
|
|
|
|
bPtr += strlen(basePath);
|
|
|
|
|
|
|
|
/* step 2: check for some property with transforms
|
|
|
|
* - 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
|
|
|
|
*/
|
|
|
|
if ((curves) || (flags & ACT_TRANS_LOC) == 0) {
|
|
|
|
pPtr = strstr(bPtr, "location");
|
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_LOC;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((curves) || (flags & ACT_TRANS_SCALE) == 0) {
|
|
|
|
pPtr = strstr(bPtr, "scale");
|
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_SCALE;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((curves) || (flags & ACT_TRANS_ROT) == 0) {
|
|
|
|
pPtr = strstr(bPtr, "rotation");
|
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_ROT;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((curves) || (flags & ACT_TRANS_BBONE) == 0) {
|
|
|
|
/* bbone shape properties */
|
|
|
|
pPtr = strstr(bPtr, "bbone_");
|
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_BBONE;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((curves) || (flags & ACT_TRANS_PROP) == 0) {
|
|
|
|
/* custom properties only */
|
2019-08-15 01:05:15 +10:00
|
|
|
pPtr = strstr(bPtr, "[\"");
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pPtr) {
|
|
|
|
flags |= ACT_TRANS_PROP;
|
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (curves) {
|
2019-04-17 06:17:24 +02:00
|
|
|
BLI_addtail(curves, BLI_genericNodeN(fcu));
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* free basePath */
|
|
|
|
MEM_freeN(basePath);
|
|
|
|
|
|
|
|
/* return flags found */
|
|
|
|
return flags;
|
2009-09-17 10:14:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ************** Pose Management Tools ****************** */
|
|
|
|
|
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
|
|
|
/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_rest(bPose *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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPoseChannel *pchan;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-22 09:39:35 +10:00
|
|
|
if (!pose) {
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
2019-04-22 09:39:35 +10:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02: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
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
zero_v3(pchan->loc);
|
|
|
|
zero_v3(pchan->eul);
|
|
|
|
unit_qt(pchan->quat);
|
|
|
|
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
|
|
|
|
pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->roll1 = pchan->roll2 = 0.0f;
|
2019-04-23 13:15:30 +03:00
|
|
|
pchan->curve_in_x = pchan->curve_in_y = 0.0f;
|
|
|
|
pchan->curve_out_x = pchan->curve_out_y = 0.0f;
|
2019-04-17 06:17:24 +02:00
|
|
|
pchan->ease1 = pchan->ease2 = 0.0f;
|
2019-04-20 18:06:31 +03:00
|
|
|
pchan->scale_in_x = pchan->scale_in_y = 1.0f;
|
|
|
|
pchan->scale_out_x = pchan->scale_out_y = 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2019-04-17 06:17:24 +02: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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat);
|
|
|
|
copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
|
|
|
|
copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head);
|
|
|
|
copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail);
|
|
|
|
|
|
|
|
pchanto->roll1 = pchanfrom->roll1;
|
|
|
|
pchanto->roll2 = pchanfrom->roll2;
|
2019-04-23 13:15:30 +03:00
|
|
|
pchanto->curve_in_x = pchanfrom->curve_in_x;
|
|
|
|
pchanto->curve_in_y = pchanfrom->curve_in_y;
|
|
|
|
pchanto->curve_out_x = pchanfrom->curve_out_x;
|
|
|
|
pchanto->curve_out_y = pchanfrom->curve_out_y;
|
2019-04-17 06:17:24 +02:00
|
|
|
pchanto->ease1 = pchanfrom->ease1;
|
|
|
|
pchanto->ease2 = pchanfrom->ease2;
|
2019-04-20 18:06:31 +03:00
|
|
|
pchanto->scale_in_x = pchanfrom->scale_in_x;
|
|
|
|
pchanto->scale_in_y = pchanfrom->scale_in_y;
|
|
|
|
pchanto->scale_out_x = pchanfrom->scale_out_x;
|
|
|
|
pchanto->scale_out_y = pchanfrom->scale_out_y;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
pchanto->rotmode = pchanfrom->rotmode;
|
|
|
|
pchanto->flag = pchanfrom->flag;
|
|
|
|
pchanto->protectflag = pchanfrom->protectflag;
|
2018-07-31 13:23:01 +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
|
|
|
/* 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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bPoseChannel *pchanto, *pchanfrom;
|
|
|
|
|
|
|
|
if (to == NULL || from == NULL) {
|
|
|
|
CLOG_ERROR(
|
|
|
|
&LOG, "Pose copy error, pose to:%p from:%p", (void *)to, (void *)from); /* debug temp */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to == from) {
|
|
|
|
CLOG_ERROR(&LOG, "source and target are the same");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pchanfrom = from->chanbase.first; pchanfrom; pchanfrom = pchanfrom->next) {
|
|
|
|
pchanto = BKE_pose_channel_find_name(to, pchanfrom->name);
|
|
|
|
if (pchanto != NULL) {
|
2019-10-14 10:45:35 +02:00
|
|
|
BKE_pose_copy_pchan_result(pchanto, pchanfrom);
|
2019-04-17 06:17:24 +02: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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
pose->flag |= POSE_RECALC;
|
|
|
|
/* Depsgraph components depends on actual pose state,
|
|
|
|
* if pose was changed depsgraph is to be updated as well.
|
|
|
|
*/
|
|
|
|
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
|
|
|
*/
|
2019-04-17 06:17:24 +02:00
|
|
|
void what_does_obaction(
|
|
|
|
Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
|
2009-01-29 11:22:34 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
bActionGroup *agrp = BKE_action_group_find_name(act, groupname);
|
|
|
|
|
|
|
|
/* clear workob */
|
|
|
|
BKE_object_workob_clear(workob);
|
|
|
|
|
|
|
|
/* init workob */
|
|
|
|
copy_m4_m4(workob->obmat, ob->obmat);
|
|
|
|
copy_m4_m4(workob->parentinv, ob->parentinv);
|
|
|
|
copy_m4_m4(workob->constinv, ob->constinv);
|
|
|
|
workob->parent = ob->parent;
|
|
|
|
|
|
|
|
workob->rotmode = ob->rotmode;
|
|
|
|
|
|
|
|
workob->trackflag = ob->trackflag;
|
|
|
|
workob->upflag = ob->upflag;
|
|
|
|
|
|
|
|
workob->partype = ob->partype;
|
|
|
|
workob->par1 = ob->par1;
|
|
|
|
workob->par2 = ob->par2;
|
|
|
|
workob->par3 = ob->par3;
|
|
|
|
|
|
|
|
workob->constraints.first = ob->constraints.first;
|
|
|
|
workob->constraints.last = ob->constraints.last;
|
|
|
|
|
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;
|
2019-04-17 06:17:24 +02:00
|
|
|
if (pose) {
|
|
|
|
/* 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) {
|
|
|
|
BKE_pose_channels_hash_make(pose);
|
|
|
|
}
|
|
|
|
if (pose->flag & POSE_CONSTRAINTS_NEED_UPDATE_FLAGS) {
|
|
|
|
BKE_pose_update_constraint_flags(pose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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). */
|
2019-04-17 06:17:24 +02:00
|
|
|
if (agrp) {
|
|
|
|
/* specifically evaluate this group only */
|
|
|
|
PointerRNA id_ptr;
|
|
|
|
|
|
|
|
/* get RNA-pointer for the workob's ID */
|
|
|
|
RNA_id_pointer_create(&workob->id, &id_ptr);
|
|
|
|
|
|
|
|
/* execute action for this group only */
|
|
|
|
animsys_evaluate_action_group(&id_ptr, act, agrp, cframe);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
AnimData adt = {NULL};
|
|
|
|
|
|
|
|
/* init animdata, and attach to workob */
|
|
|
|
workob->adt = &adt;
|
|
|
|
|
|
|
|
adt.action = act;
|
|
|
|
|
|
|
|
/* execute effects of Action on to workob (or it's PoseChannels) */
|
2019-07-31 14:56:17 +02:00
|
|
|
BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM, false);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2009-01-29 11:22:34 +00:00
|
|
|
}
|