2023-05-31 16:19:06 +02:00
|
|
|
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2012-02-17 19:59:41 +01:00
|
|
|
#pragma once
|
2019-09-13 13:11:41 +02:00
|
|
|
|
2019-02-17 22:08:12 +01:00
|
|
|
/** \file
|
|
|
|
* \ingroup bke
|
|
|
|
* \brief Blender kernel action and pose functionality.
|
2011-02-18 14:05:18 +01:00
|
|
|
*/
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
#include "BLI_compiler_attrs.h"
|
|
|
|
|
2020-05-08 18:16:39 +02:00
|
|
|
#include "DNA_listBase.h"
|
|
|
|
|
2019-11-29 11:42:18 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-11-06 17:58:12 +01:00
|
|
|
struct BlendDataReader;
|
2020-12-16 06:26:23 +01:00
|
|
|
struct BlendLibReader;
|
|
|
|
struct BlendWriter;
|
2020-11-06 17:58:12 +01:00
|
|
|
struct bArmature;
|
|
|
|
|
2009-02-09 11:04:11 +01:00
|
|
|
/* The following structures are defined in DNA_action_types.h, and DNA_anim_types.h */
|
T77086 Animation: Passing Dependency Graph to Drivers
Custom driver functions need access to the dependency graph that is
triggering the evaluation of the driver. This patch passes the
dependency graph pointer through all the animation-related calls.
Instead of passing the evaluation time to functions, the code now passes
an `AnimationEvalContext` pointer:
```
typedef struct AnimationEvalContext {
struct Depsgraph *const depsgraph;
const float eval_time;
} AnimationEvalContext;
```
These structs are read-only, meaning that the code cannot change the
evaluation time. Note that the `depsgraph` pointer itself is const, but
it points to a non-const depsgraph.
FCurves and Drivers can be evaluated at a different time than the
current scene time, for example when evaluating NLA strips. This means
that, even though the current time is stored in the dependency graph, we
need an explicit evaluation time.
There are two functions that allow creation of `AnimationEvalContext`
objects:
- `BKE_animsys_eval_context_construct(Depsgraph *depsgraph, float
eval_time)`, which creates a new context object from scratch, and
- `BKE_animsys_eval_context_construct_at(AnimationEvalContext
*anim_eval_context, float eval_time)`, which can be used to create a
`AnimationEvalContext` with the same depsgraph, but at a different
time. This makes it possible to later add fields without changing any
of the code that just want to change the eval time.
This also provides a fix for T75553, although it does require a change
to the custom driver function. The driver should call
`custom_function(depsgraph)`, and the function should use that depsgraph
instead of information from `bpy.context`.
Reviewed By: brecht, sergey
Differential Revision: https://developer.blender.org/D8047
2020-07-17 17:38:09 +02:00
|
|
|
struct AnimationEvalContext;
|
Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:
- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
`ob.pose.bones['bone_name'].color`).
When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.
Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.
The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.
This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-22 11:11:52 +02:00
|
|
|
struct BoneColor;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct FCurve;
|
2023-08-14 16:45:18 +02:00
|
|
|
struct ID;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct Main;
|
|
|
|
struct Object;
|
2009-01-18 11:41:45 +01:00
|
|
|
struct bAction;
|
2009-02-09 11:04:11 +01:00
|
|
|
struct bActionGroup;
|
2009-09-24 23:22:24 +02:00
|
|
|
struct bItasc;
|
2019-01-28 11:08:24 +01:00
|
|
|
struct bPose;
|
2002-10-12 13:37:38 +02:00
|
|
|
struct bPoseChannel;
|
2019-04-18 20:19:57 +02:00
|
|
|
struct bPoseChannel_Runtime;
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2009-09-17 12:14:56 +02:00
|
|
|
/* Action Lib Stuff ----------------- */
|
2009-02-09 11:04:11 +01:00
|
|
|
|
|
|
|
/* Allocate a new bAction with the given name */
|
2018-01-10 23:55:41 +01:00
|
|
|
struct bAction *BKE_action_add(struct Main *bmain, const char name[]);
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 04:12:50 +01:00
|
|
|
|
2009-09-17 12:14:56 +02:00
|
|
|
/* Action API ----------------- */
|
|
|
|
|
2023-07-09 10:22:29 +02:00
|
|
|
/**
|
|
|
|
* Types of transforms applied to the given item:
|
|
|
|
* - these are the return flags for #BKE_action_get_item_transform_flags()
|
2009-09-17 12:14:56 +02:00
|
|
|
*/
|
|
|
|
typedef enum eAction_TransformFlags {
|
2012-05-12 22:39:39 +02:00
|
|
|
/* location */
|
|
|
|
ACT_TRANS_LOC = (1 << 0),
|
|
|
|
/* rotation */
|
|
|
|
ACT_TRANS_ROT = (1 << 1),
|
|
|
|
/* scaling */
|
|
|
|
ACT_TRANS_SCALE = (1 << 2),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-05-17 17:19:06 +02:00
|
|
|
/* bbone shape - for all the parameters, provided one is set */
|
|
|
|
ACT_TRANS_BBONE = (1 << 3),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
/* strictly not a transform, but custom properties are also
|
|
|
|
* quite often used in modern rigs
|
|
|
|
*/
|
2016-05-17 17:19:06 +02:00
|
|
|
ACT_TRANS_PROP = (1 << 4),
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-12 22:39:39 +02:00
|
|
|
/* all flags */
|
|
|
|
ACT_TRANS_ONLY = (ACT_TRANS_LOC | ACT_TRANS_ROT | ACT_TRANS_SCALE),
|
2019-01-15 13:57:49 +01:00
|
|
|
ACT_TRANS_ALL = (ACT_TRANS_ONLY | ACT_TRANS_PROP),
|
2009-09-17 12:14:56 +02:00
|
|
|
} eAction_TransformFlags;
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Return flags indicating which transforms the given object/posechannel has
|
2018-11-14 02:53:15 +01:00
|
|
|
* - if 'curves' is provided, a list of links to these curves are also returned
|
2021-12-07 07:19:15 +01:00
|
|
|
* whose nodes WILL NEED FREEING.
|
2009-09-17 12:14:56 +02:00
|
|
|
*/
|
2023-07-09 10:22:29 +02:00
|
|
|
eAction_TransformFlags BKE_action_get_item_transform_flags(struct bAction *act,
|
|
|
|
struct Object *ob,
|
|
|
|
struct bPoseChannel *pchan,
|
2023-07-12 03:49:55 +02:00
|
|
|
ListBase *curves)
|
|
|
|
ATTR_WARN_UNUSED_RESULT;
|
2009-09-17 12:14:56 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Calculate the extents of given action.
|
|
|
|
*/
|
2023-07-09 10:17:58 +02:00
|
|
|
void BKE_action_frame_range_calc(const struct bAction *act,
|
|
|
|
bool include_modifiers,
|
|
|
|
float *r_start,
|
2023-07-12 03:49:55 +02:00
|
|
|
float *r_end) ATTR_NONNULL(3, 4);
|
2009-02-09 11:04:11 +01:00
|
|
|
|
2023-07-09 10:17:58 +02:00
|
|
|
/**
|
|
|
|
* Retrieve the intended playback frame range, using the manually set range if available,
|
|
|
|
* or falling back to scanning F-Curves for their first & last frames otherwise.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_action_frame_range_get(const struct bAction *act, float *r_start, float *r_end)
|
|
|
|
ATTR_NONNULL(2, 3);
|
2021-05-02 23:03:00 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Check if the given action has any keyframes.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
bool BKE_action_has_motion(const struct bAction *act) ATTR_WARN_UNUSED_RESULT;
|
2009-05-23 11:36:18 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Is the action configured as cyclic.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
bool BKE_action_is_cyclic(const struct bAction *act) ATTR_WARN_UNUSED_RESULT;
|
2021-07-27 09:39:52 +02:00
|
|
|
|
2022-06-23 11:41:44 +02:00
|
|
|
/**
|
|
|
|
* Remove all fcurves from the action.
|
|
|
|
*/
|
|
|
|
void BKE_action_fcurves_clear(struct bAction *act);
|
|
|
|
|
2009-02-09 11:04:11 +01:00
|
|
|
/* Action Groups API ----------------- */
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Get the active action-group for an Action.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
struct bActionGroup *get_active_actiongroup(struct bAction *act) ATTR_WARN_UNUSED_RESULT;
|
2009-09-17 12:14:56 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Make the given Action-Group the active one.
|
|
|
|
*/
|
2009-02-09 11:04:11 +01:00
|
|
|
void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Sync colors used for action/bone group with theme settings.
|
|
|
|
*/
|
2012-07-03 03:15:03 +02:00
|
|
|
void action_group_colors_sync(struct bActionGroup *grp, const struct bActionGroup *ref_grp);
|
2012-06-01 15:54:44 +02:00
|
|
|
|
Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:
- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
`ob.pose.bones['bone_name'].color`).
When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.
Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.
The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.
This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-22 11:11:52 +02:00
|
|
|
/**
|
|
|
|
* Set colors used on this action group.
|
|
|
|
*/
|
|
|
|
void action_group_colors_set(struct bActionGroup *grp, const struct BoneColor *color);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set colors used on this action group, using the color of the pose bone.
|
|
|
|
*
|
|
|
|
* If `pchan->color` is set to a non-default color, that is used. Otherwise the
|
|
|
|
* armature bone color is used.
|
2024-02-26 17:40:57 +01:00
|
|
|
*
|
|
|
|
* Note that if `pchan->bone` is `nullptr`, this function silently does nothing.
|
Anim: move bone colors from bone groups to individual bones
Move control over the color of bones from bone groups to the bones
themselves. Instead of using bone groups (which are defined on the pose,
and thus owned by the object), the color is stored on:
- the bone (`struct Bone`, or RNA `armature.bones['bone_name'].color`)
- a possible override on the pose bone (`struct bPoseChannel`, or RNA
`ob.pose.bones['bone_name'].color`).
When the pose bone is set to its default color, the color is determined
by the armature bone. In armature edit mode, the armature bone colors
are always used, as then the pose data is unavailable.
Versioning code converts bone group colors to bone colors. If the
Armature has a single user, the group color is stored on the bones
directly. If it has multiple users, the group colors will be stored on
the pose bones instead.
The bone group color is not removed from DNA for forward compatibility,
that is, to avoid immediate dataloss when saving a 3.6 file with 4.0.
This is part of the replacement of bone groups & armature layers with
bone collections. See the design task at #108941.
Pull request: https://projects.blender.org/blender/blender/pulls/109976
2023-08-22 11:11:52 +02:00
|
|
|
*/
|
|
|
|
void action_group_colors_set_from_posebone(bActionGroup *grp, const bPoseChannel *pchan);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Add a new action group with the given name to the action>
|
|
|
|
*/
|
2010-04-01 08:26:41 +02:00
|
|
|
struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Add given channel into (active) group
|
|
|
|
* - assumes that channel is not linked to anything anymore
|
|
|
|
* - always adds at the end of the group
|
|
|
|
*/
|
2009-02-09 11:04:11 +01:00
|
|
|
void action_groups_add_channel(struct bAction *act,
|
|
|
|
struct bActionGroup *agrp,
|
|
|
|
struct FCurve *fcurve);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove the given channel from all groups.
|
|
|
|
*/
|
2009-02-09 11:04:11 +01:00
|
|
|
void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Reconstruct group channel pointers.
|
|
|
|
* Assumes that the groups referred to by the FCurves are already in act->groups.
|
|
|
|
* Reorders the main channel list to match group order.
|
|
|
|
*/
|
2019-12-17 15:20:11 +01:00
|
|
|
void BKE_action_groups_reconstruct(struct bAction *act);
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find a group with the given name.
|
|
|
|
*/
|
2012-05-05 18:03:57 +02:00
|
|
|
struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char name[]);
|
2009-02-09 11:04:11 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Clear all 'temp' flags on all groups.
|
|
|
|
*/
|
2010-12-29 12:51:53 +01:00
|
|
|
void action_groups_clear_tempflags(struct bAction *act);
|
2009-02-09 11:04:11 +01:00
|
|
|
|
2021-11-11 17:51:38 +01:00
|
|
|
/**
|
|
|
|
* Return whether the action has one unique point in time keyed.
|
|
|
|
*
|
2021-11-13 03:07:13 +01:00
|
|
|
* This is mostly for the pose library, which will have different behavior depending on whether an
|
2021-11-11 17:51:38 +01:00
|
|
|
* Action corresponds to a "pose" (one keyframe) or "animation snippet" (multiple keyframes).
|
|
|
|
*
|
|
|
|
* \return `false` when there is no keyframe at all or keys on different points in time, `true`
|
2021-11-13 03:07:13 +01:00
|
|
|
* when exactly one point in time is keyed.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
bool BKE_action_has_single_frame(const struct bAction *act) ATTR_WARN_UNUSED_RESULT;
|
2021-11-11 17:51:38 +01:00
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* Pose API ----------------- */
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channel_free(struct bPoseChannel *pchan) ATTR_NONNULL(1);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Deallocates a pose channel.
|
|
|
|
* Does not free the pose channel itself.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channel_free_ex(struct bPoseChannel *pchan, bool do_id_user) ATTR_NONNULL(1);
|
== Bone Groups ==
I'm committing some work-in-progress code for "bone groups" now, as I there have been are some major bugs caused by the timeoffset stuff (some of my test files were not loading, and other files were showing all sorts of weird problems).
Anyway, in this commit, the following things for "bone groups" have been done:
* Bone groups are stored per armature (internally, this is per bPose block)
* Added controls for editing bone-groups per armature - "add", "remove", "rename". These can be found in the "Links and Materials" panel in PoseMode, beside the settings for PoseLib.
* Reorganised buttons for editing selected bones in PoseMode. I've replaced the "dist" and "weight" buttons (they existed in EditMode anyway) with a menu to choose the bone-group and the custom-shape-ob field. In the place of the old custom-shape-ob field, I've restored the "Hide" button. This might break muscle-memory a bit, but there isn't a lot of space to play with there.
Some stuff I'd been originally planning to do before committing:
* When adding keyframes for bones, an action-group with the same name as the bone's group will be added to the action, and the action-channel will be made a member of that.
* New action/bone groups have unique names (renaming/adding new should check if name exists before assigning it)
* There's a setting under Bone-Groups stuff which sets which custom-colour set is used to colour that group's bones. Currently, this is non-functional, as the necessary drawing code for armatures is not in place yet.
2008-01-20 03:55:35 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Clears the runtime cache of a pose channel without free.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channel_runtime_reset(struct bPoseChannel_Runtime *runtime) ATTR_NONNULL(1);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Reset all non-persistent fields.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channel_runtime_reset_on_copy(struct bPoseChannel_Runtime *runtime) ATTR_NONNULL(1);
|
2020-08-03 17:17:57 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Deallocates runtime cache of a pose channel
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channel_runtime_free(struct bPoseChannel_Runtime *runtime) ATTR_NONNULL(1);
|
2019-04-18 20:19:57 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Deallocates runtime cache of a pose channel's B-Bone shape.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channel_free_bbone_cache(struct bPoseChannel_Runtime *runtime) ATTR_NONNULL(1);
|
2018-11-22 11:38:03 +01:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channels_free(struct bPose *pose) ATTR_NONNULL(1);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Removes and deallocates all channels from a pose.
|
|
|
|
* Does not free the pose itself.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channels_free_ex(struct bPose *pose, bool do_id_user) ATTR_NONNULL(1);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Removes the hash for quick lookup of channels, must be done when adding/removing channels.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_channels_hash_ensure(struct bPose *pose) ATTR_NONNULL(1);
|
|
|
|
void BKE_pose_channels_hash_free(struct bPose *pose) ATTR_NONNULL(1);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Selectively remove pose channels.
|
|
|
|
*/
|
2015-06-12 19:20:07 +02:00
|
|
|
void BKE_pose_channels_remove(struct Object *ob,
|
|
|
|
bool (*filter_fn)(const char *bone_name, void *user_data),
|
2023-07-12 03:49:55 +02:00
|
|
|
void *user_data) ATTR_NONNULL(1, 2);
|
2015-06-12 19:20:07 +02:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_free_data_ex(struct bPose *pose, bool do_id_user) ATTR_NONNULL(1);
|
|
|
|
void BKE_pose_free_data(struct bPose *pose) ATTR_NONNULL(1);
|
2013-10-26 05:56:32 +02:00
|
|
|
void BKE_pose_free(struct bPose *pose);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Removes and deallocates all data from a pose, and also frees the pose.
|
|
|
|
*/
|
2013-12-25 11:43:26 +01:00
|
|
|
void BKE_pose_free_ex(struct bPose *pose, bool do_id_user);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Allocate a new pose on the heap, and copy the src pose and its channels
|
|
|
|
* into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL.
|
|
|
|
*
|
|
|
|
* \param dst: Should be freed already, makes entire duplicate.
|
|
|
|
*/
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
void BKE_pose_copy_data_ex(struct bPose **dst,
|
|
|
|
const struct bPose *src,
|
2022-01-06 11:37:31 +01:00
|
|
|
int flag,
|
|
|
|
bool copy_constraints);
|
|
|
|
void BKE_pose_copy_data(struct bPose **dst, const struct bPose *src, bool copy_constraints);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Copy the internal members of each pose channel including constraints
|
|
|
|
* and ID-Props, used when duplicating bones in edit-mode.
|
|
|
|
* (unlike copy_pose_channel_data which only does posing-related stuff).
|
|
|
|
*
|
|
|
|
* \note use when copying bones in edit-mode (on returned value from #BKE_pose_channel_ensure)
|
|
|
|
*/
|
2013-10-26 05:56:32 +02:00
|
|
|
void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
|
2024-01-22 13:47:13 +01:00
|
|
|
void BKE_pose_channel_session_uid_generate(struct bPoseChannel *pchan);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Return a pointer to the pose channel of the given name
|
|
|
|
* from this pose.
|
|
|
|
*/
|
2012-05-05 18:03:57 +02:00
|
|
|
struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name);
|
2021-11-09 12:22:06 +01:00
|
|
|
/**
|
2023-08-29 10:59:06 +02:00
|
|
|
* Checks if the bone is on a visible bone collection
|
2021-11-09 12:22:06 +01:00
|
|
|
*
|
|
|
|
* \return true if on a visible layer, false otherwise.
|
|
|
|
*/
|
2023-08-29 10:59:06 +02:00
|
|
|
bool BKE_pose_is_bonecoll_visible(const struct bArmature *arm,
|
|
|
|
const struct bPoseChannel *pchan) ATTR_WARN_UNUSED_RESULT;
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Find the active pose-channel for an object
|
|
|
|
*
|
2023-08-29 10:59:06 +02:00
|
|
|
* \param check_bonecoll: checks if the bone is on a visible bone collection (this might be skipped
|
2021-11-09 12:22:06 +01:00
|
|
|
* (e.g. for "Show Active" from the Outliner).
|
|
|
|
* \return #bPoseChannel if found or NULL.
|
2023-08-29 10:59:06 +02:00
|
|
|
* \note #Object, not #bPose is used here, as we need info (collection/active bone) from Armature.
|
2021-11-09 12:22:06 +01:00
|
|
|
*/
|
2023-08-29 10:59:06 +02:00
|
|
|
struct bPoseChannel *BKE_pose_channel_active(struct Object *ob, bool check_bonecoll);
|
2021-11-09 12:22:06 +01:00
|
|
|
/**
|
2023-08-29 10:59:06 +02:00
|
|
|
* Find the active pose-channel for an object if it is on a visible bone collection
|
|
|
|
* (calls #BKE_pose_channel_active with check_bonecoll set to true)
|
2021-11-09 12:22:06 +01:00
|
|
|
*
|
|
|
|
* \return #bPoseChannel if found or NULL.
|
2023-08-29 10:59:06 +02:00
|
|
|
* \note #Object, not #bPose is used here, as we need info (collection/active bone) from Armature.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2023-08-29 10:59:06 +02:00
|
|
|
struct bPoseChannel *BKE_pose_channel_active_if_bonecoll_visible(struct Object *ob)
|
2023-07-12 03:49:55 +02:00
|
|
|
ATTR_WARN_UNUSED_RESULT;
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Use this when detecting the "other selected bone",
|
|
|
|
* when we have multiple armatures in pose mode.
|
|
|
|
*
|
|
|
|
* In this case the active-selected is an obvious choice when finding the target for a
|
|
|
|
* constraint for eg. however from the users perspective the active pose bone of the
|
|
|
|
* active object is the _real_ active bone, so any other non-active selected bone
|
2023-02-12 04:37:16 +01:00
|
|
|
* is a candidate for being the other selected bone, see: #58447.
|
2021-12-07 07:19:15 +01:00
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
struct bPoseChannel *BKE_pose_channel_active_or_first_selected(struct Object *ob)
|
|
|
|
ATTR_WARN_UNUSED_RESULT;
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Looks to see if the channel with the given name already exists
|
|
|
|
* in this pose - if not a new one is allocated and initialized.
|
|
|
|
*
|
|
|
|
* \note Use with care, not on Armature poses but for temporal ones.
|
|
|
|
* \note (currently used for action constraints and in rebuild_pose).
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
struct bPoseChannel *BKE_pose_channel_ensure(struct bPose *pose, const char *name) ATTR_NONNULL(2);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* \see #ED_armature_ebone_get_mirrored (edit-mode, matching function)
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
struct bPoseChannel *BKE_pose_channel_get_mirrored(const struct bPose *pose,
|
|
|
|
const char *name) ATTR_WARN_UNUSED_RESULT;
|
2009-07-21 12:18:08 +02:00
|
|
|
|
2024-01-22 13:47:13 +01:00
|
|
|
void BKE_pose_check_uids_unique_and_report(const struct bPose *pose);
|
2020-08-03 17:17:57 +02:00
|
|
|
|
2013-10-01 15:28:59 +02:00
|
|
|
#ifndef NDEBUG
|
2023-07-12 03:49:55 +02:00
|
|
|
bool BKE_pose_channels_is_valid(const struct bPose *pose) ATTR_WARN_UNUSED_RESULT;
|
2013-10-01 15:28:59 +02:00
|
|
|
#endif
|
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Checks for IK constraint, Spline IK, and also for Follow-Path constraint.
|
|
|
|
* can do more constraints flags later. pose should be entirely OK.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_update_constraint_flags(struct bPose *pose) ATTR_NONNULL(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 19:35:38 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Tag constraint flags for update.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_tag_update_constraint_flags(struct bPose *pose) ATTR_NONNULL(1);
|
2015-03-19 14:28:49 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Return the name of structure pointed by `pose->ikparam`.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
const char *BKE_pose_ikparam_get_name(struct bPose *pose) ATTR_WARN_UNUSED_RESULT;
|
2009-09-24 23:22:24 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Allocate and initialize `pose->ikparam` according to `pose->iksolver`.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_ikparam_init(struct bPose *pose) ATTR_NONNULL(1);
|
2009-09-24 23:22:24 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Initialize a #bItasc structure with default value.
|
|
|
|
*/
|
2012-05-05 18:03:57 +02:00
|
|
|
void BKE_pose_itasc_init(struct bItasc *itasc);
|
2009-09-24 23:22:24 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Checks if a bone is part of an IK chain or not.
|
|
|
|
*/
|
2013-09-13 05:03:46 +02:00
|
|
|
bool BKE_pose_channel_in_IK_chain(struct Object *ob, struct bPoseChannel *pchan);
|
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* Bone Groups API --------------------- */
|
2009-07-21 12:18:08 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Adds a new bone-group (name may be NULL).
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
struct bActionGroup *BKE_pose_add_group(struct bPose *pose, const char *name) ATTR_NONNULL(1);
|
2009-07-21 12:18:08 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove the given bone-group (expects 'virtual' index (+1 one, used by active_group etc.))
|
|
|
|
* index might be invalid ( < 1), in which case it will be find from grp.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_remove_group(struct bPose *pose, struct bActionGroup *grp, int index)
|
|
|
|
ATTR_NONNULL(1);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Remove the indexed bone-group (expects 'virtual' index (+1 one, used by active_group etc.)).
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_remove_group_index(struct bPose *pose, int index) ATTR_NONNULL(1);
|
2009-07-21 12:18:08 +02:00
|
|
|
|
2018-06-17 17:05:51 +02:00
|
|
|
/* Assorted Evaluation ----------------- */
|
2009-07-21 12:18:08 +02:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* For the calculation of the effects of an Action at the given frame on an object
|
|
|
|
* This is currently only used for the Action Constraint
|
|
|
|
*/
|
2011-06-15 16:06:25 +02:00
|
|
|
void what_does_obaction(struct Object *ob,
|
|
|
|
struct Object *workob,
|
|
|
|
struct bPose *pose,
|
|
|
|
struct bAction *act,
|
|
|
|
char groupname[],
|
2023-07-12 03:49:55 +02:00
|
|
|
const struct AnimationEvalContext *anim_eval_context) ATTR_NONNULL(1, 2);
|
2002-10-12 13:37:38 +02:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_copy_pchan_result(struct bPoseChannel *pchanto, const struct bPoseChannel *pchanfrom)
|
|
|
|
ATTR_NONNULL(1, 2);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Both poses should be in sync.
|
|
|
|
*/
|
2013-01-24 15:48:08 +01:00
|
|
|
bool BKE_pose_copy_result(struct bPose *to, struct bPose *from);
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Zero the pose transforms for the entire pose or only for selected bones.
|
|
|
|
*/
|
2020-07-21 15:51:27 +02:00
|
|
|
void BKE_pose_rest(struct bPose *pose, bool selected_bones_only);
|
2006-11-11 17:45:17 +01:00
|
|
|
|
2021-12-07 07:19:15 +01:00
|
|
|
/**
|
|
|
|
* Tag pose for recalculation. Also tag all related data to be recalculated.
|
|
|
|
*/
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_tag_recalc(struct Main *bmain, struct bPose *pose) ATTR_NONNULL(1, 2);
|
2015-05-12 10:13:36 +02:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_pose_blend_write(struct BlendWriter *writer, struct bPose *pose, struct bArmature *arm)
|
2023-07-12 05:29:35 +02:00
|
|
|
ATTR_NONNULL(1, 2, 3);
|
2023-08-14 16:45:18 +02:00
|
|
|
void BKE_pose_blend_read_data(struct BlendDataReader *reader,
|
|
|
|
struct ID *id_owner,
|
|
|
|
struct bPose *pose) ATTR_NONNULL(1, 2);
|
2023-08-25 01:39:26 +02:00
|
|
|
void BKE_pose_blend_read_after_liblink(struct BlendLibReader *reader,
|
|
|
|
struct Object *ob,
|
|
|
|
struct bPose *pose) ATTR_NONNULL(1, 2);
|
2020-11-06 17:58:12 +01:00
|
|
|
|
2023-07-31 03:50:54 +02:00
|
|
|
/* `action_mirror.cc` */
|
2022-04-04 05:17:03 +02:00
|
|
|
|
2023-07-12 03:49:55 +02:00
|
|
|
void BKE_action_flip_with_pose(struct bAction *act, struct Object *ob_arm) ATTR_NONNULL(1, 2);
|
2021-03-26 03:12:56 +01:00
|
|
|
|
2002-10-12 13:37:38 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|