[Bf-blender-cvs] [f8d13a1b58f] blender-v3.3-release: Cleanup: Use c++ casting in liboverride BKE code.
Bastien Montagne
noreply at git.blender.org
Fri Aug 5 11:04:31 CEST 2022
Commit: f8d13a1b58f774f33db87c581c5b4b263171cf74
Author: Bastien Montagne
Date: Fri Aug 5 11:03:57 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBf8d13a1b58f774f33db87c581c5b4b263171cf74
Cleanup: Use c++ casting in liboverride BKE code.
No functional change expected here!
===================================================================
M source/blender/blenkernel/intern/lib_override.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc
index 5618d0f6aac..758a317e415 100644
--- a/source/blender/blenkernel/intern/lib_override.cc
+++ b/source/blender/blenkernel/intern/lib_override.cc
@@ -82,8 +82,8 @@ static void lib_override_library_property_operation_clear(
BLI_INLINE void lib_override_object_posemode_transfer(ID *id_dst, ID *id_src)
{
if (GS(id_src->name) == ID_OB && GS(id_dst->name) == ID_OB) {
- Object *ob_src = (Object *)id_src;
- Object *ob_dst = (Object *)id_dst;
+ Object *ob_src = reinterpret_cast<Object *>(id_src);
+ Object *ob_dst = reinterpret_cast<Object *>(id_dst);
if (ob_src->type == OB_ARMATURE && (ob_src->mode & OB_MODE_POSE) != 0) {
ob_dst->restore_mode = ob_dst->mode;
ob_dst->mode |= OB_MODE_POSE;
@@ -187,7 +187,7 @@ void BKE_lib_override_library_copy(ID *dst_id, const ID *src_id, const bool do_f
* Otherwise, source is only an override template, it then becomes reference of dest ID. */
dst_id->override_library->reference = src_id->override_library->reference ?
src_id->override_library->reference :
- (ID *)src_id;
+ const_cast<ID *>(src_id);
id_us_plus(dst_id->override_library->reference);
dst_id->override_library->hierarchy_root = src_id->override_library->hierarchy_root;
@@ -683,7 +683,7 @@ static void lib_override_group_tag_data_object_to_collection_init_collection_pro
LinkNodePair **collections_linkedlist_p;
if (!BLI_ghash_ensure_p(data->linked_object_to_instantiating_collections,
ob,
- (void ***)&collections_linkedlist_p)) {
+ reinterpret_cast<void ***>(&collections_linkedlist_p))) {
*collections_linkedlist_p = static_cast<LinkNodePair *>(
BLI_memarena_calloc(data->mem_arena, sizeof(**collections_linkedlist_p)));
}
@@ -724,7 +724,7 @@ static void lib_override_hierarchy_dependencies_recursive_tag_from(LibOverrideGr
ID *id = data->id_root;
const bool is_override = data->is_override;
- if ((*(uint *)&id->tag & data->tag) == 0) {
+ if ((*reinterpret_cast<uint *>(&id->tag) & data->tag) == 0) {
/* This ID is not tagged, no reason to proceed further to its parents. */
return;
}
@@ -782,7 +782,7 @@ static bool lib_override_hierarchy_dependencies_recursive_tag(LibOverrideGroupTa
if (entry->tags & MAINIDRELATIONS_ENTRY_TAGS_PROCESSED_TO) {
/* This ID has already been processed. */
- return (*(uint *)&id->tag & data->tag) != 0;
+ return (*reinterpret_cast<uint *>(&id->tag) & data->tag) != 0;
}
/* This way we won't process again that ID, should we encounter it again through another
* relationship hierarchy. */
@@ -815,11 +815,11 @@ static bool lib_override_hierarchy_dependencies_recursive_tag(LibOverrideGroupTa
*
* This will cover e.g. the case where user override an armature, and would expect the mesh
* object deformed by that armature to also be overridden. */
- if ((*(uint *)&id->tag & data->tag) != 0 && !is_resync) {
+ if ((*reinterpret_cast<uint *>(&id->tag) & data->tag) != 0 && !is_resync) {
lib_override_hierarchy_dependencies_recursive_tag_from(data);
}
- return (*(uint *)&id->tag & data->tag) != 0;
+ return (*reinterpret_cast<uint *>(&id->tag) & data->tag) != 0;
}
static void lib_override_linked_group_tag_recursive(LibOverrideGroupTagData *data)
@@ -1224,9 +1224,9 @@ static void lib_override_library_create_post_process(Main *bmain,
switch (GS(id_root->name)) {
case ID_GR: {
Object *ob_reference = id_instance_hint != nullptr && GS(id_instance_hint->name) == ID_OB ?
- (Object *)id_instance_hint :
+ reinterpret_cast<Object *>(id_instance_hint) :
nullptr;
- Collection *collection_new = ((Collection *)id_root->newid);
+ Collection *collection_new = (reinterpret_cast<Collection *>(id_root->newid));
if (is_resync && BKE_collection_is_in_scene(collection_new)) {
break;
}
@@ -1236,11 +1236,11 @@ static void lib_override_library_create_post_process(Main *bmain,
else if (id_instance_hint != nullptr) {
BLI_assert(GS(id_instance_hint->name) == ID_GR);
BKE_collection_add_from_collection(
- bmain, scene, ((Collection *)id_instance_hint), collection_new);
+ bmain, scene, (reinterpret_cast<Collection *>(id_instance_hint)), collection_new);
}
else {
BKE_collection_add_from_collection(
- bmain, scene, ((Collection *)id_root), collection_new);
+ bmain, scene, (reinterpret_cast<Collection *>(id_root)), collection_new);
}
BLI_assert(BKE_collection_is_in_scene(collection_new));
@@ -1249,9 +1249,10 @@ static void lib_override_library_create_post_process(Main *bmain,
break;
}
case ID_OB: {
- Object *ob_new = (Object *)id_root->newid;
+ Object *ob_new = reinterpret_cast<Object *>(id_root->newid);
if (BLI_gset_lookup(all_objects_in_scene, ob_new) == nullptr) {
- BKE_collection_object_add_from(bmain, scene, (Object *)id_root, ob_new);
+ BKE_collection_object_add_from(
+ bmain, scene, reinterpret_cast<Object *>(id_root), ob_new);
all_objects_in_scene = BKE_scene_objects_as_gset(scene, all_objects_in_scene);
}
break;
@@ -1264,7 +1265,7 @@ static void lib_override_library_create_post_process(Main *bmain,
/* We need to ensure all new overrides of objects are properly instantiated. */
Collection *default_instantiating_collection = residual_storage;
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
- Object *ob_new = (Object *)ob->id.newid;
+ Object *ob_new = reinterpret_cast<Object *>(ob->id.newid);
if (ob_new == nullptr || (ID_IS_LINKED(ob_new) && ob_new->id.lib != owner_library)) {
continue;
}
@@ -1298,7 +1299,7 @@ static void lib_override_library_create_post_process(Main *bmain,
case ID_OB: {
/* Add the other objects to one of the collections instantiating the
* root object, or scene's master collection if none found. */
- Object *ob_ref = (Object *)id_ref;
+ Object *ob_ref = reinterpret_cast<Object *>(id_ref);
LISTBASE_FOREACH (Collection *, collection, &bmain->collections) {
if (BKE_collection_has_object(collection, ob_ref) &&
(view_layer != nullptr ?
@@ -1328,8 +1329,10 @@ static void lib_override_library_create_post_process(Main *bmain,
ID *id_ref = id_root->newid != nullptr ? id_root->newid : id_root;
switch (GS(id_ref->name)) {
case ID_GR:
- BKE_collection_add_from_collection(
- bmain, scene, (Collection *)id_ref, default_instantiating_collection);
+ BKE_collection_add_from_collection(bmain,
+ scene,
+ reinterpret_cast<Collection *>(id_ref),
+ default_instantiating_collection);
break;
default:
/* Add to master collection. */
@@ -1802,14 +1805,15 @@ static bool lib_override_library_resync(Main *bmain,
if (GS(reference_id->name) != GS(id->name)) {
switch (GS(id->name)) {
case ID_KE:
- reference_id = (ID *)BKE_key_from_id(reference_id);
+ reference_id = reinterpret_cast<ID *>(BKE_key_from_id(reference_id));
break;
case ID_GR:
BLI_assert(GS(reference_id->name) == ID_SCE);
- reference_id = (ID *)((Scene *)reference_id)->master_collection;
+ reference_id = reinterpret_cast<ID *>(
+ reinterpret_cast<Scene *>(reference_id)->master_collection);
break;
case ID_NT:
- reference_id = (ID *)ntreeFromID(id);
+ reference_id = reinterpret_cast<ID *>(ntreeFromID(id));
break;
default:
break;
@@ -2310,7 +2314,7 @@ static bool lib_override_resync_tagging_finalize_recurse(
BLI_assert(id_root->override_library != nullptr);
LinkNodePair **id_resync_roots_p;
- if (!BLI_ghash_ensure_p(id_roots, id_root, (void ***)&id_resync_roots_p)) {
+ if (!BLI_ghash_ensure_p(id_roots, id_root, reinterpret_cast<void ***>(&id_resync_roots_p))) {
*id_resync_roots_p = MEM_cnew<LinkNodePair>(__func__);
}
@@ -2485,8 +2489,8 @@ static void lib_override_library_main_resync_on_library_indirect_level(
2,
"Resyncing all dependencies under root %s (%p), first one being '%s'...",
id_root->name,
- library,
- ((ID *)id_resync_roots->list->link)->name);
+ reinterpret_cast<void *>(library),
+ reinterpret_cast<ID *>(id_resync_roots->list->link)->name);
const bool success = lib_override_library_resync(bmain,
scene,
view_layer,
@@ -2580,7 +2584,7 @@ static int lib_override_sort_libraries_func(LibraryIDLinkCallbackData *cb_data)
if (owner_library_indirect_level >= id->lib->temp_index) {
id->lib->temp_index = owner_library_indirect_level + 1;
- *(bool *)cb_data->user_data = true;
+ *reinterpret_cast<bool *>(cb_data->user_data) = true;
}
}
return IDWALK_RET_NOP;
@@ -2738,7 +2742,7 @@ void BKE_lib_override_library_make_local(ID *id)
}
if (GS(id->name) == ID_SCE) {
- Collection *master_collection = ((Scene *)id)->master_collection;
+ Collection *master_collection = reinterpret_cast<Scene *>(id)->master_collection;
if (master_collection != nullptr) {
master_collection->id.flag &= ~LIB_EMBEDDED_DATA_LIB_OVERRIDE;
}
@@ -3120,9 +3124,9 @@ bool BKE_lib_override_library_status_check_local(Main *bmain, ID *loc
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list