Blender V4.5
ipo.cc File Reference
#include <cmath>
#include <cstddef>
#include <cstdio>
#include <cstring>
#include "DNA_anim_types.h"
#include "DNA_camera_types.h"
#include "DNA_constraint_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_light_types.h"
#include "DNA_material_types.h"
#include "DNA_nla_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#include "BLI_dynstr.h"
#include "BLI_endian_switch.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
#include "BLI_string_utils.hh"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_action.hh"
#include "BKE_anim_data.hh"
#include "BKE_fcurve.hh"
#include "BKE_fcurve_driver.h"
#include "BKE_global.hh"
#include "BKE_idtype.hh"
#include "BKE_ipo.h"
#include "BKE_key.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"
#include "BKE_nla.hh"
#include "ANIM_action.hh"
#include "ANIM_versioning.hh"
#include "CLG_log.h"
#include "MEM_guardedalloc.h"
#include "SEQ_iterator.hh"
#include "BLO_read_write.hh"

Go to the source code of this file.

Classes

struct  AdrBit2Path
struct  Seq_callback_data

Macros

#define DNA_DEPRECATED_ALLOW
#define RET_ABP(items)

Functions

static void ipo_free_data (ID *id)
static void ipo_foreach_id (ID *id, LibraryForeachIDData *data)
static void ipo_blend_read_data (BlendDataReader *reader, ID *id)
static AdrBit2Pathadrcode_bitmaps_to_paths (int blocktype, int adrcode, int *tot)
static const char * ob_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * pchan_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * constraint_adrcodes_to_paths (int adrcode, int *r_array_index)
static char * shapekey_adrcodes_to_paths (ID *id, int adrcode, int *)
static const char * mtex_adrcodes_to_paths (int adrcode, int *)
static const char * texture_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * material_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * camera_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * light_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * sound_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * world_adrcodes_to_paths (int adrcode, int *r_array_index)
static const char * particle_adrcodes_to_paths (int adrcode, int *r_array_index)
static char * get_rna_access (ID *id, int blocktype, int adrcode, const char actname[], const char constname[], Strip *strip, int *r_array_index)
static short adrcode_to_dtar_transchan (short adrcode)
static ChannelDriveridriver_to_cdriver (IpoDriver *idriver)
static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo)
static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Strip *strip, int muteipo)
static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Strip *strip, ListBase *animgroups, ListBase *anim, ListBase *drivers)
static void convert_pre_animato_action_to_animato_action_in_place (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers)
static void ensure_action_is_layered (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers)
static void ipo_to_animdata (Main *bmain, ID *id, Ipo *ipo, char actname[], char constname[], Strip *strip)
static void action_to_animdata (ID *id, bAction *act)
static void nlastrips_to_animdata (ID *id, ListBase *strips)
static bool strip_convert_callback (Strip *strip, void *userdata)
void do_versions_ipos_to_layered_actions (Main *bmain)

Variables

static CLG_LogRef LOG = {"bke.ipo"}
IDTypeInfo IDType_ID_IP
static AdrBit2Path ob_layer_bits []

Macro Definition Documentation

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 23 of file ipo.cc.

◆ RET_ABP

#define RET_ABP ( items)
Value:
{ \
*tot = ARRAY_SIZE(items); \
return items; \
} \
(void)0
#define ARRAY_SIZE(arr)

Definition at line 224 of file ipo.cc.

Referenced by adrcode_bitmaps_to_paths().

Function Documentation

◆ action_to_animdata()

◆ adrcode_bitmaps_to_paths()

AdrBit2Path * adrcode_bitmaps_to_paths ( int blocktype,
int adrcode,
int * tot )
static

Definition at line 232 of file ipo.cc.

References ID_OB, OB_LAY, ob_layer_bits, and RET_ABP.

Referenced by icu_to_fcurves().

◆ adrcode_to_dtar_transchan()

◆ camera_adrcodes_to_paths()

const char * camera_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

Definition at line 772 of file ipo.cc.

References CAM_END, CAM_LENS, CAM_ORTHO, CAM_SHIFT_X, CAM_SHIFT_Y, CAM_STA, CAM_YF_APERT, and CAM_YF_FDIST.

Referenced by get_rna_access().

◆ constraint_adrcodes_to_paths()

const char * constraint_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

Definition at line 421 of file ipo.cc.

References CO_ENFORCE, and CO_HEADTAIL.

