diff options
author | Michael Kowalski <makowalski@nvidia.com> | 2022-09-23 23:56:14 +0300 |
---|---|---|
committer | Michael Kowalski <makowalski@nvidia.com> | 2022-09-23 23:56:14 +0300 |
commit | b2ad97ba97f3e55d1dd463e29ca0b2ec6fe761e1 (patch) | |
tree | f94394835c6b731e4e379f4ef48fb78b4af4b9ca /source/blender/blenkernel/intern/object.cc | |
parent | b31807c75f0c18c43ac6979e6da57dc9d420167a (diff) | |
parent | 7e980f2b8cb96aa6d04dc72899d08473367eeeb9 (diff) |
Merge branch 'master' into tmp-usd-alab-v2-T100452tmp-usd-alab-v2-T100452
Diffstat (limited to 'source/blender/blenkernel/intern/object.cc')
-rw-r--r-- | source/blender/blenkernel/intern/object.cc | 199 |
1 files changed, 113 insertions, 86 deletions
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 62ebb45b0ed..7ea6a4c597e 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -145,6 +145,8 @@ #include "atomic_ops.h" using blender::float3; +using blender::MutableSpan; +using blender::Span; static CLG_LogRef LOG = {"bke.object"}; @@ -186,7 +188,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in /* Do not copy runtime data. */ BKE_object_runtime_reset_on_copy(ob_dst, flag); - /* We never handle usercount here for own data. */ + /* We never handle user-count here for own data. */ const int flag_subdata = flag | LIB_ID_CREATE_NO_USER_REFCOUNT; if (ob_src->totcol) { @@ -243,7 +245,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in BLI_listbase_clear(&ob_dst->modifiers); BLI_listbase_clear(&ob_dst->greasepencil_modifiers); - /* NOTE: Also takes care of softbody and particle systems copying. */ + /* NOTE: Also takes care of soft-body and particle systems copying. */ BKE_object_modifier_stack_copy(ob_dst, ob_src, true, flag_subdata); BLI_listbase_clear((ListBase *)&ob_dst->drawdata); @@ -394,7 +396,7 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data) 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. */ + /* 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) { @@ -449,7 +451,7 @@ static void object_foreach_id(ID *id, LibraryForeachIDData *data) if (object->soft->effector_weights) { BKE_LIB_FOREACHID_PROCESS_IDSUPER( - data, object->soft->effector_weights->group, IDWALK_CB_NOP); + data, object->soft->effector_weights->group, IDWALK_CB_USER); } } } @@ -734,9 +736,9 @@ static void object_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_data_address(reader, &sb->shared); if (sb->shared == nullptr) { /* Link deprecated caches if they exist, so we can use them for versioning. - * We should only do this when sb->shared == nullptr, because those pointers + * We should only do this when `sb->shared == nullptr`, because those pointers * are always set (for compatibility with older Blenders). We mustn't link - * the same pointcache twice. */ + * the same point-cache twice. */ BKE_ptcache_blend_read_data(reader, &sb->ptcaches, &sb->pointcache, false); } else { @@ -1139,7 +1141,7 @@ static void object_lib_override_apply_post(ID *id_dst, ID *id_src) * This code is a workaround this to check all point-caches from both source and destination * objects in parallel, and transfer those flags when it makes sense. * - * This allows to keep baked caches across liboverrides applies. + * This allows to keep baked caches across lib-overrides applies. * * NOTE: This is fairly hackish and weak, but so is the point-cache system as its whole. A more * robust solution would be e.g. to have a specific RNA entry point to deal with such cases @@ -1168,7 +1170,7 @@ static void object_lib_override_apply_post(ID *id_dst, ID *id_src) point_cache_dst != nullptr; point_cache_dst = point_cache_dst->next, point_cache_src = (point_cache_src != nullptr) ? point_cache_src->next : nullptr) { - /* Always force updating info about caches of applied liboverrides. */ + /* Always force updating info about caches of applied lib-overrides. */ point_cache_dst->flag |= PTCACHE_FLAG_INFO_DIRTY; if (point_cache_src == nullptr || !STREQ(point_cache_dst->name, point_cache_src->name)) { continue; @@ -1237,7 +1239,7 @@ IDTypeInfo IDType_ID_OB = { /* foreach_id */ object_foreach_id, /* foreach_cache */ nullptr, /* foreach_path */ object_foreach_path, - /* owner_get */ nullptr, + /* owner_pointer_get */ nullptr, /* blend_write */ object_blend_write, /* blend_read_data */ object_blend_read_data, @@ -1298,10 +1300,10 @@ void BKE_object_free_modifiers(Object *ob, const int flag) while ((gp_md = (GpencilModifierData *)BLI_pophead(&ob->greasepencil_modifiers))) { BKE_gpencil_modifier_free_ex(gp_md, flag); } - /* particle modifiers were freed, so free the particlesystems as well */ + /* Particle modifiers were freed, so free the particle-systems as well. */ BKE_object_free_particlesystems(ob); - /* same for softbody */ + /* Same for soft-body */ BKE_object_free_softbody(ob); /* modifiers may have stored data in the DM cache */ @@ -1446,11 +1448,11 @@ static bool object_modifier_type_copy_check(ModifierType md_type) } /** - * Find a `psys` matching given `psys_src` in `ob_dst` (i.e. sharing the same ParticleSettings ID), - * or add one, and return valid `psys` from `ob_dst`. + * Find a `psys` matching given `psys_src` in `ob_dst` + * (i.e. sharing the same #ParticleSettings ID), or add one, and return valid `psys` from `ob_dst`. * * \note Order handling is fairly weak here. This code assumes that it is called **before** the - * modifier using the psys is actually copied, and that this copied modifier will be added at the + * modifier using the `psys` is actually copied, and that this copied modifier will be added at the * end of the stack. That way we can be sure that the particle modifier will be before the one * using its particle system in the stack. */ @@ -1665,7 +1667,7 @@ static void copy_ccg_data(Mesh *mesh_destination, Mesh *mesh_source, int layer_t const int layer_index = CustomData_get_layer_index(data_destination, layer_type); CustomData_free_layer(data_destination, layer_type, num_elements, layer_index); BLI_assert(!CustomData_has_layer(data_destination, layer_type)); - CustomData_add_layer(data_destination, layer_type, CD_CALLOC, nullptr, num_elements); + CustomData_add_layer(data_destination, layer_type, CD_SET_DEFAULT, nullptr, num_elements); BLI_assert(CustomData_has_layer(data_destination, layer_type)); CustomData_copy_layer_type_data(data_source, data_destination, layer_type, 0, 0, num_elements); } @@ -2038,7 +2040,7 @@ bool BKE_object_is_mode_compat(const struct Object *ob, eObjectMode object_mode) int BKE_object_visibility(const Object *ob, const int dag_eval_mode) { - if ((ob->base_flag & BASE_VISIBLE_DEPSGRAPH) == 0) { + if ((ob->base_flag & BASE_ENABLED_AND_MAYBE_VISIBLE_IN_VIEWPORT) == 0) { return 0; } @@ -2256,26 +2258,29 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name) return ob; } -static Object *object_add_common(Main *bmain, ViewLayer *view_layer, int type, const char *name) +static Object *object_add_common( + Main *bmain, const Scene *scene, ViewLayer *view_layer, int type, const char *name) { Object *ob = BKE_object_add_only_object(bmain, type, name); ob->data = BKE_object_obdata_add_from_type(bmain, type, name); - BKE_view_layer_base_deselect_all(view_layer); + BKE_view_layer_base_deselect_all(scene, view_layer); DEG_id_tag_update_ex( bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); return ob; } -Object *BKE_object_add(Main *bmain, ViewLayer *view_layer, int type, const char *name) +Object *BKE_object_add( + Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name) { - Object *ob = object_add_common(bmain, view_layer, type, name); + Object *ob = object_add_common(bmain, scene, view_layer, type, name); LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer); BKE_collection_viewlayer_object_add(bmain, view_layer, layer_collection->collection, ob); /* NOTE: There is no way to be sure that #BKE_collection_viewlayer_object_add will actually * manage to find a valid collection in given `view_layer` to add the new object to. */ + BKE_view_layer_synced_ensure(scene, view_layer); Base *base = BKE_view_layer_base_find(view_layer, ob); if (base != nullptr) { BKE_view_layer_base_select_and_set_active(view_layer, base); @@ -2287,17 +2292,23 @@ Object *BKE_object_add(Main *bmain, ViewLayer *view_layer, int type, const char Object *BKE_object_add_from( Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name, Object *ob_src) { - Object *ob = object_add_common(bmain, view_layer, type, name); + Object *ob = object_add_common(bmain, scene, view_layer, type, name); BKE_collection_object_add_from(bmain, scene, ob_src, ob); + BKE_view_layer_synced_ensure(scene, view_layer); Base *base = BKE_view_layer_base_find(view_layer, ob); BKE_view_layer_base_select_and_set_active(view_layer, base); return ob; } -Object *BKE_object_add_for_data( - Main *bmain, ViewLayer *view_layer, int type, const char *name, ID *data, bool do_id_user) +Object *BKE_object_add_for_data(Main *bmain, + const Scene *scene, + ViewLayer *view_layer, + int type, + const char *name, + ID *data, + bool do_id_user) { /* same as object_add_common, except we don't create new ob->data */ Object *ob = BKE_object_add_only_object(bmain, type, name); @@ -2306,13 +2317,14 @@ Object *BKE_object_add_for_data( id_us_plus(data); } - BKE_view_layer_base_deselect_all(view_layer); + BKE_view_layer_base_deselect_all(scene, view_layer); DEG_id_tag_update_ex( bmain, &ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); LayerCollection *layer_collection = BKE_layer_collection_get_active(view_layer); BKE_collection_object_add(bmain, layer_collection->collection, ob); + BKE_view_layer_synced_ensure(scene, view_layer); Base *base = BKE_view_layer_base_find(view_layer, ob); BKE_view_layer_base_select_and_set_active(view_layer, base); @@ -2414,7 +2426,7 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys, const int f } /* XXX(@campbellbarton): from reading existing code this seems correct but intended usage of - * point-cache should /w cloth should be added in 'ParticleSystem'. */ + * point-cache should with cloth should be added in 'ParticleSystem'. */ if (psysn->clmd) { psysn->clmd->point_cache = psysn->pointcache; } @@ -2472,8 +2484,8 @@ void BKE_object_copy_particlesystems(Object *ob_dst, const Object *ob_src, const static void copy_object_pose(Object *obn, const Object *ob, const int flag) { - /* NOTE: need to clear obn->pose pointer first, - * so that BKE_pose_copy_data works (otherwise there's a crash) */ + /* NOTE: need to clear `obn->pose` pointer first, + * so that #BKE_pose_copy_data works (otherwise there's a crash) */ obn->pose = nullptr; BKE_pose_copy_data_ex(&obn->pose, ob->pose, flag, true); /* true = copy constraints */ @@ -2528,10 +2540,14 @@ Object *BKE_object_pose_armature_get(Object *ob) return nullptr; } -Object *BKE_object_pose_armature_get_visible(Object *ob, ViewLayer *view_layer, View3D *v3d) +Object *BKE_object_pose_armature_get_visible(Object *ob, + const Scene *scene, + ViewLayer *view_layer, + View3D *v3d) { Object *ob_armature = BKE_object_pose_armature_get(ob); if (ob_armature) { + BKE_view_layer_synced_ensure(scene, view_layer); Base *base = BKE_view_layer_base_find(view_layer, ob_armature); if (base) { if (BASE_VISIBLE(v3d, base)) { @@ -2542,12 +2558,11 @@ Object *BKE_object_pose_armature_get_visible(Object *ob, ViewLayer *view_layer, return nullptr; } -Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, - View3D *v3d, - uint *r_objects_len, - bool unique) +Object **BKE_object_pose_array_get_ex( + const Scene *scene, ViewLayer *view_layer, View3D *v3d, uint *r_objects_len, bool unique) { - Object *ob_active = OBACT(view_layer); + BKE_view_layer_synced_ensure(scene, view_layer); + Object *ob_active = BKE_view_layer_active_object_get(view_layer); Object *ob_pose = BKE_object_pose_armature_get(ob_active); Object **objects = nullptr; if (ob_pose == ob_active) { @@ -2556,7 +2571,7 @@ Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, ob_params.no_dup_data = unique; objects = BKE_view_layer_array_from_objects_in_mode_params( - view_layer, v3d, r_objects_len, &ob_params); + scene, view_layer, v3d, r_objects_len, &ob_params); } else if (ob_pose != nullptr) { *r_objects_len = 1; @@ -2569,21 +2584,26 @@ Object **BKE_object_pose_array_get_ex(ViewLayer *view_layer, } return objects; } -Object **BKE_object_pose_array_get_unique(ViewLayer *view_layer, View3D *v3d, uint *r_objects_len) +Object **BKE_object_pose_array_get_unique(const Scene *scene, + ViewLayer *view_layer, + View3D *v3d, + uint *r_objects_len) { - return BKE_object_pose_array_get_ex(view_layer, v3d, r_objects_len, true); + return BKE_object_pose_array_get_ex(scene, view_layer, v3d, r_objects_len, true); } -Object **BKE_object_pose_array_get(ViewLayer *view_layer, View3D *v3d, uint *r_objects_len) +Object **BKE_object_pose_array_get(const Scene *scene, + ViewLayer *view_layer, + View3D *v3d, + uint *r_objects_len) { - return BKE_object_pose_array_get_ex(view_layer, v3d, r_objects_len, false); + return BKE_object_pose_array_get_ex(scene, view_layer, v3d, r_objects_len, false); } -Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, - View3D *v3d, - uint *r_bases_len, - bool unique) +Base **BKE_object_pose_base_array_get_ex( + const Scene *scene, ViewLayer *view_layer, View3D *v3d, uint *r_bases_len, bool unique) { - Base *base_active = BASACT(view_layer); + BKE_view_layer_synced_ensure(scene, view_layer); + Base *base_active = BKE_view_layer_active_base_get(view_layer); Object *ob_pose = base_active ? BKE_object_pose_armature_get(base_active->object) : nullptr; Base *base_pose = nullptr; Base **bases = nullptr; @@ -2603,7 +2623,7 @@ Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, ob_params.no_dup_data = unique; bases = BKE_view_layer_array_from_bases_in_mode_params( - view_layer, v3d, r_bases_len, &ob_params); + scene, view_layer, v3d, r_bases_len, &ob_params); } else if (base_pose != nullptr) { *r_bases_len = 1; @@ -2616,13 +2636,19 @@ Base **BKE_object_pose_base_array_get_ex(ViewLayer *view_layer, } return bases; } -Base **BKE_object_pose_base_array_get_unique(ViewLayer *view_layer, View3D *v3d, uint *r_bases_len) +Base **BKE_object_pose_base_array_get_unique(const Scene *scene, + ViewLayer *view_layer, + View3D *v3d, + uint *r_bases_len) { - return BKE_object_pose_base_array_get_ex(view_layer, v3d, r_bases_len, true); + return BKE_object_pose_base_array_get_ex(scene, view_layer, v3d, r_bases_len, true); } -Base **BKE_object_pose_base_array_get(ViewLayer *view_layer, View3D *v3d, uint *r_bases_len) +Base **BKE_object_pose_base_array_get(const Scene *scene, + ViewLayer *view_layer, + View3D *v3d, + uint *r_bases_len) { - return BKE_object_pose_base_array_get_ex(view_layer, v3d, r_bases_len, false); + return BKE_object_pose_base_array_get_ex(scene, view_layer, v3d, r_bases_len, false); } void BKE_object_transform_copy(Object *ob_tar, const Object *ob_src) @@ -2890,7 +2916,7 @@ void BKE_object_rot_to_mat3(const Object *ob, float mat[3][3], bool use_drot) axis_angle_to_mat3(dmat, ob->drotAxis, ob->drotAngle); } else { - /* quats are normalized before use to eliminate scaling issues */ + /* Quaternions are normalized before use to eliminate scaling issues. */ float tquat[4]; normalize_qt_qt(tquat, ob->quat); @@ -2926,7 +2952,7 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat) float quat[4]; float dquat[4]; - /* without drot we could apply 'mat' directly */ + /* Without `drot` we could apply 'mat' directly. */ mat3_normalized_to_quat(quat, mat); axis_angle_to_quat(dquat, ob->drotAxis, ob->drotAngle); invert_qt_normalized(dquat); @@ -2939,12 +2965,12 @@ void BKE_object_mat3_to_rot(Object *ob, float mat[3][3], bool use_compat) float quat[4]; float dquat[4]; - /* without drot we could apply 'mat' directly */ + /* Without `drot` we could apply 'mat' directly. */ mat3_normalized_to_quat(quat, mat); eulO_to_quat(dquat, ob->drot, ob->rotmode); invert_qt_normalized(dquat); mul_qt_qtqt(quat, dquat, quat); - /* end drot correction */ + /* End `drot` correction. */ if (use_compat) { quat_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, quat); @@ -3105,12 +3131,11 @@ static bool ob_parcurve(Object *ob, Object *par, float r_mat[4][4]) return false; } - /* ctime is now a proper var setting of Curve which gets set by Animato like any other var + /* `ctime` is now a proper var setting of Curve which gets set by Animato like any other var * that's animated, but this will only work if it actually is animated. * * We divide the curve-time calculated in the previous step by the length of the path, - * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range. - */ + * to get a time factor, which then gets clamped to lie within 0.0 - 1.0 range. */ if (cu->pathlen) { ctime = cu->ctime / cu->pathlen; } @@ -3189,6 +3214,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) BKE_object_get_evaluated_mesh(par); if (me_eval) { + const MVert *verts = BKE_mesh_verts(me_eval); int count = 0; int numVerts = me_eval->totvert; @@ -3222,14 +3248,14 @@ static void give_parvert(Object *par, int nr, float vec[3]) /* Get the average of all verts with (original index == nr). */ for (int i = 0; i < numVerts; i++) { if (index[i] == nr) { - add_v3_v3(vec, me_eval->mvert[i].co); + add_v3_v3(vec, verts[i].co); count++; } } } else { if (nr < numVerts) { - add_v3_v3(vec, me_eval->mvert[nr].co); + add_v3_v3(vec, verts[nr].co); count++; } } @@ -3243,7 +3269,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) else { /* use first index if its out of range */ if (me_eval->totvert) { - copy_v3_v3(vec, me_eval->mvert[0].co); + copy_v3_v3(vec, verts[0].co); } } } @@ -3388,7 +3414,7 @@ static void solve_parenting( mul_m4_m4m4(r_obmat, tmat, locmat); if (r_originmat) { - /* usable originmat */ + /* Usable `r_originmat`. */ copy_m3_m4(r_originmat, tmat); } @@ -4069,7 +4095,7 @@ bool BKE_object_minmax_dupli(Depsgraph *depsgraph, } else { Object temp_ob = blender::dna::shallow_copy(*dob->ob); - /* Do not modify the original boundbox. */ + /* Do not modify the original bounding-box. */ temp_ob.runtime.bb = nullptr; BKE_object_replace_data_on_shallow_copy(&temp_ob, dob->ob_data); const BoundBox *bb = BKE_object_boundbox_get(&temp_ob); @@ -4122,15 +4148,15 @@ void BKE_object_foreach_display_point(Object *ob, void (*func_cb)(const float[3], void *), void *user_data) { - /* TODO: pointcloud and curves object support */ + /* TODO: point-cloud and curves object support. */ const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob); float3 co; if (mesh_eval != nullptr) { - const MVert *mv = mesh_eval->mvert; + const MVert *verts = BKE_mesh_verts(mesh_eval); const int totvert = mesh_eval->totvert; - for (int i = 0; i < totvert; i++, mv++) { - mul_v3_m4v3(co, obmat, mv->co); + for (int i = 0; i < totvert; i++) { + mul_v3_m4v3(co, obmat, verts[i].co); func_cb(co, user_data); } } @@ -4161,10 +4187,11 @@ void BKE_scene_foreach_display_point(Depsgraph *depsgraph, void (*func_cb)(const float[3], void *), void *user_data) { - DEG_OBJECT_ITER_BEGIN (depsgraph, - ob, - DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE | - DEG_ITER_OBJECT_FLAG_DUPLI) { + DEGObjectIterSettings deg_iter_settings{}; + deg_iter_settings.depsgraph = depsgraph; + deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE | + DEG_ITER_OBJECT_FLAG_DUPLI; + DEG_OBJECT_ITER_BEGIN (°_iter_settings, ob) { if ((ob->base_flag & BASE_SELECTED) != 0) { BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data); } @@ -4271,7 +4298,7 @@ void BKE_object_handle_update_ex(Depsgraph *depsgraph, * is evaluated on the rebuilt pose, otherwise we get incorrect poses * on file load */ if (ob->pose == nullptr || (ob->pose->flag & POSE_RECALC)) { - /* No need to pass bmain here, we assume we do not need to rebuild DEG from here... */ + /* No need to pass `bmain` here, we assume we do not need to rebuild DEG from here. */ BKE_pose_rebuild(nullptr, ob, (bArmature *)ob->data, true); } } @@ -4754,7 +4781,8 @@ bool BKE_object_shapekey_remove(Main *bmain, Object *ob, KeyBlock *kb) switch (ob->type) { case OB_MESH: { Mesh *mesh = (Mesh *)ob->data; - BKE_keyblock_convert_to_mesh(key->refkey, mesh->mvert, mesh->totvert); + MutableSpan<MVert> verts = mesh->verts_for_write(); + BKE_keyblock_convert_to_mesh(key->refkey, verts.data(), mesh->totvert); break; } case OB_CURVES_LEGACY: @@ -5132,19 +5160,21 @@ static void obrel_list_add(LinkNode **links, Object *ob) ob->id.tag |= LIB_TAG_DOIT; } -LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer, +LinkNode *BKE_object_relational_superset(const Scene *scene, + struct ViewLayer *view_layer, eObjectSet objectSet, eObRelationTypes includeFilter) { LinkNode *links = nullptr; /* Remove markers from all objects */ - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + BKE_view_layer_synced_ensure(scene, view_layer); + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { base->object->id.tag &= ~LIB_TAG_DOIT; } /* iterate over all selected and visible objects */ - LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { + LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { if (objectSet == OB_SET_ALL) { /* as we get all anyways just add it */ Object *ob = base->object; @@ -5180,7 +5210,7 @@ LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer, /* child relationship */ if (includeFilter & (OB_REL_CHILDREN | OB_REL_CHILDREN_RECURSIVE)) { - LISTBASE_FOREACH (Base *, local_base, &view_layer->object_bases) { + LISTBASE_FOREACH (Base *, local_base, BKE_view_layer_object_bases_get(view_layer)) { if (BASE_EDITABLE(((View3D *)nullptr), local_base)) { Object *child = local_base->object; @@ -5250,32 +5280,31 @@ KDTree_3d *BKE_object_as_kdtree(Object *ob, int *r_tot) const int *index; if (me_eval && (index = (const int *)CustomData_get_layer(&me_eval->vdata, CD_ORIGINDEX))) { - MVert *mvert = me_eval->mvert; - uint totvert = me_eval->totvert; + const Span<MVert> verts = me->verts(); /* Tree over-allocates in case where some verts have #ORIGINDEX_NONE. */ tot = 0; - tree = BLI_kdtree_3d_new(totvert); + tree = BLI_kdtree_3d_new(verts.size()); /* We don't how many verts from the DM we can use. */ - for (i = 0; i < totvert; i++) { + for (i = 0; i < verts.size(); i++) { if (index[i] != ORIGINDEX_NONE) { float co[3]; - mul_v3_m4v3(co, ob->obmat, mvert[i].co); + mul_v3_m4v3(co, ob->obmat, verts[i].co); BLI_kdtree_3d_insert(tree, index[i], co); tot++; } } } else { - MVert *mvert = me->mvert; + const Span<MVert> verts = me->verts(); - tot = me->totvert; + tot = verts.size(); tree = BLI_kdtree_3d_new(tot); for (i = 0; i < tot; i++) { float co[3]; - mul_v3_m4v3(co, ob->obmat, mvert[i].co); + mul_v3_m4v3(co, ob->obmat, verts[i].co); BLI_kdtree_3d_insert(tree, i, co); } } @@ -5420,8 +5449,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, depsgraph, scene, ob->track, false, recursion, frame, type); } - /* skip subframe if object is parented - * to vertex of a dynamic paint canvas */ + /* Skip sub-frame if object is parented to vertex of a dynamic paint canvas. */ if (no_update && (ELEM(ob->partype, PARVERT1, PARVERT3))) { return false; } @@ -5452,8 +5480,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, if (update_mesh) { BKE_animsys_evaluate_animdata( &ob->id, ob->adt, &anim_eval_context, ADT_RECALC_ANIM, flush_to_original); - /* ignore cache clear during subframe updates - * to not mess up cache validity */ + /* Ignore cache clear during sub-frame updates to not mess up cache validity. */ object_cacheIgnoreClear(ob, 1); BKE_object_handle_update(depsgraph, scene, ob); object_cacheIgnoreClear(ob, 0); |