2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
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
|
2012-02-22 15:35:42 +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.
|
|
|
|
*
|
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
|
|
|
* Contributor(s): Full recode, Ton Roosendaal, Crete 2005
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/armature.c
|
|
|
|
* \ingroup bke
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-08-13 19:41:45 +00:00
|
|
|
#include <ctype.h>
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2008-01-28 00:53:54 +00:00
|
|
|
#include <float.h>
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2016-01-09 09:12:06 +11:00
|
|
|
#include "BLI_listbase.h"
|
|
|
|
#include "BLI_string.h"
|
|
|
|
#include "BLI_ghash.h"
|
2016-05-13 11:05:12 +02:00
|
|
|
#include "BLI_task.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-11-26 03:43:39 +00:00
|
|
|
#include "DNA_anim_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_armature_types.h"
|
2006-09-03 12:16:14 +00:00
|
|
|
#include "DNA_constraint_types.h"
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
#include "DNA_lattice_types.h"
|
2016-05-13 11:05:12 +02:00
|
|
|
#include "DNA_listBase.h"
|
2006-09-03 12:16:14 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#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
|
|
|
|
2009-11-26 03:43:39 +00:00
|
|
|
#include "BKE_animsys.h"
|
2006-09-03 12:16:14 +00:00
|
|
|
#include "BKE_armature.h"
|
|
|
|
#include "BKE_action.h"
|
2009-11-01 11:29:40 +00:00
|
|
|
#include "BKE_anim.h"
|
2006-09-03 12:16:14 +00:00
|
|
|
#include "BKE_constraint.h"
|
2005-07-16 19:07:02 +00:00
|
|
|
#include "BKE_curve.h"
|
2010-04-20 21:38:55 +00:00
|
|
|
#include "BKE_deform.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_displist.h"
|
2009-10-28 15:33:45 +00:00
|
|
|
#include "BKE_idprop.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_library.h"
|
2016-07-10 16:38:17 +02:00
|
|
|
#include "BKE_library_query.h"
|
|
|
|
#include "BKE_library_remap.h"
|
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
|
|
|
#include "BKE_lattice.h"
|
2006-09-03 12:16:14 +00:00
|
|
|
#include "BKE_main.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_object.h"
|
2011-11-06 06:08:18 +00:00
|
|
|
#include "BKE_scene.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2018-07-19 16:48:21 +02:00
|
|
|
#include "DEG_depsgraph_build.h"
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
#include "BIK_api.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* **************** Generic Functions, data level *************** */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2013-02-05 12:46:15 +00:00
|
|
|
bArmature *BKE_armature_add(Main *bmain, const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
bArmature *arm;
|
2012-02-22 15:35:42 +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
|
|
|
arm = BKE_libblock_alloc(bmain, ID_AR, name, 0);
|
2012-05-06 15:15:33 +00:00
|
|
|
arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE;
|
2009-07-21 13:12:40 +00:00
|
|
|
arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */
|
2012-02-22 15:35:42 +00:00
|
|
|
arm->layer = 1;
|
2017-01-22 02:54:35 +13:00
|
|
|
arm->ghostsize = 1;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
return arm;
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
bArmature *BKE_armature_from_object(Object *ob)
|
2009-01-10 19:34:23 +00:00
|
|
|
{
|
2012-02-22 16:21:17 +00:00
|
|
|
if (ob->type == OB_ARMATURE)
|
2009-01-10 19:34:23 +00:00
|
|
|
return (bArmature *)ob->data;
|
|
|
|
return NULL;
|
|
|
|
}
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
int BKE_armature_bonelist_count(ListBase *lb)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
for (Bone *bone = lb->first; bone; bone = bone->next) {
|
|
|
|
i += 1 + BKE_armature_bonelist_count(&bone->childbase);
|
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_armature_bonelist_free(ListBase *lb)
|
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
|
|
|
{
|
|
|
|
Bone *bone;
|
2009-10-28 15:33:45 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (bone = lb->first; bone; bone = bone->next) {
|
|
|
|
if (bone->prop) {
|
2009-10-28 15:33:45 +00:00
|
|
|
IDP_FreeProperty(bone->prop);
|
|
|
|
MEM_freeN(bone->prop);
|
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
|
|
|
}
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_bonelist_free(&bone->childbase);
|
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
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-10-28 15:33:45 +00:00
|
|
|
BLI_freelistN(lb);
|
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
|
|
|
|
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 armature (does not free the armature itself). */
|
2012-05-05 14:03:12 +00:00
|
|
|
void BKE_armature_free(bArmature *arm)
|
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
|
|
|
{
|
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
|
|
|
BKE_animdata_free(&arm->id, false);
|
2012-02-22 15:35:42 +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
|
|
|
BKE_armature_bonelist_free(&arm->bonebase);
|
2012-02-22 15:35:42 +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 editmode data */
|
|
|
|
if (arm->edbo) {
|
|
|
|
BLI_freelistN(arm->edbo);
|
2009-07-19 02:26:01 +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
|
|
|
MEM_freeN(arm->edbo);
|
|
|
|
arm->edbo = NULL;
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2016-07-20 19:49:45 +02:00
|
|
|
void BKE_armature_make_local(Main *bmain, bArmature *arm, const bool lib_local)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2016-07-20 19:49:45 +02:00
|
|
|
BKE_id_make_local_generic(bmain, &arm->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
|
|
|
}
|
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
|
|
|
static void copy_bonechildren(
|
|
|
|
Bone *bone_dst, const Bone *bone_src, const Bone *bone_src_act, Bone **r_bone_dst_act, const int flag)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
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
|
|
|
Bone *bone_src_child, *bone_dst_child;
|
2012-02-22 15:35:42 +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
|
|
|
if (bone_src == bone_src_act) {
|
|
|
|
*r_bone_dst_act = bone_dst;
|
|
|
|
}
|
2009-11-09 21:03:54 +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
|
|
|
if (bone_src->prop) {
|
|
|
|
bone_dst->prop = IDP_CopyProperty_ex(bone_src->prop, flag);
|
|
|
|
}
|
2009-12-07 15:54:27 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* Copy this bone's list */
|
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
|
|
|
BLI_duplicatelist(&bone_dst->childbase, &bone_src->childbase);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* For each child in the list, update it's children */
|
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
|
|
|
for (bone_src_child = bone_src->childbase.first, bone_dst_child = bone_dst->childbase.first;
|
|
|
|
bone_src_child;
|
|
|
|
bone_src_child = bone_src_child->next, bone_dst_child = bone_dst_child->next)
|
|
|
|
{
|
|
|
|
bone_dst_child->parent = bone_dst;
|
|
|
|
copy_bonechildren(bone_dst_child, bone_src_child, bone_src_act, r_bone_dst_act, 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
|
|
|
}
|
|
|
|
}
|
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
|
|
|
/**
|
|
|
|
* Only copy internal data of Armature ID from source to already allocated/initialized destination.
|
|
|
|
* You probably nerver want to use that directly, use id_copy or BKE_id_copy_ex for typical needs.
|
|
|
|
*
|
|
|
|
* WARNING! This function will not handle ID user count!
|
|
|
|
*
|
|
|
|
* \param flag Copying options (see BKE_library.h's LIB_ID_COPY_... flags for more).
|
|
|
|
*/
|
|
|
|
void BKE_armature_copy_data(Main *UNUSED(bmain), bArmature *arm_dst, const bArmature *arm_src, const int flag)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
{
|
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
|
|
|
Bone *bone_src, *bone_dst;
|
|
|
|
Bone *bone_dst_act = NULL;
|
|
|
|
|
|
|
|
/* We never handle usercount here for own data. */
|
|
|
|
const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
|
2012-02-22 15:35:42 +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
|
|
|
BLI_duplicatelist(&arm_dst->bonebase, &arm_src->bonebase);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-08-17 14:43:20 +00:00
|
|
|
/* Duplicate the childrens' lists */
|
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
|
|
|
bone_dst = arm_dst->bonebase.first;
|
|
|
|
for (bone_src = arm_src->bonebase.first; bone_src; bone_src = bone_src->next) {
|
|
|
|
bone_dst->parent = NULL;
|
|
|
|
copy_bonechildren(bone_dst, bone_src, arm_src->act_bone, &bone_dst_act, flag_subdata);
|
|
|
|
bone_dst = bone_dst->next;
|
2012-02-22 15:35:42 +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
|
|
|
arm_dst->act_bone = bone_dst_act;
|
2011-04-21 09:38:09 +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
|
|
|
arm_dst->edbo = NULL;
|
|
|
|
arm_dst->act_edbone = NULL;
|
|
|
|
}
|
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
|
|
|
bArmature *BKE_armature_copy(Main *bmain, const bArmature *arm)
|
|
|
|
{
|
|
|
|
bArmature *arm_copy;
|
|
|
|
BKE_id_copy_ex(bmain, &arm->id, (ID **)&arm_copy, 0, false);
|
|
|
|
return arm_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
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
static Bone *get_named_bone_bonechildren(ListBase *lb, const char *name)
|
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
|
|
|
{
|
|
|
|
Bone *curBone, *rbone;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
for (curBone = lb->first; curBone; curBone = curBone->next) {
|
|
|
|
if (STREQ(curBone->name, name))
|
|
|
|
return curBone;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
rbone = get_named_bone_bonechildren(&curBone->childbase, name);
|
2012-02-22 16:21:17 +00:00
|
|
|
if (rbone)
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
return rbone;
|
|
|
|
}
|
2012-02-22 15:35:42 +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
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
/**
|
|
|
|
* Walk the list until the bone is found (slow!),
|
|
|
|
* use #BKE_armature_bone_from_name_map for multiple lookups.
|
|
|
|
*/
|
2012-05-05 16:03:57 +00:00
|
|
|
Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name)
|
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
|
|
|
{
|
2012-02-22 16:21:17 +00:00
|
|
|
if (!arm)
|
2012-02-22 15:35:42 +00:00
|
|
|
return NULL;
|
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
return get_named_bone_bonechildren(&arm->bonebase, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void armature_bone_from_name_insert_recursive(GHash *bone_hash, ListBase *lb)
|
|
|
|
{
|
|
|
|
for (Bone *bone = lb->first; bone; bone = bone->next) {
|
|
|
|
BLI_ghash_insert(bone_hash, bone->name, bone);
|
|
|
|
armature_bone_from_name_insert_recursive(bone_hash, &bone->childbase);
|
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
|
|
|
}
|
2016-01-09 09:12:06 +11:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-01-09 09:12:06 +11:00
|
|
|
/**
|
|
|
|
* Create a (name -> bone) map.
|
|
|
|
*
|
|
|
|
* \note typically #bPose.chanhash us used via #BKE_pose_channel_find_name
|
|
|
|
* this is for the cases we can't use pose channels.
|
|
|
|
*/
|
|
|
|
GHash *BKE_armature_bone_from_name_map(bArmature *arm)
|
|
|
|
{
|
|
|
|
const int bones_count = BKE_armature_bonelist_count(&arm->bonebase);
|
|
|
|
GHash *bone_hash = BLI_ghash_str_new_ex(__func__, bones_count);
|
|
|
|
armature_bone_from_name_insert_recursive(bone_hash, &arm->bonebase);
|
|
|
|
return bone_hash;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2015-03-04 14:38:16 +11:00
|
|
|
bool BKE_armature_bone_flag_test_recursive(const Bone *bone, int flag)
|
|
|
|
{
|
|
|
|
if (bone->flag & flag) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (bone->parent) {
|
|
|
|
return BKE_armature_bone_flag_test_recursive(bone->parent, flag);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* Finds the best possible extension to the name on a particular axis. (For renaming, check for
|
|
|
|
* unique names afterwards) strip_number: removes number extensions (TODO: not used)
|
|
|
|
* axis: the axis to name on
|
|
|
|
* head/tail: the head/tail co-ordinate of the bone on the specified axis */
|
|
|
|
int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short axis, float head, float tail)
|
2008-01-28 00:53:54 +00:00
|
|
|
{
|
2009-01-29 10:19:43 +00:00
|
|
|
unsigned int len;
|
2012-02-22 15:35:42 +00:00
|
|
|
char basename[MAXBONENAME] = "";
|
|
|
|
char extension[5] = "";
|
2008-01-28 00:53:54 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
len = strlen(name);
|
2012-02-22 16:21:17 +00:00
|
|
|
if (len == 0)
|
2012-02-22 15:35:42 +00:00
|
|
|
return 0;
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(basename, name, sizeof(basename));
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* Figure out extension to append:
|
2008-01-28 00:53:54 +00:00
|
|
|
* - The extension to append is based upon the axis that we are working on.
|
|
|
|
* - If head happens to be on 0, then we must consider the tail position as well to decide
|
|
|
|
* which side the bone is on
|
|
|
|
* -> If tail is 0, then it's bone is considered to be on axis, so no extension should be added
|
|
|
|
* -> Otherwise, extension is added from perspective of object based on which side tail goes to
|
|
|
|
* - If head is non-zero, extension is added from perspective of object based on side head is on
|
|
|
|
*/
|
2012-02-22 16:21:17 +00:00
|
|
|
if (axis == 2) {
|
2008-01-28 00:53:54 +00:00
|
|
|
/* z-axis - vertical (top/bottom) */
|
2013-11-10 12:56:50 +00:00
|
|
|
if (IS_EQF(head, 0.0f)) {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (tail < 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Bot");
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (tail > 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Top");
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (head < 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Bot");
|
2008-01-28 00:53:54 +00:00
|
|
|
else
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Top");
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (axis == 1) {
|
2008-01-28 00:53:54 +00:00
|
|
|
/* y-axis - depth (front/back) */
|
2013-11-10 12:56:50 +00:00
|
|
|
if (IS_EQF(head, 0.0f)) {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (tail < 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Fr");
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (tail > 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Bk");
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (head < 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Fr");
|
2008-01-28 00:53:54 +00:00
|
|
|
else
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "Bk");
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* x-axis - horizontal (left/right) */
|
2013-11-10 12:56:50 +00:00
|
|
|
if (IS_EQF(head, 0.0f)) {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (tail < 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "R");
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (tail > 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "L");
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (head < 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "R");
|
2012-02-22 15:35:42 +00:00
|
|
|
/* XXX Shouldn't this be simple else, as for z and y axes? */
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (head > 0)
|
2008-04-13 15:14:32 +00:00
|
|
|
strcpy(extension, "L");
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* Simple name truncation
|
2008-01-28 00:53:54 +00:00
|
|
|
* - truncate if there is an extension and it wouldn't be able to fit
|
2008-04-13 15:14:32 +00:00
|
|
|
* - otherwise, just append to end
|
2008-01-28 00:53:54 +00:00
|
|
|
*/
|
2012-02-22 16:21:17 +00:00
|
|
|
if (extension[0]) {
|
2013-11-26 06:39:14 +11:00
|
|
|
bool changed = true;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2013-11-26 06:39:14 +11:00
|
|
|
while (changed) { /* remove extensions */
|
|
|
|
changed = false;
|
2012-05-06 15:15:33 +00:00
|
|
|
if (len > 2 && basename[len - 2] == '.') {
|
|
|
|
if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */
|
|
|
|
basename[len - 2] = '\0';
|
2012-02-22 15:35:42 +00:00
|
|
|
len -= 2;
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = true;
|
2008-04-13 15:14:32 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (len > 3 && basename[len - 3] == '.') {
|
|
|
|
if ((basename[len - 2] == 'F' && basename[len - 1] == 'r') || /* Fr */
|
|
|
|
(basename[len - 2] == 'B' && basename[len - 1] == 'k')) /* Bk */
|
2012-02-22 15:35:42 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
basename[len - 3] = '\0';
|
2012-02-22 15:35:42 +00:00
|
|
|
len -= 3;
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = true;
|
2008-04-13 15:14:32 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
}
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (len > 4 && basename[len - 4] == '.') {
|
|
|
|
if ((basename[len - 3] == 'T' && basename[len - 2] == 'o' && basename[len - 1] == 'p') || /* Top */
|
|
|
|
(basename[len - 3] == 'B' && basename[len - 2] == 'o' && basename[len - 1] == 't')) /* Bot */
|
2012-02-22 15:35:42 +00:00
|
|
|
{
|
2012-05-06 15:15:33 +00:00
|
|
|
basename[len - 4] = '\0';
|
2012-02-22 15:35:42 +00:00
|
|
|
len -= 4;
|
2013-11-26 06:39:14 +11:00
|
|
|
changed = true;
|
2008-04-13 15:14:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-13 03:21:27 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */
|
2012-05-06 15:15:33 +00:00
|
|
|
strncpy(name, basename, len - strlen(extension));
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
2011-02-13 03:21:27 +00:00
|
|
|
|
|
|
|
BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension);
|
|
|
|
|
2010-04-18 14:47:45 +00:00
|
|
|
return 1;
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
else
|
2010-04-18 14:47:45 +00:00
|
|
|
return 0;
|
2008-01-28 00:53:54 +00:00
|
|
|
}
|
2005-08-13 19:41:45 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* ************* B-Bone support ******************* */
|
|
|
|
|
2005-07-17 08:58:42 +00:00
|
|
|
/* data has MAX_BBONE_SUBDIV+1 interpolated points, will become desired amount with equal distances */
|
2016-05-18 03:19:06 +12:00
|
|
|
void equalize_bbone_bezier(float *data, int desired)
|
2005-07-17 08:58:42 +00:00
|
|
|
{
|
|
|
|
float *fp, totdist, ddist, dist, fac1, fac2;
|
2012-05-06 15:15:33 +00:00
|
|
|
float pdist[MAX_BBONE_SUBDIV + 1];
|
|
|
|
float temp[MAX_BBONE_SUBDIV + 1][4];
|
2005-07-17 08:58:42 +00:00
|
|
|
int a, nr;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
pdist[0] = 0.0f;
|
2012-02-22 16:21:17 +00:00
|
|
|
for (a = 0, fp = data; a < MAX_BBONE_SUBDIV; a++, fp += 4) {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_qt_qt(temp[a], fp);
|
2012-05-06 15:15:33 +00:00
|
|
|
pdist[a + 1] = pdist[a] + len_v3v3(fp, fp + 4);
|
2005-07-17 08:58:42 +00:00
|
|
|
}
|
|
|
|
/* do last point */
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_qt_qt(temp[a], fp);
|
2012-02-22 15:35:42 +00:00
|
|
|
totdist = pdist[a];
|
|
|
|
|
2005-07-17 08:58:42 +00:00
|
|
|
/* go over distances and calculate new points */
|
2012-05-06 15:15:33 +00:00
|
|
|
ddist = totdist / ((float)desired);
|
2012-02-22 15:35:42 +00:00
|
|
|
nr = 1;
|
2012-05-06 15:15:33 +00:00
|
|
|
for (a = 1, fp = data + 4; a < desired; a++, fp += 4) {
|
|
|
|
dist = ((float)a) * ddist;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-17 08:58:42 +00:00
|
|
|
/* we're looking for location (distance) 'dist' in the array */
|
2013-10-14 07:10:38 +00:00
|
|
|
while ((nr < MAX_BBONE_SUBDIV) && (dist >= pdist[nr]))
|
2005-07-17 08:58:42 +00:00
|
|
|
nr++;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
fac1 = pdist[nr] - pdist[nr - 1];
|
2012-02-22 15:35:42 +00:00
|
|
|
fac2 = pdist[nr] - dist;
|
|
|
|
fac1 = fac2 / fac1;
|
|
|
|
fac2 = 1.0f - fac1;
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
fp[0] = fac1 * temp[nr - 1][0] + fac2 * temp[nr][0];
|
|
|
|
fp[1] = fac1 * temp[nr - 1][1] + fac2 * temp[nr][1];
|
|
|
|
fp[2] = fac1 * temp[nr - 1][2] + fac2 * temp[nr][2];
|
|
|
|
fp[3] = fac1 * temp[nr - 1][3] + fac2 * temp[nr][3];
|
2005-07-17 08:58:42 +00:00
|
|
|
}
|
|
|
|
/* set last point, needed for orientation calculus */
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_qt_qt(fp, temp[MAX_BBONE_SUBDIV]);
|
2005-07-17 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* returns pointer to static array, filled with desired amount of bone->segments elements */
|
2005-08-21 11:26:53 +00:00
|
|
|
/* this calculation is done within unit bone space */
|
2013-08-19 10:14:22 +00:00
|
|
|
void b_bone_spline_setup(bPoseChannel *pchan, int rest, Mat4 result_array[MAX_BBONE_SUBDIV])
|
2005-07-16 19:07:02 +00:00
|
|
|
{
|
|
|
|
bPoseChannel *next, *prev;
|
2012-02-22 15:35:42 +00:00
|
|
|
Bone *bone = pchan->bone;
|
2016-05-23 21:32:12 +10:00
|
|
|
float h1[3], h2[3], scale[3], length, roll1 = 0.0f, roll2;
|
2007-11-05 18:44:42 +00:00
|
|
|
float mat3[3][3], imat[4][4], posemat[4][4], scalemat[4][4], iscalemat[4][4];
|
2012-05-06 15:15:33 +00:00
|
|
|
float data[MAX_BBONE_SUBDIV + 1][4], *fp;
|
2014-02-02 01:27:06 +11:00
|
|
|
int a;
|
|
|
|
bool do_scale = false;
|
2007-11-05 18:44:42 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
length = bone->length;
|
2007-11-05 18:44:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (!rest) {
|
2007-11-05 18:44:42 +00:00
|
|
|
/* check if we need to take non-uniform bone scaling into account */
|
2014-02-02 01:27:06 +11:00
|
|
|
mat4_to_size(scale, pchan->pose_mat);
|
2007-11-05 18:44:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (fabsf(scale[0] - scale[1]) > 1e-6f || fabsf(scale[1] - scale[2]) > 1e-6f) {
|
2014-02-02 01:27:06 +11:00
|
|
|
size_to_mat4(scalemat, scale);
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(iscalemat, scalemat);
|
2007-11-05 18:44:42 +00:00
|
|
|
|
|
|
|
length *= scale[1];
|
2012-05-19 13:28:19 +00:00
|
|
|
do_scale = 1;
|
2007-11-05 18:44:42 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
/* get "next" and "prev" bones - these are used for handle calculations */
|
|
|
|
if (pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) {
|
|
|
|
/* use the provided bones as the next/prev - leave blank to eliminate this effect altogether */
|
|
|
|
prev = pchan->bbone_prev;
|
|
|
|
next = pchan->bbone_next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* evaluate next and prev bones */
|
|
|
|
if (bone->flag & BONE_CONNECTED)
|
|
|
|
prev = pchan->parent;
|
|
|
|
else
|
|
|
|
prev = NULL;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
next = pchan->child;
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* find the handle points, since this is inside bone space, the
|
2012-04-29 15:47:02 +00:00
|
|
|
* first point = (0, 0, 0)
|
2012-02-22 15:35:42 +00:00
|
|
|
* last point = (0, length, 0) */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (rest) {
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, pchan->bone->arm_mat);
|
2007-11-05 18:44:42 +00:00
|
|
|
}
|
2012-05-19 13:28:19 +00:00
|
|
|
else if (do_scale) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(posemat, pchan->pose_mat);
|
|
|
|
normalize_m4(posemat);
|
|
|
|
invert_m4_m4(imat, posemat);
|
2007-11-05 18:44:42 +00:00
|
|
|
}
|
2007-10-10 09:00:47 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, pchan->pose_mat);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prev) {
|
2007-10-17 17:53:59 +00:00
|
|
|
float difmat[4][4], result[3][3], imat3[3][3];
|
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* transform previous point inside this bone space */
|
2016-05-18 03:19:06 +12:00
|
|
|
if ((pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) &&
|
|
|
|
(pchan->bboneflag & PCHAN_BBONE_CUSTOM_START_REL))
|
|
|
|
{
|
|
|
|
/* Use delta movement (from restpose), and apply this relative to the current bone's head */
|
|
|
|
if (rest) {
|
|
|
|
/* in restpose, arm_head == pose_head */
|
|
|
|
h1[0] = h1[1] = h1[2] = 0.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float delta[3];
|
|
|
|
sub_v3_v3v3(delta, prev->pose_head, prev->bone->arm_head);
|
|
|
|
sub_v3_v3v3(h1, pchan->pose_head, delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Use bone head as absolute position */
|
|
|
|
if (rest)
|
|
|
|
copy_v3_v3(h1, prev->bone->arm_head);
|
|
|
|
else
|
|
|
|
copy_v3_v3(h1, prev->pose_head);
|
|
|
|
}
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(imat, h1);
|
2007-10-17 17:53:59 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (prev->bone->segments > 1) {
|
2007-10-17 17:53:59 +00:00
|
|
|
/* if previous bone is B-bone too, use average handle direction */
|
2012-02-22 15:35:42 +00:00
|
|
|
h1[1] -= length;
|
|
|
|
roll1 = 0.0f;
|
2007-10-17 17:53:59 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(h1);
|
2016-05-23 21:32:12 +10:00
|
|
|
negate_v3(h1);
|
2007-10-17 17:53:59 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prev->bone->segments == 1) {
|
2007-10-17 17:53:59 +00:00
|
|
|
/* find the previous roll to interpolate */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (rest)
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(difmat, imat, prev->bone->arm_mat);
|
2007-10-17 17:53:59 +00:00
|
|
|
else
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(difmat, imat, prev->pose_mat);
|
2012-02-22 15:35:42 +00:00
|
|
|
copy_m3_m4(result, difmat); /* the desired rotation at beginning of next bone */
|
|
|
|
|
|
|
|
vec_roll_to_mat3(h1, 0.0f, mat3); /* the result of vec_roll without roll */
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m3_m3(imat3, mat3);
|
2012-02-22 15:35:42 +00:00
|
|
|
mul_m3_m3m3(mat3, result, imat3); /* the matrix transforming vec_roll to desired roll */
|
|
|
|
|
2014-09-17 14:11:37 +10:00
|
|
|
roll1 = atan2f(mat3[2][0], mat3[2][2]);
|
2007-10-17 17:53:59 +00:00
|
|
|
}
|
2005-07-16 19:07:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-05-23 21:32:12 +10:00
|
|
|
h1[0] = 0.0f; h1[1] = 1.0; h1[2] = 0.0f;
|
2012-02-22 15:35:42 +00:00
|
|
|
roll1 = 0.0f;
|
2005-07-16 19:07:02 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
if (next) {
|
2005-07-16 19:07:02 +00:00
|
|
|
float difmat[4][4], result[3][3], imat3[3][3];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* transform next point inside this bone space */
|
2016-05-18 03:19:06 +12:00
|
|
|
if ((pchan->bboneflag & PCHAN_BBONE_CUSTOM_HANDLES) &&
|
|
|
|
(pchan->bboneflag & PCHAN_BBONE_CUSTOM_END_REL))
|
|
|
|
{
|
|
|
|
/* Use delta movement (from restpose), and apply this relative to the current bone's tail */
|
|
|
|
if (rest) {
|
|
|
|
/* in restpose, arm_tail == pose_tail */
|
|
|
|
h2[0] = h2[1] = h2[2] = 0.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float delta[3];
|
|
|
|
sub_v3_v3v3(delta, next->pose_tail, next->bone->arm_tail);
|
|
|
|
add_v3_v3v3(h2, pchan->pose_tail, delta);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Use bone tail as absolute position */
|
|
|
|
if (rest)
|
|
|
|
copy_v3_v3(h2, next->bone->arm_tail);
|
|
|
|
else
|
|
|
|
copy_v3_v3(h2, next->pose_tail);
|
|
|
|
}
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(imat, h2);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* if next bone is B-bone too, use average handle direction */
|
2012-10-14 13:08:19 +00:00
|
|
|
if (next->bone->segments > 1) {
|
|
|
|
/* pass */
|
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
h2[1] -= length;
|
2012-10-14 13:08:19 +00:00
|
|
|
}
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(h2);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* find the next roll to interpolate as well */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (rest)
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(difmat, imat, next->bone->arm_mat);
|
2007-10-10 23:36:58 +00:00
|
|
|
else
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(difmat, imat, next->pose_mat);
|
2012-02-22 15:35:42 +00:00
|
|
|
copy_m3_m4(result, difmat); /* the desired rotation at beginning of next bone */
|
|
|
|
|
|
|
|
vec_roll_to_mat3(h2, 0.0f, mat3); /* the result of vec_roll without roll */
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m3_m3(imat3, mat3);
|
2012-02-22 15:35:42 +00:00
|
|
|
mul_m3_m3m3(mat3, imat3, result); /* the matrix transforming vec_roll to desired roll */
|
|
|
|
|
2014-09-17 14:11:37 +10:00
|
|
|
roll2 = atan2f(mat3[2][0], mat3[2][2]);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-05-23 21:32:12 +10:00
|
|
|
h2[0] = 0.0f; h2[1] = 1.0f; h2[2] = 0.0f;
|
2012-02-22 15:35:42 +00:00
|
|
|
roll2 = 0.0;
|
2005-07-16 19:07:02 +00:00
|
|
|
}
|
2007-10-17 17:53:59 +00:00
|
|
|
|
2016-05-23 21:32:12 +10:00
|
|
|
{
|
2016-06-28 02:52:20 +12:00
|
|
|
const float circle_factor = length * (cubic_tangent_factor_circle_v3(h1, h2) / 0.75f);
|
2016-06-28 02:20:25 +12:00
|
|
|
|
2017-11-01 13:38:51 +13:00
|
|
|
const float combined_ease1 = bone->ease1 + (!rest ? pchan->ease1 : 0.0f);
|
|
|
|
const float combined_ease2 = bone->ease2 + (!rest ? pchan->ease2 : 0.0f);
|
|
|
|
const float hlength1 = combined_ease1 * circle_factor;
|
|
|
|
const float hlength2 = combined_ease2 * circle_factor;
|
2016-05-23 21:32:12 +10:00
|
|
|
|
|
|
|
/* and only now negate h2 */
|
|
|
|
mul_v3_fl(h1, hlength1);
|
|
|
|
mul_v3_fl(h2, -hlength2);
|
|
|
|
}
|
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
/* Add effects from bbone properties over the top
|
|
|
|
* - These properties allow users to hand-animate the
|
|
|
|
* bone curve/shape, without having to resort to using
|
|
|
|
* extra bones
|
|
|
|
* - The "bone" level offsets are for defining the restpose
|
|
|
|
* shape of the bone (e.g. for curved eyebrows for example).
|
|
|
|
* -> In the viewport, it's needed to define what the rest pose
|
|
|
|
* looks like
|
|
|
|
* -> For "rest == 0", we also still need to have it present
|
|
|
|
* so that we can "cancel out" this restpose when it comes
|
|
|
|
* time to deform some geometry, it won't cause double transforms.
|
|
|
|
* - The "pchan" level offsets are the ones that animators actually
|
|
|
|
* end up animating
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
/* add extra rolls */
|
|
|
|
roll1 += bone->roll1 + (!rest ? pchan->roll1 : 0.0f);
|
|
|
|
roll2 += bone->roll2 + (!rest ? pchan->roll2 : 0.0f);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
if (bone->flag & BONE_ADD_PARENT_END_ROLL) {
|
|
|
|
if (prev) {
|
|
|
|
if (prev->bone)
|
|
|
|
roll1 += prev->bone->roll2;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
if (!rest)
|
|
|
|
roll1 += prev->roll2;
|
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
/* extra curve x / y */
|
|
|
|
/* NOTE: Scale correction factors here are to compensate for some random floating-point glitches
|
|
|
|
* when scaling up the bone or it's parent by a factor of approximately 8.15/6, which results
|
|
|
|
* in the bone length getting scaled up too (from 1 to 8), causing the curve to flatten out.
|
|
|
|
*/
|
|
|
|
const float xscale_correction = (do_scale) ? scale[0] : 1.0f;
|
|
|
|
const float yscale_correction = (do_scale) ? scale[2] : 1.0f;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
h1[0] += (bone->curveInX + (!rest ? pchan->curveInX : 0.0f)) * xscale_correction;
|
|
|
|
h1[2] += (bone->curveInY + (!rest ? pchan->curveInY : 0.0f)) * yscale_correction;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
h2[0] += (bone->curveOutX + (!rest ? pchan->curveOutX : 0.0f)) * xscale_correction;
|
|
|
|
h2[2] += (bone->curveOutY + (!rest ? pchan->curveOutY : 0.0f)) * yscale_correction;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* make curve */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone->segments > MAX_BBONE_SUBDIV)
|
2012-02-22 15:35:42 +00:00
|
|
|
bone->segments = MAX_BBONE_SUBDIV;
|
|
|
|
|
2012-05-12 19:18:02 +00:00
|
|
|
BKE_curve_forward_diff_bezier(0.0f, h1[0], h2[0], 0.0f, data[0], MAX_BBONE_SUBDIV, 4 * sizeof(float));
|
|
|
|
BKE_curve_forward_diff_bezier(0.0f, h1[1], length + h2[1], length, data[0] + 1, MAX_BBONE_SUBDIV, 4 * sizeof(float));
|
|
|
|
BKE_curve_forward_diff_bezier(0.0f, h1[2], h2[2], 0.0f, data[0] + 2, MAX_BBONE_SUBDIV, 4 * sizeof(float));
|
|
|
|
BKE_curve_forward_diff_bezier(roll1, roll1 + 0.390464f * (roll2 - roll1), roll2 - 0.390464f * (roll2 - roll1), roll2, data[0] + 3, MAX_BBONE_SUBDIV, 4 * sizeof(float));
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
equalize_bbone_bezier(data[0], bone->segments); /* note: does stride 4! */
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* make transformation matrices for the segments for drawing */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (a = 0, fp = data[0]; a < bone->segments; a++, fp += 4) {
|
2012-05-06 15:15:33 +00:00
|
|
|
sub_v3_v3v3(h1, fp + 4, fp);
|
2012-02-22 15:35:42 +00:00
|
|
|
vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m3(result_array[a].mat, mat3);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(result_array[a].mat[3], fp);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-05-19 13:28:19 +00:00
|
|
|
if (do_scale) {
|
2007-11-05 18:44:42 +00:00
|
|
|
/* correct for scaling when this matrix is used in scaled space */
|
2014-07-21 18:55:12 +10:00
|
|
|
mul_m4_series(result_array[a].mat, iscalemat, result_array[a].mat, scalemat);
|
2007-11-05 18:44:42 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
/* BBone scale... */
|
|
|
|
{
|
|
|
|
const int num_segments = bone->segments;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
const float scaleIn = bone->scaleIn * (!rest ? pchan->scaleIn : 1.0f);
|
|
|
|
const float scaleFactorIn = 1.0f + (scaleIn - 1.0f) * ((float)(num_segments - a) / (float)num_segments);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
const float scaleOut = bone->scaleOut * (!rest ? pchan->scaleOut : 1.0f);
|
|
|
|
const float scaleFactorOut = 1.0f + (scaleOut - 1.0f) * ((float)(a + 1) / (float)num_segments);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
const float scalefac = scaleFactorIn * scaleFactorOut;
|
|
|
|
float bscalemat[4][4], bscale[3];
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
bscale[0] = scalefac;
|
|
|
|
bscale[1] = 1.0f;
|
|
|
|
bscale[2] = scalefac;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
size_to_mat4(bscalemat, bscale);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2016-05-18 03:19:06 +12:00
|
|
|
/* Note: don't multiply by inverse scale mat here, as it causes problems with scaling shearing and breaking segment chains */
|
|
|
|
/*mul_m4_series(result_array[a].mat, ibscalemat, result_array[a].mat, bscalemat);*/
|
|
|
|
mul_m4_series(result_array[a].mat, result_array[a].mat, bscalemat);
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2005-07-16 19:07:02 +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
|
|
|
/* ************ Armature Deform ******************* */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-10-28 10:12:57 +00:00
|
|
|
typedef struct bPoseChanDeform {
|
2012-02-22 15:35:42 +00:00
|
|
|
Mat4 *b_bone_mats;
|
|
|
|
DualQuat *dual_quat;
|
|
|
|
DualQuat *b_bone_dual_quats;
|
2010-10-28 10:12:57 +00:00
|
|
|
} bPoseChanDeform;
|
|
|
|
|
2016-04-25 14:57:25 +10:00
|
|
|
static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info, const bool use_quaternion)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-02-22 15:35:42 +00:00
|
|
|
Bone *bone = pchan->bone;
|
2013-08-19 10:14:22 +00:00
|
|
|
Mat4 b_bone[MAX_BBONE_SUBDIV], b_bone_rest[MAX_BBONE_SUBDIV];
|
2005-08-21 11:26:53 +00:00
|
|
|
Mat4 *b_bone_mats;
|
2012-02-22 15:35:42 +00:00
|
|
|
DualQuat *b_bone_dual_quats = NULL;
|
2005-08-21 11:26:53 +00:00
|
|
|
int a;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2013-08-19 10:14:22 +00:00
|
|
|
b_bone_spline_setup(pchan, 0, b_bone);
|
|
|
|
b_bone_spline_setup(pchan, 1, b_bone_rest);
|
|
|
|
|
2007-07-28 21:04:30 +00:00
|
|
|
/* allocate b_bone matrices and dual quats */
|
2012-05-06 15:15:33 +00:00
|
|
|
b_bone_mats = MEM_mallocN((1 + bone->segments) * sizeof(Mat4), "BBone defmats");
|
2012-02-22 15:35:42 +00:00
|
|
|
pdef_info->b_bone_mats = b_bone_mats;
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_quaternion) {
|
2012-05-06 15:15:33 +00:00
|
|
|
b_bone_dual_quats = MEM_mallocN((bone->segments) * sizeof(DualQuat), "BBone dqs");
|
2012-02-22 15:35:42 +00:00
|
|
|
pdef_info->b_bone_dual_quats = b_bone_dual_quats;
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2007-07-28 21:04:30 +00:00
|
|
|
/* first matrix is the inverse arm_mat, to bring points in local bone space
|
2012-02-22 15:35:42 +00:00
|
|
|
* for finding out which segment it belongs to */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(b_bone_mats[0].mat, bone->arm_mat);
|
2007-07-28 21:04:30 +00:00
|
|
|
|
|
|
|
/* then we make the b_bone_mats:
|
2012-02-22 15:35:42 +00:00
|
|
|
* - first transform to local bone space
|
|
|
|
* - translate over the curve to the bbone mat space
|
|
|
|
* - transform with b_bone matrix
|
|
|
|
* - transform back into global space */
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (a = 0; a < bone->segments; a++) {
|
2014-04-29 18:12:44 +10:00
|
|
|
float tmat[4][4];
|
|
|
|
|
2010-07-12 11:04:51 +00:00
|
|
|
invert_m4_m4(tmat, b_bone_rest[a].mat);
|
2014-07-21 18:55:12 +10:00
|
|
|
mul_m4_series(b_bone_mats[a + 1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat);
|
2007-07-31 19:28:52 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_quaternion)
|
2012-05-06 15:15:33 +00:00
|
|
|
mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a + 1].mat);
|
2005-08-21 11:26:53 +00:00
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], DualQuat *dq, float defmat[3][3])
|
2005-08-21 11:26:53 +00:00
|
|
|
{
|
2012-02-22 15:35:42 +00:00
|
|
|
Mat4 *b_bone = pdef_info->b_bone_mats;
|
|
|
|
float (*mat)[4] = b_bone[0].mat;
|
2007-07-28 21:04:30 +00:00
|
|
|
float segment, y;
|
2005-08-21 11:26:53 +00:00
|
|
|
int a;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2007-07-28 21:04:30 +00:00
|
|
|
/* need to transform co back to bonespace, only need y */
|
2012-05-06 15:15:33 +00:00
|
|
|
y = mat[0][1] * co[0] + mat[1][1] * co[1] + mat[2][1] * co[2] + mat[3][1];
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2005-08-21 11:26:53 +00:00
|
|
|
/* now calculate which of the b_bones are deforming this */
|
2012-05-06 15:15:33 +00:00
|
|
|
segment = bone->length / ((float)bone->segments);
|
|
|
|
a = (int)(y / segment);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2007-07-28 21:04:30 +00:00
|
|
|
/* note; by clamping it extends deform at endpoints, goes best with
|
2012-02-22 15:35:42 +00:00
|
|
|
* straight joints in restpos. */
|
2012-05-06 15:15:33 +00:00
|
|
|
CLAMP(a, 0, bone->segments - 1);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (dq) {
|
2010-10-28 10:12:57 +00:00
|
|
|
copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]);
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_m4_v3(b_bone[a + 1].mat, co);
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-28 14:05:00 +00:00
|
|
|
if (defmat) {
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_m3_m4(defmat, b_bone[a + 1].mat);
|
2012-02-28 14:05:00 +00:00
|
|
|
}
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
/* using vec with dist to bone b1 - b2 */
|
2012-01-22 17:20:37 +00:00
|
|
|
float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2014-02-03 02:46:45 +11:00
|
|
|
float dist_sq;
|
2002-10-12 11:37:38 +00:00
|
|
|
float bdelta[3];
|
|
|
|
float pdelta[3];
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
float hsqr, a, l, rad;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(bdelta, b2, b1);
|
|
|
|
l = normalize_v3(bdelta);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(pdelta, vec, b1);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-01-22 17:20:37 +00:00
|
|
|
a = dot_v3v3(bdelta, pdelta);
|
2014-03-29 22:23:27 +11:00
|
|
|
hsqr = len_squared_v3(pdelta);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (a < 0.0f) {
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
/* If we're past the end of the bone, do a spherical field attenuation thing */
|
2014-02-03 02:46:45 +11:00
|
|
|
dist_sq = len_squared_v3v3(b1, vec);
|
2012-02-22 15:35:42 +00:00
|
|
|
rad = rad1;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (a > l) {
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
/* If we're past the end of the bone, do a spherical field attenuation thing */
|
2014-02-03 02:46:45 +11:00
|
|
|
dist_sq = len_squared_v3v3(b2, vec);
|
2012-01-22 17:20:37 +00:00
|
|
|
rad = rad2;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-02-03 02:46:45 +11:00
|
|
|
dist_sq = (hsqr - (a * a));
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (l != 0.0f) {
|
2012-05-06 15:15:33 +00:00
|
|
|
rad = a / l;
|
|
|
|
rad = rad * rad2 + (1.0f - rad) * rad1;
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
else
|
|
|
|
rad = rad1;
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
a = rad * rad;
|
2014-02-03 02:46:45 +11:00
|
|
|
if (dist_sq < a)
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
return 1.0f;
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
l = rad + rdist;
|
2012-02-22 15:35:42 +00:00
|
|
|
l *= l;
|
2014-02-03 02:46:45 +11:00
|
|
|
if (rdist == 0.0f || dist_sq >= l)
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
return 0.0f;
|
|
|
|
else {
|
2014-02-03 02:46:45 +11:00
|
|
|
a = sqrtf(dist_sq) - rad;
|
2012-05-06 15:15:33 +00:00
|
|
|
return 1.0f - (a * a) / (rdist * rdist);
|
Armature "Envelope" editing.
For defining the deformation distances of Bones, three values are being
used now. The bone tip and root radius define the bone-shape itself and the
"dist" defines the soft area around it. A full (user) doc is in CMS here;
http://www.blender3d.org/cms/Armature_Envelopes.647.0.html
Note: todo still is allowing both Vertex Deform Groups and these Envelopes
together (and or per Bone).
Also part of this commit is:
- New: Hiding bones in EditMode. This is a separate 'hide flag', so you can
keep the PoseMode hidden Bones separate from EditMode.
(In the future we should do some kind of bone-grouping or so)
- While transform(), the hotkeys G,R,S only switch mode when the previous
mode was compatible. Caused conflicts with Crease/BoneDist/etc.
- Deleting the last VertexGroup now also deletes the entire Mesh 'dvert'
data. Sounds logical, but remember that VertexGroups are partial on a
Mesh, partial on Object. Weird design decision though...
Anyhoo, at this moment the only way to have Bone Envelopes deform, is
by deleting all VertexGroups!
- In PoseMode, the hotkey ALT+S now does both B-Bone size or Envelope,
depending draw type.
- In EditMode, Extrude now also works when only Root points were selected.
- Weight editing is also symmetrical btw, with the "X-axis Mirror" option
set.
2005-08-19 12:35:15 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonemat[3][3], float mat[3][3])
|
2007-07-28 21:04:30 +00:00
|
|
|
{
|
|
|
|
float wmat[3][3];
|
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->bone->segments > 1)
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m3(wmat, bbonemat);
|
2007-07-28 21:04:30 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(wmat, pchan->chan_mat);
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2009-11-10 20:50:34 +00:00
|
|
|
mul_m3_fl(wmat, weight);
|
2009-11-10 20:43:45 +00:00
|
|
|
add_m3_m3m3(mat, mat, wmat);
|
2007-07-28 21:04:30 +00:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:05:00 +00:00
|
|
|
static float dist_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float vec[3], DualQuat *dq,
|
2012-12-11 14:29:01 +00:00
|
|
|
float mat[3][3], const float co[3])
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-02-22 15:35:42 +00:00
|
|
|
Bone *bone = pchan->bone;
|
|
|
|
float fac, contrib = 0.0;
|
2007-07-28 21:04:30 +00:00
|
|
|
float cop[3], bbonemat[3][3];
|
2007-07-31 19:28:52 +00:00
|
|
|
DualQuat bbonedq;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone == NULL)
|
2012-02-22 15:35:42 +00:00
|
|
|
return 0.0f;
|
|
|
|
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(cop, co);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
fac = distfactor_to_bone(cop, bone->arm_head, bone->arm_tail, bone->rad_head, bone->rad_tail, bone->dist);
|
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (fac > 0.0f) {
|
2012-02-22 15:35:42 +00:00
|
|
|
fac *= bone->weight;
|
|
|
|
contrib = fac;
|
2012-02-22 16:21:17 +00:00
|
|
|
if (contrib > 0.0f) {
|
|
|
|
if (vec) {
|
|
|
|
if (bone->segments > 1)
|
2012-02-22 15:35:42 +00:00
|
|
|
/* applies on cop and bbonemat */
|
|
|
|
b_bone_deform(pdef_info, bone, cop, NULL, (mat) ? bbonemat : NULL);
|
2007-07-31 19:28:52 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(pchan->chan_mat, cop);
|
2007-07-31 19:28:52 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* Make this a delta from the base position */
|
2010-04-23 23:57:00 +00:00
|
|
|
sub_v3_v3(cop, co);
|
|
|
|
madd_v3_v3fl(vec, cop, fac);
|
2007-07-31 19:28:52 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (mat)
|
2007-07-31 19:28:52 +00:00
|
|
|
pchan_deform_mat_add(pchan, fac, bbonemat, mat);
|
|
|
|
}
|
|
|
|
else {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone->segments > 1) {
|
2010-10-28 10:12:57 +00:00
|
|
|
b_bone_deform(pdef_info, bone, cop, &bbonedq, NULL);
|
2009-11-10 20:43:45 +00:00
|
|
|
add_weighted_dq_dq(dq, &bbonedq, fac);
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
|
|
|
else
|
2010-10-28 10:12:57 +00:00
|
|
|
add_weighted_dq_dq(dq, pdef_info->dual_quat, fac);
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-22 15:35:42 +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
|
|
|
return contrib;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2012-02-28 14:05:00 +00:00
|
|
|
static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float weight, float vec[3], DualQuat *dq,
|
2012-12-11 14:29:01 +00:00
|
|
|
float mat[3][3], const float co[3], float *contrib)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2007-07-28 21:04:30 +00:00
|
|
|
float cop[3], bbonemat[3][3];
|
2007-07-31 19:28:52 +00:00
|
|
|
DualQuat bbonedq;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (!weight)
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(cop, co);
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (vec) {
|
2012-05-06 15:15:33 +00:00
|
|
|
if (pchan->bone->segments > 1)
|
2012-02-22 15:35:42 +00:00
|
|
|
/* applies on cop and bbonemat */
|
|
|
|
b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL);
|
2007-07-31 19:28:52 +00:00
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(pchan->chan_mat, cop);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
vec[0] += (cop[0] - co[0]) * weight;
|
|
|
|
vec[1] += (cop[1] - co[1]) * weight;
|
|
|
|
vec[2] += (cop[2] - co[2]) * weight;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (mat)
|
2007-07-31 19:28:52 +00:00
|
|
|
pchan_deform_mat_add(pchan, weight, bbonemat, mat);
|
|
|
|
}
|
|
|
|
else {
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->bone->segments > 1) {
|
2010-10-28 10:12:57 +00:00
|
|
|
b_bone_deform(pdef_info, pchan->bone, cop, &bbonedq, NULL);
|
2009-11-10 20:43:45 +00:00
|
|
|
add_weighted_dq_dq(dq, &bbonedq, weight);
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
|
|
|
else
|
2010-10-28 10:12:57 +00:00
|
|
|
add_weighted_dq_dq(dq, pdef_info->dual_quat, weight);
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
(*contrib) += weight;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2016-05-13 11:05:12 +02:00
|
|
|
typedef struct ArmatureBBoneDefmatsData {
|
|
|
|
bPoseChanDeform *pdef_info_array;
|
|
|
|
DualQuat *dualquats;
|
|
|
|
bool use_quaternion;
|
|
|
|
} ArmatureBBoneDefmatsData;
|
|
|
|
|
|
|
|
static void armature_bbone_defmats_cb(void *userdata, Link *iter, int index)
|
|
|
|
{
|
|
|
|
ArmatureBBoneDefmatsData *data = userdata;
|
|
|
|
bPoseChannel *pchan = (bPoseChannel *)iter;
|
|
|
|
|
|
|
|
if (!(pchan->bone->flag & BONE_NO_DEFORM)) {
|
|
|
|
bPoseChanDeform *pdef_info = &data->pdef_info_array[index];
|
|
|
|
const bool use_quaternion = data->use_quaternion;
|
|
|
|
|
|
|
|
if (pchan->bone->segments > 1) {
|
|
|
|
pchan_b_bone_defmats(pchan, pdef_info, use_quaternion);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_quaternion) {
|
|
|
|
pdef_info->dual_quat = &data->dualquats[index];
|
|
|
|
mat4_to_dquat(pdef_info->dual_quat, pchan->bone->arm_mat, pchan->chan_mat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-25 11:04:40 +02:00
|
|
|
void armature_deform_verts(Object *armOb, Object *target, const Mesh * mesh, float (*vertexCos)[3],
|
2012-02-22 15:35:42 +00:00
|
|
|
float (*defMats)[3][3], int numVerts, int deformflag,
|
|
|
|
float (*prevCos)[3], const char *defgrp_name)
|
2005-08-11 06:44:32 +00:00
|
|
|
{
|
2010-10-28 10:12:57 +00:00
|
|
|
bPoseChanDeform *pdef_info_array;
|
2012-02-22 15:35:42 +00:00
|
|
|
bPoseChanDeform *pdef_info = NULL;
|
|
|
|
bArmature *arm = armOb->data;
|
2005-08-21 11:26:53 +00:00
|
|
|
bPoseChannel *pchan, **defnrToPC = NULL;
|
2012-02-22 15:35:42 +00:00
|
|
|
int *defnrToPCIndex = NULL;
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformVert *dverts = NULL;
|
2007-01-06 12:33:01 +00:00
|
|
|
bDeformGroup *dg;
|
2012-02-22 15:35:42 +00:00
|
|
|
DualQuat *dualquats = NULL;
|
2005-08-11 06:44:32 +00:00
|
|
|
float obinv[4][4], premat[4][4], postmat[4][4];
|
2016-04-25 14:57:25 +10:00
|
|
|
const bool use_envelope = (deformflag & ARM_DEF_ENVELOPE) != 0;
|
|
|
|
const bool use_quaternion = (deformflag & ARM_DEF_QUATERNION) != 0;
|
|
|
|
const bool invert_vgroup = (deformflag & ARM_DEF_INVERT_VGROUP) != 0;
|
2012-02-22 15:35:42 +00:00
|
|
|
int defbase_tot = 0; /* safety for vertexgroup index overflow */
|
|
|
|
int i, target_totvert = 0; /* safety for vertexgroup overflow */
|
2014-04-01 11:34:00 +11:00
|
|
|
bool use_dverts = false;
|
2010-04-20 21:38:55 +00:00
|
|
|
int armature_def_nr;
|
2007-07-31 19:28:52 +00:00
|
|
|
int totchan;
|
2005-08-11 06:44:32 +00:00
|
|
|
|
2016-04-25 14:38:06 +10:00
|
|
|
/* in editmode, or not an armature */
|
|
|
|
if (arm->edbo || (armOb->pose == NULL)) {
|
|
|
|
return;
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2017-05-05 09:47:35 +02:00
|
|
|
if ((armOb->pose->flag & POSE_RECALC) != 0) {
|
|
|
|
printf("ERROR! Trying to evaluate influence of armature '%s' which needs Pose recalc!", armOb->id.name);
|
|
|
|
BLI_assert(0);
|
|
|
|
}
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(obinv, target->obmat);
|
|
|
|
copy_m4_m4(premat, target->obmat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(postmat, obinv, armOb->obmat);
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(premat, postmat);
|
2005-08-11 06:44:32 +00:00
|
|
|
|
2005-08-21 11:26:53 +00:00
|
|
|
/* bone defmats are already in the channels, chan_mat */
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2007-07-28 21:04:30 +00:00
|
|
|
/* initialize B_bone matrices and dual quaternions */
|
2014-11-16 13:57:58 +01:00
|
|
|
totchan = BLI_listbase_count(&armOb->pose->chanbase);
|
2010-10-28 10:12:57 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_quaternion) {
|
2012-05-06 15:15:33 +00:00
|
|
|
dualquats = MEM_callocN(sizeof(DualQuat) * totchan, "dualquats");
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform) * totchan, "bPoseChanDeform");
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2016-05-13 11:05:12 +02:00
|
|
|
ArmatureBBoneDefmatsData data = {
|
|
|
|
.pdef_info_array = pdef_info_array, .dualquats = dualquats, .use_quaternion = use_quaternion
|
|
|
|
};
|
|
|
|
BLI_task_parallel_listbase(&armOb->pose->chanbase, &data, armature_bbone_defmats_cb, totchan > 512);
|
2005-08-11 06:44:32 +00:00
|
|
|
|
2006-08-28 21:56:58 +00:00
|
|
|
/* get the def_nr for the overall armature vertex group if present */
|
2012-02-22 15:35:42 +00:00
|
|
|
armature_def_nr = defgroup_name_index(target, defgrp_name);
|
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (ELEM(target->type, OB_MESH, OB_LATTICE)) {
|
2014-11-16 13:57:58 +01:00
|
|
|
defbase_tot = BLI_listbase_count(&target->defbase);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (target->type == OB_MESH) {
|
2012-02-22 15:35:42 +00:00
|
|
|
Mesh *me = target->data;
|
2010-04-23 12:11:56 +00:00
|
|
|
dverts = me->dvert;
|
2012-02-22 16:21:17 +00:00
|
|
|
if (dverts)
|
2010-04-23 12:15:50 +00:00
|
|
|
target_totvert = me->totvert;
|
2010-04-23 12:11:56 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-02-22 15:35:42 +00:00
|
|
|
Lattice *lt = target->data;
|
2010-04-23 12:11:56 +00:00
|
|
|
dverts = lt->dvert;
|
2012-02-22 16:21:17 +00:00
|
|
|
if (dverts)
|
2012-05-06 15:15:33 +00:00
|
|
|
target_totvert = lt->pntsu * lt->pntsv * lt->pntsw;
|
2010-04-23 12:11:56 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-08-21 18:53:12 +00:00
|
|
|
/* get a vertex-deform-index to posechannel array */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (deformflag & ARM_DEF_VGROUP) {
|
|
|
|
if (ELEM(target->type, OB_MESH, OB_LATTICE)) {
|
2018-04-25 11:04:40 +02:00
|
|
|
/* if we have a Mesh, only use dverts if it has them */
|
|
|
|
if (mesh) {
|
|
|
|
use_dverts = (mesh->dvert != NULL);
|
2012-05-19 13:28:19 +00:00
|
|
|
}
|
|
|
|
else if (dverts) {
|
2014-04-01 11:34:00 +11:00
|
|
|
use_dverts = true;
|
2012-05-19 13:28:19 +00:00
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_dverts) {
|
2011-12-09 08:20:27 +00:00
|
|
|
defnrToPC = MEM_callocN(sizeof(*defnrToPC) * defbase_tot, "defnrToBone");
|
|
|
|
defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * defbase_tot, "defnrToIndex");
|
2017-02-06 11:12:35 +01:00
|
|
|
/* TODO(sergey): Some considerations here:
|
|
|
|
*
|
|
|
|
* - Make it more generic function, maybe even keep together with chanhash.
|
|
|
|
* - Check whether keeping this consistent across frames gives speedup.
|
|
|
|
* - Don't use hash for small armatures.
|
|
|
|
*/
|
|
|
|
GHash *idx_hash = BLI_ghash_ptr_new("pose channel index by name");
|
|
|
|
int pchan_index = 0;
|
|
|
|
for (pchan = armOb->pose->chanbase.first; pchan != NULL; pchan = pchan->next, ++pchan_index) {
|
|
|
|
BLI_ghash_insert(idx_hash, pchan, SET_INT_IN_POINTER(pchan_index));
|
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
for (i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) {
|
2012-05-05 16:03:57 +00:00
|
|
|
defnrToPC[i] = BKE_pose_channel_find_name(armOb->pose, dg->name);
|
2005-08-23 20:19:01 +00:00
|
|
|
/* exclude non-deforming bones */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (defnrToPC[i]) {
|
|
|
|
if (defnrToPC[i]->bone->flag & BONE_NO_DEFORM) {
|
2012-02-22 15:35:42 +00:00
|
|
|
defnrToPC[i] = NULL;
|
2010-10-28 10:12:57 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-02-06 11:12:35 +01:00
|
|
|
defnrToPCIndex[i] = GET_INT_FROM_POINTER(BLI_ghash_lookup(idx_hash, defnrToPC[i]));
|
2010-10-28 10:12:57 +00:00
|
|
|
}
|
2005-08-23 20:19:01 +00:00
|
|
|
}
|
2005-08-21 18:53:12 +00:00
|
|
|
}
|
2017-02-06 11:12:35 +01:00
|
|
|
BLI_ghash_free(idx_hash, NULL, NULL);
|
2005-08-17 13:26:42 +00:00
|
|
|
}
|
2005-08-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (i = 0; i < numVerts; i++) {
|
2005-08-21 18:53:12 +00:00
|
|
|
MDeformVert *dvert;
|
2007-07-31 19:28:52 +00:00
|
|
|
DualQuat sumdq, *dq = NULL;
|
2007-11-16 15:46:59 +00:00
|
|
|
float *co, dco[3];
|
2007-07-31 19:28:52 +00:00
|
|
|
float sumvec[3], summat[3][3];
|
|
|
|
float *vec = NULL, (*smat)[3] = NULL;
|
2007-01-06 12:33:01 +00:00
|
|
|
float contrib = 0.0f;
|
2012-02-22 15:35:42 +00:00
|
|
|
float armature_weight = 1.0f; /* default to 1 if no overall def group */
|
|
|
|
float prevco_weight = 1.0f; /* weight for optional cached vertexcos */
|
2005-08-11 06:44:32 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_quaternion) {
|
2007-07-31 19:28:52 +00:00
|
|
|
memset(&sumdq, 0, sizeof(DualQuat));
|
2012-02-22 15:35:42 +00:00
|
|
|
dq = &sumdq;
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
sumvec[0] = sumvec[1] = sumvec[2] = 0.0f;
|
2012-02-22 15:35:42 +00:00
|
|
|
vec = sumvec;
|
2005-08-11 06:44:32 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (defMats) {
|
2009-11-10 20:50:34 +00:00
|
|
|
zero_m3(summat);
|
2007-07-31 19:28:52 +00:00
|
|
|
smat = summat;
|
|
|
|
}
|
2007-07-28 21:04:30 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 17:19:05 +00:00
|
|
|
if (use_dverts || armature_def_nr != -1) {
|
2018-04-25 11:04:40 +02:00
|
|
|
if (mesh) {
|
|
|
|
BLI_assert(i < mesh->totvert);
|
|
|
|
dvert = mesh->dvert + i;
|
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (dverts && i < target_totvert)
|
2012-02-22 15:35:42 +00:00
|
|
|
dvert = dverts + i;
|
|
|
|
else
|
|
|
|
dvert = NULL;
|
|
|
|
}
|
|
|
|
else
|
2006-08-28 01:12:36 +00:00
|
|
|
dvert = NULL;
|
2006-08-28 21:56:58 +00:00
|
|
|
|
2012-10-22 17:19:05 +00:00
|
|
|
if (armature_def_nr != -1 && dvert) {
|
2012-02-22 15:35:42 +00:00
|
|
|
armature_weight = defvert_find_weight(dvert, armature_def_nr);
|
2010-12-31 11:51:00 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (invert_vgroup)
|
2012-05-06 15:15:33 +00:00
|
|
|
armature_weight = 1.0f - armature_weight;
|
2010-12-31 11:51:00 +00:00
|
|
|
|
2007-11-16 15:46:59 +00:00
|
|
|
/* hackish: the blending factor can be used for blending with prevCos too */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prevCos) {
|
2012-02-22 15:35:42 +00:00
|
|
|
prevco_weight = armature_weight;
|
|
|
|
armature_weight = 1.0f;
|
2007-11-16 15:46:59 +00:00
|
|
|
}
|
2006-08-28 21:56:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check if there's any point in calculating for this vert */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (armature_weight == 0.0f)
|
2012-02-22 15:35:42 +00:00
|
|
|
continue;
|
|
|
|
|
2007-11-16 15:46:59 +00:00
|
|
|
/* get the coord we work on */
|
2012-02-22 15:35:42 +00:00
|
|
|
co = prevCos ? prevCos[i] : vertexCos[i];
|
|
|
|
|
2007-01-06 12:33:01 +00:00
|
|
|
/* Apply the object's matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(premat, co);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_dverts && dvert && dvert->totweight) { /* use weight groups ? */
|
2012-02-22 15:35:42 +00:00
|
|
|
MDeformWeight *dw = dvert->dw;
|
2006-08-28 01:12:36 +00:00
|
|
|
int deformed = 0;
|
2011-12-14 22:54:38 +00:00
|
|
|
unsigned int j;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (j = dvert->totweight; j != 0; j--, dw++) {
|
2011-12-14 22:54:38 +00:00
|
|
|
const int index = dw->def_nr;
|
2012-06-11 11:00:58 +00:00
|
|
|
if (index >= 0 && index < defbase_tot && (pchan = defnrToPC[index])) {
|
2011-12-14 22:54:38 +00:00
|
|
|
float weight = dw->weight;
|
2012-02-22 15:35:42 +00:00
|
|
|
Bone *bone = pchan->bone;
|
|
|
|
pdef_info = pdef_info_array + defnrToPCIndex[index];
|
2007-01-06 12:33:01 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
deformed = 1;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone && bone->flag & BONE_MULT_VG_ENV) {
|
2012-02-22 15:35:42 +00:00
|
|
|
weight *= distfactor_to_bone(co, bone->arm_head, bone->arm_tail,
|
|
|
|
bone->rad_head, bone->rad_tail, bone->dist);
|
2005-08-21 18:53:12 +00:00
|
|
|
}
|
2010-10-28 10:12:57 +00:00
|
|
|
pchan_bone_deform(pchan, pdef_info, weight, vec, dq, smat, co, &contrib);
|
2005-08-21 18:53:12 +00:00
|
|
|
}
|
2005-08-11 06:44:32 +00:00
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
/* if there are vertexgroups but not groups with bones
|
2012-02-22 15:35:42 +00:00
|
|
|
* (like for softbody groups) */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (deformed == 0 && use_envelope) {
|
2012-02-22 15:35:42 +00:00
|
|
|
pdef_info = pdef_info_array;
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next, pdef_info++) {
|
|
|
|
if (!(pchan->bone->flag & BONE_NO_DEFORM))
|
2010-10-28 10:12:57 +00:00
|
|
|
contrib += dist_bone_deform(pchan, pdef_info, vec, dq, smat, co);
|
2005-09-09 15:16:39 +00:00
|
|
|
}
|
|
|
|
}
|
2005-08-11 06:44:32 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (use_envelope) {
|
2012-02-22 15:35:42 +00:00
|
|
|
pdef_info = pdef_info_array;
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next, pdef_info++) {
|
|
|
|
if (!(pchan->bone->flag & BONE_NO_DEFORM))
|
2010-10-28 10:12:57 +00:00
|
|
|
contrib += dist_bone_deform(pchan, pdef_info, vec, dq, smat, co);
|
2005-08-11 06:44:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-28 11:44:32 +00:00
|
|
|
/* actually should be EPSILON? weight values and contrib can be like 10e-39 small */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (contrib > 0.0001f) {
|
|
|
|
if (use_quaternion) {
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_dq(dq, contrib);
|
2007-11-05 17:38:07 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (armature_weight != 1.0f) {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(dco, co);
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3m3_dq(dco, (defMats) ? summat : NULL, dq);
|
2010-04-23 23:57:00 +00:00
|
|
|
sub_v3_v3(dco, co);
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(dco, armature_weight);
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(co, dco);
|
2007-11-05 17:38:07 +00:00
|
|
|
}
|
|
|
|
else
|
2012-04-29 15:47:02 +00:00
|
|
|
mul_v3m3_dq(co, (defMats) ? summat : NULL, dq);
|
2007-11-05 17:38:07 +00:00
|
|
|
|
2007-07-31 19:28:52 +00:00
|
|
|
smat = summat;
|
|
|
|
}
|
|
|
|
else {
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_v3_fl(vec, armature_weight / contrib);
|
2009-11-10 20:43:45 +00:00
|
|
|
add_v3_v3v3(co, vec, co);
|
2007-07-31 19:28:52 +00:00
|
|
|
}
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (defMats) {
|
2007-07-28 21:04:30 +00:00
|
|
|
float pre[3][3], post[3][3], tmpmat[3][3];
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m3_m4(pre, premat);
|
|
|
|
copy_m3_m4(post, postmat);
|
|
|
|
copy_m3_m3(tmpmat, defMats[i]);
|
2007-07-28 21:04:30 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (!use_quaternion) /* quaternion already is scale corrected */
|
2012-05-06 15:15:33 +00:00
|
|
|
mul_m3_fl(smat, armature_weight / contrib);
|
2007-07-31 19:28:52 +00:00
|
|
|
|
2014-07-21 18:55:12 +10:00
|
|
|
mul_m3_series(defMats[i], post, smat, pre, tmpmat);
|
2007-07-28 21:04:30 +00:00
|
|
|
}
|
2007-01-06 12:33:01 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2007-01-06 12:33:01 +00:00
|
|
|
/* always, check above code */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(postmat, co);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2007-11-16 15:46:59 +00:00
|
|
|
/* interpolate with previous modifier position using weight group */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prevCos) {
|
2012-02-22 15:35:42 +00:00
|
|
|
float mw = 1.0f - prevco_weight;
|
2012-05-06 15:15:33 +00:00
|
|
|
vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0];
|
|
|
|
vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1];
|
|
|
|
vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2];
|
2007-11-16 15:46:59 +00:00
|
|
|
}
|
2005-08-11 06:44:32 +00:00
|
|
|
}
|
2005-08-11 22:27:53 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (dualquats)
|
2012-02-22 15:35:42 +00:00
|
|
|
MEM_freeN(dualquats);
|
2012-02-22 16:21:17 +00:00
|
|
|
if (defnrToPC)
|
2012-02-22 15:35:42 +00:00
|
|
|
MEM_freeN(defnrToPC);
|
2012-02-22 16:21:17 +00:00
|
|
|
if (defnrToPCIndex)
|
2012-02-22 15:35:42 +00:00
|
|
|
MEM_freeN(defnrToPCIndex);
|
2010-10-28 10:12:57 +00:00
|
|
|
|
2005-08-21 11:26:53 +00:00
|
|
|
/* free B_bone matrices */
|
2012-02-22 15:35:42 +00:00
|
|
|
pdef_info = pdef_info_array;
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next, pdef_info++) {
|
|
|
|
if (pdef_info->b_bone_mats)
|
2010-10-28 10:12:57 +00:00
|
|
|
MEM_freeN(pdef_info->b_bone_mats);
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pdef_info->b_bone_dual_quats)
|
2010-10-28 10:12:57 +00:00
|
|
|
MEM_freeN(pdef_info->b_bone_dual_quats);
|
2005-08-21 11:26:53 +00:00
|
|
|
}
|
2010-10-28 10:12:57 +00:00
|
|
|
|
|
|
|
MEM_freeN(pdef_info_array);
|
2005-08-11 06:44:32 +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
|
|
|
/* ************ END Armature Deform ******************* */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-12-11 14:29:01 +00:00
|
|
|
void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[4][4], int UNUSED(root),
|
2012-02-22 15:35:42 +00:00
|
|
|
int UNUSED(posed))
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(M_accumulatedMatrix, bone->arm_mat);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2006-12-22 09:05:37 +00:00
|
|
|
/* **************** Space to Space API ****************** */
|
|
|
|
|
|
|
|
/* Convert World-Space Matrix to Pose-Space Matrix */
|
2012-12-11 14:29:01 +00:00
|
|
|
void BKE_armature_mat_world_to_pose(Object *ob, float inmat[4][4], float outmat[4][4])
|
2006-12-22 09:05:37 +00:00
|
|
|
{
|
|
|
|
float obmat[4][4];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2006-12-22 09:05:37 +00:00
|
|
|
/* prevent crashes */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (ob == NULL)
|
2012-02-22 15:35:42 +00:00
|
|
|
return;
|
|
|
|
|
2006-12-22 09:05:37 +00:00
|
|
|
/* get inverse of (armature) object's matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(obmat, ob->obmat);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2006-12-22 09:05:37 +00:00
|
|
|
/* multiply given matrix by object's-inverse to find pose-space matrix */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(outmat, inmat, obmat);
|
2006-12-22 09:05:37 +00:00
|
|
|
}
|
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* Convert World-Space Location to Pose-Space Location
|
2007-02-05 01:28:14 +00:00
|
|
|
* NOTE: this cannot be used to convert to pose-space location of the supplied
|
2012-02-22 15:35:42 +00:00
|
|
|
* pose-channel into its local space (i.e. 'visual'-keyframing) */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3])
|
2007-02-05 01:28:14 +00:00
|
|
|
{
|
2014-04-29 18:12:44 +10:00
|
|
|
float xLocMat[4][4];
|
2007-02-05 01:28:14 +00:00
|
|
|
float nLocMat[4][4];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2007-02-05 01:28:14 +00:00
|
|
|
/* build matrix for location */
|
2014-04-29 18:12:44 +10:00
|
|
|
unit_m4(xLocMat);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(xLocMat[3], inloc);
|
2007-02-05 01:28:14 +00:00
|
|
|
|
|
|
|
/* get bone-space cursor matrix and extract location */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_mat_world_to_pose(ob, xLocMat, nLocMat);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(outloc, nLocMat[3]);
|
2007-02-05 01:28:14 +00:00
|
|
|
}
|
|
|
|
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
/* Simple helper, computes the offset bone matrix.
|
|
|
|
* offs_bone = yoffs(b-1) + root(b) + bonemat(b).
|
|
|
|
* Not exported, as it is only used in this file currently... */
|
2012-12-11 14:29:01 +00:00
|
|
|
static void get_offset_bone_mat(Bone *bone, float offs_bone[4][4])
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
{
|
2015-09-04 12:35:43 +02:00
|
|
|
BLI_assert(bone->parent != NULL);
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
|
|
|
|
/* Bone transform itself. */
|
|
|
|
copy_m4_m3(offs_bone, bone->bone_mat);
|
|
|
|
|
|
|
|
/* The bone's root offset (is in the parent's coordinate system). */
|
|
|
|
copy_v3_v3(offs_bone[3], bone->head);
|
|
|
|
|
|
|
|
/* Get the length translation of parent (length along y axis). */
|
|
|
|
offs_bone[3][1] += bone->parent->length;
|
|
|
|
}
|
|
|
|
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Construct the matrices (rot/scale and loc) to apply the PoseChannels into the armature (object) space.
|
|
|
|
* I.e. (roughly) the "pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b)" in the
|
|
|
|
* pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b)
|
|
|
|
* ...function.
|
|
|
|
*
|
|
|
|
* This allows to get the transformations of a bone in its object space, *before* constraints (and IK)
|
|
|
|
* get applied (used by pose evaluation code).
|
|
|
|
* And reverse: to find pchan transformations needed to place a bone at a given loc/rot/scale
|
|
|
|
* in object space (used by interactive transform, and snapping code).
|
|
|
|
*
|
|
|
|
* Note that, with the HINGE/NO_SCALE/NO_LOCAL_LOCATION options, the location matrix
|
|
|
|
* will differ from the rotation/scale matrix...
|
|
|
|
*
|
|
|
|
* NOTE: This cannot be used to convert to pose-space transforms of the supplied
|
|
|
|
* pose-channel into its local space (i.e. 'visual'-keyframing).
|
|
|
|
* (note: I don't understand that, so I keep it :p --mont29).
|
2007-01-07 22:30:44 +00:00
|
|
|
*/
|
2012-12-11 14:29:01 +00:00
|
|
|
void BKE_pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[4][4], float loc_mat[4][4])
|
2006-12-22 09:05:37 +00:00
|
|
|
{
|
2012-01-17 13:30:20 +00:00
|
|
|
Bone *bone, *parbone;
|
|
|
|
bPoseChannel *parchan;
|
|
|
|
|
|
|
|
/* set up variables for quicker access below */
|
2012-02-22 15:35:42 +00:00
|
|
|
bone = pchan->bone;
|
|
|
|
parbone = bone->parent;
|
|
|
|
parchan = pchan->parent;
|
2012-01-17 13:30:20 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (parchan) {
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
float offs_bone[4][4];
|
|
|
|
/* yoffs(b-1) + root(b) + bonemat(b). */
|
|
|
|
get_offset_bone_mat(bone, offs_bone);
|
2012-01-17 13:30:20 +00:00
|
|
|
|
|
|
|
/* Compose the rotscale matrix for this bone. */
|
2012-02-22 16:21:17 +00:00
|
|
|
if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_NO_SCALE)) {
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Parent rest rotation and scale. */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(rotscale_mat, parbone->arm_mat, offs_bone);
|
2010-10-22 06:25:14 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (bone->flag & BONE_HINGE) {
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Parent rest rotation and pose scale. */
|
|
|
|
float tmat[4][4], tscale[3];
|
2010-10-22 06:25:14 +00:00
|
|
|
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Extract the scale of the parent pose matrix. */
|
|
|
|
mat4_to_size(tscale, parchan->pose_mat);
|
|
|
|
size_to_mat4(tmat, tscale);
|
|
|
|
|
|
|
|
/* Applies the parent pose scale to the rest matrix. */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(tmat, tmat, parbone->arm_mat);
|
2012-01-17 13:30:20 +00:00
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(rotscale_mat, tmat, offs_bone);
|
2012-01-17 13:30:20 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (bone->flag & BONE_NO_SCALE) {
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Parent pose rotation and rest scale (i.e. no scaling). */
|
|
|
|
float tmat[4][4];
|
|
|
|
copy_m4_m4(tmat, parchan->pose_mat);
|
|
|
|
normalize_m4(tmat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(rotscale_mat, tmat, offs_bone);
|
2012-01-17 13:30:20 +00:00
|
|
|
}
|
|
|
|
else
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(rotscale_mat, parchan->pose_mat, offs_bone);
|
2012-01-17 13:30:20 +00:00
|
|
|
|
|
|
|
/* Compose the loc matrix for this bone. */
|
2012-04-29 13:18:59 +00:00
|
|
|
/* NOTE: That version does not modify bone's loc when HINGE/NO_SCALE options are set. */
|
2010-10-22 06:25:14 +00:00
|
|
|
|
2012-01-17 13:30:20 +00:00
|
|
|
/* In this case, use the object's space *orientation*. */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone->flag & BONE_NO_LOCAL_LOCATION) {
|
2012-01-17 13:30:20 +00:00
|
|
|
/* XXX I'm sure that code can be simplified! */
|
|
|
|
float bone_loc[4][4], bone_rotscale[3][3], tmat4[4][4], tmat3[3][3];
|
|
|
|
unit_m4(bone_loc);
|
|
|
|
unit_m4(loc_mat);
|
|
|
|
unit_m4(tmat4);
|
|
|
|
|
|
|
|
mul_v3_m4v3(bone_loc[3], parchan->pose_mat, offs_bone[3]);
|
|
|
|
|
|
|
|
unit_m3(bone_rotscale);
|
|
|
|
copy_m3_m4(tmat3, parchan->pose_mat);
|
|
|
|
mul_m3_m3m3(bone_rotscale, tmat3, bone_rotscale);
|
|
|
|
|
|
|
|
copy_m4_m3(tmat4, bone_rotscale);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(loc_mat, bone_loc, tmat4);
|
2012-01-17 13:30:20 +00:00
|
|
|
}
|
|
|
|
/* Those flags do not affect position, use plain parent transform space! */
|
2012-05-06 15:15:33 +00:00
|
|
|
else if (bone->flag & (BONE_HINGE | BONE_NO_SCALE)) {
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(loc_mat, parchan->pose_mat, offs_bone);
|
2012-01-17 13:30:20 +00:00
|
|
|
}
|
|
|
|
/* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */
|
|
|
|
else
|
|
|
|
copy_m4_m4(loc_mat, rotscale_mat);
|
2010-10-22 06:25:14 +00:00
|
|
|
}
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Root bones. */
|
|
|
|
else {
|
|
|
|
/* Rotation/scaling. */
|
|
|
|
copy_m4_m4(rotscale_mat, pchan->bone->arm_mat);
|
|
|
|
/* Translation. */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->bone->flag & BONE_NO_LOCAL_LOCATION) {
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Translation of arm_mat, without the rotation. */
|
|
|
|
unit_m4(loc_mat);
|
|
|
|
copy_v3_v3(loc_mat[3], pchan->bone->arm_mat[3]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
copy_m4_m4(loc_mat, rotscale_mat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert Pose-Space Matrix to Bone-Space Matrix.
|
|
|
|
* NOTE: this cannot be used to convert to pose-space transforms of the supplied
|
2012-02-22 15:35:42 +00:00
|
|
|
* pose-channel into its local space (i.e. 'visual'-keyframing) */
|
2012-12-11 14:29:01 +00:00
|
|
|
void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
|
2012-01-17 13:30:20 +00:00
|
|
|
{
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
float rotscale_mat[4][4], loc_mat[4][4], inmat_[4][4];
|
|
|
|
|
|
|
|
/* Security, this allows to call with inmat == outmat! */
|
|
|
|
copy_m4_m4(inmat_, inmat);
|
2010-10-22 06:25:14 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat);
|
2012-01-17 13:30:20 +00:00
|
|
|
invert_m4(rotscale_mat);
|
|
|
|
invert_m4(loc_mat);
|
2010-10-22 03:56:50 +00:00
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(outmat, rotscale_mat, inmat_);
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
mul_v3_m4v3(outmat[3], loc_mat, inmat_[3]);
|
2006-12-22 09:05:37 +00:00
|
|
|
}
|
|
|
|
|
More pose armature code factorization:
* New armature_mat_bone_to_pose, which is just the reverse of armature_mat_pose_to_bone (currently used by armature evaluation code only, but might be used by constraints space conversion code too, see note below).
* Found another place where another (a bit erroneous) pose_to_bone code existed (apply_targetless_ik(), in transform_conversion.c, used by "auto ik" option), replaced it by a call to armature_mat_pose_to_bone.
Notes:
* All those changes leave many #if 0 commented code, I will remove those in a few weeks.
* There is at least one other place where generic armature_mat_(pose_to_bone/bone_to_pose) functions should be usable: the space conversion function of constraints (constraint_mat_convertspace(), in BKE's constraint.c), but here I have some problems (old code is also somewhat erroneous, but using new one makes old rigs using bone space constraints wrong, e.g. sintel one, and it’s just impossible to make conversion code...). So I'll wait and investigate more for this one.
2012-02-19 11:09:44 +00:00
|
|
|
/* Convert Bone-Space Matrix to Pose-Space Matrix. */
|
2012-12-11 14:29:01 +00:00
|
|
|
void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
|
More pose armature code factorization:
* New armature_mat_bone_to_pose, which is just the reverse of armature_mat_pose_to_bone (currently used by armature evaluation code only, but might be used by constraints space conversion code too, see note below).
* Found another place where another (a bit erroneous) pose_to_bone code existed (apply_targetless_ik(), in transform_conversion.c, used by "auto ik" option), replaced it by a call to armature_mat_pose_to_bone.
Notes:
* All those changes leave many #if 0 commented code, I will remove those in a few weeks.
* There is at least one other place where generic armature_mat_(pose_to_bone/bone_to_pose) functions should be usable: the space conversion function of constraints (constraint_mat_convertspace(), in BKE's constraint.c), but here I have some problems (old code is also somewhat erroneous, but using new one makes old rigs using bone space constraints wrong, e.g. sintel one, and it’s just impossible to make conversion code...). So I'll wait and investigate more for this one.
2012-02-19 11:09:44 +00:00
|
|
|
{
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
float rotscale_mat[4][4], loc_mat[4][4], inmat_[4][4];
|
|
|
|
|
|
|
|
/* Security, this allows to call with inmat == outmat! */
|
|
|
|
copy_m4_m4(inmat_, inmat);
|
More pose armature code factorization:
* New armature_mat_bone_to_pose, which is just the reverse of armature_mat_pose_to_bone (currently used by armature evaluation code only, but might be used by constraints space conversion code too, see note below).
* Found another place where another (a bit erroneous) pose_to_bone code existed (apply_targetless_ik(), in transform_conversion.c, used by "auto ik" option), replaced it by a call to armature_mat_pose_to_bone.
Notes:
* All those changes leave many #if 0 commented code, I will remove those in a few weeks.
* There is at least one other place where generic armature_mat_(pose_to_bone/bone_to_pose) functions should be usable: the space conversion function of constraints (constraint_mat_convertspace(), in BKE's constraint.c), but here I have some problems (old code is also somewhat erroneous, but using new one makes old rigs using bone space constraints wrong, e.g. sintel one, and it’s just impossible to make conversion code...). So I'll wait and investigate more for this one.
2012-02-19 11:09:44 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat);
|
More pose armature code factorization:
* New armature_mat_bone_to_pose, which is just the reverse of armature_mat_pose_to_bone (currently used by armature evaluation code only, but might be used by constraints space conversion code too, see note below).
* Found another place where another (a bit erroneous) pose_to_bone code existed (apply_targetless_ik(), in transform_conversion.c, used by "auto ik" option), replaced it by a call to armature_mat_pose_to_bone.
Notes:
* All those changes leave many #if 0 commented code, I will remove those in a few weeks.
* There is at least one other place where generic armature_mat_(pose_to_bone/bone_to_pose) functions should be usable: the space conversion function of constraints (constraint_mat_convertspace(), in BKE's constraint.c), but here I have some problems (old code is also somewhat erroneous, but using new one makes old rigs using bone space constraints wrong, e.g. sintel one, and it’s just impossible to make conversion code...). So I'll wait and investigate more for this one.
2012-02-19 11:09:44 +00:00
|
|
|
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(outmat, rotscale_mat, inmat_);
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
mul_v3_m4v3(outmat[3], loc_mat, inmat_[3]);
|
More pose armature code factorization:
* New armature_mat_bone_to_pose, which is just the reverse of armature_mat_pose_to_bone (currently used by armature evaluation code only, but might be used by constraints space conversion code too, see note below).
* Found another place where another (a bit erroneous) pose_to_bone code existed (apply_targetless_ik(), in transform_conversion.c, used by "auto ik" option), replaced it by a call to armature_mat_pose_to_bone.
Notes:
* All those changes leave many #if 0 commented code, I will remove those in a few weeks.
* There is at least one other place where generic armature_mat_(pose_to_bone/bone_to_pose) functions should be usable: the space conversion function of constraints (constraint_mat_convertspace(), in BKE's constraint.c), but here I have some problems (old code is also somewhat erroneous, but using new one makes old rigs using bone space constraints wrong, e.g. sintel one, and it’s just impossible to make conversion code...). So I'll wait and investigate more for this one.
2012-02-19 11:09:44 +00:00
|
|
|
}
|
|
|
|
|
2007-01-07 22:30:44 +00:00
|
|
|
/* Convert Pose-Space Location to Bone-Space Location
|
|
|
|
* NOTE: this cannot be used to convert to pose-space location of the supplied
|
2012-02-22 15:35:42 +00:00
|
|
|
* pose-channel into its local space (i.e. 'visual'-keyframing) */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3])
|
2006-12-22 09:05:37 +00:00
|
|
|
{
|
2014-04-29 18:12:44 +10:00
|
|
|
float xLocMat[4][4];
|
2006-12-22 09:05:37 +00:00
|
|
|
float nLocMat[4][4];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2006-12-22 09:05:37 +00:00
|
|
|
/* build matrix for location */
|
2014-04-29 18:12:44 +10:00
|
|
|
unit_m4(xLocMat);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(xLocMat[3], inloc);
|
2006-12-22 09:05:37 +00:00
|
|
|
|
|
|
|
/* get bone-space cursor matrix and extract location */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_mat_pose_to_bone(pchan, xLocMat, nLocMat);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(outloc, nLocMat[3]);
|
2006-12-22 09:05:37 +00:00
|
|
|
}
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph, Object *ob, bPoseChannel *pchan, float inmat[4][4], float outmat[4][4])
|
2012-02-01 05:59:50 +00:00
|
|
|
{
|
|
|
|
bPoseChannel work_pchan = *pchan;
|
|
|
|
|
|
|
|
/* recalculate pose matrix with only parent transformations,
|
|
|
|
* bone loc/sca/rot is ignored, scene and frame are not used. */
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_pose_where_is_bone(depsgraph, NULL, ob, &work_pchan, 0.0f, false);
|
2012-02-01 05:59:50 +00:00
|
|
|
|
|
|
|
/* find the matrix, need to remove the bone transforms first so this is
|
|
|
|
* calculated as a matrix to set rather then a difference ontop of whats
|
|
|
|
* already there. */
|
|
|
|
unit_m4(outmat);
|
2014-04-01 11:34:00 +11:00
|
|
|
BKE_pchan_apply_mat4(&work_pchan, outmat, false);
|
2012-02-01 05:59:50 +00:00
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_mat_pose_to_bone(&work_pchan, inmat, outmat);
|
2012-02-01 05:59:50 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
/* same as BKE_object_mat3_to_rot() */
|
2014-04-01 11:34:00 +11:00
|
|
|
void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat)
|
2010-10-26 12:48:07 +00:00
|
|
|
{
|
2015-10-24 07:02:51 +11:00
|
|
|
BLI_ASSERT_UNIT_M3(mat);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (pchan->rotmode) {
|
2012-02-22 15:35:42 +00:00
|
|
|
case ROT_MODE_QUAT:
|
2015-10-24 07:02:51 +11:00
|
|
|
mat3_normalized_to_quat(pchan->quat, mat);
|
2012-02-22 15:35:42 +00:00
|
|
|
break;
|
|
|
|
case ROT_MODE_AXISANGLE:
|
2015-10-24 07:02:51 +11:00
|
|
|
mat3_normalized_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, mat);
|
2012-02-22 15:35:42 +00:00
|
|
|
break;
|
|
|
|
default: /* euler */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (use_compat)
|
2015-10-24 07:02:51 +11:00
|
|
|
mat3_normalized_to_compatible_eulO(pchan->eul, pchan->eul, pchan->rotmode, mat);
|
2012-02-22 15:35:42 +00:00
|
|
|
else
|
2015-10-24 07:02:51 +11:00
|
|
|
mat3_normalized_to_eulO(pchan->eul, pchan->rotmode, mat);
|
2013-07-21 08:16:37 +00:00
|
|
|
break;
|
2010-10-26 12:48:07 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-19 15:34:26 +00:00
|
|
|
|
|
|
|
/* Apply a 4x4 matrix to the pose bone,
|
2012-05-05 14:03:12 +00:00
|
|
|
* similar to BKE_object_apply_mat4() */
|
2014-04-01 11:34:00 +11:00
|
|
|
void BKE_pchan_apply_mat4(bPoseChannel *pchan, float mat[4][4], bool use_compat)
|
2010-02-19 15:34:26 +00:00
|
|
|
{
|
2010-10-26 12:48:07 +00:00
|
|
|
float rot[3][3];
|
|
|
|
mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat);
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pchan_mat3_to_rot(pchan, rot, use_compat);
|
2010-02-19 15:34:26 +00:00
|
|
|
}
|
|
|
|
|
2007-01-17 05:53:44 +00:00
|
|
|
/* Remove rest-position effects from pose-transform for obtaining
|
2010-02-19 15:34:26 +00:00
|
|
|
* 'visual' transformation of pose-channel.
|
2012-02-22 15:35:42 +00:00
|
|
|
* (used by the Visual-Keyframing stuff) */
|
2012-12-11 14:29:01 +00:00
|
|
|
void BKE_armature_mat_pose_to_delta(float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4])
|
2007-01-17 05:53:44 +00:00
|
|
|
{
|
2011-04-21 01:21:28 +00:00
|
|
|
float imat[4][4];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2011-04-21 01:21:28 +00:00
|
|
|
invert_m4_m4(imat, arm_mat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(delta_mat, imat, pose_mat);
|
2007-01-17 05:53:44 +00:00
|
|
|
}
|
|
|
|
|
2009-09-28 10:19:20 +00:00
|
|
|
/* **************** Rotation Mode Conversions ****************************** */
|
|
|
|
/* Used for Objects and Pose Channels, since both can have multiple rotation representations */
|
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* Called from RNA when rotation mode changes
|
|
|
|
* - the result should be that the rotations given in the provided pointers have had conversions
|
|
|
|
* applied (as appropriate), such that the rotation of the element hasn't 'visually' changed */
|
2012-04-29 17:11:40 +00:00
|
|
|
void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode)
|
2009-09-28 10:19:20 +00:00
|
|
|
{
|
|
|
|
/* check if any change - if so, need to convert data */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (newMode > 0) { /* to euler */
|
|
|
|
if (oldMode == ROT_MODE_AXISANGLE) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* axis-angle to euler */
|
2012-04-29 17:11:40 +00:00
|
|
|
axis_angle_to_eulO(eul, newMode, axis, *angle);
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (oldMode == ROT_MODE_QUAT) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* quat to euler */
|
2010-12-07 01:56:32 +00:00
|
|
|
normalize_qt(quat);
|
2012-04-29 15:47:02 +00:00
|
|
|
quat_to_eulO(eul, newMode, quat);
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
|
|
|
/* else { no conversion needed } */
|
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (newMode == ROT_MODE_QUAT) { /* to quat */
|
|
|
|
if (oldMode == ROT_MODE_AXISANGLE) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* axis angle to quat */
|
2009-11-10 20:43:45 +00:00
|
|
|
axis_angle_to_quat(quat, axis, *angle);
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (oldMode > 0) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* euler to quat */
|
2012-02-22 15:35:42 +00:00
|
|
|
eulO_to_quat(quat, eul, oldMode);
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
|
|
|
/* else { no conversion needed } */
|
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (newMode == ROT_MODE_AXISANGLE) { /* to axis-angle */
|
|
|
|
if (oldMode > 0) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* euler to axis angle */
|
2012-02-22 15:35:42 +00:00
|
|
|
eulO_to_axis_angle(axis, angle, eul, oldMode);
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (oldMode == ROT_MODE_QUAT) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* quat to axis angle */
|
2010-12-07 01:56:32 +00:00
|
|
|
normalize_qt(quat);
|
2012-02-22 15:35:42 +00:00
|
|
|
quat_to_axis_angle(axis, angle, quat);
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-09-28 10:19:20 +00:00
|
|
|
/* when converting to axis-angle, we need a special exception for the case when there is no axis */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (IS_EQF(axis[0], axis[1]) && IS_EQF(axis[1], axis[2])) {
|
2009-09-28 10:19:20 +00:00
|
|
|
/* for now, rotate around y-axis then (so that it simply becomes the roll) */
|
2012-02-22 15:35:42 +00:00
|
|
|
axis[1] = 1.0f;
|
2009-09-28 10:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* **************** The new & simple (but OK!) armature evaluation ********* */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* ****************** And how it works! ****************************************
|
|
|
|
*
|
|
|
|
* This is the bone transformation trick; they're hierarchical so each bone(b)
|
|
|
|
* is in the coord system of bone(b-1):
|
|
|
|
*
|
|
|
|
* arm_mat(b)= arm_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b)
|
|
|
|
*
|
|
|
|
* -> yoffs is just the y axis translation in parent's coord system
|
|
|
|
* -> d_root is the translation of the bone root, also in parent's coord system
|
|
|
|
*
|
|
|
|
* pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b)
|
|
|
|
*
|
|
|
|
* we then - in init deform - store the deform in chan_mat, such that:
|
|
|
|
*
|
|
|
|
* pose_mat(b)= arm_mat(b) * chan_mat(b)
|
|
|
|
*
|
|
|
|
* *************************************************************************** */
|
2014-04-06 19:15:17 +02:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* Computes vector and roll based on a rotation.
|
|
|
|
* "mat" must contain only a rotation, and no scaling. */
|
2012-12-11 14:29:01 +00:00
|
|
|
void mat3_to_vec_roll(float mat[3][3], float r_vec[3], float *r_roll)
|
2006-11-21 10:52:11 +00:00
|
|
|
{
|
2012-10-15 09:11:17 +00:00
|
|
|
if (r_vec) {
|
|
|
|
copy_v3_v3(r_vec, mat[1]);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2012-10-15 09:11:17 +00:00
|
|
|
if (r_roll) {
|
2010-03-22 09:30:00 +00:00
|
|
|
float vecmat[3][3], vecmatinv[3][3], rollmat[3][3];
|
2006-01-11 19:40:06 +00:00
|
|
|
|
2010-03-22 09:30:00 +00:00
|
|
|
vec_roll_to_mat3(mat[1], 0.0f, vecmat);
|
|
|
|
invert_m3_m3(vecmatinv, vecmat);
|
|
|
|
mul_m3_m3m3(rollmat, vecmatinv, mat);
|
2006-01-11 19:40:06 +00:00
|
|
|
|
2012-10-15 09:11:17 +00:00
|
|
|
*r_roll = atan2f(rollmat[2][0], rollmat[2][2]);
|
2010-03-22 09:30:00 +00:00
|
|
|
}
|
2006-01-11 19:40:06 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2014-04-06 19:15:17 +02:00
|
|
|
/* Calculates the rest matrix of a bone based on its vector and a roll around that vector. */
|
|
|
|
/* Given v = (v.x, v.y, v.z) our (normalized) bone vector, we want the rotation matrix M
|
|
|
|
* from the Y axis (so that M * (0, 1, 0) = v).
|
|
|
|
* -> The rotation axis a lays on XZ plane, and it is orthonormal to v, hence to the projection of v onto XZ plane.
|
|
|
|
* -> a = (v.z, 0, -v.x)
|
|
|
|
* We know a is eigenvector of M (so M * a = a).
|
|
|
|
* Finally, we have w, such that M * w = (0, 1, 0) (i.e. the vector that will be aligned with Y axis once transformed).
|
|
|
|
* We know w is symmetric to v by the Y axis.
|
|
|
|
* -> w = (-v.x, v.y, -v.z)
|
|
|
|
*
|
|
|
|
* Solving this, we get (x, y and z being the components of v):
|
|
|
|
* ┌ (x^2 * y + z^2) / (x^2 + z^2), x, x * z * (y - 1) / (x^2 + z^2) ┐
|
|
|
|
* M = │ x * (y^2 - 1) / (x^2 + z^2), y, z * (y^2 - 1) / (x^2 + z^2) │
|
|
|
|
* └ x * z * (y - 1) / (x^2 + z^2), z, (x^2 + z^2 * y) / (x^2 + z^2) ┘
|
|
|
|
*
|
|
|
|
* This is stable as long as v (the bone) is not too much aligned with +/-Y (i.e. x and z components
|
|
|
|
* are not too close to 0).
|
|
|
|
*
|
|
|
|
* Since v is normalized, we have x^2 + y^2 + z^2 = 1, hence x^2 + z^2 = 1 - y^2 = (1 - y)(1 + y).
|
|
|
|
* This allows to simplifies M like this:
|
|
|
|
* ┌ 1 - x^2 / (1 + y), x, -x * z / (1 + y) ┐
|
|
|
|
* M = │ -x, y, -z │
|
|
|
|
* └ -x * z / (1 + y), z, 1 - z^2 / (1 + y) ┘
|
|
|
|
*
|
|
|
|
* Written this way, we see the case v = +Y is no more a singularity. The only one remaining is the bone being
|
|
|
|
* aligned with -Y.
|
|
|
|
*
|
|
|
|
* Let's handle the asymptotic behavior when bone vector is reaching the limit of y = -1. Each of the four corner
|
|
|
|
* elements can vary from -1 to 1, depending on the axis a chosen for doing the rotation. And the "rotation" here
|
|
|
|
* is in fact established by mirroring XZ plane by that given axis, then inversing the Y-axis.
|
|
|
|
* For sufficiently small x and z, and with y approaching -1, all elements but the four corner ones of M
|
|
|
|
* will degenerate. So let's now focus on these corner elements.
|
|
|
|
*
|
|
|
|
* We rewrite M so that it only contains its four corner elements, and combine the 1 / (1 + y) factor:
|
|
|
|
* ┌ 1 + y - x^2, -x * z ┐
|
|
|
|
* M* = 1 / (1 + y) * │ │
|
|
|
|
* └ -x * z, 1 + y - z^2 ┘
|
|
|
|
*
|
|
|
|
* When y is close to -1, computing 1 / (1 + y) will cause severe numerical instability, so we ignore it and
|
|
|
|
* normalize M instead. We know y^2 = 1 - (x^2 + z^2), and y < 0, hence y = -sqrt(1 - (x^2 + z^2)).
|
|
|
|
* Since x and z are both close to 0, we apply the binomial expansion to the first order:
|
|
|
|
* y = -sqrt(1 - (x^2 + z^2)) = -1 + (x^2 + z^2) / 2. Which gives:
|
|
|
|
* ┌ z^2 - x^2, -2 * x * z ┐
|
|
|
|
* M* = 1 / (x^2 + z^2) * │ │
|
|
|
|
* └ -2 * x * z, x^2 - z^2 ┘
|
|
|
|
*/
|
2014-05-21 15:22:31 +02:00
|
|
|
void vec_roll_to_mat3_normalized(const float nor[3], const float roll, float mat[3][3])
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2014-04-17 10:19:32 +02:00
|
|
|
#define THETA_THRESHOLD_NEGY 1.0e-9f
|
|
|
|
#define THETA_THRESHOLD_NEGY_CLOSE 1.0e-5f
|
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
float theta;
|
|
|
|
float rMatrix[3][3], bMatrix[3][3];
|
2010-08-15 15:14:08 +00:00
|
|
|
|
2015-09-02 00:43:53 +10:00
|
|
|
BLI_ASSERT_UNIT_V3(nor);
|
|
|
|
|
2014-04-16 18:20:27 +02:00
|
|
|
theta = 1.0f + nor[1];
|
2006-11-18 23:07:32 +00:00
|
|
|
|
2014-04-06 19:15:17 +02:00
|
|
|
/* With old algo, 1.0e-13f caused T23954 and T31333, 1.0e-6f caused T27675 and T30438,
|
|
|
|
* so using 1.0e-9f as best compromise.
|
2011-06-16 07:59:22 +00:00
|
|
|
*
|
2014-04-06 19:15:17 +02:00
|
|
|
* New algo is supposed much more precise, since less complex computations are performed,
|
|
|
|
* but it uses two different threshold values...
|
2014-04-17 10:19:32 +02:00
|
|
|
*
|
|
|
|
* Note: When theta is close to zero, we have to check we do have non-null X/Z components as well
|
|
|
|
* (due to float precision errors, we can have nor = (0.0, 0.99999994, 0.0)...).
|
2011-06-16 07:59:22 +00:00
|
|
|
*/
|
2014-04-17 10:19:32 +02:00
|
|
|
if (theta > THETA_THRESHOLD_NEGY_CLOSE || ((nor[0] || nor[2]) && theta > THETA_THRESHOLD_NEGY)) {
|
2014-04-06 19:15:17 +02:00
|
|
|
/* nor is *not* -Y.
|
|
|
|
* We got these values for free... so be happy with it... ;)
|
|
|
|
*/
|
|
|
|
bMatrix[0][1] = -nor[0];
|
|
|
|
bMatrix[1][0] = nor[0];
|
|
|
|
bMatrix[1][1] = nor[1];
|
|
|
|
bMatrix[1][2] = nor[2];
|
|
|
|
bMatrix[2][1] = -nor[2];
|
2014-04-17 10:19:32 +02:00
|
|
|
if (theta > THETA_THRESHOLD_NEGY_CLOSE) {
|
2014-04-06 19:15:17 +02:00
|
|
|
/* If nor is far enough from -Y, apply the general case. */
|
|
|
|
bMatrix[0][0] = 1 - nor[0] * nor[0] / theta;
|
|
|
|
bMatrix[2][2] = 1 - nor[2] * nor[2] / theta;
|
|
|
|
bMatrix[2][0] = bMatrix[0][2] = -nor[0] * nor[2] / theta;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* If nor is too close to -Y, apply the special case. */
|
|
|
|
theta = nor[0] * nor[0] + nor[2] * nor[2];
|
2014-05-03 08:49:29 +02:00
|
|
|
bMatrix[0][0] = (nor[0] + nor[2]) * (nor[0] - nor[2]) / -theta;
|
2014-04-06 19:15:17 +02:00
|
|
|
bMatrix[2][2] = -bMatrix[0][0];
|
|
|
|
bMatrix[2][0] = bMatrix[0][2] = 2.0f * nor[0] * nor[2] / theta;
|
|
|
|
}
|
2003-04-24 23:13:58 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-04-06 19:15:17 +02:00
|
|
|
/* If nor is -Y, simple symmetry by Z axis. */
|
|
|
|
unit_m3(bMatrix);
|
|
|
|
bMatrix[0][0] = bMatrix[1][1] = -1.0;
|
2012-02-22 15:35:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make Roll matrix */
|
2013-06-22 23:58:52 +00:00
|
|
|
axis_angle_normalized_to_mat3(rMatrix, nor, roll);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* Combine and output result */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_m3m3(mat, rMatrix, bMatrix);
|
2014-04-17 10:19:32 +02:00
|
|
|
|
|
|
|
#undef THETA_THRESHOLD_NEGY
|
|
|
|
#undef THETA_THRESHOLD_NEGY_CLOSE
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2014-05-21 15:22:31 +02:00
|
|
|
void vec_roll_to_mat3(const float vec[3], const float roll, float mat[3][3])
|
|
|
|
{
|
|
|
|
float nor[3];
|
|
|
|
|
|
|
|
normalize_v3_v3(nor, vec);
|
|
|
|
vec_roll_to_mat3_normalized(nor, roll, mat);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* recursive part, calculates restposition of entire tree of children */
|
|
|
|
/* used by exiting editmode too */
|
2015-09-04 12:12:49 +02:00
|
|
|
void BKE_armature_where_is_bone(Bone *bone, Bone *prevbone, const bool use_recursion)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
float vec[3];
|
2012-02-22 15:35:42 +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
|
|
|
/* Bone Space */
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(vec, bone->tail, bone->head);
|
2015-09-04 12:12:49 +02:00
|
|
|
bone->length = len_v3(vec);
|
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
|
|
|
vec_roll_to_mat3(vec, bone->roll, bone->bone_mat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* this is called on old file reading too... */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone->xwidth == 0.0f) {
|
2012-02-22 15:35:42 +00:00
|
|
|
bone->xwidth = 0.1f;
|
|
|
|
bone->zwidth = 0.1f;
|
|
|
|
bone->segments = 1;
|
2005-07-16 19:07:02 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prevbone) {
|
Armature pose evaluation: more factorization of code.
Now constraints' space conversion code also uses generic armature_mat_(pose_to_bone/bone_to_pose). Previous own function (constraint_pchan_diff_mat) was somewhat inconsistent too with Hinge/NoScale/LocalLocation options...
As with previous similar changes, this might break some old rigs, in very specific cases (when constraint-evaluating an hinge/noscale/local_location bone in local space).
In the same part of code, removed unnecessary matrices copying, mult_m4_m4m4 can take the same matrix as input and output, nowadays...
Also found a bug-generator weakness in those armature_mat_ functions (if both input and output mat where the same, result was wrong, now systematically copying input mat, as done in LIB's matrix funcs).
Finally, factorized offset bone matrix generation into its own small function too, as it is used in two different places in armature.c (pchan_to_pose_mat itself, and restpose's where_is_armature_bone).
Note: I think all parts of blender's code related to that topic have now been tackled, but yet have to check BGE, it’s probably using that stuff too, one way or the other...
2012-02-22 20:06:33 +00:00
|
|
|
float offs_bone[4][4];
|
|
|
|
/* yoffs(b-1) + root(b) + bonemat(b) */
|
|
|
|
get_offset_bone_mat(bone, offs_bone);
|
2012-02-22 15:35:42 +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
|
|
|
/* Compose the matrix for this bone */
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(bone->arm_mat, prevbone->arm_mat, offs_bone);
|
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
|
|
|
}
|
|
|
|
else {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m3(bone->arm_mat, bone->bone_mat);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(bone->arm_mat[3], bone->head);
|
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
|
|
|
}
|
2012-02-22 15:35:42 +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
|
|
|
/* and the kiddies */
|
2015-09-04 12:12:49 +02:00
|
|
|
if (use_recursion) {
|
|
|
|
prevbone = bone;
|
|
|
|
for (bone = bone->childbase.first; bone; bone = bone->next) {
|
|
|
|
BKE_armature_where_is_bone(bone, prevbone, use_recursion);
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* updates vectors and matrices on rest-position level, only needed
|
2012-03-03 20:19:11 +00:00
|
|
|
* after editing armature itself, now only on reading file */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_armature_where_is(bArmature *arm)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
Bone *bone;
|
2012-02-22 15:35:42 +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
|
|
|
/* hierarchical from root to children */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (bone = arm->bonebase.first; bone; bone = bone->next) {
|
2015-09-04 12:12:49 +02:00
|
|
|
BKE_armature_where_is_bone(bone, NULL, true);
|
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
|
|
|
|
2010-02-23 17:56:45 +00:00
|
|
|
/* if bone layer is protected, copy the data from from->pose
|
|
|
|
* when used with linked libraries this copies from the linked pose into the local pose */
|
2006-11-30 15:54:21 +00:00
|
|
|
static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected)
|
2006-11-11 16:45:17 +00:00
|
|
|
{
|
2012-02-22 15:35:42 +00:00
|
|
|
bPose *pose = ob->pose, *frompose = from->pose;
|
2012-08-30 13:11:53 +00:00
|
|
|
bPoseChannel *pchan, *pchanp;
|
2006-11-11 16:45:17 +00:00
|
|
|
bConstraint *con;
|
2010-01-05 19:34:19 +00:00
|
|
|
int error = 0;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (frompose == NULL)
|
2012-02-22 15:35:42 +00:00
|
|
|
return;
|
2010-01-05 19:34:19 +00:00
|
|
|
|
|
|
|
/* in some cases when rigs change, we cant synchronize
|
|
|
|
* to avoid crashing check for possible errors here */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
if (pchan->bone->layer & layer_protected) {
|
2012-05-05 16:03:57 +00:00
|
|
|
if (BKE_pose_channel_find_name(frompose, pchan->name) == NULL) {
|
2012-02-22 15:35:42 +00:00
|
|
|
printf("failed to sync proxy armature because '%s' is missing pose channel '%s'\n",
|
|
|
|
from->id.name, pchan->name);
|
2010-01-05 19:34:19 +00:00
|
|
|
error = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (error)
|
2010-01-05 19:34:19 +00:00
|
|
|
return;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2006-11-11 16:45:17 +00:00
|
|
|
/* clear all transformation values from library */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_rest(frompose);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2008-03-16 03:51:00 +00:00
|
|
|
/* copy over all of the proxy's bone groups */
|
2012-05-06 15:15:33 +00:00
|
|
|
/* TODO for later
|
|
|
|
* - implement 'local' bone groups as for constraints
|
|
|
|
* Note: this isn't trivial, as bones reference groups by index not by pointer,
|
|
|
|
* so syncing things correctly needs careful attention */
|
2008-03-16 03:51:00 +00:00
|
|
|
BLI_freelistN(&pose->agroups);
|
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
2008-11-12 21:16:53 +00:00
|
|
|
BLI_duplicatelist(&pose->agroups, &frompose->agroups);
|
2012-02-22 15:35:42 +00:00
|
|
|
pose->active_group = frompose->active_group;
|
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
2012-05-05 16:03:57 +00:00
|
|
|
pchanp = BKE_pose_channel_find_name(frompose, pchan->name);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-06-20 21:10:34 +00:00
|
|
|
if (UNLIKELY(pchanp == NULL)) {
|
|
|
|
/* happens for proxies that become invalid because of a missing link
|
2012-10-20 20:36:51 +00:00
|
|
|
* for regular cases it shouldn't happen at all */
|
2012-06-20 21:10:34 +00:00
|
|
|
}
|
|
|
|
else if (pchan->bone->layer & layer_protected) {
|
2008-01-04 11:21:50 +00:00
|
|
|
ListBase proxylocal_constraints = {NULL, NULL};
|
2013-03-17 10:26:23 +00:00
|
|
|
bPoseChannel pchanw;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2006-11-11 16:45:17 +00:00
|
|
|
/* copy posechannel to temp, but restore important pointers */
|
2012-02-22 15:35:42 +00:00
|
|
|
pchanw = *pchanp;
|
2016-11-11 18:05:01 +01:00
|
|
|
pchanw.bone = pchan->bone;
|
2012-02-22 15:35:42 +00:00
|
|
|
pchanw.prev = pchan->prev;
|
|
|
|
pchanw.next = pchan->next;
|
|
|
|
pchanw.parent = pchan->parent;
|
|
|
|
pchanw.child = pchan->child;
|
2014-12-08 16:46:42 +01:00
|
|
|
pchanw.custom_tx = pchan->custom_tx;
|
2013-08-14 10:39:16 +00:00
|
|
|
|
|
|
|
pchanw.mpath = pchan->mpath;
|
|
|
|
pchan->mpath = NULL;
|
|
|
|
|
2009-11-27 12:42:42 +00:00
|
|
|
/* this is freed so copy a copy, else undo crashes */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchanw.prop) {
|
2012-02-22 15:35:42 +00:00
|
|
|
pchanw.prop = IDP_CopyProperty(pchanw.prop);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2014-10-29 14:11:19 +01:00
|
|
|
/* use the values from the existing props */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->prop) {
|
2010-02-15 18:43:54 +00:00
|
|
|
IDP_SyncGroupValues(pchanw.prop, pchan->prop);
|
|
|
|
}
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-02-22 15:35:42 +00:00
|
|
|
/* constraints - proxy constraints are flushed... local ones are added after
|
|
|
|
* 1. extract constraints not from proxy (CONSTRAINT_PROXY_LOCAL) from pchan's constraints
|
|
|
|
* 2. copy proxy-pchan's constraints on-to new
|
|
|
|
* 3. add extracted local constraints back on top
|
2010-04-29 15:31:53 +00:00
|
|
|
*
|
2014-04-11 11:47:07 +10:00
|
|
|
* Note for BKE_constraints_copy: when copying constraints, disable 'do_extern' otherwise
|
2012-12-23 11:31:15 +00:00
|
|
|
* we get the libs direct linked in this blend.
|
|
|
|
*/
|
2014-04-11 11:47:07 +10:00
|
|
|
BKE_constraints_proxylocal_extract(&proxylocal_constraints, &pchan->constraints);
|
|
|
|
BKE_constraints_copy(&pchanw.constraints, &pchanp->constraints, false);
|
2010-12-21 14:49:34 +00:00
|
|
|
BLI_movelisttolist(&pchanw.constraints, &proxylocal_constraints);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2008-01-04 11:21:50 +00:00
|
|
|
/* constraints - set target ob pointer to own object */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (con = pchanw.constraints.first; con; con = con->next) {
|
2015-03-30 21:17:07 +11:00
|
|
|
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
ListBase targets = {NULL, NULL};
|
|
|
|
bConstraintTarget *ct;
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (cti && cti->get_constraint_targets) {
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
cti->get_constraint_targets(con, &targets);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (ct = targets.first; ct; ct = ct->next) {
|
|
|
|
if (ct->tar == from)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
ct->tar = ob;
|
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (cti->flush_constraint_targets)
|
== Constraints System - Recode 2 ==
Once again, I've recoded the constraints system. This time, the goals were:
* To make it more future-proof by 'modernising' the coding style. The long functions filled with switch statements, have given way to function-pointers with smaller functions for specific purposes.
* To make it support constraints which use multiple targets more readily that it did. In the past, it was assumed that constraints could only have at most one target.
As a result, a lot of code has been shuffled around, and modified. Also, the subversion number has been bumped up.
Known issues:
* PyConstraints, which were the main motivation for supporting multiple-targets, are currently broken. There are some bimport() error that keeps causing problems. I've also temporarily removed the doDriver support, although it may return in another form soon.
* Constraints BPy-API is currently has a few features which currently don't work yet
* Outliner currently only displays the names of the constraints instead of the fancy subtarget/target/constraint-name display it used to do. What gets displayed here needs further investigation, as the old way was certainly not that great (and is not compatible with the new system too)
2007-10-21 23:00:29 +00:00
|
|
|
cti->flush_constraint_targets(con, &targets, 0);
|
|
|
|
}
|
2006-11-11 16:45:17 +00:00
|
|
|
}
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2006-11-11 16:45:17 +00:00
|
|
|
/* free stuff from current channel */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_channel_free(pchan);
|
2018-06-17 17:05:51 +02:00
|
|
|
|
2012-08-30 13:11:53 +00:00
|
|
|
/* copy data in temp back over to the cleaned-out (but still allocated) original channel */
|
2012-02-22 15:35:42 +00:00
|
|
|
*pchan = pchanw;
|
2013-08-12 13:52:13 +00:00
|
|
|
if (pchan->custom) {
|
|
|
|
id_us_plus(&pchan->custom->id);
|
|
|
|
}
|
2006-11-11 16:45:17 +00:00
|
|
|
}
|
2010-01-12 18:56:39 +00:00
|
|
|
else {
|
|
|
|
/* always copy custom shape */
|
2012-02-22 15:35:42 +00:00
|
|
|
pchan->custom = pchanp->custom;
|
2013-08-12 13:52:13 +00:00
|
|
|
if (pchan->custom) {
|
|
|
|
id_us_plus(&pchan->custom->id);
|
|
|
|
}
|
2013-02-06 12:16:53 +00:00
|
|
|
if (pchanp->custom_tx)
|
|
|
|
pchan->custom_tx = BKE_pose_channel_find_name(pose, pchanp->custom_tx->name);
|
2010-02-15 18:43:54 +00:00
|
|
|
|
|
|
|
/* ID-Property Syncing */
|
|
|
|
{
|
2012-02-22 15:35:42 +00:00
|
|
|
IDProperty *prop_orig = pchan->prop;
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchanp->prop) {
|
2012-02-22 15:35:42 +00:00
|
|
|
pchan->prop = IDP_CopyProperty(pchanp->prop);
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prop_orig) {
|
2010-02-15 18:43:54 +00:00
|
|
|
/* copy existing values across when types match */
|
|
|
|
IDP_SyncGroupValues(pchan->prop, prop_orig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-02-22 15:35:42 +00:00
|
|
|
pchan->prop = NULL;
|
2010-02-15 18:43:54 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
if (prop_orig) {
|
2010-02-15 18:43:54 +00:00
|
|
|
IDP_FreeProperty(prop_orig);
|
|
|
|
MEM_freeN(prop_orig);
|
|
|
|
}
|
|
|
|
}
|
2010-01-12 18:56:39 +00:00
|
|
|
}
|
2006-11-11 16:45:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int counter)
|
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
|
|
|
{
|
2012-05-05 16:03:57 +00:00
|
|
|
bPoseChannel *pchan = BKE_pose_channel_verify(pose, bone->name); /* verify checks and/or adds */
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
pchan->bone = bone;
|
|
|
|
pchan->parent = parchan;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
counter++;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
for (bone = bone->childbase.first; bone; bone = bone->next) {
|
2012-02-22 15:35:42 +00:00
|
|
|
counter = rebuild_pose_bone(pose, bone, pchan, counter);
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
/* for quick detecting of next bone in chain, only b-bone uses it now */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone->flag & BONE_CONNECTED)
|
2012-05-05 16:03:57 +00:00
|
|
|
pchan->child = BKE_pose_channel_find_name(pose, bone->name);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +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
|
|
|
return counter;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
2016-07-21 16:15:00 +02:00
|
|
|
/**
|
|
|
|
* Clear pointers of object's pose (needed in remap case, since we cannot always wait for a complete pose rebuild).
|
|
|
|
*/
|
|
|
|
void BKE_pose_clear_pointers(bPose *pose)
|
|
|
|
{
|
|
|
|
for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
pchan->bone = NULL;
|
|
|
|
pchan->child = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-03 16:10:37 +02:00
|
|
|
void BKE_pose_remap_bone_pointers(bArmature *armature, bPose *pose)
|
|
|
|
{
|
|
|
|
GHash *bone_hash = BKE_armature_bone_from_name_map(armature);
|
|
|
|
for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
pchan->bone = BLI_ghash_lookup(bone_hash, pchan->name);
|
|
|
|
}
|
|
|
|
BLI_ghash_free(bone_hash, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2018-07-19 16:48:21 +02:00
|
|
|
/**
|
|
|
|
* Only after leave editmode, duplicating, validating older files, library syncing.
|
|
|
|
*
|
|
|
|
* \note pose->flag is set for it.
|
|
|
|
*
|
|
|
|
* \param bmain May be NULL, only used to tag depsgraph as being dirty...
|
|
|
|
*/
|
2018-07-31 11:38:10 +02:00
|
|
|
void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_user)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
Bone *bone;
|
|
|
|
bPose *pose;
|
|
|
|
bPoseChannel *pchan, *next;
|
2012-02-22 15:35:42 +00:00
|
|
|
int counter = 0;
|
|
|
|
|
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
|
|
|
/* only done here */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (ob->pose == NULL) {
|
2010-01-19 11:31:49 +00:00
|
|
|
/* create new pose */
|
2012-02-22 15:35:42 +00:00
|
|
|
ob->pose = MEM_callocN(sizeof(bPose), "new pose");
|
|
|
|
|
2010-01-19 11:31:49 +00:00
|
|
|
/* set default settings for animviz */
|
|
|
|
animviz_settings_init(&ob->pose->avs);
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
pose = ob->pose;
|
|
|
|
|
2005-07-17 22:15:12 +00:00
|
|
|
/* clear */
|
2016-07-21 16:15:00 +02:00
|
|
|
BKE_pose_clear_pointers(pose);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2005-07-16 19:07:02 +00:00
|
|
|
/* first step, check if all channels are there */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (bone = arm->bonebase.first; bone; bone = bone->next) {
|
2012-02-22 15:35:42 +00:00
|
|
|
counter = rebuild_pose_bone(pose, bone, NULL, counter);
|
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
|
|
|
|
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
|
|
|
/* and a check for garbage */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = pose->chanbase.first; pchan; pchan = next) {
|
2012-02-22 15:35:42 +00:00
|
|
|
next = pchan->next;
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->bone == NULL) {
|
2018-07-31 11:38:10 +02:00
|
|
|
BKE_pose_channel_free_ex(pchan, do_id_user);
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_channels_hash_free(pose);
|
2005-10-20 21:02:04 +00:00
|
|
|
BLI_freelinkN(&pose->chanbase, pchan);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
/* printf("rebuild pose %s, %d bones\n", ob->id.name, counter); */
|
|
|
|
|
2006-11-11 16:45:17 +00:00
|
|
|
/* synchronize protected layers with proxy */
|
2018-05-16 15:41:53 +02:00
|
|
|
/* HACK! To preserve 2.7x behavior that you always can pose even locked bones,
|
|
|
|
* do not do any restauration if this is a COW temp copy! */
|
2018-05-16 17:23:52 +02:00
|
|
|
/* Switched back to just NO_MAIN tag, for some reasons (c) using COW tag was working this morning, but not anymore... */
|
|
|
|
if (ob->proxy != NULL && (ob->id.tag & LIB_TAG_NO_MAIN) == 0) {
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_object_copy_proxy_drivers(ob, ob->proxy);
|
2006-11-11 16:45:17 +00:00
|
|
|
pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected);
|
2010-01-20 14:28:49 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2018-07-19 16:48:21 +02:00
|
|
|
BKE_pose_update_constraint_flags(pose); /* for IK detection for example */
|
|
|
|
|
|
|
|
pose->flag &= ~POSE_RECALC;
|
|
|
|
pose->flag |= POSE_WAS_REBUILT;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2018-07-19 16:48:21 +02:00
|
|
|
BKE_pose_channels_hash_make(pose);
|
2010-07-12 11:04:51 +00:00
|
|
|
|
2018-07-19 16:48:21 +02:00
|
|
|
/* Rebuilding poses forces us to also rebuild the dependency graph, since there is one node per pose/bone... */
|
|
|
|
if (bmain != NULL) {
|
|
|
|
DEG_relations_tag_update(bmain);
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
/* ********************** THE POSE SOLVER ******************* */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2010-03-01 05:19:07 +00:00
|
|
|
/* loc/rot/size to given mat4 */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
float smat[3][3];
|
|
|
|
float rmat[3][3];
|
|
|
|
float tmat[3][3];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2008-12-19 11:45:46 +00:00
|
|
|
/* get scaling matrix */
|
2010-03-01 05:19:07 +00:00
|
|
|
size_to_mat3(smat, pchan->size);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-09-11 12:05:09 +00:00
|
|
|
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->rotmode > 0) {
|
2009-09-11 12:05:09 +00:00
|
|
|
/* euler rotations (will cause gimble lock, but this can be alleviated a bit with rotation orders) */
|
2010-03-01 05:19:07 +00:00
|
|
|
eulO_to_mat3(rmat, pchan->eul, pchan->rotmode);
|
2008-12-19 11:45:46 +00:00
|
|
|
}
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
2009-10-08 00:57:00 +00:00
|
|
|
/* axis-angle - not really that great for 3D-changing orientations */
|
2010-03-01 05:19:07 +00:00
|
|
|
axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle);
|
2009-09-11 12:05:09 +00:00
|
|
|
}
|
2008-12-19 11:45:46 +00:00
|
|
|
else {
|
2012-07-03 19:09:07 +00:00
|
|
|
/* quats are normalized before use to eliminate scaling issues */
|
2010-03-01 05:19:07 +00:00
|
|
|
float quat[4];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-03-04 04:35:12 +00:00
|
|
|
/* NOTE: we now don't normalize the stored values anymore, since this was kindof evil in some cases
|
2012-02-22 15:35:42 +00:00
|
|
|
* but if this proves to be too problematic, switch back to the old system of operating directly on
|
2010-03-01 05:19:07 +00:00
|
|
|
* the stored copy
|
|
|
|
*/
|
2010-12-07 01:56:32 +00:00
|
|
|
normalize_qt_qt(quat, pchan->quat);
|
2010-03-01 05:19:07 +00:00
|
|
|
quat_to_mat3(rmat, quat);
|
2008-12-19 11:45:46 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2008-12-19 11:45:46 +00:00
|
|
|
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m3_m3m3(tmat, rmat, smat);
|
2010-03-01 05:19:07 +00:00
|
|
|
copy_m4_m3(chan_mat, tmat);
|
2012-02-22 15:35:42 +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
|
|
|
/* prevent action channels breaking chains */
|
2005-07-04 20:09:32 +00:00
|
|
|
/* need to check for bone here, CONSTRAINT_TYPE_ACTION uses this call */
|
2012-02-22 16:21:17 +00:00
|
|
|
if ((pchan->bone == NULL) || !(pchan->bone->flag & BONE_CONNECTED)) {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(chan_mat[3], pchan->loc);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-01 05:19:07 +00:00
|
|
|
/* loc/rot/size to mat4 */
|
|
|
|
/* used in constraint.c too */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pchan_calc_mat(bPoseChannel *pchan)
|
2010-03-01 05:19:07 +00:00
|
|
|
{
|
2012-02-22 15:35:42 +00:00
|
|
|
/* this is just a wrapper around the copy of this function which calculates the matrix
|
2010-03-01 05:19:07 +00:00
|
|
|
* and stores the result in any given channel
|
|
|
|
*/
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pchan_to_mat4(pchan, pchan->chan_mat);
|
2010-03-01 05:19:07 +00:00
|
|
|
}
|
|
|
|
|
2011-12-04 17:24:34 +00:00
|
|
|
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
|
|
|
|
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
/* NLA strip modifiers */
|
2009-01-04 14:14:06 +00:00
|
|
|
static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseChannel *pchan)
|
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
|
|
|
{
|
|
|
|
bActionModifier *amod;
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
bActionStrip *strip, *strip2;
|
2013-01-27 16:45:00 +00:00
|
|
|
float scene_cfra = BKE_scene_frame_get(scene);
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
int do_modif;
|
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
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (strip = armob->nlastrips.first; strip; strip = strip->next) {
|
2014-04-01 11:34:00 +11:00
|
|
|
do_modif = false;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (scene_cfra >= strip->start && scene_cfra <= strip->end)
|
2014-04-01 11:34:00 +11:00
|
|
|
do_modif = true;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
if ((scene_cfra > strip->end) && (strip->flag & ACTSTRIP_HOLDLASTFRAME)) {
|
2014-04-01 11:34:00 +11:00
|
|
|
do_modif = true;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* if there are any other strips active, ignore modifiers for this strip -
|
|
|
|
* 'hold' option should only hold action modifiers if there are
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
* no other active strips */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (strip2 = strip->next; strip2; strip2 = strip2->next) {
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
if (strip2 == strip) continue;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
if (scene_cfra >= strip2->start && scene_cfra <= strip2->end) {
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
if (!(strip2->flag & ACTSTRIP_MUTE))
|
2014-04-01 11:34:00 +11:00
|
|
|
do_modif = false;
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* if there are any later, activated, strips with 'hold' set, they take precedence,
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
* so ignore modifiers for this strip */
|
2012-05-06 15:15:33 +00:00
|
|
|
for (strip2 = strip->next; strip2; strip2 = strip2->next) {
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
if (scene_cfra < strip2->start) continue;
|
|
|
|
if ((strip2->flag & ACTSTRIP_HOLDLASTFRAME) && !(strip2->flag & ACTSTRIP_MUTE)) {
|
2014-04-01 11:34:00 +11:00
|
|
|
do_modif = false;
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
Patch #7779: Make the 'Hold' option work with NLA action modifiers
Patch by: Matt Ebb (broken)
Currently in Blender, NLA action modifiers can work in very wacky and mysterious ways.
If an action is being modified with a path deform, when it reaches the end of that strip, it will snap back to the original un-modified location, regardless of whether the strip 'Hold' option is on. It's very frustrating to work with, and causes all sorts of problems - if you use a path to make a character walk from point A to point B, you generally want him to stay at point B, and not jump somewhere completely different, just because the strip ended.
This patch fixes this behaviour, and makes it much more sensible and predictable. There is a chance that this will break old files that were reliant on the old broken behaviour though, but I think it's definitely worthwhile to fix this problem.
Check the demo file in Blender 2.45 vs one with this patch applied - you can see the difference in behaviour.
Demo File Link (attachment in original tracker post):
https://projects.blender.org/tracker/download.php/9/127/7779/4856/wheelsetup2.zip
2007-11-21 04:49:13 +00:00
|
|
|
if (do_modif) {
|
2006-11-03 08:40:18 +00:00
|
|
|
/* temporal solution to prevent 2 strips accumulating */
|
2012-05-06 15:15:33 +00:00
|
|
|
if (scene_cfra == strip->end && strip->next && strip->next->start == scene_cfra)
|
2006-11-03 08:40:18 +00:00
|
|
|
continue;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
for (amod = strip->modifiers.first; amod; amod = amod->next) {
|
2007-03-24 03:00:54 +00:00
|
|
|
switch (amod->type) {
|
2012-05-06 15:15:33 +00:00
|
|
|
case ACTSTRIP_MOD_DEFORM:
|
|
|
|
{
|
|
|
|
/* validate first */
|
|
|
|
if (amod->ob && amod->ob->type == OB_CURVE && amod->channel[0]) {
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(pchan->name, amod->channel)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
float mat4[4][4], mat3[3][3];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2017-11-20 12:37:11 +01:00
|
|
|
curve_deform_vector(amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis);
|
2012-05-06 15:15:33 +00:00
|
|
|
copy_m4_m4(mat4, pchan->pose_mat);
|
|
|
|
mul_m4_m3m4(pchan->pose_mat, mat3, mat4);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-06 15:15:33 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2007-03-24 03:00:54 +00:00
|
|
|
break;
|
2012-05-06 15:15:33 +00:00
|
|
|
case ACTSTRIP_MOD_NOISE:
|
|
|
|
{
|
2015-01-26 16:03:11 +01:00
|
|
|
if (STREQ(pchan->name, amod->channel)) {
|
2012-05-06 15:15:33 +00:00
|
|
|
float nor[3], loc[3], ofs;
|
|
|
|
float eul[3], size[3], eulo[3], sizeo[3];
|
|
|
|
|
|
|
|
/* calculate turbulance */
|
|
|
|
ofs = amod->turbul / 200.0f;
|
|
|
|
|
|
|
|
/* make a copy of starting conditions */
|
|
|
|
copy_v3_v3(loc, pchan->pose_mat[3]);
|
|
|
|
mat4_to_eul(eul, pchan->pose_mat);
|
|
|
|
mat4_to_size(size, pchan->pose_mat);
|
|
|
|
copy_v3_v3(eulo, eul);
|
|
|
|
copy_v3_v3(sizeo, size);
|
|
|
|
|
|
|
|
/* apply noise to each set of channels */
|
|
|
|
if (amod->channels & 4) {
|
|
|
|
/* for scaling */
|
|
|
|
nor[0] = BLI_gNoise(amod->noisesize, size[0] + ofs, size[1], size[2], 0, 0) - ofs;
|
|
|
|
nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1] + ofs, size[2], 0, 0) - ofs;
|
|
|
|
nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2] + ofs, 0, 0) - ofs;
|
|
|
|
add_v3_v3(size, nor);
|
|
|
|
|
|
|
|
if (sizeo[0] != 0)
|
|
|
|
mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]);
|
|
|
|
if (sizeo[1] != 0)
|
|
|
|
mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]);
|
|
|
|
if (sizeo[2] != 0)
|
|
|
|
mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]);
|
|
|
|
}
|
|
|
|
if (amod->channels & 2) {
|
|
|
|
/* for rotation */
|
|
|
|
nor[0] = BLI_gNoise(amod->noisesize, eul[0] + ofs, eul[1], eul[2], 0, 0) - ofs;
|
|
|
|
nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1] + ofs, eul[2], 0, 0) - ofs;
|
|
|
|
nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2] + ofs, 0, 0) - ofs;
|
|
|
|
|
|
|
|
compatible_eul(nor, eulo);
|
|
|
|
add_v3_v3(eul, nor);
|
|
|
|
compatible_eul(eul, eulo);
|
|
|
|
|
|
|
|
loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size);
|
|
|
|
}
|
|
|
|
if (amod->channels & 1) {
|
|
|
|
/* for location */
|
|
|
|
nor[0] = BLI_gNoise(amod->noisesize, loc[0] + ofs, loc[1], loc[2], 0, 0) - ofs;
|
|
|
|
nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1] + ofs, loc[2], 0, 0) - ofs;
|
|
|
|
nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2] + ofs, 0, 0) - ofs;
|
|
|
|
|
|
|
|
add_v3_v3v3(pchan->pose_mat[3], loc, nor);
|
|
|
|
}
|
2007-05-05 09:31:01 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-24 03:00:54 +00:00
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-04 17:24:34 +00:00
|
|
|
#endif
|
|
|
|
|
2010-10-22 11:38:10 +00:00
|
|
|
/* calculate tail of posechannel */
|
2012-05-05 16:03:57 +00:00
|
|
|
void BKE_pose_where_is_bone_tail(bPoseChannel *pchan)
|
2010-10-22 11:38:10 +00:00
|
|
|
{
|
|
|
|
float vec[3];
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(vec, pchan->pose_mat[1]);
|
2010-10-22 11:38:10 +00:00
|
|
|
mul_v3_fl(vec, pchan->bone->length);
|
|
|
|
add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec);
|
|
|
|
}
|
2005-11-16 14:32:57 +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
|
|
|
/* The main armature solver, does all constraints excluding IK */
|
2010-02-19 15:34:26 +00:00
|
|
|
/* pchan is validated, as having bone and parent pointer
|
|
|
|
* 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers.
|
|
|
|
*/
|
2017-08-16 12:45:11 +10:00
|
|
|
void BKE_pose_where_is_bone(
|
2018-04-06 12:07:27 +02:00
|
|
|
struct Depsgraph *depsgraph, Scene *scene,
|
2017-08-16 12:45:11 +10:00
|
|
|
Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2012-01-17 13:30:20 +00:00
|
|
|
/* This gives a chan_mat with actions (ipos) results. */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (do_extra)
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pchan_calc_mat(pchan);
|
2012-01-17 13:30:20 +00:00
|
|
|
else
|
|
|
|
unit_m4(pchan->chan_mat);
|
2010-02-19 15:34:26 +00:00
|
|
|
|
2012-01-17 13:30:20 +00:00
|
|
|
/* Construct the posemat based on PoseChannels, that we do before applying constraints. */
|
2012-02-22 15:35:42 +00:00
|
|
|
/* pose_mat(b) = pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat);
|
2012-01-17 13:30:20 +00:00
|
|
|
|
|
|
|
/* Only rootbones get the cyclic offset (unless user doesn't want that). */
|
|
|
|
/* XXX That could be a problem for snapping and other "reverse transform" features... */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (!pchan->parent) {
|
|
|
|
if ((pchan->bone->flag & BONE_NO_CYCLICOFFSET) == 0)
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(pchan->pose_mat[3], ob->pose->cyclic_offset);
|
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
|
|
|
}
|
2012-01-17 13:30:20 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (do_extra) {
|
2012-05-06 15:15:33 +00:00
|
|
|
#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */
|
2010-02-19 15:34:26 +00:00
|
|
|
/* do NLA strip modifiers - i.e. curve follow */
|
|
|
|
do_strip_modifiers(scene, ob, bone, pchan);
|
2011-12-04 17:24:34 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-19 15:34:26 +00:00
|
|
|
/* Do constraints */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->constraints.first) {
|
2010-02-19 15:34:26 +00:00
|
|
|
bConstraintOb *cob;
|
2012-01-17 13:30:20 +00:00
|
|
|
float vec[3];
|
2010-02-19 15:34:26 +00:00
|
|
|
|
|
|
|
/* make a copy of location of PoseChannel for later */
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(vec, pchan->pose_mat[3]);
|
2010-02-19 15:34:26 +00:00
|
|
|
|
|
|
|
/* prepare PoseChannel for Constraint solving
|
|
|
|
* - makes a copy of matrix, and creates temporary struct to use
|
|
|
|
*/
|
2018-05-25 11:05:51 +02:00
|
|
|
cob = BKE_constraints_make_evalob(depsgraph, scene, ob, pchan, CONSTRAINT_OBTYPE_BONE);
|
2010-02-19 15:34:26 +00:00
|
|
|
|
|
|
|
/* Solve PoseChannel's Constraints */
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_constraints_solve(depsgraph, &pchan->constraints, cob, ctime); /* ctime doesnt alter objects */
|
2010-02-19 15:34:26 +00:00
|
|
|
|
|
|
|
/* cleanup after Constraint Solving
|
|
|
|
* - applies matrix back to pchan, and frees temporary struct used
|
|
|
|
*/
|
2012-12-23 11:31:15 +00:00
|
|
|
BKE_constraints_clear_evalob(cob);
|
2010-02-19 15:34:26 +00:00
|
|
|
|
|
|
|
/* prevent constraints breaking a chain */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->bone->flag & BONE_CONNECTED) {
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(pchan->pose_mat[3], vec);
|
2010-02-19 15:34:26 +00:00
|
|
|
}
|
== Constraints System ==
After just over a week of coding, I've finished doing a major refactor/cleanup of the constraints code. In the process, quite a few old kludges and ugly hacks have been removed. Also, some new features which will greatly benefit riggers have been implemented.
=== What's New ===
* The long-awaited ``ChildOf Constraint'':
This allows you to animate parent influences, and choose which transformation channels the parent affects the child on (i.e. no translation/rotation/scaling). It should be noted that disabling some combinations may not totally work as expected. Also, the 'Set Inverse' and 'Clear Inverse' buttons at the bottom of this constraint's panel set/clear the inverse correction for the parent's effects. Use these to make the owner not stick/be glued to the parent.
* Constraint/Target Evaluation Spaces:
In some constraints, there are now 1-2 combo boxes at the bottom of their panel, which allows you to pick which `co-ordinate space' they are evaluated in. This is much more flexible than the old 'local' options for bones only were.
* Action Constraint - Loc/Rot/Size Inputs
The Action Constraint can finally use the target's location/rotation/scaling transforms as input, to control the owner of the constraint. This should work much more reliably than it used to. The target evaluation should now also be more accurate due to the new space conversion stuff.
* Transform - No longer in Crazy Space (TM)
Transforming objects/bones with constraints applied should no longer occur in Crazy Space. They are now correctly inverse-corrected. This also applies to old-style object tracking.
=== General Code Changes ===
* solve_constraints is now in constraints.c. I've removed the old `blend consecutive constraints of same type' junk, which made the code more complex than it needed to be.
* evaluate_constraint is now only passed the constraint, and two matrices. A few unused variables have been removed from here.
* A tempolary struct, bConstraintOb, is now passed to solve_constraints instead of relying on an ugly, static workobject in some cases. This works much better.
* Made the formatting of constraint code consistent
* There's a version patch for older files so that constraint settings are correctly converted to the new system. This is currently done for MajorVersion <= 244, and SubVersion < 3. I've bumped up the subversion to 3 for this purpose. However, with the imminent 2.45 release, this may need to be adjusted accordingly.
* LocEulSizeToMat4 and LocQuatSizeToMat4 now work in the order Size, Rot, Location. I've also added a few other math functions.
* Mat4BlendMat4 is now in arithb. I've modified it's method slightly, to use other arithb functions, instead of its crazy blending scheme.
* Moved some of the RigidBodyJoint constraint's code out of blenkernel, and into src. It shouldn't be setting its target in its data initialisation function based + accessing scene stuff where it was doing so.
=== Future Work ===
* Geometry to act as targets for constraints. A space has been reserved for this already.
* Tidy up UI buttons of constraints
2007-07-15 03:35:37 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-01-17 13:30:20 +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
|
|
|
/* calculate head */
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]);
|
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
|
|
|
/* calculate tail */
|
2012-05-05 16:03:57 +00:00
|
|
|
BKE_pose_where_is_bone_tail(pchan);
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
/* This only reads anim data from channels, and writes to channels */
|
|
|
|
/* This is the only function adding poses */
|
2018-04-06 12:07:27 +02:00
|
|
|
void BKE_pose_where_is(struct Depsgraph *depsgraph, Scene *scene, Object *ob)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
bArmature *arm;
|
|
|
|
Bone *bone;
|
2005-07-28 10:01:10 +00:00
|
|
|
bPoseChannel *pchan;
|
Result of 2 weeks of quiet coding work in Greece :)
Aim was to get a total refresh of the animation system. This
is needed because;
- we need to upgrade it with 21st century features
- current code is spaghetti/hack combo, and hides good design
- it should become lag-free with using dependency graphs
A full log, with complete code API/structure/design explanation
will follow, that's a load of work... so here below the list with
hot changes;
- The entire object update system (matrices, geometry) is now
centralized. Calls to where_is_object and makeDispList are
forbidden, instead we tag objects 'changed' and let the
depgraph code sort it out
- Removed all old "Ika" code
- Depgraph is aware of all relationships, including meta balls,
constraints, bevelcurve, and so on.
- Made depgraph aware of relation types and layers, to do smart
flushing of 'changed' events. Nothing gets calculated too often!
- Transform uses depgraph to detect changes
- On frame-advance, depgraph flushes animated changes
Armatures;
Almost all armature related code has been fully built from scratch.
It now reveils the original design much better, with a very clean
implementation, lag free without even calculating each Bone more than
once. Result is quite a speedup yes!
Important to note is;
1) Armature is data containing the 'rest position'
2) Pose is the changes of rest position, and always on object level.
That way more Objects can use same Pose. Also constraints are in Pose
3) Actions only contain the Ipos to change values in Poses.
- Bones draw unrotated now
- Drawing bones speedup enormously (10-20 times)
- Bone selecting in EditMode, selection state is saved for PoseMode,
and vice-versa
- Undo in editmode
- Bone renaming does vertexgroups, constraints, posechannels, actions,
for all users of Armature in entire file
- Added Bone renaming in NKey panel
- Nkey PoseMode shows eulers now
- EditMode and PoseMode now have 'active' bone too (last clicked)
- Parenting in EditMode' CTRL+P, ALT+P, with nice options!
- Pose is added in Outliner now, with showing that constraints are in
the Pose, not Armature
- Disconnected IK solving from constraints. It's a separate phase now,
on top of the full Pose calculations
- Pose itself has a dependency graph too, so evaluation order is lag free.
TODO NOW;
- Rotating in Posemode has incorrect inverse transform (Martin will fix)
- Python Bone/Armature/Pose API disabled... needs full recode too
(wait for my doc!)
- Game engine will need upgrade too
- Depgraph code needs revision, cleanup, can be much faster!
(But, compliments for Jean-Luc, it works like a charm!)
- IK changed, it now doesnt use previous position to advance to next
position anymore. That system looks nice (no flips) but is not well
suited for NLA and background render.
TODO LATER;
We now can do loadsa new nifty features as well; like:
- Kill PoseMode (can be option for armatures itself)
- Make B-Bones (Bezier, Bspline, like for spines)
- Move all silly button level edit to 3d window (like CTRL+I = add
IK)
- Much better & informative drawing
- Fix action/nla editors
- Put all ipos in Actions (object, mesh key, lamp color)
- Add hooks
- Null bones
- Much more advanced constraints...
Bugfixes;
- OGL render (view3d header) had wrong first frame on anim render
- Ipo 'recording' mode had wrong playback speed
- Vertex-key mode now sticks to show 'active key', until frame change
-Ton-
2005-07-03 17:35:38 +00:00
|
|
|
float imat[4][4];
|
2009-01-05 09:54:39 +00:00
|
|
|
float ctime;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (ob->type != OB_ARMATURE)
|
2012-02-22 15:35:42 +00:00
|
|
|
return;
|
2009-01-05 15:19:31 +00:00
|
|
|
arm = ob->data;
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-02-22 16:21:17 +00:00
|
|
|
if (ELEM(NULL, arm, scene))
|
2012-02-22 15:35:42 +00:00
|
|
|
return;
|
2018-07-19 16:48:21 +02:00
|
|
|
if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) {
|
|
|
|
/* WARNING! passing NULL bmain here means we won't tag depsgraph's as dirty - hopefully this is OK. */
|
2018-07-31 11:38:10 +02:00
|
|
|
BKE_pose_rebuild(NULL, ob, arm, true);
|
2018-07-19 16:48:21 +02:00
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2012-05-05 14:33:36 +00:00
|
|
|
ctime = BKE_scene_frame_get(scene); /* not accurate... */
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-01-02 19:10:35 +00:00
|
|
|
/* In editmode or restposition we read the data from the bones */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (arm->edbo || (arm->flag & ARM_RESTPOS)) {
|
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2012-02-22 15:35:42 +00:00
|
|
|
bone = pchan->bone;
|
2012-02-22 16:21:17 +00:00
|
|
|
if (bone) {
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(pchan->pose_mat, bone->arm_mat);
|
2011-10-28 12:40:15 +00:00
|
|
|
copy_v3_v3(pchan->pose_head, bone->arm_head);
|
|
|
|
copy_v3_v3(pchan->pose_tail, bone->arm_tail);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2012-02-22 15:35:42 +00:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat); /* imat is needed */
|
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
/* 1. clear flags */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2012-05-06 15:15:33 +00:00
|
|
|
pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE);
|
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
|
|
|
}
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-11-01 11:29:40 +00:00
|
|
|
/* 2a. construct the IK tree (standard IK) */
|
2018-04-06 12:07:27 +02:00
|
|
|
BIK_initialize_tree(depsgraph, scene, ob, ctime);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
|
|
|
/* 2b. construct the Spline IK trees
|
2009-11-01 11:29:40 +00:00
|
|
|
* - this is not integrated as an IK plugin, since it should be able
|
|
|
|
* to function in conjunction with standard IK
|
|
|
|
*/
|
2015-05-12 12:50:24 +05:00
|
|
|
BKE_pose_splineik_init_tree(scene, ob, ctime);
|
2012-02-22 15:35:42 +00:00
|
|
|
|
2009-09-24 21:22:24 +00:00
|
|
|
/* 3. the main loop, channels are already hierarchical sorted from root to children */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2009-11-01 11:29:40 +00:00
|
|
|
/* 4a. if we find an IK root, we handle it separated */
|
2012-02-22 16:21:17 +00:00
|
|
|
if (pchan->flag & POSE_IKTREE) {
|
2018-04-06 12:07:27 +02:00
|
|
|
BIK_execute_tree(depsgraph, scene, ob, pchan, ctime);
|
Integration of new IK lib features in Armature Poses.
Best is to forget yesterday's commit and old docs. New docs are underway...
Here's how IK works now;
- IK chains can go all the way to the furthest parent Bone. Disregarding
the old option "IK to Parent" and disgregarding whether a Bone has an
offset to its parent (offsets now work for IK, so you can also make
T-bones).
- The old "IK to Parent" option now only does what it should do: it denotes
whether a Bone is directly connected to a Parent Bone, or not.
In the UI and in code this option is now called "Connected".
- You can also define yourself which Bone will become the "Root" for an IK
chain. This can be any Parent of the IK tip (where the IK constraint is).
By default it goes all the way, unless you set a value for the new IK
Constraint Panel option "Chain Lenght".
- "Tree IK" now is detected automatic, when multiple IK Roots are on the
same Bone, and when there's a branched structure.
Multiple IK's on a single chain (no branches) is still executed as usual,
doing the IK's sequentially.
- Note: Branched structures, with _partial_ overlapping IK chains, that don't
share the same Root will possibly disconnect branches.
- When you select a Bone with IK, it now draws a yellow dashed line to its
Root.
- The IK options "Location Weight" and "Rotation Weight" are relative,
in case there's a Tree IK structure. These weights cannot be set to
zero. To animate or disable IK Targets, use the "Influence" slider.
- This new IK is backwards and upwards compatible for Blender files.
Of course, the new features won't show in older Blender binaries! :)
Other changes & notes;
- In PoseMode, the Constraint Panel now also draws in Editing Buttons, next
to the Bones Panel.
- IK Constraint Panel was redesigned... it's still a bit squished
- Buttons "No X DoF" is now called "Lock X". This to follow convention to
name options positive.
- Added Undo push for Make/Clear Parent in Editmode Armature
- Use CTRL+P "Make Parent" on a single selected Bone to make it become
connected (ALT+P had already "Disconnect").
On todo next; Visualizing & review of Bone DoF limits and stiffness
2005-08-28 12:23:06 +00:00
|
|
|
}
|
2009-11-01 11:29:40 +00:00
|
|
|
/* 4b. if we find a Spline IK root, we handle it separated too */
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (pchan->flag & POSE_IKSPLINE) {
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_splineik_execute_tree(depsgraph, scene, ob, pchan, ctime);
|
2009-11-01 11:29:40 +00:00
|
|
|
}
|
2009-09-24 21:22:24 +00:00
|
|
|
/* 5. otherwise just call the normal solver */
|
2012-02-22 16:21:17 +00:00
|
|
|
else if (!(pchan->flag & POSE_DONE)) {
|
2018-04-06 12:07:27 +02:00
|
|
|
BKE_pose_where_is_bone(depsgraph, scene, ob, pchan, ctime, 1);
|
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-09-24 21:22:24 +00:00
|
|
|
/* 6. release the IK tree */
|
|
|
|
BIK_release_tree(scene, ob, ctime);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2012-02-22 15:35:42 +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
|
|
|
/* calculating deform matrices */
|
2012-02-22 16:21:17 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
if (pchan->bone) {
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, pchan->bone->arm_mat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(pchan->chan_mat, pchan->pose_mat, imat);
|
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-09-14 02:04:26 +00:00
|
|
|
|
2012-03-22 13:27:24 +00:00
|
|
|
/************** Bounding box ********************/
|
2012-05-13 11:05:52 +00:00
|
|
|
static int minmax_armature(Object *ob, float r_min[3], float r_max[3])
|
2012-03-22 13:27:24 +00:00
|
|
|
{
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
/* For now, we assume BKE_pose_where_is has already been called (hence we have valid data in pachan). */
|
2012-03-22 13:27:24 +00:00
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
2012-05-13 11:05:52 +00:00
|
|
|
minmax_v3v3_v3(r_min, r_max, pchan->pose_head);
|
|
|
|
minmax_v3v3_v3(r_min, r_max, pchan->pose_tail);
|
2012-03-22 13:27:24 +00:00
|
|
|
}
|
|
|
|
|
2014-02-08 06:07:10 +11:00
|
|
|
return (BLI_listbase_is_empty(&ob->pose->chanbase) == false);
|
2012-03-22 13:27:24 +00:00
|
|
|
}
|
|
|
|
|
2015-08-13 18:12:08 +02:00
|
|
|
static void boundbox_armature(Object *ob)
|
2012-03-22 13:27:24 +00:00
|
|
|
{
|
|
|
|
BoundBox *bb;
|
|
|
|
float min[3], max[3];
|
|
|
|
|
2016-01-07 14:34:33 +05:00
|
|
|
if (ob->bb == NULL) {
|
2016-03-04 21:50:54 +11:00
|
|
|
ob->bb = MEM_callocN(sizeof(BoundBox), "Armature boundbox");
|
2016-01-07 14:34:33 +05:00
|
|
|
}
|
2012-03-22 13:27:24 +00:00
|
|
|
bb = ob->bb;
|
|
|
|
|
|
|
|
INIT_MINMAX(min, max);
|
|
|
|
if (!minmax_armature(ob, min, max)) {
|
|
|
|
min[0] = min[1] = min[2] = -1.0f;
|
|
|
|
max[0] = max[1] = max[2] = 1.0f;
|
|
|
|
}
|
|
|
|
|
2012-05-05 14:03:12 +00:00
|
|
|
BKE_boundbox_init_from_minmax(bb, min, max);
|
2016-03-04 21:50:54 +11:00
|
|
|
|
|
|
|
bb->flag &= ~BOUNDBOX_DIRTY;
|
2012-03-22 13:27:24 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 16:03:57 +00:00
|
|
|
BoundBox *BKE_armature_boundbox_get(Object *ob)
|
2012-03-22 13:27:24 +00:00
|
|
|
{
|
2015-08-13 18:12:08 +02:00
|
|
|
boundbox_armature(ob);
|
2012-03-22 13:27:24 +00:00
|
|
|
|
|
|
|
return ob->bb;
|
|
|
|
}
|
2015-05-12 13:57:11 +05:00
|
|
|
|
2015-09-04 04:18:49 +10:00
|
|
|
bool BKE_pose_minmax(Object *ob, float r_min[3], float r_max[3], bool use_hidden, bool use_select)
|
|
|
|
{
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
if (ob->pose) {
|
|
|
|
bArmature *arm = ob->data;
|
|
|
|
bPoseChannel *pchan;
|
|
|
|
|
|
|
|
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
|
|
|
/* XXX pchan->bone may be NULL for duplicated bones, see duplicateEditBoneObjects() comment
|
|
|
|
* (editarmature.c:2592)... Skip in this case too! */
|
|
|
|
if (pchan->bone &&
|
|
|
|
(!((use_hidden == false) && (PBONE_VISIBLE(arm, pchan->bone) == false)) &&
|
|
|
|
!((use_select == true) && ((pchan->bone->flag & BONE_SELECTED) == 0))))
|
|
|
|
{
|
|
|
|
bPoseChannel *pchan_tx = (pchan->custom && pchan->custom_tx) ? pchan->custom_tx : pchan;
|
2015-09-21 15:03:31 +10:00
|
|
|
BoundBox *bb_custom = ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) ?
|
|
|
|
BKE_object_boundbox_get(pchan->custom) : NULL;
|
2015-09-04 04:18:49 +10:00
|
|
|
if (bb_custom) {
|
2015-09-21 15:03:31 +10:00
|
|
|
float mat[4][4], smat[4][4];
|
2015-09-21 23:49:58 +10:00
|
|
|
scale_m4_fl(smat, PCHAN_CUSTOM_DRAW_SIZE(pchan));
|
2015-09-21 15:03:31 +10:00
|
|
|
mul_m4_series(mat, ob->obmat, pchan_tx->pose_mat, smat);
|
2015-09-04 04:18:49 +10:00
|
|
|
BKE_boundbox_minmax(bb_custom, mat, r_min, r_max);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float vec[3];
|
|
|
|
mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head);
|
|
|
|
minmax_v3v3_v3(r_min, r_max, vec);
|
|
|
|
mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail);
|
|
|
|
minmax_v3v3_v3(r_min, r_max, vec);
|
|
|
|
}
|
|
|
|
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return changed;
|
|
|
|
}
|
|
|
|
|
2015-05-12 13:57:11 +05:00
|
|
|
/************** Graph evaluation ********************/
|
|
|
|
|
2015-05-13 06:10:49 +10:00
|
|
|
bPoseChannel *BKE_armature_ik_solver_find_root(
|
|
|
|
bPoseChannel *pchan,
|
|
|
|
bKinematicConstraint *data)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
|
|
|
bPoseChannel *rootchan = pchan;
|
|
|
|
if (!(data->flag & CONSTRAINT_IK_TIP)) {
|
|
|
|
/* Exclude tip from chain. */
|
|
|
|
rootchan = rootchan->parent;
|
|
|
|
}
|
|
|
|
if (rootchan != NULL) {
|
|
|
|
int segcount = 0;
|
|
|
|
while (rootchan->parent) {
|
|
|
|
/* Continue up chain, until we reach target number of items. */
|
|
|
|
segcount++;
|
|
|
|
if (segcount == data->rootbone) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rootchan = rootchan->parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rootchan;
|
|
|
|
}
|
|
|
|
|
2015-05-13 06:10:49 +10:00
|
|
|
bPoseChannel *BKE_armature_splineik_solver_find_root(
|
|
|
|
bPoseChannel *pchan,
|
|
|
|
bSplineIKConstraint *data)
|
2015-05-12 13:57:11 +05:00
|
|
|
{
|
|
|
|
bPoseChannel *rootchan = pchan;
|
|
|
|
int segcount = 0;
|
|
|
|
BLI_assert(rootchan != NULL);
|
|
|
|
while (rootchan->parent) {
|
|
|
|
/* Continue up chain, until we reach target number of items. */
|
|
|
|
segcount++;
|
|
|
|
if (segcount == data->chainlen) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rootchan = rootchan->parent;
|
|
|
|
}
|
|
|
|
return rootchan;
|
|
|
|
}
|