Referenced by get_rna_access().

◆ convert_pre_animato_action_to_animato_action_in_place()

void convert_pre_animato_action_to_animato_action_in_place ( ID * id,
bAction * act,
ListBase * groups,
ListBase * curves,
ListBase * drivers )
static

Convert a pre-Animato Action to an Animato Action and drivers.

New curves may not be converted directly into the given Action (i.e. for Actions linked to Objects, where ob->ipo and ob->action need to be combined).

Pre-Animato Actions can contain drivers, which are added to drivers.

Note: this was refactored from older code. In general groups and curves should just be from act, and drivers should be from the adt of id. However, this is not always the case for drivers, and diving into the spaghetti of where this is called it wasn't clear to me (Nathan) if that's actually always the case for groups and curves either, so I (Nathan) left them as separate parameters to be on the safe side.

Definition at line 1806 of file ipo.cc.

References BLI_assert_msg, BLI_freelinkN(), BLI_freelistN(), BLI_listbase_is_empty(), ListBase::first, bAction::groups, id_us_min(), ipo_to_animato(), and LISTBASE_FOREACH_MUTABLE.

Referenced by ensure_action_is_layered().

◆ do_versions_ipos_to_layered_actions()

void do_versions_ipos_to_layered_actions ( struct Main * bmain)

Called from do_versions() in readfile.cc to convert the old IPO/adrcode system to the new Layered Action system.

Note: this only deals with animation data that is pre-Animato, and upgrades it all the way past Animato to modern Layered Actions and drivers. Actions that are already Animato actions are ignored, as they are versioned elsewhere (see animrig::versioning::convert_legacy_actions()). This is admittedly weird, but it's due to the fact that versioning pre-Animato data requires creating new datablocks, which must happen at a stage after the standard versioning where the simpler Animato-to-Layered upgrades are done.

The basic method used here, is to loop over data-blocks which have IPO-data, and add those IPO's to new AnimData blocks as Actions. Action/NLA data only works well for Objects, so these only need to be checked for there.

Data that has been converted should be freed immediately, which means that it is immediately clear which data-blocks have yet to be converted, and also prevent freeing errors when we exit.

Note
Currently done after all file reading.

Definition at line 2147 of file ipo.cc.

References AnimData::action, blender::animrig::versioning::action_is_layered(), action_to_animdata(), Main::actions, BKE_action_add(), BKE_animdata_ensure_id(), BKE_animdata_from_id(), BKE_fcurves_free(), BLI_freelinkN(), BLI_listbase_is_empty(), Ipo::blocktype, Main::cameras, bPose::chanbase, CLOG_ERROR, Object::constraints, blender::animrig::versioning::convert_legacy_animato_action(), Ipo::curve, bAction::curves, Main::curves, Scene::ed, ensure_action_is_layered(), ListBase::first, ID::flag, blender::seq::for_each_callback(), G, G_DEBUG, bAction::groups, Camera::id, Curve::id, Ipo::id, Key::id, Light::id, Material::id, Object::id, Tex::id, World::id, ID_FLAG_FAKEUSER, ID_OB, id_us_min(), bAction::idroot, bConstraintChannel::ipo, Main::ipo, ipo_to_animato(), ipo_to_animdata(), Main::lights, LISTBASE_FOREACH, LOG, Main::materials, bConstraintChannel::name, ID::name, bConstraintChannel::next, ID::next, nlastrips_to_animdata(), Main::objects, Object::pose, printf, Main::scenes, Main::shapekeys, strip_convert_callback(), blender::animrig::versioning::tag_action_user_for_slotted_actions_conversion(), Main::textures, ID::us, Main::versionfile, and Main::worlds.

Referenced by do_versions_after_setup().

◆ ensure_action_is_layered()

void ensure_action_is_layered ( ID * id,
bAction * act,
ListBase * groups,
ListBase * curves,
ListBase * drivers )
static

Ensure that the action is a modern layered action, upgrading if necessary.

This deals with both Animato and pre-Animato actions, ensuring that they are fully upgraded. In the case of a pre-Animato action, it may contain drivers as well, which are converted and added to drivers.

Much of the behavior of this function, and the reason for most of the parameters, is due to convert_pre_animato_action_to_animato_action_in_place(). See its documentation for more details.

See also
convert_pre_animato_action_to_animato_action_in_place()

Definition at line 1863 of file ipo.cc.

