tornavis/source/blender/blenkernel/BKE_pose_backup.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

69 lines
1.9 KiB
C
Raw Normal View History

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup bke
*
* Pose Backups can be created from the current pose, and later restored. The
* backup is restricted to those bones animated by a given Action, so that
* operations are as fast as possible.
*/
#pragma once
#include <stdbool.h>
#include "BLI_listbase.h"
#ifdef __cplusplus
extern "C" {
#endif
struct PoseBackup;
/**
* Create a backup of those bones that are selected AND animated in the given action.
*
* The backup is owned by the caller, and should be freed with `BKE_pose_backup_free()`.
*/
struct PoseBackup *BKE_pose_backup_create_selected_bones(
const struct Object *ob, const struct bAction *action) ATTR_WARN_UNUSED_RESULT;
/**
* Create a backup of those bones that are animated in the given action.
*
* The backup is owned by the caller, and should be freed with `BKE_pose_backup_free()`.
*/
struct PoseBackup *BKE_pose_backup_create_all_bones(
const struct Object *ob, const struct bAction *action) ATTR_WARN_UNUSED_RESULT;
bool BKE_pose_backup_is_selection_relevant(const struct PoseBackup *pose_backup);
void BKE_pose_backup_restore(const struct PoseBackup *pbd);
void BKE_pose_backup_free(struct PoseBackup *pbd);
Anim: expose pose blending & backup system to RNA Expose `BKE_pose_apply_action_blend` and a simplified pose backup system to RNA. This will make it possible to easily create some interactive tools in Python for pose blending. When creating a backup via this API, it is stored on the `Object::runtime` struct. Any backup that was there before is freed first. This way the Python code doesn't need access to the actual `PoseBackup *`, simplifying memory management. The limitation of having only a single backup shouldn't be too problematic, as it is meant for things like interactive manipulation of the current pose. Typical use looks like: - Interactive operator starts, and creates a backup of the current pose. - While the operator is running: - The pose backup is restored, so that the next steps always use the same reference pose. - Depending on user input, determine a blend factor. - Blend some pose from the pose library into the current pose. - On confirmation, leave the pose as-is. - On cancellation, restore the backup. - Free the backup. `BKE_pose_apply_action_blend` is exposed to RNA to make the above possible. An alternative approach would be to rely on the operator redo system. However, since for poses this would use the global undo, it can get prohibitively slow. This change is to make it easier to prototype things; further into the future the undo system for poses should be improved, but that's an entire project on its own. Reviewed By: sergey Differential Revision: https://developer.blender.org/D16900
2023-01-02 16:39:51 +01:00
/**
* Create a backup of those bones that are animated in the given action.
*
* The backup is owned by the Object, and there can be only one backup at a time.
* It should be freed with `BKE_pose_backup_clear(ob)`.
*/
void BKE_pose_backup_create_on_object(struct Object *ob, const struct bAction *action);
/**
* Restore the pose backup owned by this OBject.
*
* \return true on success, false if there was no pose backup to restore.
*
* \see #BKE_pose_backup_create_on_object
*/
bool BKE_pose_backup_restore_on_object(struct Object *ob);
/**
* Free the pose backup that was stored on this object's runtime data.
*/
void BKE_pose_backup_clear(struct Object *ob);
#ifdef __cplusplus
}
#endif