2023-11-07 05:42:52 +01:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-10-12 12:46:47 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
|
|
|
/** \file
|
|
|
|
* \ingroup animrig
|
|
|
|
*
|
|
|
|
* \brief Functions to modify FCurves.
|
|
|
|
*/
|
2024-01-19 14:54:31 +01:00
|
|
|
#pragma once
|
2023-10-12 12:46:47 +02:00
|
|
|
|
2023-11-17 11:34:30 +01:00
|
|
|
#include "BLI_math_vector_types.hh"
|
2023-11-07 14:33:52 +01:00
|
|
|
#include "DNA_anim_types.h"
|
2023-10-12 12:46:47 +02:00
|
|
|
struct AnimData;
|
|
|
|
struct FCurve;
|
|
|
|
|
|
|
|
namespace blender::animrig {
|
2023-11-17 11:34:30 +01:00
|
|
|
|
2023-12-08 13:09:11 +01:00
|
|
|
/* This is used to pass in the settings for a keyframe into a function. */
|
|
|
|
struct KeyframeSettings {
|
|
|
|
eBezTriple_KeyframeType keyframe_type;
|
|
|
|
eBezTriple_Handle handle;
|
|
|
|
eBezTriple_Interpolation interpolation;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to generate the KeyframeSettings struct.
|
|
|
|
*
|
2023-12-17 06:04:40 +01:00
|
|
|
* \param from_userprefs: if true read the user preferences for the settings, else return static
|
2023-12-08 13:09:11 +01:00
|
|
|
* defaults.
|
|
|
|
*/
|
|
|
|
KeyframeSettings get_keyframe_settings(bool from_userprefs);
|
|
|
|
|
2023-11-17 11:34:30 +01:00
|
|
|
/** Initialize the given BezTriple with default values. */
|
|
|
|
void initialize_bezt(BezTriple *beztr,
|
|
|
|
float2 position,
|
2023-12-08 13:09:11 +01:00
|
|
|
const KeyframeSettings &settings,
|
2023-11-17 11:34:30 +01:00
|
|
|
eFCurve_Flags fcu_flags);
|
|
|
|
|
2023-11-03 11:53:42 +01:00
|
|
|
/**
|
|
|
|
* \note The caller needs to run #BKE_nla_tweakedit_remap to get NLA relative frame.
|
|
|
|
* The caller should also check #BKE_fcurve_is_protected before keying.
|
|
|
|
*/
|
2023-10-12 12:46:47 +02:00
|
|
|
bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra);
|
|
|
|
|
2023-11-07 14:33:52 +01:00
|
|
|
/**
|
|
|
|
* \brief Lesser Key-framing API call.
|
|
|
|
*
|
|
|
|
* Use this when validation of necessary animation data isn't necessary as it already
|
|
|
|
* exists, and there is a #BezTriple that can be directly copied into the array.
|
|
|
|
*
|
|
|
|
* This function adds a given #BezTriple to an F-Curve. It will allocate
|
|
|
|
* memory for the array if needed, and will insert the #BezTriple into a
|
|
|
|
* suitable place in chronological order.
|
|
|
|
*
|
2023-11-07 17:24:36 +01:00
|
|
|
* \returns The index of the keyframe array into which the bezt has been added.
|
|
|
|
*
|
|
|
|
* \note Any recalculate of the F-Curve that needs to be done will need to be done by the caller.
|
2023-11-07 14:33:52 +01:00
|
|
|
*/
|
|
|
|
int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Main Key-framing API call.
|
|
|
|
*
|
|
|
|
* Use this when validation of necessary animation data isn't necessary as it
|
|
|
|
* already exists. It will insert a keyframe using the current value being keyframed.
|
|
|
|
* Returns the index at which a keyframe was added (or -1 if failed).
|
|
|
|
*
|
|
|
|
* This function is a wrapper for #insert_bezt_fcurve(), and should be used when
|
|
|
|
* adding a new keyframe to a curve, when the keyframe doesn't exist anywhere else yet.
|
|
|
|
* It returns the index at which the keyframe was added.
|
|
|
|
*
|
2023-11-07 17:24:36 +01:00
|
|
|
* \returns The index of the keyframe array into which the bezt has been added.
|
|
|
|
*
|
2023-11-07 14:33:52 +01:00
|
|
|
* \param keyframe_type: The type of keyframe (#eBezTriple_KeyframeType).
|
|
|
|
* \param flag: Optional flags (#eInsertKeyFlags) for controlling how keys get added
|
|
|
|
* and/or whether updates get done.
|
|
|
|
*/
|
2023-12-07 12:05:09 +01:00
|
|
|
int insert_vert_fcurve(FCurve *fcu,
|
|
|
|
const float2 position,
|
2023-12-08 13:09:11 +01:00
|
|
|
const KeyframeSettings &settings,
|
2023-12-07 12:05:09 +01:00
|
|
|
eInsertKeyFlags flag);
|
2023-11-07 14:33:52 +01:00
|
|
|
|
2023-10-12 12:46:47 +02:00
|
|
|
} // namespace blender::animrig
|