References blender::animrig::versioning::action_is_layered(), BLI_listbase_is_empty(), blender::animrig::versioning::convert_legacy_animato_action(), convert_pre_animato_action_to_animato_action_in_place(), and blender::animrig::versioning::tag_action_user_for_slotted_actions_conversion().

Referenced by action_to_animdata(), do_versions_ipos_to_layered_actions(), and nlastrips_to_animdata().

◆ fcurve_add_to_list()

◆ get_rna_access()

◆ icu_to_fcurves()

void icu_to_fcurves ( ID * id,
ListBase * groups,
ListBase * list,
IpoCurve * icu,
char * actname,
char * constname,
Strip * strip,
int muteipo )
static

Convert IPO-Curve to F-Curve (including Driver data), and free any of the old data that is not relevant, BUT do not free the IPO-Curve itself...

Parameters
`id`data-block that the IPO-Curve is attached to and/or which the new data-paths will start from. May be null, which may impact the data-paths of the created F-Curves in some cases.
actnamename of Action-Channel (if applicable) that IPO-Curve's IPO-block belonged to.
constnamename of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to seq.
seqsequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to.

Definition at line 1407 of file ipo.cc.

References AC_EUL_X, AC_EUL_Y, AC_EUL_Z, add_fmodifier(), IpoCurve::adrcode, adrcode_bitmaps_to_paths(), AdrBit2Path::array_index, FCurve::array_index, b, FCurve::bezt, IpoCurve::bezt, BEZT_IPO_CONST, BEZT_KEYTYPE_KEYFRAME, AdrBit2Path::bit, BKE_fcurve_copy(), BKE_fcurve_create(), BLI_strdup(), IpoCurve::blocktype, IpoCurve::bp, data, FModifier::data, FCurve::driver, IpoCurve::driver, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ, ELEM, Strip::enddisp, FCurve::extend, IpoCurve::extrap, FCM_EXTRAPOLATE_CYCLIC, FCM_EXTRAPOLATE_CYCLIC_OFFSET, FCURVE_ACTIVE, fcurve_add_to_list(), FCURVE_DISABLED, FCURVE_DISCRETE_VALUES, FCURVE_INT_VALUES, FCURVE_MUTED, FCURVE_PROTECTED, FCURVE_SELECTED, FCURVE_VISIBLE, ListBase::first, FCurve::flag, IpoCurve::flag, Strip::flag, FMODIFIER_TYPE_CYCLES, G, G_DEBUG, get_rna_access(), GS, BezTriple::h1, BezTriple::h2, HD_AUTO, HD_AUTO_ANIM, BezTriple::hide, i, ID_CU_LEGACY, ID_OB, ID_PO, idriver_to_cdriver(), BezTriple::ipo, IpoCurve::ipo, IPO_ACTIVE, IPO_AUTO_HORIZ, IPO_CYCL, IPO_CYCLX, IPO_DIR, IPO_HORIZ, IPO_MIXED, IPO_MUTE, IPO_PROTECT, IPO_SELECT, IPO_VISIBLE, M_PI, MEM_calloc_arrayN(), FCurve::modifiers, mul(), ID::name, OB_ROT_X, OB_ROT_Y, OB_ROT_Z, AdrBit2Path::path, Curve::pathlen, printf, FCurve::rna_path, SEQ_IPO_FRAME_LOCKED, Strip::startdisp, STREQ, DriverVar::targets, FCurve::totvert, IpoCurve::totvert, DriverTarget::transChan, ChannelDriver::variables, and BezTriple::vec.

Referenced by ipo_to_animato().

◆ idriver_to_cdriver()

◆ ipo_blend_read_data()

◆ ipo_foreach_id()

◆ ipo_free_data()

void ipo_free_data ( ID * id)
static

◆ ipo_to_animato()

void ipo_to_animato ( ID * id,
Ipo * ipo,
char actname[],
char constname[],
Strip * strip,
ListBase * animgroups,
ListBase * anim,
ListBase * drivers )
static

Convert an IPO block to listbases of Animato data.

This does not assume that any ID or AnimData uses it, but does assume that it is given two lists, which it will perform driver/animation-data separation.

