Core: foreach_id: add optional support for deprecated ID pointers.
This commit adds a new option flag to the lib_query foreach_id code, which will make deprecated ID pointers to be processed as well. NOTE: Currently there is no report to the callbakcs about the fact that it is processing a deprecated ID. This can be easily added later if it becomes necessary. Part of implementing #105134: Removal of readfile's lib_link & expand code.
This commit is contained in:
@@ -180,7 +180,10 @@ void BKE_constraints_copy_ex(struct ListBase *dst,
|
||||
/**
|
||||
* Run the given callback on all ID-blocks in list of constraints.
|
||||
*/
|
||||
void BKE_constraints_id_loop(struct ListBase *list, ConstraintIDFunc func, void *userdata);
|
||||
void BKE_constraints_id_loop(struct ListBase *list,
|
||||
ConstraintIDFunc func,
|
||||
const int flag,
|
||||
void *userdata);
|
||||
void BKE_constraint_free_data(struct bConstraint *con);
|
||||
/**
|
||||
* Free data of a specific constraint if it has any info.
|
||||
|
||||
@@ -152,6 +152,7 @@ enum {
|
||||
IDWALK_INCLUDE_UI = (1 << 2),
|
||||
/** Do not process ID pointers inside embedded IDs. Needed by depsgraph processing e.g. */
|
||||
IDWALK_IGNORE_EMBEDDED_ID = (1 << 3),
|
||||
|
||||
/**
|
||||
* Do not access original processed pointer's data, only process its address value.
|
||||
*
|
||||
@@ -185,6 +186,9 @@ enum {
|
||||
* ignored.
|
||||
*/
|
||||
IDWALK_DO_LIBRARY_POINTER = (1 << 10),
|
||||
/** Also process the DNA-deprecated pointers. Should only be used in readfile related code (for
|
||||
* proper lib_linking and expanding of older files). */
|
||||
IDWALK_DO_DEPRECATED_POINTERS = (1 << 11),
|
||||
};
|
||||
|
||||
typedef struct LibraryForeachIDData LibraryForeachIDData;
|
||||
@@ -202,9 +206,9 @@ int BKE_lib_query_foreachid_process_callback_flag_override(struct LibraryForeach
|
||||
int cb_flag,
|
||||
bool do_replace);
|
||||
|
||||
#define BKE_LIB_FOREACHID_PROCESS_ID(data_, id_, cb_flag_) \
|
||||
/** Should typically only be used when processing deprecated ID types (like IPO ones). */
|
||||
#define BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data_, id_, cb_flag_) \
|
||||
{ \
|
||||
CHECK_TYPE_ANY((id_), ID *, void *); \
|
||||
BKE_lib_query_foreachid_process((data_), (ID **)&(id_), (cb_flag_)); \
|
||||
if (BKE_lib_query_foreachid_iter_stop((data_))) { \
|
||||
return; \
|
||||
@@ -212,6 +216,13 @@ int BKE_lib_query_foreachid_process_callback_flag_override(struct LibraryForeach
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#define BKE_LIB_FOREACHID_PROCESS_ID(data_, id_, cb_flag_) \
|
||||
{ \
|
||||
CHECK_TYPE_ANY((id_), ID *, void *); \
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data_, id_, cb_flag_); \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#define BKE_LIB_FOREACHID_PROCESS_IDSUPER_P(data_, id_super_p_, cb_flag_) \
|
||||
{ \
|
||||
CHECK_TYPE(&((*(id_super_p_))->id), ID *); \
|
||||
|
||||
@@ -167,7 +167,8 @@ static void action_free_data(ID *id)
|
||||
|
||||
static void action_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
bAction *act = (bAction *)id;
|
||||
bAction *act = reinterpret_cast<bAction *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
LISTBASE_FOREACH (FCurve *, fcu, &act->curves) {
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, BKE_fcurve_foreach_id(fcu, data));
|
||||
@@ -176,6 +177,15 @@ static void action_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
LISTBASE_FOREACH (TimeMarker *, marker, &act->markers) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, marker->camera, IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
LISTBASE_FOREACH (bActionChannel *, chan, &act->chanbase) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, chan->ipo, IDWALK_CB_USER);
|
||||
LISTBASE_FOREACH (bConstraintChannel *, chan_constraint, &chan->constraintChannels) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, chan_constraint->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void action_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -95,13 +95,19 @@ static void camera_free_data(ID *id)
|
||||
|
||||
static void camera_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Camera *camera = (Camera *)id;
|
||||
Camera *camera = reinterpret_cast<Camera *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, camera->dof.focus_object, IDWALK_CB_NOP);
|
||||
LISTBASE_FOREACH (CameraBGImage *, bgpic, &camera->bg_images) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, bgpic->ima, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, bgpic->clip, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, camera->ipo, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, camera->dof_ob, IDWALK_CB_NOP);
|
||||
}
|
||||
}
|
||||
|
||||
struct CameraCyclesCompatibilityData {
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idprop.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_mesh.hh"
|
||||
#include "BKE_mesh_runtime.hh"
|
||||
#include "BKE_movieclip.h"
|
||||
@@ -5540,6 +5541,7 @@ static void con_unlink_refs_cb(bConstraint * /*con*/,
|
||||
static void con_invoke_id_looper(const bConstraintTypeInfo *cti,
|
||||
bConstraint *con,
|
||||
ConstraintIDFunc func,
|
||||
const int flag,
|
||||
void *userdata)
|
||||
{
|
||||
if (cti->id_looper) {
|
||||
@@ -5547,6 +5549,10 @@ static void con_invoke_id_looper(const bConstraintTypeInfo *cti,
|
||||
}
|
||||
|
||||
func(con, (ID **)&con->space_object, false, userdata);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
func(con, reinterpret_cast<ID **>(&con->ipo), false, userdata);
|
||||
}
|
||||
}
|
||||
|
||||
void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user)
|
||||
@@ -5562,7 +5568,7 @@ void BKE_constraint_free_data_ex(bConstraint *con, bool do_id_user)
|
||||
|
||||
/* unlink the referenced resources it uses */
|
||||
if (do_id_user) {
|
||||
con_invoke_id_looper(cti, con, con_unlink_refs_cb, nullptr);
|
||||
con_invoke_id_looper(cti, con, con_unlink_refs_cb, IDWALK_NOP, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5877,13 +5883,16 @@ bConstraint *BKE_constraint_add_for_object(Object *ob, const char *name, short t
|
||||
|
||||
/* ......... */
|
||||
|
||||
void BKE_constraints_id_loop(ListBase *conlist, ConstraintIDFunc func, void *userdata)
|
||||
void BKE_constraints_id_loop(ListBase *conlist,
|
||||
ConstraintIDFunc func,
|
||||
const int flag,
|
||||
void *userdata)
|
||||
{
|
||||
LISTBASE_FOREACH (bConstraint *, con, conlist) {
|
||||
const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con);
|
||||
|
||||
if (cti) {
|
||||
con_invoke_id_looper(cti, con, func, userdata);
|
||||
con_invoke_id_looper(cti, con, func, flag, userdata);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5936,13 +5945,13 @@ static void constraint_copy_data_ex(bConstraint *dst,
|
||||
|
||||
/* Fix user-counts for all referenced data that need it. */
|
||||
if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) {
|
||||
con_invoke_id_looper(cti, dst, con_fix_copied_refs_cb, nullptr);
|
||||
con_invoke_id_looper(cti, dst, con_fix_copied_refs_cb, IDWALK_NOP, nullptr);
|
||||
}
|
||||
|
||||
/* For proxies we don't want to make external. */
|
||||
if (do_extern) {
|
||||
/* go over used ID-links for this constraint to ensure that they are valid for proxies */
|
||||
con_invoke_id_looper(cti, dst, con_extern_cb, nullptr);
|
||||
con_invoke_id_looper(cti, dst, con_extern_cb, IDWALK_NOP, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6494,7 +6503,7 @@ void BKE_constraint_blend_read_data(BlendDataReader *reader, ID *id_owner, ListB
|
||||
/* Patch for error introduced by changing constraints (don't know how). */
|
||||
/* NOTE(@ton): If `con->data` type changes, DNA cannot resolve the pointer!. */
|
||||
/* FIXME This is likely dead code actually, since it used to be in
|
||||
* #BKE_constraint_blend_read_lib, so it would have crashed on null pointer access in any of
|
||||
* constraint 'read_lib', so it would have crashed on null pointer access in any of
|
||||
* the code below? But does not hurt to keep it around as a safety measure. */
|
||||
if (con->data == nullptr) {
|
||||
con->type = CONSTRAINT_TYPE_NULL;
|
||||
@@ -6583,7 +6592,7 @@ void BKE_constraint_blend_read_lib(BlendLibReader *reader, ID *id, ListBase *con
|
||||
cld.reader = reader;
|
||||
cld.id = id;
|
||||
|
||||
BKE_constraints_id_loop(conlist, lib_link_constraint_cb, &cld);
|
||||
BKE_constraints_id_loop(conlist, lib_link_constraint_cb, IDWALK_NOP, &cld);
|
||||
}
|
||||
|
||||
/* callback function used to expand constraint ID-links */
|
||||
@@ -6598,7 +6607,7 @@ static void expand_constraint_cb(bConstraint * /*con*/,
|
||||
|
||||
void BKE_constraint_blend_read_expand(BlendExpander *expander, ListBase *lb)
|
||||
{
|
||||
BKE_constraints_id_loop(lb, expand_constraint_cb, expander);
|
||||
BKE_constraints_id_loop(lb, expand_constraint_cb, IDWALK_NOP, expander);
|
||||
|
||||
/* deprecated manual expansion stuff */
|
||||
LISTBASE_FOREACH (bConstraint *, curcon, lb) {
|
||||
|
||||
@@ -134,7 +134,9 @@ static void curve_free_data(ID *id)
|
||||
|
||||
static void curve_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Curve *curve = (Curve *)id;
|
||||
Curve *curve = reinterpret_cast<Curve *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curve->bevobj, IDWALK_CB_NOP);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curve->taperobj, IDWALK_CB_NOP);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curve->textoncurve, IDWALK_CB_NOP);
|
||||
@@ -146,6 +148,10 @@ static void curve_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curve->vfontb, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curve->vfonti, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, curve->vfontbi, IDWALK_CB_USER);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, curve->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void curve_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "BKE_ipo.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_nla.h"
|
||||
|
||||
@@ -98,6 +99,20 @@ static void ipo_free_data(ID *id)
|
||||
}
|
||||
}
|
||||
|
||||
static void ipo_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Ipo *ipo = reinterpret_cast<Ipo *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
LISTBASE_FOREACH (IpoCurve *, icu, &ipo->curve) {
|
||||
if (icu->driver) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, icu->driver->ob, IDWALK_CB_NOP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ipo_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
Ipo *ipo = (Ipo *)id;
|
||||
@@ -176,7 +191,7 @@ IDTypeInfo IDType_ID_IP = {
|
||||
/*copy_data*/ nullptr,
|
||||
/*free_data*/ ipo_free_data,
|
||||
/*make_local*/ nullptr,
|
||||
/*foreach_id*/ nullptr,
|
||||
/*foreach_id*/ ipo_foreach_id,
|
||||
/*foreach_cache*/ nullptr,
|
||||
/*foreach_path*/ nullptr,
|
||||
/*owner_pointer_get*/ nullptr,
|
||||
|
||||
@@ -87,8 +87,14 @@ static void shapekey_free_data(ID *id)
|
||||
|
||||
static void shapekey_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Key *key = (Key *)id;
|
||||
Key *key = reinterpret_cast<Key *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_ID(data, key->from, IDWALK_CB_LOOPBACK);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, key->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static ID **shapekey_owner_pointer_get(ID *id)
|
||||
|
||||
@@ -117,8 +117,14 @@ static void lattice_free_data(ID *id)
|
||||
|
||||
static void lattice_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Lattice *lattice = (Lattice *)id;
|
||||
Lattice *lattice = reinterpret_cast<Lattice *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, lattice->key, IDWALK_CB_USER);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, lattice->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void lattice_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -282,11 +282,23 @@ static bool library_foreach_ID_link(Main *bmain,
|
||||
data.cb_flag_clear = inherit_data->cb_flag_clear;
|
||||
}
|
||||
|
||||
if (bmain != nullptr && bmain->relations != nullptr && (flag & IDWALK_READONLY) &&
|
||||
(flag & (IDWALK_DO_INTERNAL_RUNTIME_POINTERS | IDWALK_DO_LIBRARY_POINTER)) == 0 &&
|
||||
(((bmain->relations->flag & MAINIDRELATIONS_INCLUDE_UI) == 0) ==
|
||||
((data.flag & IDWALK_INCLUDE_UI) == 0)))
|
||||
bool use_bmain_relations = bmain != nullptr && bmain->relations != nullptr &&
|
||||
(flag & IDWALK_READONLY);
|
||||
/* Including UI-related ID pointers should match with the relevant setting in Main relations
|
||||
* cache. */
|
||||
if (use_bmain_relations && (((bmain->relations->flag & MAINIDRELATIONS_INCLUDE_UI) == 0) !=
|
||||
((data.flag & IDWALK_INCLUDE_UI) == 0)))
|
||||
{
|
||||
use_bmain_relations = false;
|
||||
}
|
||||
/* No special 'internal' handling of ID pointers is covered by Main relations cache. */
|
||||
if (use_bmain_relations &&
|
||||
(flag & (IDWALK_DO_INTERNAL_RUNTIME_POINTERS | IDWALK_DO_LIBRARY_POINTER |
|
||||
IDWALK_DO_DEPRECATED_POINTERS)))
|
||||
{
|
||||
use_bmain_relations = false;
|
||||
}
|
||||
if (use_bmain_relations) {
|
||||
/* Note that this is minor optimization, even in worst cases (like id being an object with
|
||||
* lots of drivers and constraints and modifiers, or material etc. with huge node tree),
|
||||
* but we might as well use it (Main->relations is always assumed valid,
|
||||
|
||||
@@ -78,6 +78,8 @@ static void library_blend_read_data(BlendDataReader * /*reader*/, ID *id)
|
||||
{
|
||||
Library *lib = (Library *)id;
|
||||
lib->runtime.name_map = nullptr;
|
||||
/* This is runtime data. */
|
||||
lib->parent = nullptr;
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_LI = {
|
||||
|
||||
@@ -104,12 +104,18 @@ static void light_free_data(ID *id)
|
||||
|
||||
static void light_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Light *lamp = (Light *)id;
|
||||
Light *lamp = reinterpret_cast<Light *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
if (lamp->nodetree) {
|
||||
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data, BKE_library_foreach_ID_embedded(data, (ID **)&lamp->nodetree));
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, lamp->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void light_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -160,7 +160,9 @@ static void material_free_data(ID *id)
|
||||
|
||||
static void material_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Material *material = (Material *)id;
|
||||
Material *material = reinterpret_cast<Material *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
/* Node-trees **are owned by IDs**, treat them as mere sub-data and not real ID! */
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data, BKE_library_foreach_ID_embedded(data, (ID **)&material->nodetree));
|
||||
@@ -171,6 +173,10 @@ static void material_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, material->gp_style->sima, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, material->gp_style->ima, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, material->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void material_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -92,10 +92,16 @@ static void metaball_free_data(ID *id)
|
||||
|
||||
static void metaball_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
MetaBall *metaball = (MetaBall *)id;
|
||||
MetaBall *metaball = reinterpret_cast<MetaBall *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
for (int i = 0; i < metaball->totcol; i++) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, metaball->mat[i], IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, metaball->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void metaball_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -211,11 +211,17 @@ static void mesh_free_data(ID *id)
|
||||
static void mesh_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Mesh *mesh = reinterpret_cast<Mesh *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, mesh->texcomesh, IDWALK_CB_NEVER_SELF);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, mesh->key, IDWALK_CB_USER);
|
||||
for (int i = 0; i < mesh->totcol; i++) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, mesh->mat[i], IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, mesh->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void mesh_foreach_path(ID *id, BPathForeachPathData *bpath_data)
|
||||
|
||||
@@ -396,7 +396,8 @@ static void library_foreach_particlesystemsObjectLooper(ParticleSystem * /*psys*
|
||||
|
||||
static void object_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Object *object = (Object *)id;
|
||||
Object *object = reinterpret_cast<Object *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
/* object data special case */
|
||||
if (object->type == OB_EMPTY) {
|
||||
@@ -413,20 +414,16 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->parent, IDWALK_CB_NEVER_SELF);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->track, IDWALK_CB_NEVER_SELF);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->poselib, IDWALK_CB_USER);
|
||||
|
||||
for (int i = 0; i < object->totcol; i++) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->mat[i], IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
/* Note that `ob->gpd` is deprecated, so no need to handle it here. */
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->instance_collection, IDWALK_CB_USER);
|
||||
|
||||
if (object->pd) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->pd->tex, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->pd->f_source, IDWALK_CB_NOP);
|
||||
}
|
||||
/* Note that ob->effect is deprecated, so no need to handle it here. */
|
||||
|
||||
if (object->pose) {
|
||||
LISTBASE_FOREACH (bPoseChannel *, pchan, &object->pose->chanbase) {
|
||||
@@ -441,7 +438,7 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data,
|
||||
BKE_constraints_id_loop(
|
||||
&pchan->constraints, library_foreach_constraintObjectLooper, data));
|
||||
&pchan->constraints, library_foreach_constraintObjectLooper, flag, data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +457,8 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
object, library_foreach_gpencil_modifiersForeachIDLink, data));
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data,
|
||||
BKE_constraints_id_loop(&object->constraints, library_foreach_constraintObjectLooper, data));
|
||||
BKE_constraints_id_loop(
|
||||
&object->constraints, library_foreach_constraintObjectLooper, flag, data));
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data, BKE_shaderfx_foreach_ID_link(object, library_foreach_shaderfxForeachIDLink, data));
|
||||
|
||||
@@ -484,6 +482,44 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(
|
||||
data, object->light_linking->blocker_collection, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, object->ipo, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->action, IDWALK_CB_USER);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->poselib, IDWALK_CB_USER);
|
||||
|
||||
LISTBASE_FOREACH (bConstraintChannel *, chan, &object->constraintChannels) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, chan->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (bActionStrip *, strip, &object->nlastrips) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, strip->object, IDWALK_CB_NOP);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, strip->act, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, strip->ipo, IDWALK_CB_USER);
|
||||
LISTBASE_FOREACH (bActionModifier *, amod, &strip->modifiers) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, amod->ob, IDWALK_CB_NOP);
|
||||
}
|
||||
}
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->gpd, IDWALK_CB_USER);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->proxy, IDWALK_CB_NOP);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, object->proxy_group, IDWALK_CB_NOP);
|
||||
/* Note that `proxy_from` is purposedly skipped here, as this should be considered as pure
|
||||
* runtime data. */
|
||||
|
||||
PartEff *paf = BKE_object_do_version_give_parteff_245(object);
|
||||
if (paf && paf->group) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, paf->group, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
FluidsimModifierData *fluidmd = reinterpret_cast<FluidsimModifierData *>(
|
||||
BKE_modifiers_findby_type(object, eModifierType_Fluidsim));
|
||||
if (fluidmd && fluidmd->fss) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, fluidmd->fss->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void object_foreach_path_pointcache(ListBase *ptcache_list,
|
||||
|
||||
@@ -167,7 +167,9 @@ static void particle_settings_free_data(ID *id)
|
||||
|
||||
static void particle_settings_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
ParticleSettings *psett = (ParticleSettings *)id;
|
||||
ParticleSettings *psett = reinterpret_cast<ParticleSettings *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, psett->instance_collection, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, psett->instance_object, IDWALK_CB_NOP);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, psett->bb_ob, IDWALK_CB_NOP);
|
||||
@@ -211,6 +213,10 @@ static void particle_settings_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
LISTBASE_FOREACH (ParticleDupliWeight *, dw, &psett->instance_weights) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, dw->ob, IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, psett->force_group, IDWALK_CB_NOP);
|
||||
}
|
||||
}
|
||||
|
||||
static void write_boid_state(BlendWriter *writer, BoidState *state)
|
||||
|
||||
@@ -808,15 +808,23 @@ static void scene_foreach_layer_collection(LibraryForeachIDData *data,
|
||||
|
||||
static bool seq_foreach_member_id_cb(Sequence *seq, void *user_data)
|
||||
{
|
||||
LibraryForeachIDData *data = (LibraryForeachIDData *)user_data;
|
||||
LibraryForeachIDData *data = static_cast<LibraryForeachIDData *>(user_data);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
/* Only for deprecated data. */
|
||||
#define FOREACHID_PROCESS_ID_NOCHECK(_data, _id_super, _cb_flag) \
|
||||
{ \
|
||||
BKE_lib_query_foreachid_process((_data), reinterpret_cast<ID **>(&(_id_super)), (_cb_flag)); \
|
||||
if (BKE_lib_query_foreachid_iter_stop(_data)) { \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#define FOREACHID_PROCESS_IDSUPER(_data, _id_super, _cb_flag) \
|
||||
{ \
|
||||
CHECK_TYPE(&((_id_super)->id), ID *); \
|
||||
BKE_lib_query_foreachid_process((_data), (ID **)&(_id_super), (_cb_flag)); \
|
||||
if (BKE_lib_query_foreachid_iter_stop(_data)) { \
|
||||
return false; \
|
||||
} \
|
||||
FOREACHID_PROCESS_ID_NOCHECK(_data, _id_super, _cb_flag); \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
@@ -836,14 +844,20 @@ static bool seq_foreach_member_id_cb(Sequence *seq, void *user_data)
|
||||
FOREACHID_PROCESS_IDSUPER(data, text_data->text_font, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
FOREACHID_PROCESS_ID_NOCHECK(data, seq->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
|
||||
#undef FOREACHID_PROCESS_IDSUPER
|
||||
#undef FOREACHID_PROCESS_ID_NOCHECK
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Scene *scene = (Scene *)id;
|
||||
Scene *scene = reinterpret_cast<Scene *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->camera, IDWALK_CB_NOP);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, scene->world, IDWALK_CB_USER);
|
||||
@@ -922,6 +936,23 @@ static void scene_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
BKE_rigidbody_world_id_loop(
|
||||
scene->rigidbody_world, scene_foreach_rigidbodyworldSceneLooper, data));
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
LISTBASE_FOREACH_MUTABLE (Base *, base_legacy, &scene->base) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, base_legacy->object, IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (SceneRenderLayer *, srl, &scene->r.layers) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, srl->mat_override, IDWALK_CB_USER);
|
||||
LISTBASE_FOREACH (FreestyleModuleConfig *, fmc, &srl->freestyleConfig.modules) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fmc->script, IDWALK_CB_NOP);
|
||||
}
|
||||
LISTBASE_FOREACH (FreestyleLineSet *, fls, &srl->freestyleConfig.linesets) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fls->linestyle, IDWALK_CB_USER);
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, fls->group, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void scene_foreach_cache(ID *id,
|
||||
|
||||
@@ -96,13 +96,17 @@ void BKE_screen_foreach_id_screen_area(LibraryForeachIDData *data, ScrArea *area
|
||||
|
||||
static void screen_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
if ((BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) == 0) {
|
||||
return;
|
||||
}
|
||||
bScreen *screen = (bScreen *)id;
|
||||
bScreen *screen = reinterpret_cast<bScreen *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, BKE_screen_foreach_id_screen_area(data, area));
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, screen->scene, IDWALK_CB_NOP);
|
||||
}
|
||||
|
||||
if (flag & IDWALK_INCLUDE_UI) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data, BKE_screen_foreach_id_screen_area(data, area));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_packedFile.h"
|
||||
#include "BKE_scene.h"
|
||||
@@ -104,6 +105,16 @@ static void sound_free_data(ID *id)
|
||||
}
|
||||
}
|
||||
|
||||
static void sound_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
bSound *sound = reinterpret_cast<bSound *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, sound->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void sound_foreach_cache(ID *id,
|
||||
IDTypeForeachCacheFunctionCallback function_callback,
|
||||
void *user_data)
|
||||
@@ -207,7 +218,7 @@ IDTypeInfo IDType_ID_SO = {
|
||||
/*copy_data*/ sound_copy_data,
|
||||
/*free_data*/ sound_free_data,
|
||||
/*make_local*/ nullptr,
|
||||
/*foreach_id*/ nullptr,
|
||||
/*foreach_id*/ sound_foreach_id,
|
||||
/*foreach_cache*/ sound_foreach_cache,
|
||||
/*foreach_path*/ sound_foreach_path,
|
||||
/*owner_pointer_get*/ nullptr,
|
||||
|
||||
@@ -136,13 +136,19 @@ static void texture_free_data(ID *id)
|
||||
|
||||
static void texture_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
Tex *texture = (Tex *)id;
|
||||
Tex *texture = reinterpret_cast<Tex *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
if (texture->nodetree) {
|
||||
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data, BKE_library_foreach_ID_embedded(data, (ID **)&texture->nodetree));
|
||||
}
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, texture->ima, IDWALK_CB_USER);
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, texture->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void texture_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -119,13 +119,18 @@ static void world_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int
|
||||
|
||||
static void world_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
World *world = (World *)id;
|
||||
World *world = reinterpret_cast<World *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
if (world->nodetree) {
|
||||
/* nodetree **are owned by IDs**, treat them as mere sub-data and not real ID! */
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(
|
||||
data, BKE_library_foreach_ID_embedded(data, (ID **)&world->nodetree));
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_ID_NOCHECK(data, world->ipo, IDWALK_CB_USER);
|
||||
}
|
||||
}
|
||||
|
||||
static void world_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
||||
|
||||
@@ -807,7 +807,7 @@ void DepsgraphNodeBuilder::build_object(int base_index,
|
||||
if (object->constraints.first != nullptr) {
|
||||
BuilderWalkUserData data;
|
||||
data.builder = this;
|
||||
BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
|
||||
BKE_constraints_id_loop(&object->constraints, constraint_walk, IDWALK_NOP, &data);
|
||||
}
|
||||
/* Object data. */
|
||||
build_object_data(object);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_lib_query.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_build.h"
|
||||
@@ -48,7 +49,7 @@ void DepsgraphNodeBuilder::build_pose_constraints(Object *object,
|
||||
/* Pull indirect dependencies via constraints. */
|
||||
BuilderWalkUserData data;
|
||||
data.builder = this;
|
||||
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
|
||||
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, IDWALK_NOP, &data);
|
||||
|
||||
/* Create node for constraint stack. */
|
||||
Scene *scene_cow = get_cow_datablock(scene_);
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_key.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_mball.h"
|
||||
#include "BKE_modifier.h"
|
||||
@@ -767,7 +768,7 @@ void DepsgraphRelationBuilder::build_object(Object *object)
|
||||
if (object->constraints.first != nullptr) {
|
||||
BuilderWalkUserData data;
|
||||
data.builder = this;
|
||||
BKE_constraints_id_loop(&object->constraints, constraint_walk, &data);
|
||||
BKE_constraints_id_loop(&object->constraints, constraint_walk, IDWALK_NOP, &data);
|
||||
}
|
||||
|
||||
/* Object constraints. */
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_constraint.h"
|
||||
#include "BKE_lib_query.h"
|
||||
|
||||
#include "RNA_prototypes.h"
|
||||
|
||||
@@ -397,7 +398,7 @@ void DepsgraphRelationBuilder::build_rig(Object *object)
|
||||
/* Build relations for indirectly linked objects. */
|
||||
BuilderWalkUserData data;
|
||||
data.builder = this;
|
||||
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, &data);
|
||||
BKE_constraints_id_loop(&pchan->constraints, constraint_walk, IDWALK_NOP, &data);
|
||||
/* Constraints stack and constraint dependencies. */
|
||||
build_constraints(&object->id, NodeType::BONE, pchan->name, &pchan->constraints, &root_map);
|
||||
/* Pose -> constraints. */
|
||||
|
||||
@@ -69,12 +69,13 @@ static void window_manager_free_data(ID *id)
|
||||
|
||||
static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
{
|
||||
wmWindowManager *wm = (wmWindowManager *)id;
|
||||
wmWindowManager *wm = reinterpret_cast<wmWindowManager *>(id);
|
||||
const int flag = BKE_lib_query_foreachid_process_flags_get(data);
|
||||
|
||||
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, win->scene, IDWALK_CB_USER_ONE);
|
||||
|
||||
/* This pointer can be nullptr during old files reading, better be safe than sorry. */
|
||||
/* This pointer can be nullptr during old files reading. */
|
||||
if (win->workspace_hook != nullptr) {
|
||||
ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook);
|
||||
BKE_lib_query_foreachid_process(data, &workspace, IDWALK_CB_USER);
|
||||
@@ -87,12 +88,16 @@ static void window_manager_foreach_id(ID *id, LibraryForeachIDData *data)
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, win->unpinned_scene, IDWALK_CB_NOP);
|
||||
|
||||
if (BKE_lib_query_foreachid_process_flags_get(data) & IDWALK_INCLUDE_UI) {
|
||||
if (flag & IDWALK_INCLUDE_UI) {
|
||||
LISTBASE_FOREACH (ScrArea *, area, &win->global_areas.areabase) {
|
||||
BKE_LIB_FOREACHID_PROCESS_FUNCTION_CALL(data,
|
||||
BKE_screen_foreach_id_screen_area(data, area));
|
||||
}
|
||||
}
|
||||
|
||||
if (flag & IDWALK_DO_DEPRECATED_POINTERS) {
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, win->screen, IDWALK_CB_NOP);
|
||||
}
|
||||
}
|
||||
|
||||
BKE_LIB_FOREACHID_PROCESS_IDSUPER(
|
||||
|
||||
Reference in New Issue
Block a user