Parameters
`id`Data-block that the IPO-Curve is attached to and/or which the new data-paths will start from. May be null, which may impact the data-paths of the created F-Curves in some cases.
`actname`Contrary to what you might think, this is not the name of an action. I (Nathan) don't know what it is, but I'm leaving this note here so people in the future are not misled by the awful parameter name.
`animgroups`List of channel groups that the converted data will be added to.
`anim`List of FCurves that the converted animation data will be added to.
`drivers`List of FCurves that converted drivers will be added to.

Definition at line 1708 of file ipo.cc.

References IpoCurve::bezt, BLI_freelinkN(), Ipo::blocktype, IpoCurve::bp, Ipo::curve, IpoCurve::driver, ELEM, ListBase::first, G, G_DEBUG, icu_to_fcurves(), Ipo::id, ID_OB, ID_REAL_USERS, id_us_min(), IPO_DRIVER_TYPE_PYTHON, LISTBASE_FOREACH, MEM_freeN(), Ipo::muteipo, IpoCurve::next, IpoDriver::ob, printf, STREQ, and IpoDriver::type.

Referenced by convert_pre_animato_action_to_animato_action_in_place(), do_versions_ipos_to_layered_actions(), and ipo_to_animdata().

◆ ipo_to_animdata()

◆ light_adrcodes_to_paths()

const char * light_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

◆ material_adrcodes_to_paths()

const char * material_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

◆ mtex_adrcodes_to_paths()

◆ nlastrips_to_animdata()

◆ ob_adrcodes_to_paths()

const char * ob_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

◆ particle_adrcodes_to_paths()

const char * particle_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

◆ pchan_adrcodes_to_paths()

const char * pchan_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

◆ shapekey_adrcodes_to_paths()

char * shapekey_adrcodes_to_paths ( ID * id,
int adrcode,
int *  )
static

Definition at line 442 of file ipo.cc.

References BKE_keyblock_find_by_index(), BLI_str_escape(), KeyBlock::name, SNPRINTF, and STRNCPY().

Referenced by get_rna_access().

◆ sound_adrcodes_to_paths()

const char * sound_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

Definition at line 862 of file ipo.cc.

References SND_ATTEN, SND_PANNING, SND_PITCH, and SND_VOLUME.

Referenced by get_rna_access().

◆ strip_convert_callback()

◆ texture_adrcodes_to_paths()

const char * texture_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

◆ world_adrcodes_to_paths()

const char * world_adrcodes_to_paths ( int adrcode,
int * r_array_index )
static

Variable Documentation

◆ IDType_ID_IP

IDTypeInfo IDType_ID_IP
Initial value:
= {
Ipo::id_type,
0,
sizeof(Ipo),
"Ipo",
N_("ipos"),
"",
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
}
@ IDTYPE_FLAGS_NO_ANIMDATA
Definition BKE_idtype.hh:46
@ IDTYPE_FLAGS_NO_COPY
Definition BKE_idtype.hh:30
@ IDTYPE_FLAGS_NO_LIBLINKING
Definition BKE_idtype.hh:32
@ INDEX_ID_IP
Definition DNA_ID.h:1192
#define FILTER_ID_IP
static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
Definition ipo.cc:123
static void ipo_foreach_id(ID *id, LibraryForeachIDData *data)
Definition ipo.cc:109
static void ipo_free_data(ID *id)
Definition ipo.cc:80
#define N_(msgid)

Definition at line 164 of file ipo.cc.

◆ LOG

CLG_LogRef LOG = {"bke.ipo"}
static

Definition at line 76 of file ipo.cc.

◆ ob_layer_bits

AdrBit2Path ob_layer_bits[]
static
Initial value:
= {
{(1 << 0), "layers", 0}, {(1 << 1), "layers", 1}, {(1 << 2), "layers", 2},
{(1 << 3), "layers", 3}, {(1 << 4), "layers", 4}, {(1 << 5), "layers", 5},
{(1 << 6), "layers", 6}, {(1 << 7), "layers", 7}, {(1 << 8), "layers", 8},
{(1 << 9), "layers", 9}, {(1 << 10), "layers", 10}, {(1 << 11), "layers", 11},
{(1 << 12), "layers", 12}, {(1 << 13), "layers", 13}, {(1 << 14), "layers", 14},
{(1 << 15), "layers", 15}, {(1 << 16), "layers", 16}, {(1 << 17), "layers", 17},
{(1 << 18), "layers", 18}, {(1 << 19), "layers", 19},
}

Definition at line 211 of file ipo.cc.

Referenced by adrcode_bitmaps_to_paths().