diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 4c35a411949..0d0f005c291 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -571,7 +571,9 @@ void BKE_pchan_bbone_deform_segment_index(const struct bPoseChannel *pchan, ((void)0) /* context.visible_pose_bones */ #define FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN(_ob, _pchan) \ - for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first; _pchan; _pchan = _pchan->next) { \ + for (bPoseChannel *_pchan = (bPoseChannel *)(_ob)->pose->chanbase.first; _pchan; \ + _pchan = _pchan->next) \ + { \ if (PBONE_VISIBLE(((bArmature *)(_ob)->data), (_pchan)->bone)) { #define FOREACH_PCHAN_VISIBLE_IN_OBJECT_END \ } \ diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 3de0aedcfe9..b543fb530a0 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -424,16 +424,16 @@ struct GSet *BKE_scene_objects_as_gset(struct Scene *scene, struct GSet *objects _instance_next = _scene->master_collection; \ } \ else { \ - _instance_next = (_bmain)->collections.first; \ + _instance_next = (Collection *)(_bmain)->collections.first; \ } \ \ while ((_instance = _instance_next)) { \ if (is_scene_collection) { \ - _instance_next = (_bmain)->collections.first; \ + _instance_next = (Collection *)(_bmain)->collections.first; \ is_scene_collection = false; \ } \ else { \ - _instance_next = _instance->id.next; \ + _instance_next = (Collection *)_instance->id.next; \ } #define FOREACH_COLLECTION_END \ diff --git a/source/blender/blenlib/BLI_array.h b/source/blender/blenlib/BLI_array.h index e5be81974b9..b84a5e1eb0a 100644 --- a/source/blender/blenlib/BLI_array.h +++ b/source/blender/blenlib/BLI_array.h @@ -9,6 +9,10 @@ * \brief A (mainly) macro array library. */ +#ifdef __cplusplus +extern "C" { +#endif + /* -------------------------------------------------------------------- */ /** \name Internal defines * \{ */ @@ -76,7 +80,8 @@ void _bli_array_grow_func(void **arr_p, (_bli_array_totalsize_static(arr) >= \ (size_t)(_##arr##_len + \ (num)))) ? /* we have an empty array and a static var big enough */ \ - (void)(arr = (void *)_##arr##_static) : /* use existing static array or allocate */ \ + (void)(*(void **)&arr = (void *) \ + _##arr##_static) : /* use existing static array or allocate */ \ (LIKELY(_bli_array_totalsize(arr) >= (size_t)(_##arr##_len + (num))) ? \ (void)0 /* do nothing */ : \ _bli_array_grow_func((void **)&(arr), \ @@ -183,4 +188,8 @@ void _bli_array_grow_func(void **arr_p, } \ ((void)0) +#ifdef __cplusplus +} +#endif + /** \} */ diff --git a/source/blender/bmesh/tools/bmesh_intersect_edges.h b/source/blender/bmesh/tools/bmesh_intersect_edges.h index 79581611a53..3054fc7aae3 100644 --- a/source/blender/bmesh/tools/bmesh_intersect_edges.h +++ b/source/blender/bmesh/tools/bmesh_intersect_edges.h @@ -8,5 +8,13 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + bool BM_mesh_intersect_edges( BMesh *bm, char hflag, float dist, bool split_faces, GHash *r_targetmap); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/bmesh/tools/bmesh_separate.h b/source/blender/bmesh/tools/bmesh_separate.h index bacd1e7dc0b..667fd9cbae2 100644 --- a/source/blender/bmesh/tools/bmesh_separate.h +++ b/source/blender/bmesh/tools/bmesh_separate.h @@ -8,8 +8,16 @@ * \ingroup bmesh */ +#ifdef __cplusplus +extern "C" { +#endif + /** * Split all faces that match `filter_fn`. * \note */ void BM_mesh_separate_faces(BMesh *bm, BMFaceFilterFunc filter_fn, void *user_data); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/editors/animation/CMakeLists.txt b/source/blender/editors/animation/CMakeLists.txt index c0ea7f85923..e8e82c5149d 100644 --- a/source/blender/editors/animation/CMakeLists.txt +++ b/source/blender/editors/animation/CMakeLists.txt @@ -24,23 +24,23 @@ set(INC_SYS set(SRC anim_channels_defines.cc - anim_channels_edit.c - anim_deps.c - anim_draw.c + anim_channels_edit.cc + anim_deps.cc + anim_draw.cc anim_filter.cc - anim_ipo_utils.c - anim_markers.c - anim_motion_paths.c - anim_ops.c - drivers.c - fmodifier_ui.c + anim_ipo_utils.cc + anim_markers.cc + anim_motion_paths.cc + anim_ops.cc + drivers.cc + fmodifier_ui.cc keyframes_draw.cc keyframes_edit.cc - keyframes_general.c + keyframes_general.cc keyframes_keylist.cc - keyframing.c - keyingsets.c - time_scrub_ui.c + keyframing.cc + keyingsets.cc + time_scrub_ui.cc anim_intern.h ) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.cc similarity index 89% rename from source/blender/editors/animation/anim_channels_edit.c rename to source/blender/editors/animation/anim_channels_edit.cc index d2ea35900de..39f91fad969 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.cc @@ -168,7 +168,7 @@ void ANIM_set_active_channel(bAnimContext *ac, { /* TODO: extend for animdata types. */ - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; /* try to build list of filtered items */ @@ -178,7 +178,7 @@ void ANIM_set_active_channel(bAnimContext *ac, } /* only clear the 'active' flag for the channels of the same type */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { /* skip if types don't match */ if (channel_type != ale->type) { continue; @@ -399,12 +399,13 @@ static void select_pchan_for_action_group(bAnimContext *ac, static ListBase /*bAnimListElem*/ anim_channels_for_selection(bAnimContext *ac) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; /* filter data */ /* NOTE: no list visible, otherwise, we get dangling */ const int filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); return anim_data; } @@ -412,7 +413,7 @@ static ListBase /*bAnimListElem*/ anim_channels_for_selection(bAnimContext *ac) static eAnimChannels_SetFlag anim_channels_selection_flag_for_toggle(const ListBase anim_data) { /* See if we should be selecting or deselecting. */ - for (bAnimListElem *ale = anim_data.first; ale; ale = ale->next) { + for (bAnimListElem *ale = static_cast(anim_data.first); ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_SCENE: if (ale->flag & SCE_DS_SELECTED) { @@ -421,9 +422,9 @@ static eAnimChannels_SetFlag anim_channels_selection_flag_for_toggle(const ListB break; case ANIMTYPE_OBJECT: #if 0 /* for now, do not take object selection into account, since it gets too annoying */ - if (ale->flag & SELECT) { - return ACHANNEL_SETFLAG_CLEAR; - } +if (ale->flag & SELECT) { +return ACHANNEL_SETFLAG_CLEAR; +} #endif break; case ANIMTYPE_GROUP: @@ -501,7 +502,7 @@ static void anim_channels_select_set(bAnimContext *ac, /* Boolean to keep active channel status during range selection. */ const bool change_active = (sel != ACHANNEL_SETFLAG_EXTEND_RANGE); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_SCENE: { if (change_active) { @@ -518,15 +519,15 @@ static void anim_channels_select_set(bAnimContext *ac, } case ANIMTYPE_OBJECT: { #if 0 /* for now, do not take object selection into account, since it gets too annoying */ - Base *base = (Base *)ale->data; - Object *ob = base->object; +Base *base = (Base *)ale->data; +Object *ob = base->object; - ACHANNEL_SET_FLAG(base, sel, SELECT); - ACHANNEL_SET_FLAG(ob, sel, SELECT); +ACHANNEL_SET_FLAG(base, sel, SELECT); +ACHANNEL_SET_FLAG(ob, sel, SELECT); - if (ob->adt) { - ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED); - } +if (ob->adt) { +ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED); +} #endif break; } @@ -669,7 +670,7 @@ static void anim_flush_channel_setting_up(bAnimContext *ac, const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* if no channel info was found, skip, since this type might not have any useful info */ - if (acf == NULL) { + if (acf == nullptr) { continue; } @@ -717,7 +718,7 @@ static void anim_flush_channel_setting_down(bAnimContext *ac, const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* if no channel info was found, skip, since this type might not have any useful info */ - if (acf == NULL) { + if (acf == nullptr) { continue; } @@ -749,11 +750,11 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode) { - bAnimListElem *ale, *match = NULL; + bAnimListElem *ale, *match = nullptr; int matchLevel = 0; /* sanity check */ - if (ELEM(NULL, anim_data, anim_data->first)) { + if (ELEM(nullptr, anim_data, anim_data->first)) { return; } @@ -762,7 +763,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, } /* find the channel that got changed */ - for (ale = anim_data->first; ale; ale = ale->next) { + for (ale = static_cast(anim_data->first); ale; ale = ale->next) { /* compare data, and type as main way of identifying the channel */ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) { /* We also have to check the ID, this is assigned to, @@ -774,14 +775,14 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, } } } - if (match == NULL) { + if (match == nullptr) { printf("ERROR: no channel matching the one changed was found\n"); return; } { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting); - if (acf == NULL) { + if (acf == nullptr) { printf("ERROR: no channel info for the changed channel\n"); return; } @@ -805,12 +806,17 @@ void ANIM_frame_channel_y_extents(bContext *C, bAnimContext *ac) return; } - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY | ANIMFILTER_CURVE_VISIBLE); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); - rctf bounds = {.xmin = FLT_MAX, .xmax = -FLT_MAX, .ymin = FLT_MAX, .ymax = -FLT_MAX}; + rctf bounds{}; + bounds.xmin = FLT_MAX; + bounds.xmax = -FLT_MAX; + bounds.ymin = FLT_MAX; + bounds.ymax = -FLT_MAX; const bool include_handles = false; float frame_range[2] = {window_region->v2d.cur.xmin, window_region->v2d.cur.xmax}; if (ac->scene->r.flag & SCER_PRV_RANGE) { @@ -851,7 +857,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f * (this doesn't guarantee that the F-Curve is in there, but at least we tried * - if no F-Curve, there is nothing to remove */ - if (ELEM(NULL, adt, fcu)) { + if (ELEM(nullptr, adt, fcu)) { return; } @@ -902,12 +908,12 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f bool ANIM_remove_empty_action_from_animdata(AnimData *adt) { - if (adt->action != NULL) { + if (adt->action != nullptr) { bAction *act = adt->action; if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { id_us_min(&act->id); - adt->action = NULL; + adt->action = nullptr; return true; } } @@ -928,7 +934,7 @@ static bool animedit_poll_channels_active(bContext *C) /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, area, CTX_wm_region(C))) { + if (ELEM(nullptr, area, CTX_wm_region(C))) { return false; } /* animation editor test */ @@ -947,7 +953,7 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C) /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, area, CTX_wm_region(C))) { + if (ELEM(nullptr, area, CTX_wm_region(C))) { return false; } /* animation editor test */ @@ -957,7 +963,7 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C) /* NLA tweak-mode test. */ if (area->spacetype == SPACE_NLA) { - if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) { + if ((scene == nullptr) || (scene->flag & SCE_NLA_EDIT_ON)) { return false; } } @@ -986,18 +992,18 @@ static const EnumPropertyItem prop_animchannel_rearrange_types[] = { {REARRANGE_ANIMCHAN_UP, "UP", 0, "Up", ""}, {REARRANGE_ANIMCHAN_DOWN, "DOWN", 0, "Down", ""}, {REARRANGE_ANIMCHAN_BOTTOM, "BOTTOM", 0, "To Bottom", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* Reordering "Islands" Defines ----------------------------------- */ /* Island definition - just a listbase container */ -typedef struct tReorderChannelIsland { +struct tReorderChannelIsland { struct tReorderChannelIsland *next, *prev; ListBase channels; /* channels within this region with the same state */ int flag; /* eReorderIslandFlag */ -} tReorderChannelIsland; +}; /* flags for channel reordering islands */ typedef enum eReorderIslandFlag { @@ -1094,7 +1100,7 @@ static bool rearrange_island_down(ListBase *list, tReorderChannelIsland *island) static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { - tReorderChannelIsland *last = list->last; + tReorderChannelIsland *last = static_cast(list->last); /* remove island from current position */ BLI_remlink(list, island); @@ -1139,7 +1145,7 @@ static AnimChanRearrangeFp rearrange_get_mode_func(eRearrangeAnimChan_Mode mode) case REARRANGE_ANIMCHAN_BOTTOM: return rearrange_island_bottom; default: - return NULL; + return nullptr; } } @@ -1156,7 +1162,7 @@ static AnimChanRearrangeFp rearrange_gpencil_get_mode_func(eRearrangeAnimChan_Mo case REARRANGE_ANIMCHAN_BOTTOM: return rearrange_island_top; default: - return NULL; + return nullptr; } } @@ -1170,7 +1176,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, const bool is_hidden) { /* always try to add to last island if possible */ - tReorderChannelIsland *island = islands->last; + tReorderChannelIsland *island = static_cast(islands->last); bool is_sel = false, is_untouchable = false; /* get flags - selected and untouchable from the channel */ @@ -1203,24 +1209,25 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, } default: printf( - "rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %u\n", + "rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %d\n", type); return; } /* do we need to add to a new island? */ if (/* 1) no islands yet */ - (island == NULL) || + (island == nullptr) || /* 2) unselected islands have single channels only - to allow up/down movement */ ((island->flag & REORDER_ISLAND_SELECTED) == 0) || /* 3) if channel is unselected, stop existing island * (it was either wrong sel status, or full already) */ (is_sel == 0) || /* 4) hidden status changes */ - ((island->flag & REORDER_ISLAND_HIDDEN) != is_hidden)) + (bool(island->flag & REORDER_ISLAND_HIDDEN) != is_hidden)) { /* create a new island now */ - island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland"); + island = static_cast( + MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland")); BLI_addtail(islands, island); if (is_sel) { @@ -1242,13 +1249,13 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, /* flatten islands out into a single list again */ static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList) { - tReorderChannelIsland *island, *isn = NULL; + tReorderChannelIsland *island, *isn = nullptr; /* make sure srcList is empty now */ BLI_assert(BLI_listbase_is_empty(srcList)); /* go through merging islands */ - for (island = islands->first; island; island = isn) { + for (island = static_cast(islands->first); island; island = isn) { isn = island->next; /* merge island channels back to main list, then delete the island */ @@ -1264,12 +1271,12 @@ static void rearrange_animchannels_filter_visible(ListBase *anim_data_visible, bAnimContext *ac, eAnim_ChannelType type) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); /* get all visible channels */ - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype)); /* now, only keep the ones that are of the types we are interested in */ LISTBASE_FOREACH_MUTABLE (bAnimListElem *, ale, &anim_data) { @@ -1300,8 +1307,8 @@ static bool rearrange_animchannel_islands(ListBase *list, eAnim_ChannelType type, ListBase *anim_data_visible) { - ListBase islands = {NULL, NULL}; - Link *channel, *chanNext = NULL; + ListBase islands = {nullptr, nullptr}; + Link *channel, *chanNext = nullptr; bool done = false; /* don't waste effort on an empty list */ @@ -1310,10 +1317,10 @@ static bool rearrange_animchannel_islands(ListBase *list, } /* group channels into islands */ - for (channel = list->first; channel; channel = chanNext) { + for (channel = static_cast(list->first); channel; channel = chanNext) { /* find out whether this channel is present in anim_data_visible or not! */ const bool is_hidden = - (BLI_findptr(anim_data_visible, channel, offsetof(bAnimListElem, data)) == NULL); + (BLI_findptr(anim_data_visible, channel, offsetof(bAnimListElem, data)) == nullptr); chanNext = channel->next; rearrange_animchannel_add_to_islands(&islands, list, channel, type, is_hidden); } @@ -1326,8 +1333,9 @@ static bool rearrange_animchannel_islands(ListBase *list, * so that we shouldn't need to encounter items we've moved already. */ if (islands.first != islands.last) { - tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first; - tReorderChannelIsland *island, *isn = NULL; + tReorderChannelIsland *first = static_cast( + (mode > 0) ? islands.last : islands.first); + tReorderChannelIsland *island, *isn = nullptr; for (island = first; island; island = isn) { isn = (mode > 0) ? island->prev : island->next; @@ -1356,15 +1364,15 @@ static bool rearrange_animchannel_islands(ListBase *list, static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode) { AnimChanRearrangeFp rearrange_func; - ListBase anim_data_visible = {NULL, NULL}; - const bool is_liboverride = (ac->obact != NULL) ? ID_IS_OVERRIDE_LIBRARY(ac->obact) : false; + ListBase anim_data_visible = {nullptr, nullptr}; + const bool is_liboverride = (ac->obact != nullptr) ? ID_IS_OVERRIDE_LIBRARY(ac->obact) : false; /* hack: invert mode so that functions will work in right order */ - mode *= -1; + mode = eRearrangeAnimChan_Mode(int(mode) * -1); /* get rearranging function */ rearrange_func = rearrange_get_mode_func(mode); - if (rearrange_func == NULL) { + if (rearrange_func == nullptr) { return; } @@ -1374,20 +1382,22 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn * * Note that both override apply code for NLA tracks collection, and NLA editing code, are * responsible to ensure that non-local tracks always remain first in the list. */ - ListBase extracted_nonlocal_nla_tracks = {NULL, NULL}; + ListBase extracted_nonlocal_nla_tracks = {nullptr, nullptr}; if (is_liboverride) { NlaTrack *nla_track; - for (nla_track = adt->nla_tracks.first; nla_track != NULL; nla_track = nla_track->next) { + for (nla_track = static_cast(adt->nla_tracks.first); nla_track != nullptr; + nla_track = nla_track->next) + { if (!BKE_nlatrack_is_nonlocal_in_liboverride(&ac->obact->id, nla_track)) { break; } } - if (nla_track != NULL && nla_track->prev != NULL) { + if (nla_track != nullptr && nla_track->prev != nullptr) { extracted_nonlocal_nla_tracks.first = adt->nla_tracks.first; extracted_nonlocal_nla_tracks.last = nla_track->prev; adt->nla_tracks.first = nla_track; - nla_track->prev->next = NULL; - nla_track->prev = NULL; + nla_track->prev->next = nullptr; + nla_track->prev = nullptr; } } @@ -1401,8 +1411,10 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn /* Add back non-local NLA tracks at the beginning of the animation data's list. */ if (!BLI_listbase_is_empty(&extracted_nonlocal_nla_tracks)) { BLI_assert(is_liboverride); - ((NlaTrack *)extracted_nonlocal_nla_tracks.last)->next = adt->nla_tracks.first; - ((NlaTrack *)adt->nla_tracks.first)->prev = extracted_nonlocal_nla_tracks.last; + ((NlaTrack *)extracted_nonlocal_nla_tracks.last)->next = static_cast( + adt->nla_tracks.first); + ((NlaTrack *)adt->nla_tracks.first)->prev = static_cast( + extracted_nonlocal_nla_tracks.last); adt->nla_tracks.first = extracted_nonlocal_nla_tracks.first; } @@ -1421,9 +1433,9 @@ static void rearrange_driver_channels(bAnimContext *ac, { /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - ListBase anim_data_visible = {NULL, NULL}; + ListBase anim_data_visible = {nullptr, nullptr}; - if (rearrange_func == NULL) { + if (rearrange_func == nullptr) { return; } @@ -1450,22 +1462,22 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) { FCurve *fcu; - if (act == NULL) { + if (act == nullptr) { return; } /* Separate F-Curves into lists per group */ LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) { - FCurve *const group_fcurves_first = agrp->channels.first; - FCurve *const group_fcurves_last = agrp->channels.last; - if (group_fcurves_first == NULL) { + FCurve *const group_fcurves_first = static_cast(agrp->channels.first); + FCurve *const group_fcurves_last = static_cast(agrp->channels.last); + if (group_fcurves_first == nullptr) { /* Empty group. */ continue; } if (group_fcurves_first == act->curves.first) { /* First of the action curves, update the start of the action curves. */ - BLI_assert(group_fcurves_first->prev == NULL); + BLI_assert(group_fcurves_first->prev == nullptr); act->curves.first = group_fcurves_last->next; } else { @@ -1474,7 +1486,7 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) if (group_fcurves_last == act->curves.last) { /* Last of the action curves, update the end of the action curves. */ - BLI_assert(group_fcurves_last->next == NULL); + BLI_assert(group_fcurves_last->next == nullptr); act->curves.last = group_fcurves_first->prev; } else { @@ -1482,7 +1494,7 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) } /* Clear links pointing outside the per-group list. */ - group_fcurves_first->prev = group_fcurves_last->next = NULL; + group_fcurves_first->prev = group_fcurves_last->next = nullptr; } /* Initialize memory for temp-group */ @@ -1493,21 +1505,21 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) /* Move any action-channels not already moved, to the temp group */ if (act->curves.first) { /* start of list */ - fcu = act->curves.first; - fcu->prev = NULL; + fcu = static_cast(act->curves.first); + fcu->prev = nullptr; tgrp->channels.first = fcu; - act->curves.first = NULL; + act->curves.first = nullptr; /* end of list */ - fcu = act->curves.last; - fcu->next = NULL; + fcu = static_cast(act->curves.last); + fcu->next = nullptr; tgrp->channels.last = fcu; - act->curves.last = NULL; + act->curves.last = nullptr; /* ensure that all of these get their group set to this temp group * (so that visibility filtering works) */ - for (fcu = tgrp->channels.first; fcu; fcu = fcu->next) { + for (fcu = static_cast(tgrp->channels.first); fcu; fcu = fcu->next) { fcu->grp = tgrp; } } @@ -1521,7 +1533,7 @@ static void join_groups_action_temp(bAction *act) { bActionGroup *agrp; - for (agrp = act->groups.first; agrp; agrp = agrp->next) { + for (agrp = static_cast(act->groups.first); agrp; agrp = agrp->next) { /* add list of channels to action's channels */ const ListBase group_channels = agrp->channels; BLI_movelisttolist(&act->curves, &agrp->channels); @@ -1536,7 +1548,7 @@ static void join_groups_action_temp(bAction *act) */ if (agrp->flag & AGRP_TEMP) { LISTBASE_FOREACH (FCurve *, fcu, &agrp->channels) { - fcu->grp = NULL; + fcu->grp = nullptr; } BLI_remlink(&act->groups, agrp); @@ -1551,13 +1563,13 @@ static void join_groups_action_temp(bAction *act) static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrangeAnimChan_Mode mode) { bActionGroup tgrp; - ListBase anim_data_visible = {NULL, NULL}; + ListBase anim_data_visible = {nullptr, nullptr}; bool do_channels; /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - if (rearrange_func == NULL) { + if (rearrange_func == nullptr) { return; } @@ -1584,7 +1596,7 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE); - for (agrp = act->groups.first; agrp; agrp = agrp->next) { + for (agrp = static_cast(act->groups.first); agrp; agrp = agrp->next) { /* only consider F-Curves if they're visible (group expanded) */ if (EXPANDED_AGRP(ac, agrp)) { rearrange_animchannel_islands( @@ -1606,7 +1618,7 @@ static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode) { - ListBase anim_data_visible = {NULL, NULL}; + ListBase anim_data_visible = {nullptr, nullptr}; NlaTrack *nlt; NlaStrip *strip; @@ -1614,7 +1626,7 @@ static void rearrange_nla_control_channels(bAnimContext *ac, /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - if (rearrange_func == NULL) { + if (rearrange_func == nullptr) { return; } @@ -1627,8 +1639,8 @@ static void rearrange_nla_control_channels(bAnimContext *ac, rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE); /* we cannot rearrange between strips, but within each strip, we can rearrange those curves */ - for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { - for (strip = nlt->strips.first; strip; strip = strip->next) { + for (nlt = static_cast(adt->nla_tracks.first); nlt; nlt = nlt->next) { + for (strip = static_cast(nlt->strips.first); strip; strip = strip->next) { rearrange_animchannel_islands( &strip->fcurves, rearrange_func, mode, ANIMTYPE_NLACURVE, &anim_data_visible); } @@ -1642,30 +1654,31 @@ static void rearrange_nla_control_channels(bAnimContext *ac, static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode mode) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_gpencil_get_mode_func(mode); - if (rearrange_func == NULL) { + if (rearrange_func == nullptr) { return; } /* get Grease Pencil datablocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_LIST_CHANNELS); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { /* only consider grease pencil container channels */ if (!ELEM(ale->type, ANIMTYPE_GPDATABLOCK, ANIMTYPE_DSGPENCIL)) { continue; } - ListBase anim_data_visible = {NULL, NULL}; - bGPdata *gpd = ale->data; + ListBase anim_data_visible = {nullptr, nullptr}; + bGPdata *gpd = static_cast(ale->data); /* only consider layers if this datablock is open */ if ((gpd->flag & GP_DATA_EXPAND) == 0) { @@ -1689,7 +1702,7 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode /* free GPD channel data */ ANIM_animdata_freelist(&anim_data); - WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, nullptr); } /* ------------------- */ @@ -1705,7 +1718,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } /* get mode */ - mode = RNA_enum_get(op->ptr, "direction"); + mode = eRearrangeAnimChan_Mode(RNA_enum_get(op->ptr, "direction")); /* method to move channels depends on the editor */ if (ac.datatype == ANIMCONT_GPENCIL) { @@ -1718,10 +1731,10 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } else if (ac.datatype == ANIMCONT_ACTION) { /* Directly rearrange action's channels */ - rearrange_action_channels(&ac, ac.data, mode); + rearrange_action_channels(&ac, static_cast(ac.data), mode); } else { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -1732,10 +1745,11 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) /* get animdata blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); - for (ale = anim_data.first; ale; ale = ale->next) { - AnimData *adt = ale->data; + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { + AnimData *adt = static_cast(ale->data); switch (ac.datatype) { case ANIMCONT_NLA: /* NLA-tracks only */ @@ -1783,8 +1797,8 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ORDER, nullptr); return OPERATOR_FINISHED; } @@ -1825,7 +1839,7 @@ static bool animchannels_grouping_poll(bContext *C) /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, area, CTX_wm_region(C))) { + if (ELEM(nullptr, area, CTX_wm_region(C))) { return false; } @@ -1872,13 +1886,13 @@ static void animchannels_group_channels(bAnimContext *ac, bAction *act = adt->action; if (act) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; int filter; /* find selected F-Curves to re-group */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(ac, &anim_data, filter, adt_ref, ANIMCONT_CHANNEL); + ANIM_animdata_filter(ac, &anim_data, eAnimFilter_Flags(filter), adt_ref, ANIMCONT_CHANNEL); if (anim_data.first) { bActionGroup *agrp; @@ -1886,10 +1900,10 @@ static void animchannels_group_channels(bAnimContext *ac, /* create new group, which should now be part of the action */ agrp = action_groups_add_new(act, name); - BLI_assert(agrp != NULL); + BLI_assert(agrp != nullptr); /* Transfer selected F-Curves across to new group. */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; bActionGroup *grp = fcu->grp; @@ -1925,16 +1939,17 @@ static int animchannels_group_exec(bContext *C, wmOperator *op) /* XXX: name for group should never be empty... */ if (name[0]) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; /* Handle each animdata block separately, so that the regrouping doesn't flow into blocks. */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { animchannels_group_channels(&ac, ale, name); } @@ -1942,7 +1957,7 @@ static int animchannels_group_exec(bContext *C, wmOperator *op) ANIM_animdata_freelist(&anim_data); /* Updates. */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); } return OPERATOR_FINISHED; @@ -1967,7 +1982,7 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) ot->prop = RNA_def_string(ot->srna, "name", "New Group", - sizeof(((bActionGroup *)NULL)->name), + sizeof(((bActionGroup *)nullptr)->name), "Name", "Name of newly created group"); /* XXX: still not too sure about this - keeping same text is confusing... */ @@ -1980,11 +1995,11 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) /** \name Ungroup Channels Operator * \{ */ -static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) +static int animchannels_ungroup_exec(bContext *C, wmOperator * /*op*/) { bAnimContext ac; - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -1996,9 +2011,10 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) /* just selected F-Curves... */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { /* find action for this F-Curve... */ if (ale->adt && ale->adt->action) { FCurve *fcu = (FCurve *)ale->data; @@ -2024,7 +2040,7 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_animdata_freelist(&anim_data); /* updates */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -2057,9 +2073,9 @@ static void tag_update_animation_element(bAnimListElem *ale) /* TODO(sergey): Technically, if the animation element is being deleted * from a driver we don't have to tag action. This is something we can check * for in the future. For now just do most reliable tag which was always happening. */ - if (adt != NULL) { + if (adt != nullptr) { DEG_id_tag_update(id, ID_RECALC_ANIMATION); - if (adt->action != NULL) { + if (adt->action != nullptr) { DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION); } } @@ -2070,10 +2086,10 @@ static void tag_update_animation_element(bAnimListElem *ale) DEG_id_tag_update(id, ID_RECALC_ANIMATION); } -static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) +static int animchannels_delete_exec(bContext *C, wmOperator * /*op*/) { bAnimContext ac; - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -2092,10 +2108,11 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); /* delete selected groups and their associated channels */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { /* only groups - don't check other types yet, since they may no-longer exist */ if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp = (bActionGroup *)ale->data; @@ -2103,12 +2120,13 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) FCurve *fcu, *fcn; /* skip this group if no AnimData available, as we can't safely remove the F-Curves */ - if (adt == NULL) { + if (adt == nullptr) { continue; } /* delete all of the Group's F-Curves, but no others */ - for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) { + for (fcu = static_cast(agrp->channels.first); fcu && fcu->grp == agrp; fcu = fcn) + { fcn = fcu->next; /* remove from group and action, then free */ @@ -2134,10 +2152,11 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); /* delete selected data channels */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_FCURVE: { /* F-Curves if we can identify its parent */ @@ -2197,8 +2216,8 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_animdata_freelist(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr); DEG_relations_tag_update(CTX_data_main(C)); return OPERATOR_FINISHED; @@ -2231,7 +2250,7 @@ static const EnumPropertyItem prop_animchannel_setflag_types[] = { {ACHANNEL_SETFLAG_CLEAR, "DISABLE", 0, "Disable", ""}, {ACHANNEL_SETFLAG_ADD, "ENABLE", 0, "Enable", ""}, {ACHANNEL_SETFLAG_INVERT, "INVERT", 0, "Invert", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* defines for set animation-channel settings */ @@ -2239,7 +2258,7 @@ static const EnumPropertyItem prop_animchannel_setflag_types[] = { static const EnumPropertyItem prop_animchannel_settings_types[] = { {ACHANNEL_SETTING_PROTECT, "PROTECT", 0, "Protect", ""}, {ACHANNEL_SETTING_MUTE, "MUTE", 0, "Mute", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* ------------------- */ @@ -2258,8 +2277,8 @@ static void setflag_anim_channels(bAnimContext *ac, bool onlysel, bool flush) { - ListBase anim_data = {NULL, NULL}; - ListBase all_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; + ListBase all_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -2270,7 +2289,8 @@ static void setflag_anim_channels(bAnimContext *ac, * "down" inside closed containers */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; - ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &all_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); } /* filter data that we're working on @@ -2293,7 +2313,8 @@ static void setflag_anim_channels(bAnimContext *ac, if (onlysel) { filter |= ANIMFILTER_SEL; } - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); /* if toggling, check if disable or enable */ if (mode == ACHANNEL_SETFLAG_TOGGLE) { @@ -2301,7 +2322,7 @@ static void setflag_anim_channels(bAnimContext *ac, mode = ACHANNEL_SETFLAG_ADD; /* see if we should turn off instead... */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ if (ANIM_channel_setting_get(ac, ale, setting) > 0) { mode = ACHANNEL_SETFLAG_CLEAR; @@ -2311,7 +2332,7 @@ static void setflag_anim_channels(bAnimContext *ac, } /* apply the setting */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { /* skip channel if setting is not available */ if (ANIM_channel_setting_get(ac, ale, setting) == -1) { continue; @@ -2346,8 +2367,8 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) } /* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */ - mode = RNA_enum_get(op->ptr, "mode"); - setting = RNA_enum_get(op->ptr, "type"); + mode = eAnimChannels_SetFlag(RNA_enum_get(op->ptr, "mode")); + setting = eAnimChannel_Settings(RNA_enum_get(op->ptr, "type")); /* check if setting is flushable */ if (setting == ACHANNEL_SETTING_EXPAND) { @@ -2360,7 +2381,7 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) setflag_anim_channels(&ac, setting, mode, true, flush); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -2495,7 +2516,7 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op) setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -2544,7 +2565,7 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op) setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -2585,11 +2606,11 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) * 3) No drivers * \{ */ -static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) +static int animchannels_clean_empty_exec(bContext *C, wmOperator * /*op*/) { bAnimContext ac; - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -2601,24 +2622,25 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) /* get animdata blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_NODUPLIS); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { ID *id = ale->id; - AnimData *adt = ale->data; + AnimData *adt = static_cast(ale->data); bool action_empty = false; bool nla_empty = false; bool drivers_empty = false; /* sanity checks */ - BLI_assert((id != NULL) && (adt != NULL)); + BLI_assert((id != nullptr) && (adt != nullptr)); /* check if this is "empty" and can be deleted */ /* (For now, there are only these 3 criteria) */ /* 1) Active Action is missing or empty */ - if (ELEM(NULL, adt->action, adt->action->curves.first)) { + if (ELEM(nullptr, adt->action, adt->action->curves.first)) { action_empty = true; } else { @@ -2626,14 +2648,14 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) } /* 2) No NLA Tracks and/or NLA Strips */ - if (adt->nla_tracks.first == NULL) { + if (adt->nla_tracks.first == nullptr) { nla_empty = true; } else { NlaTrack *nlt; /* empty tracks? */ - for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + for (nlt = static_cast(adt->nla_tracks.first); nlt; nlt = nlt->next) { if (nlt->strips.first) { /* stop searching, as we found one that actually had stuff we don't want lost * NOTE: nla_empty gets reset to false, as a previous track may have been empty @@ -2641,7 +2663,7 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) nla_empty = false; break; } - if (nlt->strips.first == NULL) { + if (nlt->strips.first == nullptr) { /* this track is empty, but another one may still have stuff in it, so can't break yet */ nla_empty = true; } @@ -2649,7 +2671,7 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) } /* 3) Drivers */ - drivers_empty = (adt->drivers.first == NULL); + drivers_empty = (adt->drivers.first == nullptr); /* remove AnimData? */ if (action_empty && nla_empty && drivers_empty) { @@ -2661,8 +2683,8 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_animdata_freelist(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_REMOVED, nullptr); return OPERATOR_FINISHED; } @@ -2694,7 +2716,7 @@ static bool animchannels_enable_poll(bContext *C) /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ - if (ELEM(NULL, area, CTX_wm_region(C))) { + if (ELEM(nullptr, area, CTX_wm_region(C))) { return false; } @@ -2706,11 +2728,11 @@ static bool animchannels_enable_poll(bContext *C) return true; } -static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) +static int animchannels_enable_exec(bContext *C, wmOperator * /*op*/) { bAnimContext ac; - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -2721,10 +2743,11 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); /* loop through filtered data and clean curves */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; /* remove disabled flags from F-Curves */ @@ -2743,7 +2766,7 @@ static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_animdata_freelist(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -2774,7 +2797,7 @@ static bool animchannels_select_filter_poll(bContext *C) { ScrArea *area = CTX_wm_area(C); - if (area == NULL) { + if (area == nullptr) { return false; } @@ -2784,7 +2807,7 @@ static bool animchannels_select_filter_poll(bContext *C) static int animchannels_select_filter_invoke(bContext *C, wmOperator *op, - const wmEvent *UNUSED(event)) + const wmEvent * /*event*/) { ScrArea *area = CTX_wm_area(C); ARegion *region_ctx = CTX_wm_region(C); @@ -2808,8 +2831,8 @@ static int animchannels_select_filter_invoke(bContext *C, } static int animchannels_select_filter_modal(bContext *C, - wmOperator *UNUSED(op), - const wmEvent *UNUSED(event)) + wmOperator * /*op*/, + const wmEvent * /*event*/) { bAnimContext ac; if (ANIM_animdata_get_context(C, &ac) == 0) { @@ -2819,7 +2842,7 @@ static int animchannels_select_filter_modal(bContext *C, ARegion *region = CTX_wm_region(C); if (UI_textbutton_activate_rna(C, region, ac.ads, "filter_text")) { /* Redraw to make sure it shows the cursor after activating */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, nullptr); } return OPERATOR_FINISHED; @@ -2876,7 +2899,7 @@ static int animchannels_selectall_exec(bContext *C, wmOperator *op) } /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr); return OPERATOR_FINISHED; } @@ -2907,7 +2930,7 @@ static void ANIM_OT_channels_select_all(wmOperatorType *ot) static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectmode) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; @@ -2922,7 +2945,8 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); float ymax; if (ac->datatype == ANIMCONT_NLA) { @@ -2933,7 +2957,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm } /* loop over data, doing box select */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { float ymin; if (ale->type == ANIMTYPE_GPDATABLOCK) { @@ -2951,7 +2975,8 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm /* if channel is within border-select region, alter it */ if (ymax >= rectf.ymin && ymin <= rectf.ymax) { /* set selection flags only */ - ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); + ANIM_channel_setting_set( + ac, ale, ACHANNEL_SETTING_SELECT, eAnimChannels_SetFlag(selectmode)); /* type specific actions */ switch (ale->type) { @@ -3013,7 +3038,7 @@ static int animchannels_box_select_exec(bContext *C, wmOperator *op) box_select_anim_channels(&ac, &rect, selectmode); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, nullptr); return OPERATOR_FINISHED; } @@ -3050,7 +3075,7 @@ static void ANIM_OT_channels_select_box(wmOperatorType *ot) static bool rename_anim_channels(bAnimContext *ac, int channel_index) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; const bAnimChannelType *acf; bAnimListElem *ale; int filter; @@ -3062,11 +3087,12 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) if (ELEM(ac->datatype, ANIMCONT_FCURVES, ANIMCONT_NLA)) { filter |= ANIMFILTER_FCURVESONLY; } - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); /* Get channel that was clicked on from index. */ - ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { + ale = static_cast(BLI_findlink(&anim_data, channel_index)); + if (ale == nullptr) { /* channel not found */ if (G.debug & G_DEBUG) { printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", @@ -3078,13 +3104,13 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) } /* Don't allow renaming linked/liboverride channels. */ - if (ale->fcurve_owner_id != NULL && + if (ale->fcurve_owner_id != nullptr && (ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) { ANIM_animdata_freelist(&anim_data); return false; } - if (ale->id != NULL) { + if (ale->id != nullptr) { if (ID_IS_LINKED(ale->id)) { ANIM_animdata_freelist(&anim_data); return false; @@ -3156,7 +3182,7 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) NLACHANNEL_FIRST_TOP(ac), x, y, - NULL, + nullptr, &channel_index); } else { @@ -3166,14 +3192,14 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) ANIM_UI_get_first_channel_top(v2d), x, y, - NULL, + nullptr, &channel_index); } return channel_index; } -static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +static int animchannels_rename_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event) { bAnimContext ac; int channel_index; @@ -3187,7 +3213,7 @@ static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), const /* handle click */ if (rename_anim_channels(&ac, channel_index)) { - WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, nullptr); return OPERATOR_FINISHED; } @@ -3366,7 +3392,7 @@ static int click_select_channel_dummy(bAnimContext *ac, bAnimListElem *ale, const short /* eEditKeyframes_Select or -1 */ selectmode) { - if (ale->adt == NULL) { + if (ale->adt == nullptr) { return 0; } @@ -3399,8 +3425,8 @@ static int click_select_channel_group(bAnimContext *ac, const int filter) { bActionGroup *agrp = (bActionGroup *)ale->data; - Object *ob = NULL; - bPoseChannel *pchan = NULL; + Object *ob = nullptr; + bPoseChannel *pchan = nullptr; /* Armatures-Specific Feature: * Since groups are used to collect F-Curves of the same Bone by default @@ -3447,7 +3473,8 @@ static int click_select_channel_group(bAnimContext *ac, } /* only select channels in group and group itself */ - for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) { + for (fcu = static_cast(agrp->channels.first); fcu && fcu->grp == agrp; + fcu = fcu->next) { fcu->flag |= FCURVE_SELECTED; } agrp->flag |= AGRP_SELECTED; @@ -3466,7 +3493,12 @@ static int click_select_channel_group(bAnimContext *ac, * Similar to outliner, do not change active element when selecting elements in range. */ if (agrp->flag & AGRP_SELECTED) { if (selectmode != SELECT_EXTEND_RANGE) { - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); + ANIM_set_active_channel(ac, + ac->data, + eAnimCont_Types(ac->datatype), + eAnimFilter_Flags(filter), + agrp, + ANIMTYPE_GROUP); if (pchan) { ED_pose_bone_select(ob, pchan, true, true); } @@ -3474,7 +3506,12 @@ static int click_select_channel_group(bAnimContext *ac, } else { if (selectmode != SELECT_EXTEND_RANGE) { - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP); + ANIM_set_active_channel(ac, + ac->data, + eAnimCont_Types(ac->datatype), + eAnimFilter_Flags(filter), + nullptr, + ANIMTYPE_GROUP); if (pchan) { ED_pose_bone_select(ob, pchan, false, true); } @@ -3509,7 +3546,12 @@ static int click_select_channel_fcurve(bAnimContext *ac, /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list. * Similar to outliner, do not change active element when selecting elements in range. */ if ((fcu->flag & FCURVE_SELECTED) && (selectmode != SELECT_EXTEND_RANGE)) { - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type); + ANIM_set_active_channel(ac, + ac->data, + eAnimCont_Types(ac->datatype), + eAnimFilter_Flags(filter), + fcu, + eAnim_ChannelType(ale->type)); } return (ND_ANIMCHAN | NA_SELECTED); @@ -3589,7 +3631,12 @@ static int click_select_channel_gplayer(bContext *C, /* change active layer, if this is selected (since we must always have an active layer). * Similar to outliner, do not change active element when selecting elements in range. */ if ((gpl->flag & GP_LAYER_SELECT) && (selectmode != SELECT_EXTEND_RANGE)) { - ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER); + ANIM_set_active_channel(ac, + ac->data, + eAnimCont_Types(ac->datatype), + eAnimFilter_Flags(filter), + gpl, + ANIMTYPE_GPLAYER); /* update other layer status */ BKE_gpencil_layer_active_set(gpd, gpl); BKE_gpencil_layer_autolock_set(gpd, false); @@ -3597,7 +3644,7 @@ static int click_select_channel_gplayer(bContext *C, } /* Grease Pencil updates */ - WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED | ND_SPACE_PROPERTIES, nullptr); return (ND_ANIMCHAN | NA_EDITED); /* Animation Editors updates */ } @@ -3639,7 +3686,7 @@ static int mouse_anim_channels(bContext *C, const int channel_index, short /* eEditKeyframes_Select or -1 */ selectmode) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; int notifierFlags = 0; @@ -3651,11 +3698,12 @@ static int mouse_anim_channels(bContext *C, if (ELEM(area->spacetype, SPACE_NLA, SPACE_GRAPH)) { filter |= ANIMFILTER_FCURVESONLY; } - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); /* get channel from index */ - ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { + ale = static_cast(BLI_findlink(&anim_data, channel_index)); + if (ale == nullptr) { /* channel not found */ if (G.debug & G_DEBUG) { printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", @@ -3676,7 +3724,9 @@ static int mouse_anim_channels(bContext *C, } /* Change selection mode to single when no active element is found. */ - if ((selectmode == SELECT_EXTEND_RANGE) && !animchannel_has_active_of_type(ac, ale->type)) { + if ((selectmode == SELECT_EXTEND_RANGE) && + !animchannel_has_active_of_type(ac, eAnim_ChannelType(ale->type))) + { selectmode = SELECT_INVERT; } @@ -3803,14 +3853,14 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE ANIM_UI_get_first_channel_top(v2d), x, y, - NULL, + nullptr, &channel_index); /* handle mouse-click in the relevant channel then */ notifierFlags = mouse_anim_channels(C, &ac, channel_index, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); + WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, nullptr); return WM_operator_flag_only_pass_through_on_press(OPERATOR_FINISHED | OPERATOR_PASS_THROUGH, event); @@ -3853,7 +3903,7 @@ static void ANIM_OT_channels_click(wmOperatorType *ot) static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool extend) { - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; bool success = false; @@ -3864,11 +3914,12 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FCURVESONLY); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); /* get channel from index */ - ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { + ale = static_cast(BLI_findlink(&anim_data, channel_index)); + if (ale == nullptr) { /* channel not found */ if (G.debug & G_DEBUG) { printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", @@ -3880,7 +3931,7 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e } fcu = (FCurve *)ale->key_data; - success = (fcu != NULL); + success = (fcu != nullptr); ANIM_animdata_freelist(&anim_data); @@ -3890,11 +3941,12 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e if (!extend) { filter = (ANIMFILTER_DATA_VISIBLE); - ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale = anim_data.first; ale; ale = ale->next) { + ANIM_animdata_filter( + ac, &anim_data, eAnimFilter_Flags(filter), ac->data, eAnimCont_Types(ac->datatype)); + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { FCurve *fcu_inner = (FCurve *)ale->key_data; - if (fcu_inner != NULL && fcu_inner->bezt != NULL) { + if (fcu_inner != nullptr && fcu_inner->bezt != nullptr) { for (i = 0, bezt = fcu_inner->bezt; i < fcu_inner->totvert; i++, bezt++) { bezt->f2 = bezt->f1 = bezt->f3 = 0; } @@ -3931,7 +3983,7 @@ static int animchannels_channel_select_keys_invoke(bContext *C, /* handle click */ if (select_anim_channel_keys(&ac, channel_index, extend)) { - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr); return OPERATOR_FINISHED; } @@ -3990,10 +4042,11 @@ static int graphkeys_view_selected_channels_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; const int filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS | ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - size_t anim_data_length = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + size_t anim_data_length = ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); if (anim_data_length == 0) { WM_report(RPT_WARNING, "No channels to operate on"); @@ -4004,13 +4057,17 @@ static int graphkeys_view_selected_channels_exec(bContext *C, wmOperator *op) const bool use_preview_range = RNA_boolean_get(op->ptr, "use_preview_range"); get_view_range(ac.scene, use_preview_range, range); - rctf bounds = {.xmin = FLT_MAX, .xmax = -FLT_MAX, .ymin = FLT_MAX, .ymax = -FLT_MAX}; + rctf bounds{}; + bounds.xmin = FLT_MAX; + bounds.xmax = -FLT_MAX; + bounds.ymin = FLT_MAX; + bounds.ymax = -FLT_MAX; bAnimListElem *ale; const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); bool valid_bounds = false; - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { rctf channel_bounds; const bool found_bounds = get_channel_bounds( &ac, ale, range, include_handles, &channel_bounds); @@ -4086,15 +4143,16 @@ static int graphkeys_channel_view_pick_invoke(bContext *C, wmOperator *op, const return OPERATOR_CANCELLED; } - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS | ANIMFILTER_LIST_CHANNELS); - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); bAnimListElem *ale; const int channel_index = animchannels_channel_get(&ac, event->mval); - ale = BLI_findlink(&anim_data, channel_index); - if (ale == NULL) { + ale = static_cast(BLI_findlink(&anim_data, channel_index)); + if (ale == nullptr) { ANIM_animdata_freelist(&anim_data); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.cc similarity index 89% rename from source/blender/editors/animation/anim_deps.c rename to source/blender/editors/animation/anim_deps.cc index 7f8b4b7d794..fd186012d61 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.cc @@ -57,7 +57,7 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale) adt = BKE_animdata_from_id(id); if (adt) { DEG_id_tag_update(id, ID_RECALC_ANIMATION); - if (adt->action != NULL) { + if (adt->action != nullptr) { DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION); } } @@ -70,7 +70,7 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale) } /* update data */ - fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL; + fcu = static_cast((ale->datatype == ALE_FCURVE) ? ale->key_data : nullptr); if (fcu && fcu->rna_path) { /* If we have an fcurve, call the update for the property we @@ -88,8 +88,7 @@ void ANIM_list_elem_update(Main *bmain, Scene *scene, bAnimListElem *ale) else { /* in other case we do standard depsgraph update, ideally * we'd be calling property update functions here too ... */ - DEG_id_tag_update(id, - /* XXX: or do we want something more restrictive? */ + DEG_id_tag_update(id, /* XXX: or do we want something more restrictive? */ ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); } } @@ -98,8 +97,7 @@ void ANIM_id_update(Main *bmain, ID *id) { if (id) { DEG_id_tag_update_ex(bmain, - id, - /* XXX: or do we want something more restrictive? */ + id, /* XXX: or do we want something more restrictive? */ ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); } } @@ -123,7 +121,7 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro /* major priority is selection status * so we need both a group and an owner */ - if (ELEM(NULL, agrp, owner_id)) { + if (ELEM(nullptr, agrp, owner_id)) { return; } @@ -137,7 +135,7 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro */ if (ob->pose) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); if (pchan) { bActionGroup *bgrp; @@ -153,7 +151,7 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro /* also sync active group status */ if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { /* if no previous F-Curve has active flag, then we're the first and only one to get it */ - if (*active_agrp == NULL) { + if (*active_agrp == nullptr) { agrp->flag |= AGRP_ACTIVE; *active_agrp = agrp; } @@ -184,7 +182,7 @@ static void animchan_sync_fcurve_scene(bAnimListElem *ale) BLI_assert(GS(owner_id->name) == ID_SCE); Scene *scene = (Scene *)owner_id; FCurve *fcu = (FCurve *)ale->data; - Sequence *seq = NULL; + Sequence *seq = nullptr; /* Only affect if F-Curve involves sequence_editor.sequences. */ char seq_name[sizeof(seq->name)]; @@ -195,7 +193,7 @@ static void animchan_sync_fcurve_scene(bAnimListElem *ale) /* Check if this strip is selected. */ Editing *ed = SEQ_editing_get(scene); seq = SEQ_get_sequence_by_name(ed->seqbasep, seq_name, false); - if (seq == NULL) { + if (seq == nullptr) { return; } @@ -217,7 +215,7 @@ static void animchan_sync_fcurve(bAnimListElem *ale) /* major priority is selection status, so refer to the checks done in anim_filter.c * skip_fcurve_selected_data() for reference about what's going on here... */ - if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) { + if (ELEM(nullptr, fcu, fcu->rna_path, owner_id)) { return; } @@ -257,11 +255,11 @@ static void animchan_sync_gplayer(bAnimListElem *ale) void ANIM_sync_animchannels_to_data(const bContext *C) { bAnimContext ac; - ListBase anim_data = {NULL, NULL}; + ListBase anim_data = {nullptr, nullptr}; bAnimListElem *ale; int filter; - bActionGroup *active_agrp = NULL; + bActionGroup *active_agrp = nullptr; /* get animation context info for filtering the channels */ if (ANIM_animdata_get_context(C, &ac) == 0) { @@ -275,10 +273,11 @@ void ANIM_sync_animchannels_to_data(const bContext *C) * don't include duplicates so that selection statuses don't override each other. */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS; - ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + ANIM_animdata_filter( + &ac, &anim_data, eAnimFilter_Flags(filter), ac.data, eAnimCont_Types(ac.datatype)); /* flush settings as appropriate depending on the types of the channels */ - for (ale = anim_data.first; ale; ale = ale->next) { + for (ale = static_cast(anim_data.first); ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_GROUP: animchan_sync_group(&ac, ale, &active_agrp); @@ -301,14 +300,14 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) { bAnimListElem *ale; - for (ale = anim_data->first; ale; ale = ale->next) { + for (ale = static_cast(anim_data->first); ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { - bGPDlayer *gpl = ale->data; + bGPDlayer *gpl = static_cast(ale->data); if (ale->update & ANIM_UPDATE_ORDER) { ale->update &= ~ANIM_UPDATE_ORDER; if (gpl) { - BKE_gpencil_layer_frames_sort(gpl, NULL); + BKE_gpencil_layer_frames_sort(gpl, nullptr); } } @@ -322,7 +321,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) } } else if (ale->datatype == ALE_MASKLAY) { - MaskLayer *masklay = ale->data; + MaskLayer *masklay = static_cast(ale->data); if (ale->update & ANIM_UPDATE_ORDER) { ale->update &= ~ANIM_UPDATE_ORDER; @@ -343,7 +342,7 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) } } else if (ale->datatype == ALE_FCURVE) { - FCurve *fcu = ale->key_data; + FCurve *fcu = static_cast(ale->key_data); if (ale->update & ANIM_UPDATE_ORDER) { ale->update &= ~ANIM_UPDATE_ORDER; @@ -397,7 +396,7 @@ void ANIM_animdata_freelist(ListBase *anim_data) { #ifndef NDEBUG bAnimListElem *ale, *ale_next; - for (ale = anim_data->first; ale; ale = ale_next) { + for (ale = static_cast(anim_data->first); ale; ale = ale_next) { ale_next = ale->next; BLI_assert(ale->update == 0); MEM_freeN(ale); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.cc similarity index 98% rename from source/blender/editors/animation/anim_draw.c rename to source/blender/editors/animation/anim_draw.cc index 78a2c476b43..3dfcffe4f8e 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.cc @@ -217,13 +217,13 @@ void ANIM_draw_action_framerange( AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) { /* sanity checks */ - if (ac == NULL) { - return NULL; + if (ac == nullptr) { + return nullptr; } /* abort if rendering - we may get some race condition issues... */ if (G.is_rendering) { - return NULL; + return nullptr; } /* apart from strictly keyframe-related contexts, this shouldn't even happen */ @@ -248,7 +248,7 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) } /* cannot handle... */ - return NULL; + return nullptr; } /* ------------------- */ @@ -293,7 +293,7 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt) void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, bool only_keys) { - KeyframeEditData ked = {{NULL}}; + KeyframeEditData ked = {{nullptr}}; KeyframeEditFunc map_cb; /* init edit data @@ -312,7 +312,7 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, boo } /* apply to F-Curve */ - ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL); + ANIM_fcurve_keyframes_loop(&ked, fcu, nullptr, map_cb, nullptr); } /* *************************************************** */ @@ -565,7 +565,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Mask *mask = CTX_data_edit_mask(C); - bDopeSheet ads = {NULL}; + bDopeSheet ads = {nullptr}; struct AnimKeylist *keylist = ED_keylist_create(); const ActKeyColumn *aknext, *akprev; float cfranext, cfraprev; @@ -586,7 +586,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra if (ob) { ob_to_keylist(&ads, ob, keylist, 0); - gpencil_to_keylist(&ads, ob->data, keylist, false); + gpencil_to_keylist(&ads, static_cast(ob->data), keylist, false); } if (mask) { @@ -613,7 +613,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra } cfranext = aknext->cfra; } - } while ((aknext != NULL) && (donenext == false)); + } while ((aknext != nullptr) && (donenext == false)); do { akprev = ED_keylist_find_prev(keylist, cfraprev); @@ -630,7 +630,7 @@ static bool find_prev_next_keyframes(bContext *C, int *r_nextfra, int *r_prevfra } cfraprev = akprev->cfra; } - } while ((akprev != NULL) && (doneprev == false)); + } while ((akprev != nullptr) && (doneprev == false)); /* free temp stuff */ ED_keylist_free(keylist); diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index 7987ac9e43a..130b95bd10f 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /* KeyingSets/Keyframing Interface ------------- */ /* list of builtin KeyingSets (defined in keyingsets.c) */ @@ -92,3 +96,7 @@ void ANIM_OT_copy_driver_button(struct wmOperatorType *ot); void ANIM_OT_paste_driver_button(struct wmOperatorType *ot); /** \} */ + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.cc similarity index 96% rename from source/blender/editors/animation/anim_ipo_utils.c rename to source/blender/editors/animation/anim_ipo_utils.cc index 91fbbea4c83..7c2b911312f 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.cc @@ -38,18 +38,18 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) int icon = 0; /* sanity checks */ - if (name == NULL) { + if (name == nullptr) { return icon; } - if (ELEM(NULL, id, fcu, fcu->rna_path)) { - if (fcu == NULL) { + if (ELEM(nullptr, id, fcu, fcu->rna_path)) { + if (fcu == nullptr) { BLI_strncpy(name, TIP_(""), name_maxncpy); } - else if (fcu->rna_path == NULL) { + else if (fcu->rna_path == nullptr) { BLI_strncpy(name, TIP_(""), name_maxncpy); } - else { /* id == NULL */ + else { /* id == nullptr */ BLI_snprintf(name, name_maxncpy, "%s[%d]", fcu->rna_path, fcu->array_index); } } @@ -62,9 +62,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* try to resolve the path */ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { - const char *structname = NULL, *propname = NULL; + const char *structname = nullptr, *propname = nullptr; char arrayindbuf[16]; - const char *arrayname = NULL; + const char *arrayname = nullptr; short free_structname = 0; /* For now, name will consist of 3 parts: struct-name, property name, array index @@ -102,7 +102,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) PropertyRNA *nameprop = RNA_struct_name_property(ptr.type); if (nameprop) { /* this gets a string which will need to be freed */ - structname = RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL); + structname = RNA_property_string_get_alloc(&ptr, nameprop, nullptr, 0, nullptr); free_structname = 1; } else { diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.cc similarity index 86% rename from source/blender/editors/animation/anim_markers.c rename to source/blender/editors/animation/anim_markers.cc index 7570fca4d78..e58c876c4df 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.cc @@ -95,7 +95,7 @@ ListBase *ED_animcontext_get_markers(const bAnimContext *ac) if (ac) { return context_get_markers(ac->scene, ac->area); } - return NULL; + return nullptr; } /* --------------------------------- */ @@ -108,12 +108,12 @@ int ED_markers_post_apply_transform( int changed_tot = 0; /* sanity check - no markers, or locked markers */ - if ((scene->toolsettings->lock_markers) || (markers == NULL)) { + if ((scene->toolsettings->lock_markers) || (markers == nullptr)) { return changed_tot; } /* affect selected markers - it's unlikely that we will want to affect all in this way? */ - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->flag & SELECT) { switch (mode) { case TFM_TIME_TRANSLATE: @@ -144,11 +144,11 @@ int ED_markers_post_apply_transform( TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x) { - TimeMarker *marker, *nearest = NULL; + TimeMarker *marker, *nearest = nullptr; float dist, min_dist = 1000000; if (markers) { - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { dist = fabsf((float)marker->frame - x); if (dist < min_dist) { @@ -174,7 +174,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float * /* sanity check */ // printf("markers = %p - %p, %p\n", markers, markers->first, markers->last); - if (ELEM(NULL, markers, markers->first, markers->last)) { + if (ELEM(nullptr, markers, markers->first, markers->last)) { *r_first = 0.0f; *r_last = 0.0f; return; @@ -182,7 +182,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float * min = FLT_MAX; max = -FLT_MAX; - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (!sel || (marker->flag & SELECT)) { if (marker->frame < min) { min = (float)marker->frame; @@ -205,34 +205,34 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *r_first, float * static bool ED_operator_markers_region_active(bContext *C) { ScrArea *area = CTX_wm_area(C); - if (area == NULL) { + if (area == nullptr) { return false; } switch (area->spacetype) { case SPACE_ACTION: { - SpaceAction *saction = area->spacedata.first; + SpaceAction *saction = static_cast(area->spacedata.first); if (saction->flag & SACTION_SHOW_MARKERS) { return true; } break; } case SPACE_GRAPH: { - SpaceGraph *sipo = area->spacedata.first; + SpaceGraph *sipo = static_cast(area->spacedata.first); if (sipo->mode != SIPO_MODE_DRIVERS && sipo->flag & SIPO_SHOW_MARKERS) { return true; } break; } case SPACE_NLA: { - SpaceNla *snla = area->spacedata.first; + SpaceNla *snla = static_cast(area->spacedata.first); if (snla->flag & SNLA_SHOW_MARKERS) { return true; } break; } case SPACE_SEQ: { - SpaceSeq *seq = area->spacedata.first; + SpaceSeq *seq = static_cast(area->spacedata.first); if (seq->flag & SEQ_SHOW_MARKERS) { return true; } @@ -244,7 +244,7 @@ static bool ED_operator_markers_region_active(bContext *C) static bool region_position_is_over_marker(View2D *v2d, ListBase *markers, float region_x) { - if (markers == NULL || BLI_listbase_is_empty(markers)) { + if (markers == nullptr || BLI_listbase_is_empty(markers)) { return false; } @@ -269,7 +269,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only } /* insertion sort - try to find a previous cfra elem */ - for (ce = lb->first; ce; ce = ce->next) { + for (ce = static_cast(lb->first); ce; ce = ce->next) { if (ce->cfra == marker->frame) { /* do because of double keys */ if (marker->flag & SELECT) { @@ -282,7 +282,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only } } - cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); + cen = static_cast(MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem")); if (ce) { BLI_insertlinkbefore(lb, ce, cen); } @@ -303,17 +303,17 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) * whether this terminated early otherwise. This may lead * to crashes if the user didn't clear the memory first. */ - lb->first = lb->last = NULL; + lb->first = lb->last = nullptr; } else { return; } - if (markers == NULL) { + if (markers == nullptr) { return; } - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { add_marker_to_cfra_elem(lb, marker, only_sel); } } @@ -347,14 +347,14 @@ TimeMarker *ED_markers_get_first_selected(ListBase *markers) TimeMarker *marker; if (markers) { - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->flag & SELECT) { return marker; } } } - return NULL; + return nullptr; } /* --------------------------------- */ @@ -366,14 +366,14 @@ void debug_markers_print_list(ListBase *markers) TimeMarker *marker; - if (markers == NULL) { + if (markers == nullptr) { printf("No markers list to print debug for\n"); return; } printf("List of markers follows: -----\n"); - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { printf( "\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag); } @@ -422,13 +422,15 @@ static void draw_marker_name(const uchar *text_color, #endif const int icon_half_width = UI_ICON_SIZE * 0.6; - const struct uiFontStyleDraw_Params fs_params = {.align = UI_STYLE_TEXT_LEFT, .word_wrap = 0}; - const rcti rect = { - .xmin = marker_x + icon_half_width, - .xmax = xmax - icon_half_width, - .ymin = text_y, - .ymax = text_y, - }; + uiFontStyleDraw_Params fs_params{}; + fs_params.align = UI_STYLE_TEXT_LEFT; + fs_params.word_wrap = 0; + + rcti rect{}; + rect.xmin = marker_x + icon_half_width; + rect.xmax = xmax - icon_half_width; + rect.ymin = text_y; + rect.ymax = text_y; UI_fontstyle_draw(fstyle, &rect, name, strlen(name), final_text_color, &fs_params); } @@ -540,14 +542,14 @@ static void get_marker_region_rect(View2D *v2d, rctf *rect) static void get_marker_clip_frame_range(View2D *v2d, float xscale, int r_range[2]) { float font_width_max = (10 * UI_SCALE_FAC) / xscale; - r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)NULL)->name) * font_width_max; + r_range[0] = v2d->cur.xmin - sizeof(((TimeMarker *)nullptr)->name) * font_width_max; r_range[1] = v2d->cur.xmax + font_width_max; } static int markers_frame_sort(const void *a, const void *b) { - const TimeMarker *marker_a = a; - const TimeMarker *marker_b = b; + const TimeMarker *marker_a = static_cast(a); + const TimeMarker *marker_b = static_cast(b); return marker_a->frame > marker_b->frame; } @@ -555,7 +557,7 @@ static int markers_frame_sort(const void *a, const void *b) void ED_markers_draw(const bContext *C, int flag) { ListBase *markers = ED_context_get_markers(C); - if (markers == NULL || BLI_listbase_is_empty(markers)) { + if (markers == nullptr || BLI_listbase_is_empty(markers)) { return; } @@ -595,7 +597,7 @@ void ED_markers_draw(const bContext *C, int flag) LISTBASE_FOREACH (TimeMarker *, marker, &sorted_markers) { const bool is_elevated = (marker->flag & SELECT) || (cfra >= marker->frame && - (marker->next == NULL || cfra < marker->next->frame)); + (marker->next == nullptr || cfra < marker->next->frame)); SET_FLAG_FROM_TEST(marker->flag, is_elevated, ELEVATED); } @@ -616,7 +618,7 @@ void ED_markers_draw(const bContext *C, int flag) } /* Now draw the elevated markers */ - for (TimeMarker *marker = sorted_markers.first; marker != NULL;) { + for (TimeMarker *marker = static_cast(sorted_markers.first); marker != nullptr;) { /* Skip this marker if it is elevated or out of the frame range. */ if ((marker->flag & ELEVATED) == 0 || !marker_is_in_frame_range(marker, clip_frame_range)) { @@ -627,7 +629,7 @@ void ED_markers_draw(const bContext *C, int flag) /* Find the next elevated marker. */ /* We use the next marker to determine how wide our text should be */ TimeMarker *next_marker = marker->next; - while (next_marker != NULL && (next_marker->flag & ELEVATED) == 0) { + while (next_marker != nullptr && (next_marker->flag & ELEVATED) == 0) { next_marker = next_marker->next; } @@ -669,7 +671,7 @@ static bool ed_markers_poll_selected_markers(bContext *C) } /* check if some marker is selected */ - if (ED_markers_get_first_selected(markers) == NULL) { + if (ED_markers_get_first_selected(markers) == nullptr) { CTX_wm_operator_poll_msg_set(C, "No markers are selected"); return false; } @@ -692,7 +694,7 @@ static bool ed_markers_poll_selected_no_locked_markers(bContext *C) } /* check if some marker is selected */ - if (ED_markers_get_first_selected(markers) == NULL) { + if (ED_markers_get_first_selected(markers) == nullptr) { CTX_wm_operator_poll_msg_set(C, "No markers are selected"); return false; } @@ -721,37 +723,37 @@ static bool ed_markers_poll_markers_exist(bContext *C) * \{ */ /* add TimeMarker at current frame */ -static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op)) +static int ed_marker_add_exec(bContext *C, wmOperator * /*op*/) { ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; int frame = CTX_data_scene(C)->r.cfra; - if (markers == NULL) { + if (markers == nullptr) { return OPERATOR_CANCELLED; } /* prefer not having 2 markers at the same place, * though the user can move them to overlap once added */ - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->frame == frame) { return OPERATOR_CANCELLED; } } /* deselect all */ - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { marker->flag &= ~SELECT; } - marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); + marker = static_cast(MEM_callocN(sizeof(TimeMarker), "TimeMarker")); marker->flag = SELECT; marker->frame = frame; SNPRINTF(marker->name, "F_%02d", frame); /* XXX: temp code only. */ BLI_addtail(markers, marker); - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); return OPERATOR_FINISHED; } @@ -799,13 +801,13 @@ static void MARKER_OT_add(wmOperatorType *ot) * modal() accept modal events while doing it, ends with apply and exit, or cancel */ -typedef struct MarkerMove { +struct MarkerMove { SpaceLink *slink; ListBase *markers; short event_type, event_val; /* store invoke-event, to verify */ int *oldframe, evtx, firstx; NumInput num; -} MarkerMove; +}; static bool ed_marker_move_use_time(MarkerMove *mm) { @@ -825,15 +827,17 @@ static bool ed_marker_move_use_time(MarkerMove *mm) static void ed_marker_move_update_header(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - MarkerMove *mm = op->customdata; - TimeMarker *marker, *selmarker = NULL; + MarkerMove *mm = static_cast(op->customdata); + TimeMarker *marker, *selmarker = nullptr; const int ofs = RNA_int_get(op->ptr, "frames"); char str[UI_MAX_DRAW_STR]; char str_ofs[NUM_STR_REP_LEN]; int totmark; const bool use_time = ed_marker_move_use_time(mm); - for (totmark = 0, marker = mm->markers->first; marker; marker = marker->next) { + for (totmark = 0, marker = static_cast(mm->markers->first); marker; + marker = marker->next) + { if (marker->flag & SELECT) { selmarker = marker; totmark++; @@ -876,11 +880,13 @@ static bool ed_marker_move_init(bContext *C, wmOperator *op) TimeMarker *marker; int a, totmark; - if (markers == NULL) { + if (markers == nullptr) { return false; } - for (totmark = 0, marker = markers->first; marker; marker = marker->next) { + for (totmark = 0, marker = static_cast(markers->first); marker; + marker = marker->next) + { if (marker->flag & SELECT) { totmark++; } @@ -890,10 +896,10 @@ static bool ed_marker_move_init(bContext *C, wmOperator *op) return false; } - op->customdata = mm = MEM_callocN(sizeof(MarkerMove), "Markermove"); + op->customdata = mm = static_cast(MEM_callocN(sizeof(MarkerMove), "Markermove")); mm->slink = CTX_wm_space_data(C); mm->markers = markers; - mm->oldframe = MEM_callocN(totmark * sizeof(int), "MarkerMove oldframe"); + mm->oldframe = static_cast(MEM_callocN(totmark * sizeof(int), "MarkerMove oldframe")); initNumInput(&mm->num); mm->num.idx_max = 0; /* one axis */ @@ -902,7 +908,7 @@ static bool ed_marker_move_init(bContext *C, wmOperator *op) /* No time unit supporting frames currently... */ mm->num.unit_type[0] = ed_marker_move_use_time(mm) ? B_UNIT_TIME : B_UNIT_NONE; - for (a = 0, marker = markers->first; marker; marker = marker->next) { + for (a = 0, marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->flag & SELECT) { mm->oldframe[a] = marker->frame; a++; @@ -915,15 +921,15 @@ static bool ed_marker_move_init(bContext *C, wmOperator *op) /* free stuff */ static void ed_marker_move_exit(bContext *C, wmOperator *op) { - MarkerMove *mm = op->customdata; + MarkerMove *mm = static_cast(op->customdata); /* free data */ MEM_freeN(mm->oldframe); MEM_freeN(op->customdata); - op->customdata = NULL; + op->customdata = nullptr; /* clear custom header prints */ - ED_area_status_text(CTX_wm_area(C), NULL); + ED_area_status_text(CTX_wm_area(C), nullptr); } static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -941,7 +947,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve } if (ed_marker_move_init(C, op)) { - MarkerMove *mm = op->customdata; + MarkerMove *mm = static_cast(op->customdata); mm->evtx = event->xy[0]; mm->firstx = event->xy[0]; @@ -970,20 +976,21 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *camera = scene->camera; #endif - MarkerMove *mm = op->customdata; + MarkerMove *mm = static_cast(op->customdata); TimeMarker *marker; int a, ofs; ofs = RNA_int_get(op->ptr, "frames"); - for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { + for (a = 0, marker = static_cast(mm->markers->first); marker; + marker = marker->next) { if (marker->flag & SELECT) { marker->frame = mm->oldframe[a] + ofs; a++; } } - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); #ifdef DURIAN_CAMERA_SWITCH /* so we get view3d redraws */ @@ -1007,7 +1014,7 @@ static void ed_marker_move_cancel(bContext *C, wmOperator *op) static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); - MarkerMove *mm = op->customdata; + MarkerMove *mm = static_cast(op->customdata); View2D *v2d = UI_view2d_fromcontext(C); const bool has_numinput = hasNumInput(&mm->num); const bool use_time = ed_marker_move_use_time(mm); @@ -1046,8 +1053,8 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, const wmEvent *even case MIDDLEMOUSE: if (WM_event_is_modal_drag_exit(event, mm->event_type, mm->event_val)) { ed_marker_move_exit(C, op); - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); return OPERATOR_FINISHED; } break; @@ -1158,20 +1165,20 @@ static void ed_marker_duplicate_apply(bContext *C) ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *newmarker; - if (markers == NULL) { + if (markers == nullptr) { return; } /* go through the list of markers, duplicate selected markers and add duplicated copies * to the beginning of the list (unselect original markers) */ - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->flag & SELECT) { /* unselect selected marker */ marker->flag &= ~SELECT; /* create and set up new marker */ - newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); + newmarker = static_cast(MEM_callocN(sizeof(TimeMarker), "TimeMarker")); newmarker->flag = SELECT; newmarker->frame = marker->frame; STRNCPY(newmarker->name, marker->name); @@ -1180,7 +1187,7 @@ static void ed_marker_duplicate_apply(bContext *C) newmarker->camera = marker->camera; #endif - if (marker->prop != NULL) { + if (marker->prop != nullptr) { newmarker->prop = IDP_CopyProperty(marker->prop); } @@ -1246,7 +1253,7 @@ static int select_timeline_marker_frame(ListBase *markers, bool extend, bool wait_to_deselect_others) { - TimeMarker *marker, *marker_cycle_selected = NULL; + TimeMarker *marker, *marker_cycle_selected = nullptr; int ret_val = OPERATOR_FINISHED; if (extend) { @@ -1254,10 +1261,11 @@ static int select_timeline_marker_frame(ListBase *markers, } /* support for selection cycling */ - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->frame == frame) { if (marker->flag & SELECT) { - marker_cycle_selected = marker->next ? marker->next : markers->first; + marker_cycle_selected = static_cast(marker->next ? marker->next : + markers->first); break; } } @@ -1301,7 +1309,7 @@ static void select_marker_camera_switch( BKE_view_layer_base_deselect_all(scene, view_layer); } - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->frame == cfra) { sel = (marker->flag & SELECT); break; @@ -1309,12 +1317,12 @@ static void select_marker_camera_switch( } BKE_view_layer_synced_ensure(scene, view_layer); - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->camera) { if (marker->frame == cfra) { base = BKE_view_layer_base_find(view_layer, marker->camera); if (base) { - ED_object_base_select(base, sel); + ED_object_base_select(base, eObjectSelect_Mode(sel)); if (sel) { ED_object_base_activate(C, base); } @@ -1349,8 +1357,8 @@ static int ed_marker_select( deselect_markers(markers); } - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); /* allowing tweaks, but needs OPERATOR_FINISHED, otherwise renaming fails, see #25987. */ return ret_val | OPERATOR_PASS_THROUGH; @@ -1458,11 +1466,11 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op) WM_operator_properties_border_to_rctf(op, &rect); UI_view2d_region_to_view_rctf(v2d, &rect, &rect); - if (markers == NULL) { + if (markers == nullptr) { return 0; } - const eSelectOp sel_op = RNA_enum_get(op->ptr, "mode"); + const eSelectOp sel_op = eSelectOp(RNA_enum_get(op->ptr, "mode")); const bool select = (sel_op != SEL_OP_SUB); if (SEL_OP_USE_PRE_DESELECT(sel_op)) { ED_markers_deselect_all(markers, SEL_DESELECT); @@ -1474,8 +1482,8 @@ static int ed_marker_box_select_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); return 1; } @@ -1516,15 +1524,15 @@ static void MARKER_OT_select_box(wmOperatorType *ot) static int ed_marker_select_all_exec(bContext *C, wmOperator *op) { ListBase *markers = ED_context_get_markers(C); - if (markers == NULL) { + if (markers == nullptr) { return OPERATOR_CANCELLED; } int action = RNA_enum_get(op->ptr, "action"); ED_markers_deselect_all(markers, action); - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); return OPERATOR_FINISHED; } @@ -1553,15 +1561,15 @@ static void MARKER_OT_select_all(wmOperatorType *ot) /** \name Select Left/Right of Frame * \{ */ -typedef enum eMarkers_LeftRightSelect_Mode { +enum eMarkers_LeftRightSelect_Mode { MARKERS_LRSEL_LEFT = 0, MARKERS_LRSEL_RIGHT, -} eMarkers_LeftRightSelect_Mode; +}; static const EnumPropertyItem prop_markers_select_leftright_modes[] = { {MARKERS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""}, {MARKERS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static void ED_markers_select_leftright(bAnimContext *ac, @@ -1571,7 +1579,7 @@ static void ED_markers_select_leftright(bAnimContext *ac, ListBase *markers = ac->markers; Scene *scene = ac->scene; - if (markers == NULL) { + if (markers == nullptr) { return; } @@ -1590,7 +1598,8 @@ static void ED_markers_select_leftright(bAnimContext *ac, static int ed_marker_select_leftright_exec(bContext *C, wmOperator *op) { - const eMarkers_LeftRightSelect_Mode mode = RNA_enum_get(op->ptr, "mode"); + const eMarkers_LeftRightSelect_Mode mode = eMarkers_LeftRightSelect_Mode( + RNA_enum_get(op->ptr, "mode")); const bool extend = RNA_boolean_get(op->ptr, "extend"); bAnimContext ac; @@ -1600,7 +1609,7 @@ static int ed_marker_select_leftright_exec(bContext *C, wmOperator *op) ED_markers_select_leftright(&ac, mode, extend); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, nullptr); return OPERATOR_FINISHED; } @@ -1633,21 +1642,21 @@ static void MARKER_OT_select_leftright(wmOperatorType *ot) * Remove selected time-markers. * \{ */ -static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) +static int ed_marker_delete_exec(bContext *C, wmOperator * /*op*/) { ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *nmarker; bool changed = false; - if (markers == NULL) { + if (markers == nullptr) { return OPERATOR_CANCELLED; } - for (marker = markers->first; marker; marker = nmarker) { + for (marker = static_cast(markers->first); marker; marker = nmarker) { nmarker = marker->next; if (marker->flag & SELECT) { - if (marker->prop != NULL) { + if (marker->prop != nullptr) { IDP_FreePropertyContent(marker->prop); MEM_freeN(marker->prop); } @@ -1657,8 +1666,8 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) } if (changed) { - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); } return OPERATOR_FINISHED; @@ -1696,8 +1705,8 @@ static int ed_marker_rename_exec(bContext *C, wmOperator *op) if (marker) { RNA_string_get(op->ptr, "name", marker->name); - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); return OPERATOR_FINISHED; } @@ -1735,15 +1744,11 @@ static void MARKER_OT_rename(wmOperatorType *ot) ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", - sizeof(((TimeMarker *)NULL)->name), + sizeof(((TimeMarker *)nullptr)->name), "Name", "New name for marker"); #if 0 - RNA_def_boolean(ot->srna, - "ensure_unique", - 0, - "Ensure Unique", - "Ensure that new name is unique within collection of markers"); +RNA_def_boolean(ot->srna, "ensure_unique", 0, "Ensure Unique", "Ensure that new name is unique within collection of markers"); #endif } @@ -1757,10 +1762,11 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); ListBase *markers = ED_context_get_markers(C); - Scene *scene_to = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")); + Scene *scene_to = static_cast( + BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"))); TimeMarker *marker, *marker_new; - if (scene_to == NULL) { + if (scene_to == nullptr) { BKE_report(op->reports, RPT_ERROR, "Scene not found"); return OPERATOR_CANCELLED; } @@ -1776,10 +1782,10 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) } /* copy markers */ - for (marker = markers->first; marker; marker = marker->next) { + for (marker = static_cast(markers->first); marker; marker = marker->next) { if (marker->flag & SELECT) { - marker_new = MEM_dupallocN(marker); - marker_new->prev = marker_new->next = NULL; + marker_new = static_cast(MEM_dupallocN(marker)); + marker_new->prev = marker_new->next = nullptr; BLI_addtail(&scene_to->markers, marker_new); } @@ -1829,19 +1835,19 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op) TimeMarker *marker; /* Don't do anything if we don't have a camera selected */ - if (ob == NULL) { + if (ob == nullptr) { BKE_report(op->reports, RPT_ERROR, "Select a camera to bind to a marker on this frame"); return OPERATOR_CANCELLED; } /* add new marker, unless we already have one on this frame, in which case, replace it */ - if (markers == NULL) { + if (markers == nullptr) { return OPERATOR_CANCELLED; } marker = ED_markers_find_nearest_marker(markers, scene->r.cfra); - if ((marker == NULL) || (marker->frame != scene->r.cfra)) { - marker = MEM_callocN(sizeof(TimeMarker), "Camera TimeMarker"); + if ((marker == nullptr) || (marker->frame != scene->r.cfra)) { + marker = static_cast(MEM_callocN(sizeof(TimeMarker), "Camera TimeMarker")); marker->flag = SELECT; marker->frame = scene->r.cfra; BLI_addtail(markers, marker); @@ -1861,8 +1867,8 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *op) BKE_scene_camera_switch_update(scene); BKE_screen_view3d_scene_sync(screen, scene); - WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, nullptr); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, nullptr); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); /* so we get view3d redraws */ return OPERATOR_FINISHED; diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.cc similarity index 93% rename from source/blender/editors/animation/anim_motion_paths.c rename to source/blender/editors/animation/anim_motion_paths.cc index 9960bd2ff75..0059c1584a0 100644 --- a/source/blender/editors/animation/anim_motion_paths.c +++ b/source/blender/editors/animation/anim_motion_paths.cc @@ -38,7 +38,7 @@ static CLG_LogRef LOG = {"ed.anim.motion_paths"}; /* Motion path needing to be baked (mpt) */ -typedef struct MPathTarget { +struct MPathTarget { struct MPathTarget *next, *prev; bMotionPath *mpath; /* motion path in question */ @@ -52,7 +52,7 @@ typedef struct MPathTarget { /* "Evaluated" Copies (these come from the background COW copy * that provide all the coordinates we want to save off). */ Object *ob_eval; /* evaluated object */ -} MPathTarget; +}; /* ........ */ @@ -72,9 +72,11 @@ Depsgraph *animviz_depsgraph_build(Main *bmain, /* Make a flat array of IDs for the DEG API. */ const int num_ids = BLI_listbase_count(targets); - ID **ids = MEM_malloc_arrayN(num_ids, sizeof(ID *), "animviz IDS"); + ID **ids = static_cast(MEM_malloc_arrayN(num_ids, sizeof(ID *), "animviz IDS")); int current_id_index = 0; - for (MPathTarget *mpt = targets->first; mpt != NULL; mpt = mpt->next) { + for (MPathTarget *mpt = static_cast(targets->first); mpt != nullptr; + mpt = mpt->next) + { ids[current_id_index++] = &mpt->ob->id; } @@ -96,7 +98,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* object itself first */ if ((ob->avs.recalc & ANIMVIZ_RECALC_PATHS) && (ob->mpath)) { /* new target for object */ - mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob"); + mpt = static_cast(MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob")); BLI_addtail(targets, mpt); mpt->mpath = ob->mpath; @@ -105,13 +107,14 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* bones */ if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) { /* new target for bone */ - mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"); + mpt = static_cast(MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone")); BLI_addtail(targets, mpt); mpt->mpath = pchan->mpath; @@ -130,7 +133,7 @@ static void motionpaths_calc_bake_targets(ListBase *targets, int cframe) MPathTarget *mpt; /* for each target, check if it can be baked on the current frame */ - for (mpt = targets->first; mpt; mpt = mpt->next) { + for (mpt = static_cast(targets->first); mpt; mpt = mpt->next) { bMotionPath *mpath = mpt->mpath; /* current frame must be within the range the cache works for @@ -147,7 +150,7 @@ static void motionpaths_calc_bake_targets(ListBase *targets, int cframe) /* Lookup evaluated pose channel, here because the depsgraph * evaluation can change them so they are not cached in mpt. */ - bPoseChannel *pchan_eval = NULL; + bPoseChannel *pchan_eval = nullptr; if (mpt->pchan) { pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, mpt->pchan->name); } @@ -182,9 +185,9 @@ static void motionpaths_calc_bake_targets(ListBase *targets, int cframe) /* Incremental update on evaluated object if possible, for fast updating * while dragging in transform. */ - bMotionPath *mpath_eval = NULL; + bMotionPath *mpath_eval = nullptr; if (mpt->pchan) { - mpath_eval = (pchan_eval) ? pchan_eval->mpath : NULL; + mpath_eval = (pchan_eval) ? pchan_eval->mpath : nullptr; } else { mpath_eval = ob_eval->mpath; @@ -204,7 +207,7 @@ static void motionpaths_calc_bake_targets(ListBase *targets, int cframe) /* Get pointer to animviz settings for the given target. */ static bAnimVizSettings *animviz_target_settings_get(MPathTarget *mpt) { - if (mpt->pchan != NULL) { + if (mpt->pchan != nullptr) { return &mpt->ob->pose->avs; } return &mpt->ob->avs; @@ -231,7 +234,7 @@ static int motionpath_get_prev_keyframe(MPathTarget *mpt, float current_frame_float = current_frame; const ActKeyColumn *ak = ED_keylist_find_prev(keylist, current_frame_float); - if (ak == NULL) { + if (ak == nullptr) { return mpt->mpath->start_frame; } @@ -256,7 +259,7 @@ static int motionpath_get_next_keyframe(MPathTarget *mpt, float current_frame_float = current_frame; const ActKeyColumn *ak = ED_keylist_find_next(keylist, current_frame_float); - if (ak == NULL) { + if (ak == nullptr) { return mpt->mpath->end_frame; } @@ -271,11 +274,11 @@ static int motionpath_get_next_next_keyframe(MPathTarget *mpt, return motionpath_get_next_keyframe(mpt, keylist, frame); } -static bool motionpath_check_can_use_keyframe_range(MPathTarget *UNUSED(mpt), +static bool motionpath_check_can_use_keyframe_range(MPathTarget * /*mpt*/, AnimData *adt, ListBase *fcurve_list) { - if (adt == NULL || fcurve_list == NULL) { + if (adt == nullptr || fcurve_list == nullptr) { return false; } /* NOTE: We might needed to do a full frame range update if there is a specific setup of NLA @@ -312,7 +315,7 @@ static void motionpath_calculate_update_range(MPathTarget *mpt, * channel which wasn't edited. * Could be optimized further by storing some flags about which channels has been modified so * we ignore all others (which can potentially make an update range unnecessary wide). */ - for (FCurve *fcu = fcurve_list->first; fcu != NULL; fcu = fcu->next) { + for (FCurve *fcu = static_cast(fcurve_list->first); fcu != nullptr; fcu = fcu->next) { struct AnimKeylist *keylist = ED_keylist_create(); fcurve_to_keylist(adt, fcu, keylist, 0); ED_keylist_prepare_for_direct_access(keylist); @@ -398,7 +401,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph, /* TODO: include reports pointer? */ /* Sanity check. */ - if (ELEM(NULL, targets, targets->first)) { + if (ELEM(nullptr, targets, targets->first)) { return; } @@ -451,7 +454,7 @@ void animviz_calc_motionpaths(Depsgraph *depsgraph, /* build list of all keyframes in active action for object or pchan */ mpt->keylist = ED_keylist_create(); - ListBase *fcurve_list = NULL; + ListBase *fcurve_list = nullptr; if (adt) { /* get pointer to animviz settings for each target */ bAnimVizSettings *avs = animviz_target_settings_get(mpt); diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.cc similarity index 96% rename from source/blender/editors/animation/anim_ops.c rename to source/blender/editors/animation/anim_ops.cc index 54c4cb2931a..99331255e39 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.cc @@ -72,7 +72,7 @@ static bool change_frame_poll(bContext *C) } } if (area->spacetype == SPACE_GRAPH) { - const SpaceGraph *sipo = area->spacedata.first; + const SpaceGraph *sipo = static_cast(area->spacedata.first); /* Driver Editor's X axis is not time. */ if (sipo->mode != SIPO_MODE_DRIVERS) { return true; @@ -138,7 +138,7 @@ static void change_frame_apply(bContext *C, wmOperator *op, const bool always_up const float old_subframe = scene->r.subframe; if (do_snap) { - if (CTX_wm_space_seq(C) && SEQ_editing_get(scene) != NULL) { + if (CTX_wm_space_seq(C) && SEQ_editing_get(scene) != nullptr) { frame = seq_frame_apply_snap(C, scene, frame); } else { @@ -197,7 +197,7 @@ static float frame_from_event(bContext *C, const wmEvent *event) static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event, SpaceSeq *sseq) { - BLI_assert(sseq != NULL); + BLI_assert(sseq != nullptr); ARegion *region = CTX_wm_region(C); if (ED_space_sequencer_check_show_strip(sseq) && !ED_time_scrub_event_in_region(region, event)) { ED_sequencer_special_preview_set(C, event->mval); @@ -206,9 +206,9 @@ static void change_frame_seq_preview_begin(bContext *C, const wmEvent *event, Sp static void change_frame_seq_preview_end(SpaceSeq *sseq) { - BLI_assert(sseq != NULL); + BLI_assert(sseq != nullptr); UNUSED_VARS_NDEBUG(sseq); - if (ED_sequencer_special_preview_get() != NULL) { + if (ED_sequencer_special_preview_get() != nullptr) { ED_sequencer_special_preview_clear(); } } @@ -230,7 +230,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event { ARegion *region = CTX_wm_region(C); bScreen *screen = CTX_wm_screen(C); - if (CTX_wm_space_seq(C) != NULL && region->regiontype == RGN_TYPE_PREVIEW) { + if (CTX_wm_space_seq(C) != nullptr && region->regiontype == RGN_TYPE_PREVIEW) { return OPERATOR_CANCELLED; } @@ -292,13 +292,13 @@ static bool need_extra_redraw_after_scrubbing_ends(bContext *C) return false; } -static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op)) +static void change_frame_cancel(bContext *C, wmOperator * /*op*/) { bScreen *screen = CTX_wm_screen(C); screen->scrubbing = false; SpaceSeq *sseq = CTX_wm_space_seq(C); - if (sseq != NULL) { + if (sseq != nullptr) { change_frame_seq_preview_end(sseq); } @@ -359,7 +359,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) screen->scrubbing = false; SpaceSeq *sseq = CTX_wm_space_seq(C); - if (sseq != NULL) { + if (sseq != nullptr) { change_frame_seq_preview_end(sseq); } if (need_extra_redraw_after_scrubbing_ends(C)) { @@ -431,7 +431,7 @@ static int anim_set_sfra_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); int frame; - if (scene == NULL) { + if (scene == nullptr) { return OPERATOR_CANCELLED; } @@ -486,7 +486,7 @@ static int anim_set_efra_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); int frame; - if (scene == NULL) { + if (scene == nullptr) { return OPERATOR_CANCELLED; } @@ -608,13 +608,13 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) /** \name Clear Preview Range Operator * \{ */ -static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op)) +static int previewrange_clear_exec(bContext *C, wmOperator * /*op*/) { Scene *scene = CTX_data_scene(C); ScrArea *curarea = CTX_wm_area(C); /* sanity checks */ - if (ELEM(NULL, scene, curarea)) { + if (ELEM(nullptr, scene, curarea)) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.cc similarity index 92% rename from source/blender/editors/animation/drivers.c rename to source/blender/editors/animation/drivers.cc index 67e0220a5dd..4c21d5f20f2 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.cc @@ -57,18 +57,18 @@ FCurve *verify_driver_fcurve(ID *id, FCurve *fcu; /* sanity checks */ - if (ELEM(NULL, id, rna_path)) { - return NULL; + if (ELEM(nullptr, id, rna_path)) { + return nullptr; } /* init animdata if none available yet */ adt = BKE_animdata_from_id(id); - if (adt == NULL && creation_mode != DRIVER_FCURVE_LOOKUP_ONLY) { + if (adt == nullptr && creation_mode != DRIVER_FCURVE_LOOKUP_ONLY) { adt = BKE_animdata_ensure_id(id); } - if (adt == NULL) { + if (adt == nullptr) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ - return NULL; + return nullptr; } /* try to find f-curve matching for this setting @@ -77,7 +77,7 @@ FCurve *verify_driver_fcurve(ID *id, */ fcu = BKE_fcurve_find(&adt->drivers, rna_path, array_index); - if (fcu == NULL && creation_mode != DRIVER_FCURVE_LOOKUP_ONLY) { + if (fcu == nullptr && creation_mode != DRIVER_FCURVE_LOOKUP_ONLY) { /* use default settings to make a F-Curve */ fcu = alloc_driver_fcurve(rna_path, array_index, creation_mode); @@ -106,7 +106,8 @@ FCurve *alloc_driver_fcurve(const char rna_path[], if (!ELEM(creation_mode, DRIVER_FCURVE_LOOKUP_ONLY, DRIVER_FCURVE_EMPTY)) { /* add some new driver data */ - fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); + fcu->driver = static_cast( + MEM_callocN(sizeof(ChannelDriver), "ChannelDriver")); /* F-Modifier or Keyframes? */ if (creation_mode == DRIVER_FCURVE_GENERATOR) { @@ -137,7 +138,7 @@ FCurve *alloc_driver_fcurve(const char rna_path[], /* Driver Management API */ /* Helper for ANIM_add_driver_with_target - Adds the actual driver */ -static int add_driver_with_target(ReportList *UNUSED(reports), +static int add_driver_with_target(ReportList * /*reports*/, ID *dst_id, const char dst_path[], int dst_index, @@ -157,7 +158,7 @@ static int add_driver_with_target(ReportList *UNUSED(reports), const char *prop_name = RNA_property_identifier(src_prop); /* Create F-Curve with Driver */ - fcu = verify_driver_fcurve(dst_id, dst_path, dst_index, add_mode); + fcu = verify_driver_fcurve(dst_id, dst_path, dst_index, eDriverFCurveCreationMode(add_mode)); if (fcu && fcu->driver) { ChannelDriver *driver = fcu->driver; @@ -279,7 +280,7 @@ static int add_driver_with_target(ReportList *UNUSED(reports), } /* set the done status */ - return (fcu != NULL); + return (fcu != nullptr); } int ANIM_add_driver_with_target(ReportList *reports, @@ -323,8 +324,8 @@ int ANIM_add_driver_with_target(ReportList *reports, /* handle curve-property mappings based on mapping_type */ switch (mapping_type) { - case CREATEDRIVER_MAPPING_N_N: /* N-N - Try to match as much as possible, - * then use the first one */ + case CREATEDRIVER_MAPPING_N_N: /* N-N - Try to match as much as possible, * then use the first + one */ { /* Use the shorter of the two (to avoid out of bounds access) */ int dst_len = RNA_property_array_check(prop) ? RNA_property_array_length(&ptr, prop) : 1; @@ -437,7 +438,7 @@ int ANIM_add_driver( short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1; /* create F-Curve with Driver */ - fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode); + fcu = verify_driver_fcurve(id, rna_path, array_index, eDriverFCurveCreationMode(add_mode)); if (fcu && fcu->driver) { ChannelDriver *driver = fcu->driver; @@ -514,18 +515,15 @@ int ANIM_add_driver( } /* set the done status */ - done_tot += (fcu != NULL); + done_tot += (fcu != nullptr); } /* done */ return done_tot; } -bool ANIM_remove_driver(ReportList *UNUSED(reports), - ID *id, - const char rna_path[], - int array_index, - short UNUSED(flag)) +bool ANIM_remove_driver( + ReportList * /*reports*/, ID *id, const char rna_path[], int array_index, short /*flag*/) { AnimData *adt; FCurve *fcu; @@ -537,9 +535,9 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), if (adt) { if (array_index == -1) { /* step through all drivers, removing all of those with the same base path */ - FCurve *fcu_iter = adt->drivers.first; + FCurve *fcu_iter = static_cast(adt->drivers.first); - while ((fcu = BKE_fcurve_iter_step(fcu_iter, rna_path)) != NULL) { + while ((fcu = BKE_fcurve_iter_step(fcu_iter, rna_path)) != nullptr) { /* Store the next fcurve for looping. */ fcu_iter = fcu->next; @@ -573,7 +571,7 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), /* Driver Management API - Copy/Paste Drivers */ /* Copy/Paste Buffer for Driver Data... */ -static FCurve *channeldriver_copypaste_buf = NULL; +static FCurve *channeldriver_copypaste_buf = nullptr; void ANIM_drivers_copybuf_free(void) { @@ -581,18 +579,18 @@ void ANIM_drivers_copybuf_free(void) if (channeldriver_copypaste_buf) { BKE_fcurve_free(channeldriver_copypaste_buf); } - channeldriver_copypaste_buf = NULL; + channeldriver_copypaste_buf = nullptr; } bool ANIM_driver_can_paste(void) { - return (channeldriver_copypaste_buf != NULL); + return (channeldriver_copypaste_buf != nullptr); } /* ------------------- */ bool ANIM_copy_driver( - ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) + ReportList *reports, ID *id, const char rna_path[], int array_index, short /*flag*/) { PointerRNA id_ptr, ptr; PropertyRNA *prop; @@ -623,7 +621,7 @@ bool ANIM_copy_driver( * which won't get used ever. */ char *tmp_path = fcu->rna_path; - fcu->rna_path = NULL; + fcu->rna_path = nullptr; /* make a copy of the F-Curve with */ channeldriver_copypaste_buf = BKE_fcurve_copy(fcu); @@ -640,7 +638,7 @@ bool ANIM_copy_driver( } bool ANIM_paste_driver( - ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) + ReportList *reports, ID *id, const char rna_path[], int array_index, short /*flag*/) { PointerRNA id_ptr, ptr; PropertyRNA *prop; @@ -659,7 +657,7 @@ bool ANIM_paste_driver( } /* if the buffer is empty, cannot paste... */ - if (channeldriver_copypaste_buf == NULL) { + if (channeldriver_copypaste_buf == nullptr) { BKE_report(reports, RPT_ERROR, "Paste driver: no driver to paste"); return 0; } @@ -672,8 +670,8 @@ bool ANIM_paste_driver( * NOTE: this step needs care to not miss new settings */ /* keyframes/samples */ - fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt); - fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt); + fcu->bezt = static_cast(MEM_dupallocN(channeldriver_copypaste_buf->bezt)); + fcu->fpt = static_cast(MEM_dupallocN(channeldriver_copypaste_buf->fpt)); fcu->totvert = channeldriver_copypaste_buf->totvert; /* modifiers */ @@ -687,14 +685,14 @@ bool ANIM_paste_driver( } /* done */ - return (fcu != NULL); + return (fcu != nullptr); } /* ************************************************** */ /* Driver Management API - Copy/Paste Driver Variables */ /* Copy/Paste Buffer for Driver Variables... */ -static ListBase driver_vars_copybuf = {NULL, NULL}; +static ListBase driver_vars_copybuf = {nullptr, nullptr}; void ANIM_driver_vars_copybuf_free(void) { @@ -703,7 +701,7 @@ void ANIM_driver_vars_copybuf_free(void) DriverVar *dvar, *dvarn; /* Free variables (and any data they use) */ - for (dvar = driver_vars_copybuf.first; dvar; dvar = dvarn) { + for (dvar = static_cast(driver_vars_copybuf.first); dvar; dvar = dvarn) { dvarn = dvar->next; driver_free_variable(&driver_vars_copybuf, dvar); } @@ -722,7 +720,7 @@ bool ANIM_driver_vars_can_paste(void) bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu) { /* sanity checks */ - if (ELEM(NULL, fcu, fcu->driver)) { + if (ELEM(nullptr, fcu, fcu->driver)) { BKE_report(reports, RPT_ERROR, "No driver to copy variables from"); return false; } @@ -743,8 +741,8 @@ bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu) bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) { - ChannelDriver *driver = (fcu) ? fcu->driver : NULL; - ListBase tmp_list = {NULL, NULL}; + ChannelDriver *driver = (fcu) ? fcu->driver : nullptr; + ListBase tmp_list = {nullptr, nullptr}; /* sanity checks */ if (BLI_listbase_is_empty(&driver_vars_copybuf)) { @@ -752,7 +750,7 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) return false; } - if (ELEM(NULL, fcu, fcu->driver)) { + if (ELEM(nullptr, fcu, fcu->driver)) { BKE_report(reports, RPT_ERROR, "Cannot paste driver variables without a driver"); return false; } @@ -765,7 +763,7 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) DriverVar *dvar, *dvarn; /* Free all existing vars first - We aren't retaining anything */ - for (dvar = driver->variables.first; dvar; dvar = dvarn) { + for (dvar = static_cast(driver->variables.first); dvar; dvar = dvarn) { dvarn = dvar->next; driver_free_variable_ex(driver, dvar); } @@ -775,8 +773,8 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) /* 3) Add new vars */ if (driver->variables.last) { - DriverVar *last = driver->variables.last; - DriverVar *first = tmp_list.first; + DriverVar *last = static_cast(driver->variables.last); + DriverVar *first = static_cast(tmp_list.first); last->next = first; first->prev = last; @@ -803,7 +801,7 @@ void ANIM_copy_as_driver(ID *target_id, const char *target_path, const char *var ANIM_driver_vars_copybuf_free(); /* Create a dummy driver F-Curve. */ - FCurve *fcu = alloc_driver_fcurve(NULL, 0, DRIVER_FCURVE_KEYFRAMES); + FCurve *fcu = alloc_driver_fcurve(nullptr, 0, DRIVER_FCURVE_KEYFRAMES); ChannelDriver *driver = fcu->driver; /* Create a variable. */ @@ -812,7 +810,7 @@ void ANIM_copy_as_driver(ID *target_id, const char *target_path, const char *var target->idtype = GS(target_id->name); target->id = target_id; - target->rna_path = MEM_dupallocN(target_path); + target->rna_path = static_cast(MEM_dupallocN(target_path)); /* Set the variable name. */ if (var_name) { @@ -868,20 +866,20 @@ EnumPropertyItem prop_driver_create_mapping_types[] = { 0, "Manually Create Later (Single)", "Create driver for this property only and without assigning any targets yet"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* Filtering callback for driver mapping types enum */ static const EnumPropertyItem *driver_mapping_type_itemf(bContext *C, - PointerRNA *UNUSED(owner_ptr), - PropertyRNA *UNUSED(owner_prop), + PointerRNA * /*owner_ptr*/, + PropertyRNA * /*owner_prop*/, bool *r_free) { EnumPropertyItem *input = prop_driver_create_mapping_types; - EnumPropertyItem *item = NULL; + EnumPropertyItem *item = nullptr; - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; int index; int totitem = 0; @@ -917,8 +915,8 @@ static const EnumPropertyItem *driver_mapping_type_itemf(bContext *C, static bool add_driver_button_poll(bContext *C) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; int index; bool driven, special; @@ -934,16 +932,16 @@ static bool add_driver_button_poll(bContext *C) /* Don't do anything if there is an fcurve for animation without a driver. */ FCurve *fcu = BKE_fcurve_find_by_rna_context_ui( - C, &ptr, prop, index, NULL, NULL, &driven, &special); - return (fcu == NULL || fcu->driver); + C, &ptr, prop, index, nullptr, nullptr, &driven, &special); + return (fcu == nullptr || fcu->driver); } /* Wrapper for creating a driver without knowing what the targets will be yet * (i.e. "manual/add later"). */ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_type) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; int index; int success = 0; @@ -968,7 +966,7 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ /* send updates */ UI_context_update_anim_flag(C); DEG_relations_tag_update(CTX_data_main(C)); - WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */ + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, nullptr); /* XXX */ return OPERATOR_FINISHED; } @@ -988,13 +986,13 @@ static int add_driver_button_menu_exec(bContext *C, wmOperator *op) /* XXX: We assume that it's fine to use the same set of properties, * since they're actually the same. */ - WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, op->ptr, NULL); + WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, op->ptr, nullptr); return OPERATOR_FINISHED; } /* Show menu or create drivers */ -static int add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int add_driver_button_menu_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { PropertyRNA *prop; @@ -1038,10 +1036,10 @@ static void UNUSED_FUNCTION(ANIM_OT_driver_button_add_menu)(wmOperatorType *ot) /* Add Driver Button Operator ------------------------ */ -static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; int index; /* try to find driver using property retrieved from UI */ @@ -1064,7 +1062,7 @@ static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent * UI_context_update_anim_flag(C); DEG_id_tag_update(ptr.owner_id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(CTX_data_main(C)); - WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, nullptr); } /* 2) Show editing panel for setting up this driver */ @@ -1095,8 +1093,8 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) static int remove_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; bool changed = false; int index; const bool all = RNA_boolean_get(op->ptr, "all"); @@ -1122,7 +1120,7 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op) /* send updates */ UI_context_update_anim_flag(C); DEG_relations_tag_update(CTX_data_main(C)); - WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); /* XXX */ + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, nullptr); /* XXX */ } return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; @@ -1151,8 +1149,8 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) static int edit_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; int index; /* try to find driver using property retrieved from UI */ @@ -1185,8 +1183,8 @@ void ANIM_OT_driver_button_edit(wmOperatorType *ot) static int copy_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; bool changed = false; int index; @@ -1229,8 +1227,8 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) static int paste_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; bool changed = false; int index; @@ -1250,7 +1248,7 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op) DEG_id_tag_update(ptr.owner_id, ID_RECALC_ANIMATION); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); /* XXX */ + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, nullptr); /* XXX */ MEM_freeN(path); } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.cc similarity index 87% rename from source/blender/editors/animation/fmodifier_ui.c rename to source/blender/editors/animation/fmodifier_ui.cc index 17cd9f85c4e..8e4d3d6d9f8 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.cc @@ -70,22 +70,22 @@ static ListBase *fmodifier_list_space_specific(const bContext *C) /* This should not be called in any other space. */ BLI_assert(false); - return NULL; + return nullptr; } /** - * Get a pointer to the panel's FModifier, and also its owner ID if \a r_owner_id is not NULL. + * Get a pointer to the panel's FModifier, and also its owner ID if \a r_owner_id is not nullptr. * Also in the graph editor, gray out the panel if the FModifier's FCurve has modifiers turned off. */ static PointerRNA *fmodifier_get_pointers(const bContext *C, const Panel *panel, ID **r_owner_id) { PointerRNA *ptr = UI_panel_custom_data_get(panel); - if (r_owner_id != NULL) { + if (r_owner_id != nullptr) { *r_owner_id = ptr->owner_id; } - if (C != NULL && CTX_wm_space_graph(C)) { + if (C != nullptr && CTX_wm_space_graph(C)) { FCurve *fcu = ANIM_graph_context_fcurve(C); uiLayoutSetActive(panel->layout, !(fcu->flag & FCURVE_MOD_OFF)); } @@ -99,8 +99,8 @@ static PointerRNA *fmodifier_get_pointers(const bContext *C, const Panel *panel, static void fmodifier_reorder(bContext *C, Panel *panel, int new_index) { ID *owner_id; - PointerRNA *ptr = fmodifier_get_pointers(NULL, panel, &owner_id); - FModifier *fcm = ptr->data; + PointerRNA *ptr = fmodifier_get_pointers(nullptr, panel, &owner_id); + FModifier *fcm = static_cast(ptr->data); const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(fcm->type); /* Cycles modifier has to be the first, so make sure it's kept that way. */ @@ -112,7 +112,7 @@ static void fmodifier_reorder(bContext *C, Panel *panel, int new_index) ListBase *modifiers = fmodifier_list_space_specific(C); /* Again, make sure we don't move a modifier before a cycles modifier. */ - FModifier *fcm_first = modifiers->first; + FModifier *fcm_first = static_cast(modifiers->first); const FModifierTypeInfo *fmi_first = get_fmodifier_typeinfo(fcm_first->type); if (fmi_first->requires_flag & FMI_REQUIRES_ORIGINAL_DATA && new_index == 0) { WM_report(RPT_ERROR, "Modifier requires original data"); @@ -133,21 +133,21 @@ static void fmodifier_reorder(bContext *C, Panel *panel, int new_index) ED_undo_push(C, "Reorder F-Curve Modifier"); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); DEG_id_tag_update(owner_id, ID_RECALC_ANIMATION); } -static short get_fmodifier_expand_flag(const bContext *UNUSED(C), Panel *panel) +static short get_fmodifier_expand_flag(const bContext * /*C*/, Panel *panel) { - PointerRNA *ptr = fmodifier_get_pointers(NULL, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(nullptr, panel, nullptr); FModifier *fcm = (FModifier *)ptr->data; return fcm->ui_expand_flag; } -static void set_fmodifier_expand_flag(const bContext *UNUSED(C), Panel *panel, short expand_flag) +static void set_fmodifier_expand_flag(const bContext * /*C*/, Panel *panel, short expand_flag) { - PointerRNA *ptr = fmodifier_get_pointers(NULL, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(nullptr, panel, nullptr); FModifier *fcm = (FModifier *)ptr->data; fcm->ui_expand_flag = expand_flag; @@ -159,7 +159,7 @@ static PanelType *fmodifier_panel_register(ARegionType *region_type, PanelTypePollFn poll, const char *id_prefix) { - PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = static_cast(MEM_callocN(sizeof(PanelType), __func__)); /* Intentionally leave the label field blank. The header is filled with buttons. */ const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type); @@ -197,7 +197,7 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type, PanelTypePollFn poll, PanelType *parent) { - PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); + PanelType *panel_type = static_cast(MEM_callocN(sizeof(PanelType), __func__)); SNPRINTF(panel_type->idname, "%s_%s", parent->idname, name); STRNCPY(panel_type->label, label); @@ -209,7 +209,7 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type, panel_type->poll = poll; panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED; - BLI_assert(parent != NULL); + BLI_assert(parent != nullptr); STRNCPY(panel_type->parent_id, parent->idname); panel_type->parent = parent; BLI_addtail(&parent->children, BLI_genericNodeN(panel_type)); @@ -228,10 +228,10 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type, #define B_FMODIFIER_REDRAW 20 /* Callback to remove the given modifier. */ -typedef struct FModifierDeleteContext { +struct FModifierDeleteContext { ID *owner_id; ListBase *modifiers; -} FModifierDeleteContext; +}; static void delete_fmodifier_cb(bContext *C, void *ctx_v, void *fcm_v) { @@ -244,7 +244,7 @@ static void delete_fmodifier_cb(bContext *C, void *ctx_v, void *fcm_v) ED_undo_push(C, "Delete F-Curve Modifier"); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); DEG_id_tag_update(ctx->owner_id, ID_RECALC_ANIMATION); } @@ -265,9 +265,9 @@ static void fmodifier_frame_range_header_draw(const bContext *C, Panel *panel) { uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); - uiItemR(layout, ptr, "use_restricted_range", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_restricted_range", 0, nullptr, ICON_NONE); } static void fmodifier_frame_range_draw(const bContext *C, Panel *panel) @@ -275,7 +275,7 @@ static void fmodifier_frame_range_draw(const bContext *C, Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); @@ -332,16 +332,17 @@ static void fmodifier_panel_header(const bContext *C, Panel *panel) 0, UI_UNIT_X, UI_UNIT_Y, - NULL, + nullptr, 0.0, 0.0, 0.0, 0.0, TIP_("Delete Modifier")); - FModifierDeleteContext *ctx = MEM_mallocN(sizeof(FModifierDeleteContext), __func__); + FModifierDeleteContext *ctx = static_cast( + MEM_mallocN(sizeof(FModifierDeleteContext), __func__)); ctx->owner_id = owner_id; ctx->modifiers = fmodifier_list_space_specific(C); - BLI_assert(ctx->modifiers != NULL); + BLI_assert(ctx->modifiers != nullptr); UI_but_funcN_set(but, delete_fmodifier_cb, ctx, fcm); @@ -368,7 +369,7 @@ static void generator_panel_draw(const bContext *C, Panel *panel) uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); - uiItemR(layout, ptr, "use_additive", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "use_additive", 0, nullptr, ICON_NONE); uiItemR(layout, ptr, "poly_order", 0, IFACE_("Order"), ICON_NONE); @@ -444,7 +445,7 @@ static void fn_generator_panel_draw(const bContext *C, Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); uiItemR(layout, ptr, "function_type", 0, "", ICON_NONE); @@ -452,13 +453,13 @@ static void fn_generator_panel_draw(const bContext *C, Panel *panel) uiLayoutSetPropDecorate(layout, false); col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "use_additive", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_additive", 0, nullptr, ICON_NONE); col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "amplitude", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "phase_multiplier", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "phase_offset", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "value_offset", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "amplitude", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "phase_multiplier", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "phase_offset", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "value_offset", 0, nullptr, ICON_NONE); fmodifier_influence_draw(layout, ptr); } @@ -489,19 +490,19 @@ static void cycles_panel_draw(const bContext *C, Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); /* Before. */ col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "mode_before", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "mode_before", 0, nullptr, ICON_NONE); uiItemR(col, ptr, "cycles_before", 0, IFACE_("Count"), ICON_NONE); /* After. */ col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "mode_after", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "mode_after", 0, nullptr, ICON_NONE); uiItemR(col, ptr, "cycles_after", 0, IFACE_("Count"), ICON_NONE); fmodifier_influence_draw(layout, ptr); @@ -533,19 +534,19 @@ static void noise_panel_draw(const bContext *C, Panel *panel) uiLayout *col; uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); - uiItemR(layout, ptr, "blend_type", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "blend_type", 0, nullptr, ICON_NONE); col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "scale", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "strength", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "phase", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "depth", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "scale", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "strength", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "offset", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "phase", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "depth", 0, nullptr, ICON_NONE); fmodifier_influence_draw(layout, ptr); } @@ -571,7 +572,7 @@ static void panel_register_noise(ARegionType *region_type, /** \name Envelope Modifier * \{ */ -static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(arg)) +static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void * /*arg*/) { Scene *scene = CTX_data_scene(C); FMod_Envelope *env = (FMod_Envelope *)fcm_dv; @@ -596,7 +597,8 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar } /* add new */ - fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); + fedn = static_cast( + MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData")); /* add the points that should occur before the point to be pasted */ if (i > 0) { @@ -618,7 +620,8 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar env->totvert++; } else { - env->data = MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); + env->data = static_cast( + MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData")); *(env->data) = fed; env->totvert = 1; @@ -627,7 +630,7 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar /* callback to remove envelope data point */ /* TODO: should we have a separate file for things like this? */ -static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void *ind_v) +static void fmod_envelope_deletepoint_cb(bContext * /*C*/, void *fcm_dv, void *ind_v) { FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; @@ -636,7 +639,8 @@ static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void /* check that no data exists for the current frame... */ if (env->totvert > 1) { /* allocate a new smaller array */ - fedn = MEM_callocN(sizeof(FCM_EnvelopeData) * (env->totvert - 1), "FCM_EnvelopeData"); + fedn = static_cast( + MEM_callocN(sizeof(FCM_EnvelopeData) * (env->totvert - 1), "FCM_EnvelopeData")); memcpy(fedn, env->data, sizeof(FCM_EnvelopeData) * (index)); memcpy(fedn + index, @@ -688,13 +692,13 @@ static void envelope_panel_draw(const bContext *C, Panel *panel) 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, - NULL, + nullptr, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame")); - UI_but_func_set(but, fmod_envelope_addpoint_cb, env, NULL); + UI_but_func_set(but, fmod_envelope_addpoint_cb, env, nullptr); col = uiLayoutColumn(layout, false); uiLayoutSetPropSep(col, false); @@ -708,7 +712,7 @@ static void envelope_panel_draw(const bContext *C, Panel *panel) row = uiLayoutRow(col, true); block = uiLayoutGetBlock(row); - uiItemR(row, &ctrl_ptr, "frame", 0, NULL, ICON_NONE); + uiItemR(row, &ctrl_ptr, "frame", 0, nullptr, ICON_NONE); uiItemR(row, &ctrl_ptr, "min", 0, IFACE_("Min"), ICON_NONE); uiItemR(row, &ctrl_ptr, "max", 0, IFACE_("Max"), ICON_NONE); @@ -720,7 +724,7 @@ static void envelope_panel_draw(const bContext *C, Panel *panel) 0, 0.9 * UI_UNIT_X, UI_UNIT_Y, - NULL, + nullptr, 0.0, 0.0, 0.0, @@ -759,7 +763,7 @@ static void limits_panel_draw(const bContext *C, Panel *panel) uiLayout *col, *row, *sub; uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); @@ -821,15 +825,15 @@ static void stepped_panel_draw(const bContext *C, Panel *panel) uiLayout *col, *sub, *row; uiLayout *layout = panel->layout; - PointerRNA *ptr = fmodifier_get_pointers(C, panel, NULL); + PointerRNA *ptr = fmodifier_get_pointers(C, panel, nullptr); uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); /* Stepping Settings. */ col = uiLayoutColumn(layout, false); - uiItemR(col, ptr, "frame_step", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "frame_step", 0, nullptr, ICON_NONE); + uiItemR(col, ptr, "frame_offset", 0, nullptr, ICON_NONE); /* Start range settings. */ row = uiLayoutRowWithHeading(layout, true, IFACE_("Start Frame")); @@ -880,11 +884,12 @@ void ANIM_fmodifier_panels(const bContext *C, if (!panels_match) { UI_panels_free_instanced(C, region); - for (FModifier *fcm = fmodifiers->first; fcm; fcm = fcm->next) { + for (FModifier *fcm = static_cast(fmodifiers->first); fcm; fcm = fcm->next) { char panel_idname[MAX_NAME]; panel_id_fn(fcm, panel_idname); - PointerRNA *fcm_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); + PointerRNA *fcm_ptr = static_cast( + MEM_mallocN(sizeof(PointerRNA), "panel customdata")); RNA_pointer_create(owner_id, &RNA_FModifier, fcm, fcm_ptr); UI_panel_add_instanced(C, region, ®ion->panels, panel_idname, fcm_ptr); @@ -892,16 +897,18 @@ void ANIM_fmodifier_panels(const bContext *C, } else { /* Assuming there's only one group of instanced panels, update the custom data pointers. */ - Panel *panel = region->panels.first; + Panel *panel = static_cast(region->panels.first); LISTBASE_FOREACH (FModifier *, fcm, fmodifiers) { /* Move to the next instanced panel corresponding to the next modifier. */ - while ((panel->type == NULL) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { + while ((panel->type == nullptr) || !(panel->type->flag & PANEL_TYPE_INSTANCED)) { panel = panel->next; - BLI_assert(panel != NULL); /* There shouldn't be fewer panels than modifiers with UIs. */ + BLI_assert(panel != + nullptr); /* There shouldn't be fewer panels than modifiers with UIs. */ } - PointerRNA *fcm_ptr = MEM_mallocN(sizeof(PointerRNA), "panel customdata"); + PointerRNA *fcm_ptr = static_cast( + MEM_mallocN(sizeof(PointerRNA), "panel customdata")); RNA_pointer_create(owner_id, &RNA_FModifier, fcm, fcm_ptr); UI_panel_custom_data_set(panel, fcm_ptr); @@ -939,7 +946,7 @@ void ANIM_modifier_panels_register_graph_only(ARegionType *region_type, * \{ */ /* Copy/Paste Buffer itself (list of FModifier 's) */ -static ListBase fmodifier_copypaste_buf = {NULL, NULL}; +static ListBase fmodifier_copypaste_buf = {nullptr, nullptr}; /* ---------- */ @@ -954,7 +961,7 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active) bool ok = true; /* sanity checks */ - if (ELEM(NULL, modifiers, modifiers->first)) { + if (ELEM(nullptr, modifiers, modifiers->first)) { return 0; } @@ -984,7 +991,7 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c bool ok = false; /* sanity checks */ - if (modifiers == NULL) { + if (modifiers == nullptr) { return 0; } @@ -996,7 +1003,7 @@ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *c } /* now copy over all the modifiers in the buffer to the end of the list */ - for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) { + for (fcm = static_cast(fmodifier_copypaste_buf.first); fcm; fcm = fcm->next) { /* make a copy of it */ FModifier *fcmN = copy_fmodifier(fcm); diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.cc similarity index 92% rename from source/blender/editors/animation/keyframes_general.c rename to source/blender/editors/animation/keyframes_general.cc index 118e01ff2fc..38f41b7518c 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.cc @@ -56,7 +56,7 @@ bool duplicate_fcurve_keys(FCurve *fcu) bool changed = false; /* this can only work when there is an F-Curve, and also when there are some BezTriples */ - if (ELEM(NULL, fcu, fcu->bezt)) { + if (ELEM(nullptr, fcu, fcu->bezt)) { return changed; } @@ -64,7 +64,8 @@ bool duplicate_fcurve_keys(FCurve *fcu) /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { /* Expand the list */ - BezTriple *newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple"); + BezTriple *newbezt = static_cast( + MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple")); memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); @@ -98,7 +99,7 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear int totCount, i; /* Check if any points. */ - if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert == 0) || + if ((fcu == nullptr) || (fcu->bezt == nullptr) || (fcu->totvert == 0) || (!cleardefault && fcu->totvert == 1)) { return; @@ -107,12 +108,12 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear /* make a copy of the old BezTriples, and clear F-Curve */ old_bezts = fcu->bezt; totCount = fcu->totvert; - fcu->bezt = NULL; + fcu->bezt = nullptr; fcu->totvert = 0; /* now insert first keyframe, as it should be ok */ bezt = old_bezts; - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); if (!(bezt->f2 & SELECT)) { lastb = fcu->bezt; lastb->f1 = lastb->f2 = lastb->f3 = 0; @@ -131,7 +132,7 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear next[1] = beztn->vec[1][1]; } else { - beztn = NULL; + beztn = nullptr; next[0] = next[1] = 0.0f; } lastb = (fcu->bezt + (fcu->totvert - 1)); @@ -144,7 +145,7 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear cur[1] = bezt->vec[1][1]; if (!(bezt->f2 & SELECT)) { - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); lastb = (fcu->bezt + (fcu->totvert - 1)); lastb->f1 = lastb->f2 = lastb->f3 = 0; continue; @@ -161,7 +162,7 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear if (cur[1] > next[1]) { if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); } } } @@ -169,7 +170,7 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear /* only add if values are a considerable distance apart */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); } } } @@ -179,18 +180,18 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear /* does current have same value as previous and next? */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); } else if (IS_EQT(cur[1], next[1], thresh) == 0) { /* add new keyframe */ - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); } } else { /* add if value doesn't equal that of previous */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); } } } @@ -223,7 +224,7 @@ void clean_fcurve(bAnimContext *ac, bAnimListElem *ale, float thresh, bool clear if (BKE_fcurve_is_empty(fcu)) { AnimData *adt = ale->adt; ANIM_fcurve_delete_from_animdata(ac, adt, fcu); - ale->key_data = NULL; + ale->key_data = nullptr; } } } @@ -271,7 +272,7 @@ static bool find_fcurve_segment(FCurve *fcu, ListBase find_fcurve_segments(FCurve *fcu) { - ListBase segments = {NULL, NULL}; + ListBase segments = {nullptr, nullptr}; /* Ignore baked curves. */ if (!fcu->bezt) { @@ -284,7 +285,7 @@ ListBase find_fcurve_segments(FCurve *fcu) while (find_fcurve_segment(fcu, current_index, &segment_start_idx, &segment_len)) { FCurveSegment *segment; - segment = MEM_callocN(sizeof(*segment), "FCurveSegment"); + segment = static_cast(MEM_callocN(sizeof(*segment), "FCurveSegment")); segment->start_index = segment_start_idx; segment->length = segment_len; BLI_addtail(&segments, segment); @@ -574,7 +575,7 @@ bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max) { FCurve *fcu = (FCurve *)ale->key_data; /* Check if the curve actually has any points. */ - if (fcu == NULL || fcu->bezt == NULL || fcu->totvert == 0) { + if (fcu == nullptr || fcu->bezt == nullptr || fcu->totvert == 0) { return true; } @@ -600,14 +601,14 @@ bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max) BLI_freelistN(&segments); uint old_totvert = fcu->totvert; - fcu->bezt = NULL; + fcu->bezt = nullptr; fcu->totvert = 0; for (int i = 0; i < old_totvert; i++) { BezTriple *bezt = (old_bezts + i); bezt->f2 &= ~BEZT_FLAG_IGNORE_TAG; if ((bezt->f2 & BEZT_FLAG_TEMP_TAG) == 0) { - insert_bezt_fcurve(fcu, bezt, 0); + insert_bezt_fcurve(fcu, bezt, eInsertKeyFlags(0)); } } /* now free the memory used by the old BezTriples */ @@ -625,16 +626,16 @@ bool decimate_fcurve(bAnimListElem *ale, float remove_ratio, float error_sq_max) * \{ */ /* temp struct used for smooth_fcurve */ -typedef struct tSmooth_Bezt { +struct tSmooth_Bezt { float *h1, *h2, *h3; /* bezt->vec[0,1,2][1] */ float y1, y2, y3; /* averaged before/new/after y-values */ -} tSmooth_Bezt; +}; void smooth_fcurve(FCurve *fcu) { int totSel = 0; - if (fcu->bezt == NULL) { + if (fcu->bezt == nullptr) { return; } @@ -651,7 +652,8 @@ void smooth_fcurve(FCurve *fcu) tSmooth_Bezt *tarray, *tsb; /* allocate memory in one go */ - tsb = tarray = MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); + tsb = tarray = static_cast( + MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array")); /* populate tarray with data of selected points */ bezt = fcu->bezt; @@ -686,9 +688,9 @@ void smooth_fcurve(FCurve *fcu) * as we don't have enough data there). */ if (ELEM(i, 0, (totSel - 1)) == 0) { const tSmooth_Bezt *tP1 = tsb - 1; - const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL); + const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (nullptr); const tSmooth_Bezt *tN1 = tsb + 1; - const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (NULL); + const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (nullptr); const float p1 = *tP1->h2; const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); @@ -733,9 +735,9 @@ void smooth_fcurve(FCurve *fcu) * \{ */ /* little cache for values... */ -typedef struct TempFrameValCache { +struct TempFrameValCache { float frame, val; -} TempFrameValCache; +}; void sample_fcurve_segment(FCurve *fcu, const float start_frame, @@ -749,12 +751,12 @@ void sample_fcurve_segment(FCurve *fcu, void sample_fcurve(FCurve *fcu) { - BezTriple *bezt, *start = NULL, *end = NULL; + BezTriple *bezt, *start = nullptr, *end = nullptr; TempFrameValCache *value_cache, *fp; int sfra, range; int i, n; - if (fcu->bezt == NULL) { /* ignore baked */ + if (fcu->bezt == nullptr) { /* ignore baked */ return; } @@ -786,7 +788,8 @@ void sample_fcurve(FCurve *fcu) sfra = (int)floor(start->vec[1][0]); if (range) { - value_cache = MEM_callocN(sizeof(TempFrameValCache) * range, "IcuFrameValCache"); + value_cache = static_cast( + MEM_callocN(sizeof(TempFrameValCache) * range, "IcuFrameValCache")); /* sample values */ for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { @@ -796,7 +799,8 @@ void sample_fcurve(FCurve *fcu) /* add keyframes with these, tagging as 'breakdowns' */ for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { - insert_vert_fcurve(fcu, fp->frame, fp->val, BEZT_KEYTYPE_BREAKDOWN, 1); + insert_vert_fcurve( + fcu, fp->frame, fp->val, BEZT_KEYTYPE_BREAKDOWN, eInsertKeyFlags(1)); } /* free temp cache */ @@ -808,13 +812,13 @@ void sample_fcurve(FCurve *fcu) } /* the current selection island has ended, so start again from scratch */ - start = NULL; - end = NULL; + start = nullptr; + end = nullptr; } else { /* just set start keyframe */ start = bezt; - end = NULL; + end = nullptr; } } } @@ -837,13 +841,13 @@ void sample_fcurve(FCurve *fcu) * \{ */ /* globals for copy/paste data (like for other copy/paste buffers) */ -static ListBase animcopybuf = {NULL, NULL}; +static ListBase animcopybuf = {nullptr, nullptr}; static float animcopy_firstframe = 999999999.0f; static float animcopy_lastframe = -999999999.0f; static float animcopy_cfra = 0.0; /* datatype for use in copy/paste buffer */ -typedef struct tAnimCopybufItem { +struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; ID *id; /* ID which owns the curve */ @@ -856,14 +860,14 @@ typedef struct tAnimCopybufItem { short id_type; /* Result of `GS(id->name)`. */ bool is_bone; /* special flag for armature bones */ -} tAnimCopybufItem; +}; void ANIM_fcurves_copybuf_free(void) { tAnimCopybufItem *aci, *acn; /* free each buffer element */ - for (aci = animcopybuf.first; aci; aci = acn) { + for (aci = static_cast(animcopybuf.first); aci; aci = acn) { acn = aci->next; /* free keyframes */ @@ -897,7 +901,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) ANIM_fcurves_copybuf_free(); /* assume that each of these is an F-Curve */ - for (ale = anim_data->first; ale; ale = ale->next) { + for (ale = static_cast(anim_data->first); ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; tAnimCopybufItem *aci; BezTriple *bezt, *nbezt, *newbuf; @@ -908,17 +912,18 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) * - this check should also eliminate any problems associated with using sample-data */ if (ANIM_fcurve_keyframes_loop( - NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) + nullptr, fcu, nullptr, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), nullptr) == 0) { continue; } /* init copybuf item info */ - aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem"); + aci = static_cast( + MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem")); aci->id = ale->id; aci->id_type = GS(ale->id->name); aci->grp = fcu->grp; - aci->rna_path = MEM_dupallocN(fcu->rna_path); + aci->rna_path = static_cast(MEM_dupallocN(fcu->rna_path)); aci->array_index = fcu->array_index; /* Detect if this is a bone. We do that here rather than during pasting because ID pointers @@ -945,7 +950,8 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (BEZT_ISSEL_ANY(bezt)) { /* add to buffer */ - newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple"); + newbuf = static_cast( + MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple")); /* assume that since we are just re-sizing the array, just copy all existing data across */ if (aci->bezt) { @@ -978,7 +984,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) } /* check if anything ended up in the buffer */ - if (ELEM(NULL, animcopybuf.first, animcopybuf.last)) { + if (ELEM(nullptr, animcopybuf.first, animcopybuf.last)) { return -1; } @@ -1014,14 +1020,14 @@ static void flip_names(tAnimCopybufItem *aci, char **r_name) len_old = str_end - str_start; postfix_l = strlen(str_end); - /* Temporary substitute with NULL terminator. */ + /* Temporary substitute with nullptr terminator. */ BLI_assert(str_start[len_old] == '\"'); str_start[len_old] = 0; const int len_new = BLI_string_flip_side_name(bname_new, str_start, false, sizeof(bname_new)); str_start[len_old] = '\"'; - str_iter = *r_name = MEM_mallocN(sizeof(char) * (prefix_l + postfix_l + len_new + 1), - "flipped_path"); + str_iter = *r_name = static_cast( + MEM_mallocN(sizeof(char) * (prefix_l + postfix_l + len_new + 1), "flipped_path")); memcpy(str_iter, aci->rna_path, prefix_l); str_iter += prefix_l; @@ -1041,11 +1047,11 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, { tAnimCopybufItem *aci; - for (aci = animcopybuf.first; aci; aci = aci->next) { + for (aci = static_cast(animcopybuf.first); aci; aci = aci->next) { if (to_simple || (aci->rna_path && fcu->rna_path)) { if (!to_simple && flip && aci->is_bone && fcu->rna_path) { if ((from_single) || (aci->array_index == fcu->array_index)) { - char *name = NULL; + char *name = nullptr; flip_names(aci, &name); if (STREQ(name, fcu->rna_path)) { MEM_freeN(name); @@ -1069,11 +1075,11 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain, FCurve *fcu, const short from_single, - const short UNUSED(to_simple)) + const short /*to_simple*/) { tAnimCopybufItem *aci; - for (aci = animcopybuf.first; aci; aci = aci->next) { + for (aci = static_cast(animcopybuf.first); aci; aci = aci->next) { /* check that paths exist */ if (aci->rna_path && fcu->rna_path) { /* find the property of the fcurve and compare against the end of the tAnimCopybufItem @@ -1120,11 +1126,11 @@ static tAnimCopybufItem *pastebuf_match_path_property(Main *bmain, /* least strict matching heuristic: indices only */ static tAnimCopybufItem *pastebuf_match_index_only(FCurve *fcu, const short from_single, - const short UNUSED(to_simple)) + const short /*to_simple*/) { tAnimCopybufItem *aci; - for (aci = animcopybuf.first; aci; aci = aci->next) { + for (aci = static_cast(animcopybuf.first); aci; aci = aci->next) { /* check that paths exist */ if ((from_single) || (aci->array_index == fcu->array_index)) { break; @@ -1265,7 +1271,7 @@ const EnumPropertyItem rna_enum_keyframe_paste_offset_items[] = { "Frame Relative", "Paste keys relative to the current frame when copying"}, {KEYFRAME_PASTE_OFFSET_NONE, "NONE", 0, "No Offset", "Paste keys from original time"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_keyframe_paste_offset_value[] = { @@ -1294,7 +1300,7 @@ const EnumPropertyItem rna_enum_keyframe_paste_offset_value[] = { 0, "No Offset", "Paste keys with the same value as they were copied"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; const EnumPropertyItem rna_enum_keyframe_paste_merge_items[] = { @@ -1310,7 +1316,7 @@ const EnumPropertyItem rna_enum_keyframe_paste_merge_items[] = { 0, "Overwrite Entire Range", "Overwrite keys in pasted range, using the range of all copied keys"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static float paste_get_y_offset(bAnimContext *ac, @@ -1406,9 +1412,9 @@ eKeyPasteError paste_animedit_keys(bAnimContext *ac, FCurve *fcu; tAnimCopybufItem *aci; - ale = anim_data->first; + ale = static_cast(anim_data->first); fcu = (FCurve *)ale->data; /* destination F-Curve */ - aci = animcopybuf.first; + aci = static_cast(animcopybuf.first); offset[1] = paste_get_y_offset(ac, aci, ale, value_offset_mode); paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, false); @@ -1423,7 +1429,7 @@ eKeyPasteError paste_animedit_keys(bAnimContext *ac, for (pass = 0; pass < 3; pass++) { uint totmatch = 0; - for (ale = anim_data->first; ale; ale = ale->next) { + for (ale = static_cast(anim_data->first); ale; ale = ale->next) { /* Find buffer item to paste from: * - If names don't matter (i.e. only 1 channel in buffer), don't check id/group * - If names do matter, only check if id-type is ok for now @@ -1432,7 +1438,7 @@ eKeyPasteError paste_animedit_keys(bAnimContext *ac, */ AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */ - tAnimCopybufItem *aci = NULL; + tAnimCopybufItem *aci = nullptr; switch (pass) { case 0: @@ -1457,9 +1463,9 @@ eKeyPasteError paste_animedit_keys(bAnimContext *ac, offset[1] = paste_get_y_offset(ac, aci, ale, value_offset_mode); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, static_cast(ale->key_data), 0, 0); paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, flip); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); + ANIM_nla_mapping_apply_fcurve(adt, static_cast(ale->key_data), 1, 0); } else { paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, flip); diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.cc similarity index 92% rename from source/blender/editors/animation/keyframing.c rename to source/blender/editors/animation/keyframing.cc index f2a16f6a33e..cd52ad34cdc 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.cc @@ -126,18 +126,18 @@ bAction *ED_id_action_ensure(Main *bmain, ID *id) /* init animdata if none available yet */ adt = BKE_animdata_from_id(id); - if (adt == NULL) { + if (adt == nullptr) { adt = BKE_animdata_ensure_id(id); } - if (adt == NULL) { + if (adt == nullptr) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : ""); - return NULL; + return nullptr; } /* init action if none available yet */ /* TODO: need some wizardry to handle NLA stuff correct */ - if (adt->action == NULL) { + if (adt->action == nullptr) { /* init action name from name of ID block */ char actname[sizeof(id->name) - 2]; SNPRINTF(actname, "%sAction", id->name + 2); @@ -164,8 +164,8 @@ bAction *ED_id_action_ensure(Main *bmain, ID *id) FCurve *ED_action_fcurve_find(bAction *act, const char rna_path[], const int array_index) { /* Sanity checks. */ - if (ELEM(NULL, act, rna_path)) { - return NULL; + if (ELEM(nullptr, act, rna_path)) { + return nullptr; } return BKE_fcurve_find(&act->curves, rna_path, array_index); } @@ -181,8 +181,8 @@ FCurve *ED_action_fcurve_ensure(Main *bmain, FCurve *fcu; /* Sanity checks. */ - if (ELEM(NULL, act, rna_path)) { - return NULL; + if (ELEM(nullptr, act, rna_path)) { + return nullptr; } /* try to find f-curve matching for this setting @@ -191,7 +191,7 @@ FCurve *ED_action_fcurve_ensure(Main *bmain, */ fcu = BKE_fcurve_find(&act->curves, rna_path, array_index); - if (fcu == NULL) { + if (fcu == nullptr) { /* use default settings to make a F-Curve */ fcu = BKE_fcurve_create(); @@ -211,13 +211,13 @@ FCurve *ED_action_fcurve_ensure(Main *bmain, agrp = BKE_action_group_find_name(act, group); /* no matching groups, so add one */ - if (agrp == NULL) { + if (agrp == nullptr) { agrp = action_groups_add_new(act, group); /* sync bone group colors if applicable */ if (ptr && (ptr->type == &RNA_PoseBone)) { Object *ob = (Object *)ptr->owner_id; - bPoseChannel *pchan = ptr->data; + bPoseChannel *pchan = static_cast(ptr->data); bPose *pose = ob->pose; bActionGroup *grp; @@ -277,7 +277,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin PropertyRNA *prop; int old_flag = fcu->flag; - if ((ptr->owner_id == NULL) && (ptr->data == NULL)) { + if ((ptr->owner_id == nullptr) && (ptr->data == nullptr)) { BKE_report(reports, RPT_ERROR, "No RNA pointer available to retrieve values for this F-curve"); return; } @@ -301,7 +301,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin if (old_flag != fcu->flag) { /* Same as if keyframes had been changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); } } @@ -338,7 +338,7 @@ static eFCU_Cycle_Type remap_cyclic_keyframe_location(FCurve *fcu, float *px, fl if (type == FCU_CYCLE_OFFSET) { /* Nasty check to handle the case when the modes are different better. */ - FMod_Cycles *data = ((FModifier *)fcu->modifiers.first)->data; + FMod_Cycles *data = static_cast(((FModifier *)fcu->modifiers.first)->data); short mode = (step >= 0) ? data->after_mode : data->before_mode; if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) { @@ -373,7 +373,7 @@ static void make_new_fcurve_cyclic(const bAction *act, FCurve *fcu) fcu->bezt[0].vec[2][0] -= fix; /* Duplicate and offset the keyframe. */ - fcu->bezt = MEM_reallocN(fcu->bezt, sizeof(BezTriple) * 2); + fcu->bezt = static_cast(MEM_reallocN(fcu->bezt, sizeof(BezTriple) * 2)); fcu->totvert = 2; fcu->bezt[1] = fcu->bezt[0]; @@ -440,7 +440,8 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) /* Keyframing modes allow not replacing the keyframe. */ else if ((flag & INSERTKEY_REPLACE) == 0) { /* insert new - if we're not restricted to replacing keyframes only */ - BezTriple *newb = MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple"); + BezTriple *newb = static_cast( + MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple")); /* Add the beztriples that should occur before the beztriple to be pasted * (originally in fcu). */ @@ -472,9 +473,9 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) * NOTE: maybe we may want to allow this later when doing samples -> bezt conversions, * but for now, having both is asking for trouble */ - else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == NULL)) { + else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == nullptr)) { /* create new keyframes array */ - fcu->bezt = MEM_callocN(sizeof(BezTriple), "beztriple"); + fcu->bezt = static_cast(MEM_callocN(sizeof(BezTriple), "beztriple")); *(fcu->bezt) = *bezt; fcu->totvert = 1; } @@ -668,7 +669,7 @@ enum { static short new_key_needed(FCurve *fcu, float cFrame, float nValue) { /* safety checking */ - if (fcu == NULL) { + if (fcu == nullptr) { return KEYNEEDED_JUSTADD; } int totCount = fcu->totvert; @@ -678,7 +679,7 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) /* loop through checking if any are the same */ BezTriple *bezt = fcu->bezt; - BezTriple *prev = NULL; + BezTriple *prev = nullptr; for (int i = 0; i < totCount; i++) { float prevPosi = 0.0f, prevVal = 0.0f; float beztPosi = 0.0f, beztVal = 0.0f; @@ -790,12 +791,12 @@ static float *setting_get_rna_values( int *tmp_int; if (length > buffer_size) { - values = MEM_malloc_arrayN(length, sizeof(float), __func__); + values = static_cast(MEM_malloc_arrayN(length, sizeof(float), __func__)); } switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - tmp_bool = MEM_malloc_arrayN(length, sizeof(*tmp_bool), __func__); + tmp_bool = static_cast(MEM_malloc_arrayN(length, sizeof(*tmp_bool), __func__)); RNA_property_boolean_get_array(ptr, prop, tmp_bool); for (int i = 0; i < length; i++) { values[i] = (float)tmp_bool[i]; @@ -803,7 +804,7 @@ static float *setting_get_rna_values( MEM_freeN(tmp_bool); break; case PROP_INT: - tmp_int = MEM_malloc_arrayN(length, sizeof(*tmp_int), __func__); + tmp_int = static_cast(MEM_malloc_arrayN(length, sizeof(*tmp_int), __func__)); RNA_property_int_get_array(ptr, prop, tmp_int); for (int i = 0; i < length; i++) { values[i] = (float)tmp_int[i]; @@ -860,14 +861,14 @@ enum { */ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) { - bConstraint *con = NULL; + bConstraint *con = nullptr; short searchtype = VISUALKEY_NONE; bool has_rigidbody = false; bool has_parent = false; - const char *identifier = NULL; + const char *identifier = nullptr; /* validate data */ - if (ELEM(NULL, ptr, ptr->data, prop)) { + if (ELEM(nullptr, ptr, ptr->data, prop)) { return false; } @@ -878,33 +879,33 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) */ if (ptr->type == &RNA_Object) { /* Object */ - Object *ob = ptr->data; + Object *ob = static_cast(ptr->data); RigidBodyOb *rbo = ob->rigidbody_object; - con = ob->constraints.first; + con = static_cast(ob->constraints.first); identifier = RNA_property_identifier(prop); - has_parent = (ob->parent != NULL); + has_parent = (ob->parent != nullptr); /* active rigidbody objects only, as only those are affected by sim */ has_rigidbody = ((rbo) && (rbo->type == RBO_TYPE_ACTIVE)); } else if (ptr->type == &RNA_PoseBone) { /* Pose Channel */ - bPoseChannel *pchan = ptr->data; + bPoseChannel *pchan = static_cast(ptr->data); - con = pchan->constraints.first; + con = static_cast(pchan->constraints.first); identifier = RNA_property_identifier(prop); - has_parent = (pchan->parent != NULL); + has_parent = (pchan->parent != nullptr); } /* check if any data to search using */ - if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false)) { + if (ELEM(nullptr, con, identifier) && (has_parent == false) && (has_rigidbody == false)) { return false; } /* location or rotation identifiers only... */ - if (identifier == NULL) { - printf("%s failed: NULL identifier\n", __func__); + if (identifier == nullptr) { + printf("%s failed: nullptr identifier\n", __func__); return false; } @@ -1042,7 +1043,7 @@ static float *visualkey_get_values( * - assume that array_index will be sane */ if (ptr->type == &RNA_Object) { - Object *ob = ptr->data; + Object *ob = static_cast(ptr->data); /* Loc code is specific... */ if (strstr(identifier, "location")) { copy_v3_v3(buffer, ob->object_to_world[3]); @@ -1054,7 +1055,7 @@ static float *visualkey_get_values( rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { - bPoseChannel *pchan = ptr->data; + bPoseChannel *pchan = static_cast(ptr->data); BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat); rotmode = pchan->rotmode; @@ -1062,7 +1063,7 @@ static float *visualkey_get_values( /* Loc code is specific... */ if (strstr(identifier, "location")) { /* only use for non-connected bones */ - if ((pchan->bone->parent == NULL) || !(pchan->bone->flag & BONE_CONNECTED)) { + if ((pchan->bone->parent == nullptr) || !(pchan->bone->flag & BONE_CONNECTED)) { copy_v3_v3(buffer, tmat[3]); *r_count = 3; return buffer; @@ -1309,18 +1310,18 @@ bool insert_keyframe_direct(ReportList *reports, float curval = 0.0f; /* no F-Curve to add keyframe to? */ - if (fcu == NULL) { + if (fcu == nullptr) { BKE_report(reports, RPT_ERROR, "No F-Curve to add keyframes to"); return false; } /* if no property given yet, try to validate from F-Curve info */ - if ((ptr.owner_id == NULL) && (ptr.data == NULL)) { + if ((ptr.owner_id == nullptr) && (ptr.data == nullptr)) { BKE_report( reports, RPT_ERROR, "No RNA pointer available to retrieve values for keyframing from"); return false; } - if (prop == NULL) { + if (prop == nullptr) { PointerRNA tmp_ptr; /* try to get property we should be affecting */ @@ -1349,7 +1350,7 @@ bool insert_keyframe_direct(ReportList *reports, int value_count; int index = fcu->array_index; - BLI_bitmap *successful_remaps = NULL; + BLI_bitmap *successful_remaps = nullptr; float *values = get_keyframe_values(reports, ptr, prop, @@ -1360,7 +1361,7 @@ bool insert_keyframe_direct(ReportList *reports, RNA_MAX_ARRAY_LENGTH, anim_eval_context, &value_count, - NULL, + nullptr, &successful_remaps); if (index >= 0 && index < value_count) { @@ -1466,7 +1467,7 @@ static AnimationEvalContext nla_time_remap(const AnimationEvalContext *anim_eval return BKE_animsys_eval_context_construct_at(anim_eval_context, remapped_frame); } - *r_nla_context = NULL; + *r_nla_context = nullptr; return *anim_eval_context; } @@ -1483,14 +1484,14 @@ int insert_keyframe(Main *bmain, eInsertKeyFlags flag) { PointerRNA id_ptr, ptr; - PropertyRNA *prop = NULL; + PropertyRNA *prop = nullptr; AnimData *adt; - ListBase tmp_nla_cache = {NULL, NULL}; - NlaKeyframingContext *nla_context = NULL; + ListBase tmp_nla_cache = {nullptr, nullptr}; + NlaKeyframingContext *nla_context = nullptr; int ret = 0; /* validate pointer first - exit if failure */ - if (id == NULL) { + if (id == nullptr) { BKE_reportf(reports, RPT_ERROR, "No ID block to insert keyframe in (path = %s)", rna_path); return 0; } @@ -1507,11 +1508,11 @@ int insert_keyframe(Main *bmain, } /* if no action is provided, keyframe to the default one attached to this ID-block */ - if (act == NULL) { + if (act == nullptr) { /* get action to add F-Curve+keyframe to */ act = ED_id_action_ensure(bmain, id); - if (act == NULL) { + if (act == nullptr) { BKE_reportf(reports, RPT_ERROR, "Could not insert keyframe, as this type does not support animation data (ID = " @@ -1532,7 +1533,7 @@ int insert_keyframe(Main *bmain, int value_count; bool force_all; - BLI_bitmap *successful_remaps = NULL; + BLI_bitmap *successful_remaps = nullptr; float *values = get_keyframe_values(reports, ptr, prop, @@ -1651,10 +1652,10 @@ int insert_keyframe(Main *bmain, BKE_animsys_free_nla_keyframing_context_cache(&tmp_nla_cache); if (ret) { - if (act != NULL) { + if (act != nullptr) { DEG_id_tag_update(&act->id, ID_RECALC_ANIMATION_NO_FLUSH); } - if (adt != NULL && adt->action != NULL && adt->action != act) { + if (adt != nullptr && adt->action != nullptr && adt->action != act) { DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH); } } @@ -1670,7 +1671,8 @@ void ED_keyframes_add(FCurve *fcu, int num_keys_to_add) return; } - fcu->bezt = MEM_recallocN(fcu->bezt, sizeof(BezTriple) * (fcu->totvert + num_keys_to_add)); + fcu->bezt = static_cast( + MEM_recallocN(fcu->bezt, sizeof(BezTriple) * (fcu->totvert + num_keys_to_add))); BezTriple *bezt = fcu->bezt + fcu->totvert; /* Pointer to the first new one. '*/ fcu->totvert += num_keys_to_add; @@ -1714,7 +1716,7 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra) /* Only delete curve too if it won't be doing anything anymore */ if (BKE_fcurve_is_empty(fcu)) { - ANIM_fcurve_delete_from_animdata(NULL, adt, fcu); + ANIM_fcurve_delete_from_animdata(nullptr, adt, fcu); } /* return success */ @@ -1725,7 +1727,7 @@ static bool delete_keyframe_fcurve(AnimData *adt, FCurve *fcu, float cfra) static void deg_tag_after_keyframe_delete(Main *bmain, ID *id, AnimData *adt) { - if (adt->action == NULL) { + if (adt->action == nullptr) { /* In the case last f-curve was removed need to inform dependency graph * about relations update, since it needs to get rid of animation operation * for this data-block. */ @@ -1752,7 +1754,7 @@ int delete_keyframe(Main *bmain, int ret = 0; /* sanity checks */ - if (ELEM(NULL, id, adt)) { + if (ELEM(nullptr, id, adt)) { BKE_report(reports, RPT_ERROR, "No ID block and/or AnimData to delete keyframe from"); return 0; } @@ -1773,7 +1775,7 @@ int delete_keyframe(Main *bmain, * NOTE: here is one of the places where we don't want new Action + F-Curve added! * so 'add' var must be 0 */ - if (act == NULL) { + if (act == nullptr) { /* if no action is provided, use the default one attached to this ID-block * - if it doesn't exist, then we're out of options... */ @@ -1808,7 +1810,7 @@ int delete_keyframe(Main *bmain, FCurve *fcu = ED_action_fcurve_find(act, rna_path, array_index); /* check if F-Curve exists and/or whether it can be edited */ - if (fcu == NULL) { + if (fcu == nullptr) { continue; } @@ -1850,7 +1852,7 @@ static int clear_keyframe(Main *bmain, bAction *act, const char rna_path[], int array_index, - eInsertKeyFlags UNUSED(flag)) + eInsertKeyFlags /*flag*/) { AnimData *adt = BKE_animdata_from_id(id); PointerRNA id_ptr, ptr; @@ -1859,7 +1861,7 @@ static int clear_keyframe(Main *bmain, int ret = 0; /* sanity checks */ - if (ELEM(NULL, id, adt)) { + if (ELEM(nullptr, id, adt)) { BKE_report(reports, RPT_ERROR, "No ID block and/or AnimData to delete keyframe from"); return 0; } @@ -1880,7 +1882,7 @@ static int clear_keyframe(Main *bmain, * NOTE: here is one of the places where we don't want new Action + F-Curve added! * so 'add' var must be 0 */ - if (act == NULL) { + if (act == nullptr) { /* if no action is provided, use the default one attached to this ID-block * - if it doesn't exist, then we're out of options... */ @@ -1912,7 +1914,7 @@ static int clear_keyframe(Main *bmain, FCurve *fcu = ED_action_fcurve_find(act, rna_path, array_index); /* check if F-Curve exists and/or whether it can be edited */ - if (fcu == NULL) { + if (fcu == nullptr) { continue; } @@ -1926,7 +1928,7 @@ static int clear_keyframe(Main *bmain, continue; } - ANIM_fcurve_delete_from_animdata(NULL, adt, fcu); + ANIM_fcurve_delete_from_animdata(nullptr, adt, fcu); /* return success */ ret++; @@ -1958,7 +1960,7 @@ static bool modify_key_op_poll(bContext *C) Scene *scene = CTX_data_scene(C); /* if no area or active scene */ - if (ELEM(NULL, area, scene)) { + if (ELEM(nullptr, area, scene)) { return false; } @@ -1980,7 +1982,7 @@ static int insert_key_exec(bContext *C, wmOperator *op) const bool confirm = op->flag & OP_IS_INVOKE; KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene); - if (ks == NULL) { + if (ks == nullptr) { return OPERATOR_CANCELLED; } @@ -1993,7 +1995,7 @@ static int insert_key_exec(bContext *C, wmOperator *op) } /* try to insert keyframes for the channels specified by KeyingSet */ - num_channels = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); + num_channels = ANIM_apply_keyingset(C, nullptr, nullptr, ks, MODIFYKEY_MODE_INSERT, cfra); if (G.debug & G_DEBUG) { BKE_reportf(op->reports, RPT_INFO, @@ -2015,7 +2017,7 @@ static int insert_key_exec(bContext *C, wmOperator *op) if (num_channels > 0) { /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr); } if (confirm) { @@ -2078,7 +2080,7 @@ void ANIM_OT_keyframe_insert_by_name(wmOperatorType *ot) /* keyingset to use (idname) */ prop = RNA_def_string( - ot->srna, "type", NULL, MAX_ID_NAME - 2, "Keying Set", "The Keying Set to use"); + ot->srna, "type", nullptr, MAX_ID_NAME - 2, "Keying Set", "The Keying Set to use"); RNA_def_property_string_search_func_runtime( prop, ANIM_keyingset_visit_for_search_no_poll, PROP_STRING_SEARCH_SUGGESTION); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -2090,7 +2092,7 @@ void ANIM_OT_keyframe_insert_by_name(wmOperatorType *ot) * then calls the menu if necessary before */ -static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Scene *scene = CTX_data_scene(C); @@ -2113,7 +2115,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN * prefer `ANIM_OT_keyframe_insert_by_name` so users can bind keys to specific * keying sets by name in the key-map instead of the index which isn't stable. */ PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type"); - const EnumPropertyItem *item_array = NULL; + const EnumPropertyItem *item_array = nullptr; int totitem; bool free; @@ -2133,7 +2135,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN /* This enum shouldn't contain headings, assert there are none. * NOTE: If in the future the enum includes them, additional layout code can be * added to show them - although that doesn't seem likely. */ - BLI_assert(item->name == NULL); + BLI_assert(item->name == nullptr); uiItemS(layout); } } @@ -2186,7 +2188,7 @@ static int delete_key_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); KeyingSet *ks = keyingset_get_from_op_with_error(op, op->type->prop, scene); - if (ks == NULL) { + if (ks == nullptr) { return OPERATOR_CANCELLED; } @@ -2202,7 +2204,7 @@ static int delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *k const bool confirm = op->flag & OP_IS_INVOKE; /* try to delete keyframes for the channels specified by KeyingSet */ - num_channels = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); + num_channels = ANIM_apply_keyingset(C, nullptr, nullptr, ks, MODIFYKEY_MODE_DELETE, cfra); if (G.debug & G_DEBUG) { printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, num_channels); } @@ -2214,7 +2216,7 @@ static int delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *k } if (num_channels > 0) { - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr); } if (confirm) { @@ -2276,7 +2278,7 @@ void ANIM_OT_keyframe_delete_by_name(wmOperatorType *ot) /* keyingset to use (idname) */ prop = RNA_def_string( - ot->srna, "type", NULL, MAX_ID_NAME - 2, "Keying Set", "The Keying Set to use"); + ot->srna, "type", nullptr, MAX_ID_NAME - 2, "Keying Set", "The Keying Set to use"); RNA_def_property_string_search_func_runtime( prop, ANIM_keyingset_visit_for_search_no_poll, PROP_STRING_SEARCH_SUGGESTION); RNA_def_property_flag(prop, PROP_HIDDEN); @@ -2288,7 +2290,7 @@ void ANIM_OT_keyframe_delete_by_name(wmOperatorType *ot) * it is more useful for animators working in the 3D view. */ -static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) +static int clear_anim_v3d_exec(bContext *C, wmOperator * /*op*/) { bool changed = false; @@ -2299,7 +2301,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) bAction *act = adt->action; FCurve *fcu, *fcn; - for (fcu = act->curves.first; fcu; fcu = fcn) { + for (fcu = static_cast(act->curves.first); fcu; fcu = fcn) { bool can_delete = false; fcn = fcu->next; @@ -2308,7 +2310,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->mode & OB_MODE_POSE) { if (fcu->rna_path) { /* Get bone-name, and check if this bone is selected. */ - bPoseChannel *pchan = NULL; + bPoseChannel *pchan = nullptr; char bone_name[sizeof(pchan->name)]; if (BLI_str_quoted_substr(fcu->rna_path, "pose.bones[", bone_name, sizeof(bone_name))) { @@ -2329,7 +2331,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) /* delete F-Curve completely */ if (can_delete) { - ANIM_fcurve_delete_from_animdata(NULL, adt, fcu); + ANIM_fcurve_delete_from_animdata(nullptr, adt, fcu); DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); changed = true; } @@ -2348,7 +2350,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) } /* send updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, nullptr); return OPERATOR_FINISHED; } @@ -2395,7 +2397,7 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op) FCurve *fcu, *fcn; const float cfra_unmap = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); - for (fcu = act->curves.first; fcu; fcu = fcn) { + for (fcu = static_cast(act->curves.first); fcu; fcu = fcn) { fcn = fcu->next; /* don't touch protected F-Curves */ @@ -2413,7 +2415,7 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op) * In object mode, we're dealing with the entire object. */ if (ob->mode & OB_MODE_POSE) { - bPoseChannel *pchan = NULL; + bPoseChannel *pchan = nullptr; /* Get bone-name, and check if this bone is selected. */ char bone_name[sizeof(pchan->name)]; @@ -2463,7 +2465,7 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op) if (selected_objects_success_len) { /* send updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, nullptr); } if (confirm) { @@ -2488,7 +2490,7 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); KeyingSet *ks = ANIM_scene_get_active_keyingset(scene); - if (ks == NULL) { + if (ks == nullptr) { return delete_key_v3d_without_keying_set(C, op); } @@ -2520,8 +2522,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; char *path; uiBut *but; const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct( @@ -2546,12 +2548,18 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) * strips themselves. These are stored separately or else the properties will * not have any effect. */ - NlaStrip *strip = ptr.data; + NlaStrip *strip = static_cast(ptr.data); FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), index); if (fcu) { - changed = insert_keyframe_direct( - op->reports, ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, 0); + changed = insert_keyframe_direct(op->reports, + ptr, + prop, + fcu, + &anim_eval_context, + eBezTriple_KeyframeType(ts->keyframe_type), + nullptr, + eInsertKeyFlags(0)); } else { BKE_report(op->reports, @@ -2564,7 +2572,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) FCurve *fcu; bool driven, special; - fcu = BKE_fcurve_find_by_rna_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); + fcu = BKE_fcurve_find_by_rna_context_ui( + C, &ptr, prop, index, nullptr, nullptr, &driven, &special); if (fcu && driven) { changed = insert_keyframe_direct(op->reports, @@ -2572,8 +2581,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) prop, fcu, &anim_eval_context, - ts->keyframe_type, - NULL, + eBezTriple_KeyframeType(ts->keyframe_type), + nullptr, INSERTKEY_DRIVER); } } @@ -2583,7 +2592,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) if (path) { const char *identifier = RNA_property_identifier(prop); - const char *group = NULL; + const char *group = nullptr; /* Special exception for keyframing transforms: * Set "group" for this manually, instead of having them appearing at the bottom @@ -2593,7 +2602,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) * TODO: Perhaps we can extend this behavior in future for other properties... */ if (ptr.type == &RNA_PoseBone) { - bPoseChannel *pchan = ptr.data; + bPoseChannel *pchan = static_cast(ptr.data); group = pchan->name; } else if ((ptr.type == &RNA_Object) && @@ -2614,13 +2623,13 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) changed = (insert_keyframe(bmain, op->reports, ptr.owner_id, - NULL, + nullptr, group, path, index, &anim_eval_context, - ts->keyframe_type, - NULL, + eBezTriple_KeyframeType(ts->keyframe_type), + nullptr, flag) != 0); MEM_freeN(path); @@ -2653,7 +2662,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) if (changed) { ID *id = ptr.owner_id; AnimData *adt = BKE_animdata_from_id(id); - if (adt->action != NULL) { + if (adt->action != nullptr) { DEG_id_tag_update(&adt->action->id, ID_RECALC_ANIMATION_NO_FLUSH); } DEG_id_tag_update(id, ID_RECALC_ANIMATION_NO_FLUSH); @@ -2662,7 +2671,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) UI_context_update_anim_flag(C); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr); } return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; @@ -2691,8 +2700,8 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) static int delete_key_button_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; Main *bmain = CTX_data_main(C); char *path; float cfra = (float) @@ -2714,7 +2723,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) * not have any effect. */ ID *id = ptr.owner_id; - NlaStrip *strip = ptr.data; + NlaStrip *strip = static_cast(ptr.data); FCurve *fcu = BKE_fcurve_find(&strip->fcurves, RNA_property_identifier(prop), 0); if (fcu) { @@ -2756,7 +2765,8 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) index = -1; } - changed = delete_keyframe(bmain, op->reports, ptr.owner_id, NULL, path, index, cfra) != 0; + changed = delete_keyframe(bmain, op->reports, ptr.owner_id, nullptr, path, index, cfra) != + 0; MEM_freeN(path); } else if (G.debug & G_DEBUG) { @@ -2773,7 +2783,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) UI_context_update_anim_flag(C); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr); } return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; @@ -2801,8 +2811,8 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) static int clear_key_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr = {NULL}; - PropertyRNA *prop = NULL; + PointerRNA ptr = {nullptr}; + PropertyRNA *prop = nullptr; Main *bmain = CTX_data_main(C); char *path; bool changed = false; @@ -2824,7 +2834,9 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) index = -1; } - changed |= (clear_keyframe(bmain, op->reports, ptr.owner_id, NULL, path, index, 0) != 0); + changed |= + (clear_keyframe( + bmain, op->reports, ptr.owner_id, nullptr, path, index, eInsertKeyFlags(0)) != 0); MEM_freeN(path); } else if (G.debug & G_DEBUG) { @@ -2840,7 +2852,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) UI_context_update_anim_flag(C); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, nullptr); } return (changed) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; @@ -2903,7 +2915,7 @@ bool autokeyframe_cfra_can_key(const Scene *scene, ID *id) bool fcurve_frame_has_keyframe(const FCurve *fcu, float frame) { /* quick sanity check */ - if (ELEM(NULL, fcu, fcu->bezt)) { + if (ELEM(nullptr, fcu, fcu->bezt)) { return false; } @@ -2959,7 +2971,7 @@ static bool action_frame_has_keyframe(bAction *act, float frame) FCurve *fcu; /* can only find if there is data */ - if (act == NULL) { + if (act == nullptr) { return false; } @@ -2970,7 +2982,7 @@ static bool action_frame_has_keyframe(bAction *act, float frame) /* loop over F-Curves, using binary-search to try to find matches * - this assumes that keyframes are only beztriples */ - for (fcu = act->curves.first; fcu; fcu = fcu->next) { + for (fcu = static_cast(act->curves.first); fcu; fcu = fcu->next) { /* only check if there are keyframes (currently only of type BezTriple) */ if (fcu->bezt && fcu->totvert) { if (fcurve_frame_has_keyframe(fcu, frame)) { @@ -2987,7 +2999,7 @@ static bool action_frame_has_keyframe(bAction *act, float frame) static bool object_frame_has_keyframe(Object *ob, float frame) { /* error checking */ - if (ob == NULL) { + if (ob == nullptr) { return false; } @@ -3013,7 +3025,7 @@ static bool object_frame_has_keyframe(Object *ob, float frame) bool id_frame_has_keyframe(ID *id, float frame) { /* sanity checks */ - if (id == NULL) { + if (id == nullptr) { return false; } @@ -3022,9 +3034,9 @@ bool id_frame_has_keyframe(ID *id, float frame) case ID_OB: /* object */ return object_frame_has_keyframe((Object *)id, frame); #if 0 - /* XXX TODO... for now, just use 'normal' behavior */ - case ID_SCE: /* scene */ - break; +/* XXX TODO... for now, just use 'normal' behavior */ +case ID_SCE: /* scene */ +break; #endif default: /* 'normal type' */ { @@ -3048,15 +3060,15 @@ bool ED_autokeyframe_object(bContext *C, Scene *scene, Object *ob, KeyingSet *ks { /* auto keyframing */ if (autokeyframe_cfra_can_key(scene, &ob->id)) { - ListBase dsources = {NULL, NULL}; + ListBase dsources = {nullptr, nullptr}; /* Now insert the key-frame(s) using the Keying Set: * 1) Add data-source override for the Object. * 2) Insert key-frames. * 3) Free the extra info. */ - ANIM_relative_keyingset_add_source(&dsources, &ob->id, NULL, NULL); - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); + ANIM_relative_keyingset_add_source(&dsources, &ob->id, nullptr, nullptr); + ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); BLI_freelistN(&dsources); return true; @@ -3068,7 +3080,7 @@ bool ED_autokeyframe_pchan( bContext *C, Scene *scene, Object *ob, bPoseChannel *pchan, KeyingSet *ks) { if (autokeyframe_cfra_can_key(scene, &ob->id)) { - ListBase dsources = {NULL, NULL}; + ListBase dsources = {nullptr, nullptr}; /* Now insert the keyframe(s) using the Keying Set: * 1) Add data-source override for the pose-channel. @@ -3076,7 +3088,7 @@ bool ED_autokeyframe_pchan( * 3) Free the extra info. */ ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); + ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); BLI_freelistN(&dsources); return true; @@ -3108,11 +3120,11 @@ bool ED_autokeyframe_property(bContext *C, * but works well enough in typical cases */ const int rnaindex_check = (rnaindex == -1) ? 0 : rnaindex; fcu = BKE_fcurve_find_by_rna_context_ui( - C, ptr, prop, rnaindex_check, NULL, &action, &driven, &special); + C, ptr, prop, rnaindex_check, nullptr, &action, &driven, &special); /* Only early out when we actually want an existing F-curve already * (e.g. auto-keyframing from buttons). */ - if (fcu == NULL && (driven || special || only_if_property_keyed)) { + if (fcu == nullptr && (driven || special || only_if_property_keyed)) { return changed; } @@ -3122,9 +3134,15 @@ bool ED_autokeyframe_property(bContext *C, ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; - changed = insert_keyframe_direct( - reports, *ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, 0); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + changed = insert_keyframe_direct(reports, + *ptr, + prop, + fcu, + &anim_eval_context, + eBezTriple_KeyframeType(ts->keyframe_type), + nullptr, + eInsertKeyFlags(0)); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); } } else if (driven) { @@ -3135,9 +3153,15 @@ bool ED_autokeyframe_property(bContext *C, ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; - changed = insert_keyframe_direct( - reports, *ptr, prop, fcu, &anim_eval_context, ts->keyframe_type, NULL, INSERTKEY_DRIVER); - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + changed = insert_keyframe_direct(reports, + *ptr, + prop, + fcu, + &anim_eval_context, + eBezTriple_KeyframeType(ts->keyframe_type), + nullptr, + INSERTKEY_DRIVER); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); } } else { @@ -3160,17 +3184,17 @@ bool ED_autokeyframe_property(bContext *C, reports, id, action, - (fcu && fcu->grp) ? fcu->grp->name : NULL, + (fcu && fcu->grp) ? fcu->grp->name : nullptr, fcu ? fcu->rna_path : path, rnaindex, &anim_eval_context, - ts->keyframe_type, - NULL, + eBezTriple_KeyframeType(ts->keyframe_type), + nullptr, flag) != 0; if (path) { MEM_freeN(path); } - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); } } return changed; @@ -3183,12 +3207,12 @@ bool ED_autokeyframe_property(bContext *C, /** Use for insert/delete key-frame. */ static KeyingSet *keyingset_get_from_op_with_error(wmOperator *op, PropertyRNA *prop, Scene *scene) { - KeyingSet *ks = NULL; + KeyingSet *ks = nullptr; const int prop_type = RNA_property_type(prop); if (prop_type == PROP_ENUM) { int type = RNA_property_enum_get(op->ptr, prop); ks = ANIM_keyingset_get_from_enum_type(scene, type); - if (ks == NULL) { + if (ks == nullptr) { BKE_report(op->reports, RPT_ERROR, "No active Keying Set"); } } @@ -3197,7 +3221,7 @@ static KeyingSet *keyingset_get_from_op_with_error(wmOperator *op, PropertyRNA * RNA_property_string_get(op->ptr, prop, type_id); ks = ANIM_keyingset_get_from_idname(scene, type_id); - if (ks == NULL) { + if (ks == nullptr) { BKE_reportf(op->reports, RPT_ERROR, "Keying set '%s' not found", type_id); } } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.cc similarity index 82% rename from source/blender/editors/animation/keyingsets.c rename to source/blender/editors/animation/keyingsets.cc index 5fc96f714f5..55a5106cfb4 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.cc @@ -54,7 +54,7 @@ static bool keyingset_poll_default_add(bContext *C) { /* as long as there's an active Scene, it's fine */ - return (CTX_data_scene(C) != NULL); + return (CTX_data_scene(C) != nullptr); } /* poll callback for editing active KeyingSet */ @@ -62,7 +62,7 @@ static bool keyingset_poll_active_edit(bContext *C) { Scene *scene = CTX_data_scene(C); - if (scene == NULL) { + if (scene == nullptr) { return 0; } @@ -76,14 +76,14 @@ static bool keyingset_poll_activePath_edit(bContext *C) Scene *scene = CTX_data_scene(C); KeyingSet *ks; - if (scene == NULL) { + if (scene == nullptr) { return 0; } if (scene->active_keyingset <= 0) { return 0; } - ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + ks = static_cast(BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); /* there must be an active KeyingSet and an active path */ return ((ks) && (ks->paths.first) && (ks->active_path > 0)); @@ -91,11 +91,11 @@ static bool keyingset_poll_activePath_edit(bContext *C) /* Add a Default (Empty) Keying Set ------------------------- */ -static int add_default_keyingset_exec(bContext *C, wmOperator *UNUSED(op)) +static int add_default_keyingset_exec(bContext *C, wmOperator * /*op*/) { Scene *scene = CTX_data_scene(C); - eKS_Settings flag = 0; - eInsertKeyFlags keyingflag = 0; + eKS_Settings flag = eKS_Settings(0); + eInsertKeyFlags keyingflag = eInsertKeyFlags(0); /* validate flags * - absolute KeyingSets should be created by default @@ -106,12 +106,12 @@ static int add_default_keyingset_exec(bContext *C, wmOperator *UNUSED(op)) keyingflag = ANIM_get_keyframing_flags(scene, false); /* call the API func, and set the active keyingset index */ - BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag); + BKE_keyingset_add(&scene->keyingsets, nullptr, nullptr, flag, keyingflag); scene->active_keyingset = BLI_listbase_count(&scene->keyingsets); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, nullptr); return OPERATOR_FINISHED; } @@ -149,7 +149,7 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + ks = static_cast(BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); /* free KeyingSet's data, then remove it from the scene */ BKE_keyingset_free(ks); @@ -159,7 +159,7 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op) scene->active_keyingset--; /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, nullptr); return OPERATOR_FINISHED; } @@ -193,10 +193,10 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + ks = static_cast(BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); /* don't use the API method for this, since that checks on values... */ - ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty"); + ksp = static_cast(MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty")); BLI_addtail(&ks->paths, ksp); ks->active_path = BLI_listbase_count(&ks->paths); @@ -224,11 +224,12 @@ void ANIM_OT_keying_set_path_add(wmOperatorType *ot) static int remove_active_ks_path_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - KeyingSet *ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + KeyingSet *ks = static_cast( + BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); /* if there is a KeyingSet, find the nominated path to remove */ if (ks) { - KS_Path *ksp = BLI_findlink(&ks->paths, ks->active_path - 1); + KS_Path *ksp = static_cast(BLI_findlink(&ks->paths, ks->active_path - 1)); if (ksp) { /* remove the active path from the KeyingSet */ @@ -270,10 +271,10 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot) static int add_keyingset_button_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - KeyingSet *ks = NULL; - PropertyRNA *prop = NULL; - PointerRNA ptr = {NULL}; - char *path = NULL; + KeyingSet *ks = nullptr; + PropertyRNA *prop = nullptr; + PointerRNA ptr = {nullptr}; + char *path = nullptr; bool changed = false; int index = 0, pflag = 0; const bool all = RNA_boolean_get(op->ptr, "all"); @@ -289,8 +290,8 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) * - add a new one if it doesn't exist */ if (scene->active_keyingset == 0) { - eKS_Settings flag = 0; - eInsertKeyFlags keyingflag = 0; + eKS_Settings flag = eKS_Settings(0); + eInsertKeyFlags keyingflag = eInsertKeyFlags(0); /* validate flags * - absolute KeyingSets should be created by default @@ -314,7 +315,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + ks = static_cast(BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); } /* check if property is able to be added */ @@ -334,7 +335,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) } /* add path to this setting */ - BKE_keyingset_add_path(ks, ptr.owner_id, NULL, path, index, pflag, KSP_GROUP_KSNAME); + BKE_keyingset_add_path(ks, ptr.owner_id, nullptr, path, index, pflag, KSP_GROUP_KSNAME); ks->active_path = BLI_listbase_count(&ks->paths); changed = true; @@ -345,7 +346,7 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) if (changed) { /* send updates */ - WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, nullptr); /* show notification/report header, so that users notice that something changed */ BKE_reportf(op->reports, RPT_INFO, "Property added to Keying Set: '%s'", ks->name); @@ -377,10 +378,10 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) static int remove_keyingset_button_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - KeyingSet *ks = NULL; - PropertyRNA *prop = NULL; - PointerRNA ptr = {NULL}; - char *path = NULL; + KeyingSet *ks = nullptr; + PropertyRNA *prop = nullptr; + PointerRNA ptr = {nullptr}; + char *path = nullptr; bool changed = false; int index = 0; @@ -404,7 +405,7 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + ks = static_cast(BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); if (ptr.owner_id && ptr.data && prop) { path = RNA_path_from_ID_to_property(&ptr, prop); @@ -427,7 +428,7 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) if (changed) { /* send updates */ - WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, nullptr); /* show warning */ BKE_report(op->reports, RPT_INFO, "Property removed from keying set"); @@ -457,7 +458,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) /* This operator checks if a menu should be shown * for choosing the KeyingSet to make the active one. */ -static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { uiPopupMenu *pup; uiLayout *layout; @@ -480,7 +481,7 @@ static int keyingset_active_menu_exec(bContext *C, wmOperator *op) scene->active_keyingset = type; /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, nullptr); return OPERATOR_FINISHED; } @@ -513,30 +514,31 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot) /* REGISTERED KEYING SETS */ /* Keying Set Type Info declarations */ -static ListBase keyingset_type_infos = {NULL, NULL}; +static ListBase keyingset_type_infos = {nullptr, nullptr}; -ListBase builtin_keyingsets = {NULL, NULL}; +ListBase builtin_keyingsets = {nullptr, nullptr}; /* --------------- */ KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]) { /* sanity checks */ - if ((name == NULL) || (name[0] == 0)) { - return NULL; + if ((name == nullptr) || (name[0] == 0)) { + return nullptr; } /* search by comparing names */ - return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname)); + return static_cast( + BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname))); } KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]) { - KeyingSet *ks, *first = NULL; + KeyingSet *ks, *first = nullptr; /* sanity checks any name to check? */ if (name[0] == 0) { - return NULL; + return nullptr; } /* get first KeyingSet to use */ @@ -544,7 +546,7 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[] first = prevKS->next; } else { - first = builtin_keyingsets.first; + first = static_cast(builtin_keyingsets.first); } /* loop over KeyingSets checking names */ @@ -554,13 +556,13 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[] } } - /* complain about missing keying sets on debug builds */ +/* complain about missing keying sets on debug builds */ #ifndef NDEBUG printf("%s: '%s' not found\n", __func__, name); #endif /* no matches found */ - return NULL; + return nullptr; } /* --------------- */ @@ -591,7 +593,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) /* find relevant builtin KeyingSets which use this, and remove them */ /* TODO: this isn't done now, since unregister is really only used at the moment when we * reload the scripts, which kind of defeats the purpose of "builtin"? */ - for (ks = builtin_keyingsets.first; ks; ks = ksn) { + for (ks = static_cast(builtin_keyingsets.first); ks; ks = ksn) { ksn = ks->next; /* remove if matching typeinfo name */ @@ -600,7 +602,9 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) BKE_keyingset_free(ks); BLI_remlink(&builtin_keyingsets, ks); - for (scene = bmain->scenes.first; scene; scene = scene->id.next) { + for (scene = static_cast(bmain->scenes.first); scene; + scene = static_cast(scene->id.next)) + { BLI_remlink_safe(&scene->keyingsets, ks); } @@ -617,7 +621,7 @@ void ANIM_keyingset_infos_exit(void) KeyingSetInfo *ksi, *next; /* free type infos */ - for (ksi = keyingset_type_infos.first; ksi; ksi = next) { + for (ksi = static_cast(keyingset_type_infos.first); ksi; ksi = next) { next = ksi->next; /* free extra RNA data, and remove from list */ @@ -634,11 +638,11 @@ void ANIM_keyingset_infos_exit(void) bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id) { /* sanity checks */ - if (ELEM(NULL, ks, id)) { + if (ELEM(nullptr, ks, id)) { return false; } - return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != NULL; + return BLI_findptr(&ks->paths, id, offsetof(KS_Path, id)) != nullptr; } /* ******************************************* */ @@ -649,8 +653,8 @@ bool ANIM_keyingset_find_id(KeyingSet *ks, ID *id) KeyingSet *ANIM_scene_get_active_keyingset(const Scene *scene) { /* if no scene, we've got no hope of finding the Keying Set */ - if (scene == NULL) { - return NULL; + if (scene == nullptr) { + return nullptr; } /* currently, there are several possibilities here: @@ -659,9 +663,10 @@ KeyingSet *ANIM_scene_get_active_keyingset(const Scene *scene) * - < 0: a builtin keying set */ if (scene->active_keyingset > 0) { - return BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + return static_cast(BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1)); } - return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1); + return static_cast( + BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1)); } int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks) @@ -669,7 +674,7 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks) int index; /* if no KeyingSet provided, have none */ - if (ks == NULL) { + if (ks == nullptr) { return 0; } @@ -705,9 +710,9 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(const Scene *scene, const char *tra return ANIM_scene_get_active_keyingset(scene); } if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) { - return ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_AVAILABLE_ID); + return ANIM_builtin_keyingset_get_named(nullptr, ANIM_KS_AVAILABLE_ID); } - return ANIM_builtin_keyingset_get_named(NULL, transformKSName); + return ANIM_builtin_keyingset_get_named(nullptr, transformKSName); } static void anim_keyingset_visit_for_search_impl(const bContext *C, @@ -716,16 +721,16 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C, const bool use_poll) { /* Poll requires context. */ - if (use_poll && (C == NULL)) { + if (use_poll && (C == nullptr)) { return; } - Scene *scene = C ? CTX_data_scene(C) : NULL; + Scene *scene = C ? CTX_data_scene(C) : nullptr; KeyingSet *ks; /* Active Keying Set. */ if (!use_poll || (scene && scene->active_keyingset)) { - StringPropertySearchVisitParams visit_params = {NULL}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = "__ACTIVE__"; visit_params.info = "Active Keying Set"; visit_fn(visit_user_data, &visit_params); @@ -733,11 +738,11 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C, /* User-defined Keying Sets. */ if (scene && scene->keyingsets.first) { - for (ks = scene->keyingsets.first; ks; ks = ks->next) { + for (ks = static_cast(scene->keyingsets.first); ks; ks = ks->next) { if (use_poll && !ANIM_keyingset_context_ok_poll((bContext *)C, ks)) { continue; } - StringPropertySearchVisitParams visit_params = {NULL}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = ks->idname; visit_params.info = ks->name; visit_fn(visit_user_data, &visit_params); @@ -745,11 +750,11 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C, } /* Builtin Keying Sets. */ - for (ks = builtin_keyingsets.first; ks; ks = ks->next) { + for (ks = static_cast(builtin_keyingsets.first); ks; ks = ks->next) { if (use_poll && !ANIM_keyingset_context_ok_poll((bContext *)C, ks)) { continue; } - StringPropertySearchVisitParams visit_params = {NULL}; + StringPropertySearchVisitParams visit_params = {nullptr}; visit_params.text = ks->idname; visit_params.info = ks->name; visit_fn(visit_user_data, &visit_params); @@ -757,9 +762,9 @@ static void anim_keyingset_visit_for_search_impl(const bContext *C, } void ANIM_keyingset_visit_for_search(const bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), - const char *UNUSED(edit_text), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, StringPropertySearchVisitFunc visit_fn, void *visit_user_data) { @@ -767,9 +772,9 @@ void ANIM_keyingset_visit_for_search(const bContext *C, } void ANIM_keyingset_visit_for_search_no_poll(const bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), - const char *UNUSED(edit_text), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, + const char * /*edit_text*/, StringPropertySearchVisitFunc visit_fn, void *visit_user_data) { @@ -779,17 +784,17 @@ void ANIM_keyingset_visit_for_search_no_poll(const bContext *C, /* Menu of All Keying Sets ----------------------------- */ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; - EnumPropertyItem *item = NULL, item_tmp = {0}; + EnumPropertyItem *item = nullptr, item_tmp = {0}; int totitem = 0; int i = 0; - if (C == NULL) { + if (C == nullptr) { return DummyRNA_DEFAULT_items; } @@ -813,7 +818,7 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { - for (ks = scene->keyingsets.first; ks; ks = ks->next, i++) { + for (ks = static_cast(scene->keyingsets.first); ks; ks = ks->next, i++) { if (ANIM_keyingset_context_ok_poll(C, ks)) { item_tmp.identifier = ks->idname; item_tmp.name = ks->name; @@ -829,7 +834,7 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, /* builtin Keying Sets */ i = -1; - for (ks = builtin_keyingsets.first; ks; ks = ks->next, i--) { + for (ks = static_cast(builtin_keyingsets.first); ks; ks = ks->next, i--) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) { item_tmp.identifier = ks->idname; @@ -848,26 +853,28 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, KeyingSet *ANIM_keyingset_get_from_enum_type(Scene *scene, int type) { - KeyingSet *ks = NULL; + KeyingSet *ks = nullptr; if (type == 0) { type = scene->active_keyingset; } if (type > 0) { - ks = BLI_findlink(&scene->keyingsets, type - 1); + ks = static_cast(BLI_findlink(&scene->keyingsets, type - 1)); } else { - ks = BLI_findlink(&builtin_keyingsets, -type - 1); + ks = static_cast(BLI_findlink(&builtin_keyingsets, -type - 1)); } return ks; } KeyingSet *ANIM_keyingset_get_from_idname(Scene *scene, const char *idname) { - KeyingSet *ks = BLI_findstring(&scene->keyingsets, idname, offsetof(KeyingSet, idname)); - if (ks == NULL) { - ks = BLI_findstring(&builtin_keyingsets, idname, offsetof(KeyingSet, idname)); + KeyingSet *ks = static_cast( + BLI_findstring(&scene->keyingsets, idname, offsetof(KeyingSet, idname))); + if (ks == nullptr) { + ks = static_cast( + BLI_findstring(&builtin_keyingsets, idname, offsetof(KeyingSet, idname))); } return ks; } @@ -883,7 +890,7 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* get the associated 'type info' for this KeyingSet */ - if (ksi == NULL) { + if (ksi == nullptr) { return 0; } /* TODO: check for missing callbacks! */ @@ -901,10 +908,10 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) * - this is basically a wrapper for PointerRNA's in a linked list * - do not allow this to be accessed from outside for now */ -typedef struct tRKS_DSource { +struct tRKS_DSource { struct tRKS_DSource *next, *prev; PointerRNA ptr; /* the whole point of this exercise! */ -} tRKS_DSource; +}; /* Iterator used for overriding the behavior of iterators defined for * relative Keying Sets, with the main usage of this being operators @@ -917,7 +924,7 @@ static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, { tRKS_DSource *ds; - for (ds = dsources->first; ds; ds = ds->next) { + for (ds = static_cast(dsources->first); ds; ds = ds->next) { /* run generate callback on this data */ ksi->generate(ksi, C, ks, &ds->ptr); } @@ -931,15 +938,15 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s * - we must have somewhere to output the data * - we must have both srna+data (and with id too optionally), or id by itself only */ - if (dsources == NULL) { + if (dsources == nullptr) { return; } - if (ELEM(NULL, srna, data) && (id == NULL)) { + if (ELEM(nullptr, srna, data) && (id == nullptr)) { return; } /* allocate new elem, and add to the list */ - ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource"); + ds = static_cast(MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource")); BLI_addtail(dsources, ds); /* depending on what data we have, create using ID or full pointer call */ @@ -956,8 +963,8 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s eModifyKey_Returns ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) { /* sanity check */ - if (ks == NULL) { - return 0; + if (ks == nullptr) { + return eModifyKey_Returns(0); } /* if relative Keying Sets, poll and build up the paths */ @@ -970,7 +977,7 @@ eModifyKey_Returns ANIM_validate_keyingset(bContext *C, ListBase *dsources, Keyi BKE_keyingset_free(ks); /* get the associated 'type info' for this KeyingSet */ - if (ksi == NULL) { + if (ksi == nullptr) { return MODIFYKEY_MISSING_TYPEINFO; } /* TODO: check for missing callbacks! */ @@ -1002,7 +1009,7 @@ eModifyKey_Returns ANIM_validate_keyingset(bContext *C, ListBase *dsources, Keyi } /* succeeded; return 0 to tag error free */ - return 0; + return eModifyKey_Returns(0); } /* Determine which keying flags apply based on the override flags */ @@ -1013,12 +1020,12 @@ static eInsertKeyFlags keyingset_apply_keying_flags(const eInsertKeyFlags base_f /* Pass through all flags by default (i.e. even not explicitly listed ones). */ eInsertKeyFlags result = base_flags; - /* The logic for whether a keying flag applies is as follows: - * - If the flag in question is set in "overrides", that means that the - * status of that flag in "own_flags" is used - * - If however the flag isn't set, then its value in "base_flags" is used - * instead (i.e. no override) - */ +/* The logic for whether a keying flag applies is as follows: + * - If the flag in question is set in "overrides", that means that the + * status of that flag in "own_flags" is used + * - If however the flag isn't set, then its value in "base_flags" is used + * instead (i.e. no override) + */ #define APPLY_KEYINGFLAG_OVERRIDE(kflag) \ if (overrides & kflag) { \ result &= ~kflag; \ @@ -1044,25 +1051,26 @@ int ANIM_apply_keyingset( Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); KS_Path *ksp; - ListBase nla_cache = {NULL, NULL}; + ListBase nla_cache = {nullptr, nullptr}; const eInsertKeyFlags base_kflags = ANIM_get_keyframing_flags(scene, true); - const char *groupname = NULL; - eInsertKeyFlags kflag = 0; + const char *groupname = nullptr; + eInsertKeyFlags kflag = eInsertKeyFlags(0); int num_channels = 0; char keytype = scene->toolsettings->keyframe_type; /* sanity checks */ - if (ks == NULL) { + if (ks == nullptr) { return 0; } /* get flags to use */ if (mode == MODIFYKEY_MODE_INSERT) { /* use context settings as base */ - kflag = keyingset_apply_keying_flags(base_kflags, ks->keyingoverride, ks->keyingflag); + kflag = keyingset_apply_keying_flags( + base_kflags, eInsertKeyFlags(ks->keyingoverride), eInsertKeyFlags(ks->keyingflag)); } else if (mode == MODIFYKEY_MODE_DELETE) { - kflag = 0; + kflag = eInsertKeyFlags(0); } /* if relative Keying Sets, poll and build up the paths */ @@ -1076,12 +1084,12 @@ int ANIM_apply_keyingset( } /* apply the paths as specified in the KeyingSet now */ - for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + for (ksp = static_cast(ks->paths.first); ksp; ksp = ksp->next) { int arraylen, i; eInsertKeyFlags kflag2; /* skip path if no ID pointer is specified */ - if (ksp->id == NULL) { + if (ksp->id == nullptr) { BKE_reportf(reports, RPT_WARNING, "Skipping path in keying set, as it has no ID (KS = '%s', path = '%s[%d]')", @@ -1093,11 +1101,12 @@ int ANIM_apply_keyingset( /* Since keying settings can be defined on the paths too, * apply the settings for this path first. */ - kflag2 = keyingset_apply_keying_flags(kflag, ksp->keyingoverride, ksp->keyingflag); + kflag2 = keyingset_apply_keying_flags( + kflag, eInsertKeyFlags(ksp->keyingoverride), eInsertKeyFlags(ksp->keyingflag)); /* get pointer to name of group to add channels to */ if (ksp->groupmode == KSP_GROUP_NONE) { - groupname = NULL; + groupname = nullptr; } else if (ksp->groupmode == KSP_GROUP_KSNAME) { groupname = ks->name; @@ -1147,7 +1156,7 @@ int ANIM_apply_keyingset( ksp->rna_path, i, &anim_eval_context, - keytype, + eBezTriple_KeyframeType(keytype), &nla_cache, kflag2); } @@ -1172,7 +1181,7 @@ int ANIM_apply_keyingset( } /* send notifiers for updates (this doesn't require context to work!) */ - WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_ADDED, nullptr); } BKE_animsys_free_nla_keyframing_context_cache(&nla_cache); diff --git a/source/blender/editors/animation/time_scrub_ui.c b/source/blender/editors/animation/time_scrub_ui.cc similarity index 94% rename from source/blender/editors/animation/time_scrub_ui.c rename to source/blender/editors/animation/time_scrub_ui.cc index b19e1b1ec43..9b21f80f0ab 100644 --- a/source/blender/editors/animation/time_scrub_ui.c +++ b/source/blender/editors/animation/time_scrub_ui.cc @@ -123,19 +123,13 @@ static void draw_current_frame(const Scene *scene, float outline_color[4]; UI_GetThemeColorShade4fv(TH_CFRAME, 5, outline_color); + rctf rect{}; + rect.xmin = frame_x - box_width / 2 + U.pixelsize / 2; + rect.xmax = frame_x + box_width / 2 + U.pixelsize / 2; + rect.ymin = scrub_region_rect->ymin + box_padding; + rect.ymax = scrub_region_rect->ymax - box_padding; UI_draw_roundbox_4fv_ex( - &(const rctf){ - .xmin = frame_x - box_width / 2 + U.pixelsize / 2, - .xmax = frame_x + box_width / 2 + U.pixelsize / 2, - .ymin = scrub_region_rect->ymin + box_padding, - .ymax = scrub_region_rect->ymax - box_padding, - }, - bg_color, - NULL, - 1.0f, - outline_color, - U.pixelsize, - 4 * UI_SCALE_FAC); + &rect, bg_color, nullptr, 1.0f, outline_color, U.pixelsize, 4 * UI_SCALE_FAC); uchar text_color[4]; UI_GetThemeColor4ubv(TH_HEADER_TEXT_HI, text_color); @@ -237,7 +231,7 @@ void ED_time_scrub_channel_search_draw(const bContext *C, ARegion *region, bDope uiItemR(layout, &ptr, "filter_text", 0, "", ICON_NONE); uiItemR(layout, &ptr, "use_filter_invert", 0, "", ICON_ARROW_LEFTRIGHT); UI_block_align_end(block); - UI_block_layout_resolve(block, NULL, NULL); + UI_block_layout_resolve(block, nullptr, nullptr); /* Make sure the events are consumed from the search and don't reach other UI blocks since this * is drawn on top of animation-channels. */ diff --git a/source/blender/editors/armature/CMakeLists.txt b/source/blender/editors/armature/CMakeLists.txt index b07b9a1cf6f..75d3e56a2f0 100644 --- a/source/blender/editors/armature/CMakeLists.txt +++ b/source/blender/editors/armature/CMakeLists.txt @@ -4,6 +4,7 @@ set(INC ../include + ../../asset_system ../../blenfont ../../blenkernel ../../blenlib @@ -25,23 +26,23 @@ set(INC_SYS ) set(SRC - armature_add.c - armature_edit.c - armature_naming.c - armature_ops.c - armature_relations.c - armature_select.c - armature_skinning.c - armature_utils.c + armature_add.cc + armature_edit.cc + armature_naming.cc + armature_ops.cc + armature_relations.cc + armature_select.cc + armature_skinning.cc + armature_utils.cc editarmature_undo.cc meshlaplacian.cc - pose_edit.c - pose_group.c - pose_lib_2.c - pose_select.c - pose_slide.c - pose_transform.c - pose_utils.c + pose_edit.cc + pose_group.cc + pose_lib_2.cc + pose_select.cc + pose_slide.cc + pose_transform.cc + pose_utils.cc armature_intern.h meshlaplacian.h diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.cc similarity index 90% rename from source/blender/editors/armature/armature_add.c rename to source/blender/editors/armature/armature_add.cc index 6f8a3d8fca9..ccd52f82284 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.cc @@ -51,10 +51,10 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) { - EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); + EditBone *bone = static_cast(MEM_callocN(sizeof(EditBone), "eBone")); STRNCPY(bone->name, name); - ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, bone->name, nullptr); BLI_addtail(arm->edbo, bone); @@ -86,7 +86,7 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool view_aligned) { - bArmature *arm = obedit_arm->data; + bArmature *arm = static_cast(obedit_arm->data); EditBone *bone; ED_armature_edit_deselect_all(obedit_arm); @@ -112,7 +112,7 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool * If we want the support to be expanded we should something like the * offset we do for mesh click extrude. */ -static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_click_extrude_exec(bContext *C, wmOperator * /*op*/) { bArmature *arm; EditBone *ebone, *newbone, *flipbone; @@ -123,10 +123,10 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) scene = CTX_data_scene(C); obedit = CTX_data_edit_object(C); - arm = obedit->data; + arm = static_cast(obedit->data); /* find the active or selected bone */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone) { break; @@ -134,15 +134,15 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) } } - if (ebone == NULL) { - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + if (ebone == nullptr) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone) { break; } } } - if (ebone == NULL) { + if (ebone == nullptr) { return OPERATOR_CANCELLED; } @@ -152,14 +152,14 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_edit_deselect_all(obedit); /* we re-use code for mirror editing... */ - flipbone = NULL; + flipbone = nullptr; if (arm->flag & ARM_MIRROR_EDIT) { flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); } for (a = 0; a < 2; a++) { if (a == 1) { - if (flipbone == NULL) { + if (flipbone == nullptr) { break; } SWAP(EditBone *, flipbone, ebone); @@ -261,7 +261,7 @@ EditBone *add_points_bone(Object *obedit, float head[3], float tail[3]) { EditBone *ebo; - ebo = ED_armature_ebone_add(obedit->data, "Bone"); + ebo = ED_armature_ebone_add(static_cast(obedit->data), "Bone"); copy_v3_v3(ebo->head, head); copy_v3_v3(ebo->tail, tail); @@ -274,14 +274,14 @@ static EditBone *get_named_editbone(ListBase *edbo, const char *name) EditBone *eBone; if (name) { - for (eBone = edbo->first; eBone; eBone = eBone->next) { + for (eBone = static_cast(edbo->first); eBone; eBone = eBone->next) { if (STREQ(name, eBone->name)) { return eBone; } } } - return NULL; + return nullptr; } void preEditBoneDuplicate(ListBase *editbones) @@ -298,14 +298,14 @@ static bPoseChannel *pchan_duplicate_map(const bPose *pose, GHash *name_map, bPoseChannel *pchan_src) { - bPoseChannel *pchan_dst = NULL; + bPoseChannel *pchan_dst = nullptr; const char *name_src = pchan_src->name; - const char *name_dst = BLI_ghash_lookup(name_map, name_src); + const char *name_dst = static_cast(BLI_ghash_lookup(name_map, name_src)); if (name_dst) { pchan_dst = BKE_pose_channel_find_name(pose, name_dst); } - if (pchan_dst == NULL) { + if (pchan_dst == nullptr) { pchan_dst = pchan_src; } @@ -314,7 +314,7 @@ static bPoseChannel *pchan_duplicate_map(const bPose *pose, void postEditBoneDuplicate(ListBase *editbones, Object *ob) { - if (ob->pose == NULL) { + if (ob->pose == nullptr) { return; } @@ -361,7 +361,7 @@ void postEditBoneDuplicate(ListBase *editbones, Object *ob) } } - BLI_ghash_free(name_map, NULL, NULL); + BLI_ghash_free(name_map, nullptr, nullptr); } static void updateDuplicateSubtarget(EditBone *dup_bone, @@ -379,15 +379,15 @@ static void updateDuplicateSubtarget(EditBone *dup_bone, if ((pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name))) { if ((conlist = &pchan->constraints)) { - for (curcon = conlist->first; curcon; curcon = curcon->next) { + for (curcon = static_cast(conlist->first); curcon; curcon = curcon->next) { /* does this constraint have a subtarget in * this armature? */ - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; if (BKE_constraint_targets_get(curcon, &targets)) { - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { if ((ct->tar == ob) && (ct->subtarget[0])) { oldtarget = get_named_editbone(editbones, ct->subtarget); if (oldtarget) { @@ -429,7 +429,11 @@ static void updateDuplicateActionConstraintSettings( float mat[4][4]; - bConstraintOb cob = {.depsgraph = NULL, .scene = NULL, .ob = ob, .pchan = pchan}; + bConstraintOb cob{}; + cob.depsgraph = nullptr; + cob.scene = nullptr; + cob.ob = ob; + cob.pchan = pchan; BKE_constraint_custom_object_space_init(&cob, curcon); unit_m4(mat); @@ -494,11 +498,12 @@ static void updateDuplicateActionConstraintSettings( /* See if there is any channels that uses this bone */ ListBase ani_curves; BLI_listbase_clear(&ani_curves); - if ((act != NULL) && - BKE_fcurves_filter(&ani_curves, &act->curves, "pose.bones[", orig_bone->name)) { + if ((act != nullptr) && + BKE_fcurves_filter(&ani_curves, &act->curves, "pose.bones[", orig_bone->name)) + { /* Create a copy and mirror the animation */ - for (LinkData *ld = ani_curves.first; ld; ld = ld->next) { - FCurve *old_curve = ld->data; + for (LinkData *ld = static_cast(ani_curves.first); ld; ld = ld->next) { + FCurve *old_curve = static_cast(ld->data); FCurve *new_curve = BKE_fcurve_copy(old_curve); bActionGroup *agrp; @@ -543,10 +548,10 @@ static void updateDuplicateActionConstraintSettings( /* Make sure that a action group name for the new bone exists */ agrp = BKE_action_group_find_name(act, dup_bone->name); - if (agrp == NULL) { + if (agrp == nullptr) { agrp = action_groups_add_new(act, dup_bone->name); } - BLI_assert(agrp != NULL); + BLI_assert(agrp != nullptr); action_groups_add_channel(act, agrp, new_curve); } } @@ -586,7 +591,11 @@ static void updateDuplicateLocRotConstraintSettings(Object *ob, unit_m4(local_mat); - bConstraintOb cob = {.depsgraph = NULL, .scene = NULL, .ob = ob, .pchan = pchan}; + bConstraintOb cob{}; + cob.depsgraph = nullptr; + cob.scene = nullptr; + cob.ob = ob; + cob.pchan = pchan; BKE_constraint_custom_object_space_init(&cob, curcon); BKE_constraint_mat_convertspace( @@ -641,7 +650,11 @@ static void updateDuplicateTransformConstraintSettings(Object *ob, float target_mat[4][4], own_mat[4][4], imat[4][4]; - bConstraintOb cob = {.depsgraph = NULL, .scene = NULL, .ob = ob, .pchan = pchan}; + bConstraintOb cob{}; + cob.depsgraph = nullptr; + cob.scene = nullptr; + cob.ob = ob; + cob.pchan = pchan; BKE_constraint_custom_object_space_init(&cob, curcon); unit_m4(own_mat); @@ -817,13 +830,13 @@ static void updateDuplicateConstraintSettings(EditBone *dup_bone, EditBone *orig bConstraint *curcon; ListBase *conlist; - if ((pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name)) == NULL || - (conlist = &pchan->constraints) == NULL) + if ((pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name)) == nullptr || + (conlist = &pchan->constraints) == nullptr) { return; } - for (curcon = conlist->first; curcon; curcon = curcon->next) { + for (curcon = static_cast(conlist->first); curcon; curcon = curcon->next) { switch (curcon->type) { case CONSTRAINT_TYPE_ACTION: updateDuplicateActionConstraintSettings(dup_bone, orig_bone, ob, pchan, curcon); @@ -844,13 +857,13 @@ static void updateDuplicateConstraintSettings(EditBone *dup_bone, EditBone *orig static void updateDuplicateCustomBoneShapes(bContext *C, EditBone *dup_bone, Object *ob) { - if (ob->pose == NULL) { + if (ob->pose == nullptr) { return; } bPoseChannel *pchan; pchan = BKE_pose_channel_ensure(ob->pose, dup_bone->name); - if (pchan->custom != NULL) { + if (pchan->custom != nullptr) { Main *bmain = CTX_data_main(C); char name_flip[MAX_ID_NAME - 2]; @@ -866,9 +879,9 @@ static void updateDuplicateCustomBoneShapes(bContext *C, EditBone *dup_bone, Obj Object *shape_ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); /* If name_flip doesn't exist, BKE_libblock_find_name() returns pchan->custom (best match) */ - shape_ob = shape_ob == pchan->custom ? NULL : shape_ob; + shape_ob = shape_ob == pchan->custom ? nullptr : shape_ob; - if (shape_ob != NULL) { + if (shape_ob != nullptr) { /* A flipped shape object exists, use it! */ pchan->custom = shape_ob; } @@ -909,7 +922,7 @@ static void copy_pchan(EditBone *src_bone, EditBone *dst_bone, Object *src_ob, O EditBone *duplicateEditBoneObjects( EditBone *cur_bone, const char *name, ListBase *editbones, Object *src_ob, Object *dst_ob) { - EditBone *e_bone = MEM_mallocN(sizeof(EditBone), "addup_editbone"); + EditBone *e_bone = static_cast(MEM_mallocN(sizeof(EditBone), "addup_editbone")); /* Copy data from old bone to new bone */ memcpy(e_bone, cur_bone, sizeof(EditBone)); @@ -917,11 +930,11 @@ EditBone *duplicateEditBoneObjects( cur_bone->temp.ebone = e_bone; e_bone->temp.ebone = cur_bone; - if (name != NULL) { + if (name != nullptr) { STRNCPY(e_bone->name, name); } - ED_armature_ebone_unique_name(editbones, e_bone->name, NULL); + ED_armature_ebone_unique_name(editbones, e_bone->name, nullptr); BLI_addtail(editbones, e_bone); copy_pchan(cur_bone, e_bone, src_ob, dst_ob); @@ -951,10 +964,10 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) for (uint ob_index = 0; ob_index < objects_len; ob_index++) { EditBone *ebone_iter; /* The beginning of the duplicated bones in the edbo list */ - EditBone *ebone_first_dupe = NULL; + EditBone *ebone_first_dupe = nullptr; Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); ED_armature_edit_sync_selection(arm->edbo); /* XXX why is this needed? */ @@ -962,7 +975,9 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { - for (ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + for (ebone_iter = static_cast(arm->edbo->first); ebone_iter; + ebone_iter = ebone_iter->next) + { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { EditBone *ebone; @@ -975,7 +990,8 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) } /* Find the selected bones and duplicate them as needed */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { @@ -989,7 +1005,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) /* Only use flipped name if not yet in use. Otherwise we'd get again inconsistent * namings (different numbers), better keep default behavior in this case. */ - if (ED_armature_ebone_find_name(arm->edbo, new_bone_name_buff) == NULL) { + if (ED_armature_ebone_find_name(arm->edbo, new_bone_name_buff) == nullptr) { new_bone_name = new_bone_name_buff; } } @@ -1003,7 +1019,8 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) } /* Run though the list and fix the pointers */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { @@ -1011,9 +1028,9 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) if (!ebone_iter->parent) { /* If this bone has no parent, - * Set the duplicate->parent to NULL + * Set the duplicate->parent to nullptr */ - ebone->parent = NULL; + ebone->parent = nullptr; } else if (ebone_iter->parent->temp.ebone) { /* If this bone has a parent that was duplicated, @@ -1050,7 +1067,8 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) } /* Deselect the old bones and select the new ones */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (EBONE_VISIBLE(arm, ebone_iter)) { @@ -1097,15 +1115,15 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot) /* Get the duplicated or existing mirrored copy of the bone. */ static EditBone *get_symmetrized_bone(bArmature *arm, EditBone *bone) { - if (bone == NULL) { - return NULL; + if (bone == nullptr) { + return nullptr; } - if (bone->temp.ebone != NULL) { + if (bone->temp.ebone != nullptr) { return bone->temp.ebone; } EditBone *mirror = ED_armature_ebone_get_mirrored(arm->edbo, bone); - return (mirror != NULL) ? mirror : bone; + return (mirror != nullptr) ? mirror : bone; } /** @@ -1130,10 +1148,10 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) for (uint ob_index = 0; ob_index < objects_len; ob_index++) { EditBone *ebone_iter; /* The beginning of the duplicated mirrored bones in the edbo list */ - EditBone *ebone_first_dupe = NULL; + EditBone *ebone_first_dupe = nullptr; Object *obedit = objects[ob_index]; - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); ED_armature_edit_sync_selection(arm->edbo); /* XXX why is this needed? */ @@ -1144,14 +1162,16 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) * and unique selected bones with an unique flippable name. * * Storing temp pointers to mirrored unselected ebones. */ - for (ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + for (ebone_iter = static_cast(arm->edbo->first); ebone_iter; + ebone_iter = ebone_iter->next) + { if (!(EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED))) { /* Skipping invisible selected bones. */ continue; } char name_flip[MAXBONENAME]; - if (ebone_iter == NULL) { + if (ebone_iter == nullptr) { continue; } @@ -1205,11 +1225,12 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) } /* Find the selected bones and duplicate them as needed, with mirrored name. */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (EBONE_VISIBLE(arm, ebone_iter) && (ebone_iter->flag & BONE_SELECTED)) { - if (ebone_iter->temp.ebone != NULL) { + if (ebone_iter->temp.ebone != nullptr) { /* This will be set if the mirror bone already exists (no need to make a new one) * but we do need to make sure that the 'pchan' settings (constraints etc) * is synchronized. */ @@ -1242,7 +1263,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) } /* Run through the list and fix the pointers. */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (ebone_iter->temp.ebone) { @@ -1254,11 +1276,11 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) /* Copy flags in case bone is pre-existing data. */ ebone->flag = (ebone->flag & ~flag_copy) | (ebone_iter->flag & flag_copy); - if (ebone_iter->parent == NULL) { + if (ebone_iter->parent == nullptr) { /* If this bone has no parent, - * Set the duplicate->parent to NULL + * Set the duplicate->parent to nullptr */ - ebone->parent = NULL; + ebone->parent = nullptr; ebone->flag &= ~BONE_CONNECTED; } else { @@ -1311,7 +1333,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) * so we don't need this anymore */ /* Deselect the old bones and select the new ones */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (EBONE_VISIBLE(arm, ebone_iter)) { @@ -1320,7 +1343,8 @@ static int armature_symmetrize_exec(bContext *C, wmOperator *op) } /* New bones will be selected, but some of the bones may already exist */ - for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; + for (ebone_iter = static_cast(arm->edbo->first); + ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { EditBone *ebone = ebone_iter->temp.ebone; @@ -1354,7 +1378,7 @@ void ARMATURE_OT_symmetrize(wmOperatorType *ot) static const EnumPropertyItem arm_symmetrize_direction_items[] = { {-1, "NEGATIVE_X", 0, "-X to +X", ""}, {+1, "POSITIVE_X", 0, "+X to -X", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -1394,14 +1418,14 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool forked_iter = forked; - EditBone *newbone = NULL, *ebone, *flipbone, *first = NULL; + EditBone *newbone = nullptr, *ebone, *flipbone, *first = nullptr; int a, totbone = 0, do_extrude; /* since we allow root extrude too, we have to make sure selection is OK */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { @@ -1414,7 +1438,9 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) } /* Duplicate the necessary bones */ - for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ((ebone) && (ebone != first)); + ebone = ebone->next) + { if (EBONE_VISIBLE(arm, ebone)) { /* we extrude per definition the tip */ do_extrude = false; @@ -1433,7 +1459,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) if (do_extrude) { /* we re-use code for mirror editing... */ - flipbone = NULL; + flipbone = nullptr; if (arm->flag & ARM_MIRROR_EDIT) { flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (flipbone) { @@ -1443,23 +1469,23 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } } - if ((flipbone == NULL) && (forked_iter)) { + if ((flipbone == nullptr) && (forked_iter)) { flipbone = ebone; } } for (a = 0; a < 2; a++) { if (a == 1) { - if (flipbone == NULL) { + if (flipbone == nullptr) { break; } SWAP(EditBone *, flipbone, ebone); } totbone++; - newbone = MEM_callocN(sizeof(EditBone), "extrudebone"); + newbone = static_cast(MEM_callocN(sizeof(EditBone), "extrudebone")); - if (do_extrude == true) { + if (do_extrude != 0) { copy_v3_v3(newbone->head, ebone->tail); copy_v3_v3(newbone->tail, newbone->head); newbone->parent = ebone; @@ -1512,7 +1538,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) BLI_strncat(newbone->name, (a == 0) ? "_L" : "_R", sizeof(newbone->name)); } } - ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, newbone->name, nullptr); /* Add the new bone to the list */ BLI_addtail(arm->edbo, newbone); @@ -1614,7 +1640,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) ED_armature_edit_deselect_all(obedit); /* Create a bone. */ - bone = ED_armature_ebone_add(obedit->data, name); + bone = ED_armature_ebone_add(static_cast(obedit->data), name); copy_v3_v3(bone->head, curs); @@ -1625,7 +1651,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) add_v3_v3v3(bone->tail, bone->head, imat[2]); /* bone with unit length 1, pointing up Z */ } - ED_armature_edit_refresh_layer_used(obedit->data); + ED_armature_edit_refresh_layer_used(static_cast(obedit->data)); /* NOTE: notifier might evolve. */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); @@ -1681,7 +1707,7 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) float val2[3]; float val3[3]; - newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv"); + newbone = static_cast(MEM_mallocN(sizeof(EditBone), "ebone subdiv")); *newbone = *ebone; BLI_addtail(arm->edbo, newbone); @@ -1703,12 +1729,12 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) newbone->flag |= BONE_CONNECTED; - newbone->prop = NULL; + newbone->prop = nullptr; - ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, newbone->name, nullptr); /* correct parent bones */ - for (tbone = arm->edbo->first; tbone; tbone = tbone->next) { + for (tbone = static_cast(arm->edbo->first); tbone; tbone = tbone->next) { if (tbone->parent == ebone) { tbone->parent = newbone; } diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.cc similarity index 89% rename from source/blender/editors/armature/armature_edit.c rename to source/blender/editors/armature/armature_edit.cc index 328597bc98e..86cfecd5ba0 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.cc @@ -60,7 +60,7 @@ void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const boo copy_m3_m4(mat3, mat); normalize_m3(mat3); /* Do the rotations */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { float tmat[3][3]; /* find the current bone's roll matrix */ @@ -74,7 +74,7 @@ void ED_armature_edit_transform(bArmature *arm, const float mat[4][4], const boo mul_m4_v3(mat, ebone->tail); /* apply the transformed roll back */ - mat3_to_vec_roll(tmat, NULL, &ebone->roll); + mat3_to_vec_roll(tmat, nullptr, &ebone->roll); if (do_props) { ebone->rad_head *= scale; @@ -103,7 +103,7 @@ void ED_armature_origin_set( { const bool is_editmode = BKE_object_is_in_editmode(ob); EditBone *ebone; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); float cent[3]; /* Put the armature into edit-mode. */ @@ -121,7 +121,7 @@ void ED_armature_origin_set( if (around == V3D_AROUND_CENTER_BOUNDS) { float min[3], max[3]; INIT_MINMAX(min, max); - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { minmax_v3v3_v3(min, max, ebone->head); minmax_v3v3_v3(min, max, ebone->tail); } @@ -130,7 +130,7 @@ void ED_armature_origin_set( else { /* #V3D_AROUND_CENTER_MEDIAN. */ int total = 0; zero_v3(cent); - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { total += 2; add_v3_v3(cent, ebone->head); add_v3_v3(cent, ebone->tail); @@ -142,7 +142,7 @@ void ED_armature_origin_set( } /* Do the adjustments */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { sub_v3_v3(ebone->head, cent); sub_v3_v3(ebone->tail, cent); } @@ -206,7 +206,7 @@ float ED_armature_ebone_roll_to_vector(const EditBone *bone, } /* NOTE: ranges arithmetic is used below. */ -typedef enum eCalcRollTypes { +enum eCalcRollTypes { /* pos */ CALC_ROLL_POS_X = 0, CALC_ROLL_POS_Y, @@ -227,10 +227,10 @@ typedef enum eCalcRollTypes { CALC_ROLL_ACTIVE, CALC_ROLL_VIEW, CALC_ROLL_CURSOR, -} eCalcRollTypes; +}; static const EnumPropertyItem prop_calc_roll_types[] = { - RNA_ENUM_ITEM_HEADING(N_("Positive"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Positive"), nullptr), {CALC_ROLL_TAN_POS_X, "POS_X", 0, "Local +X Tangent", ""}, {CALC_ROLL_TAN_POS_Z, "POS_Z", 0, "Local +Z Tangent", ""}, @@ -238,7 +238,7 @@ static const EnumPropertyItem prop_calc_roll_types[] = { {CALC_ROLL_POS_Y, "GLOBAL_POS_Y", 0, "Global +Y Axis", ""}, {CALC_ROLL_POS_Z, "GLOBAL_POS_Z", 0, "Global +Z Axis", ""}, - RNA_ENUM_ITEM_HEADING(N_("Negative"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Negative"), nullptr), {CALC_ROLL_TAN_NEG_X, "NEG_X", 0, "Local -X Tangent", ""}, {CALC_ROLL_TAN_NEG_Z, "NEG_Z", 0, "Local -Z Tangent", ""}, @@ -246,11 +246,11 @@ static const EnumPropertyItem prop_calc_roll_types[] = { {CALC_ROLL_NEG_Y, "GLOBAL_NEG_Y", 0, "Global -Y Axis", ""}, {CALC_ROLL_NEG_Z, "GLOBAL_NEG_Z", 0, "Global -Z Axis", ""}, - RNA_ENUM_ITEM_HEADING(N_("Other"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Other"), nullptr), {CALC_ROLL_ACTIVE, "ACTIVE", 0, "Active Bone", ""}, {CALC_ROLL_VIEW, "VIEW", 0, "View Axis", ""}, {CALC_ROLL_CURSOR, "CURSOR", 0, "Cursor", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static int armature_calc_roll_exec(bContext *C, wmOperator *op) @@ -260,7 +260,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) Object *ob_active = CTX_data_edit_object(C); int ret = OPERATOR_FINISHED; - eCalcRollTypes type = RNA_enum_get(op->ptr, "type"); + eCalcRollTypes type = eCalcRollTypes(RNA_enum_get(op->ptr, "type")); const bool axis_only = RNA_boolean_get(op->ptr, "axis_only"); /* axis_flip when matching the active bone never makes sense */ bool axis_flip = ((type >= CALC_ROLL_ACTIVE) ? RNA_boolean_get(op->ptr, "axis_flip") : @@ -272,14 +272,14 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; float imat[3][3]; EditBone *ebone; if ((type >= CALC_ROLL_NEG_X) && (type <= CALC_ROLL_TAN_NEG_Z)) { - type -= (CALC_ROLL_ACTIVE - CALC_ROLL_NEG_X); + type = eCalcRollTypes(int(type) - (CALC_ROLL_ACTIVE - CALC_ROLL_NEG_X)); axis_flip = true; } @@ -295,7 +295,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) mul_m4_v3(ob->world_to_object, cursor_local); /* cursor */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { float cursor_rel[3]; sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); @@ -310,7 +310,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } } else if (ELEM(type, CALC_ROLL_TAN_POS_X, CALC_ROLL_TAN_POS_Z)) { - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (ebone->parent) { bool is_edit = (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)); bool is_edit_parent = (EBONE_VISIBLE(arm, ebone->parent) && @@ -352,7 +352,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) /* parentless bones use cross product with child */ if (is_edit_parent) { - if (ebone->parent->parent == NULL) { + if (ebone->parent->parent == nullptr) { ebone->parent->roll = ED_armature_ebone_roll_to_vector( ebone->parent, vec, axis_only); changed = true; @@ -367,7 +367,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) float vec[3] = {0.0f, 0.0f, 0.0f}; if (type == CALC_ROLL_VIEW) { /* View */ RegionView3D *rv3d = CTX_wm_region_view3d(C); - if (rv3d == NULL) { + if (rv3d == nullptr) { BKE_report(op->reports, RPT_ERROR, "No region view3d available"); ret = OPERATOR_CANCELLED; goto cleanup; @@ -378,9 +378,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } else if (type == CALC_ROLL_ACTIVE) { float mat[3][3]; - bArmature *arm_active = ob_active->data; + bArmature *arm_active = static_cast(ob_active->data); ebone = (EditBone *)arm_active->act_edbone; - if (ebone == NULL) { + if (ebone == nullptr) { BKE_report(op->reports, RPT_ERROR, "No active bone set"); ret = OPERATOR_CANCELLED; goto cleanup; @@ -409,7 +409,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) negate_v3(vec); } - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ ebone->roll = ED_armature_ebone_roll_to_vector(ebone, vec, axis_only); @@ -419,7 +419,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } if (arm->flag & ARM_MIRROR_EDIT) { - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { @@ -477,7 +477,7 @@ static int armature_roll_clear_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -528,7 +528,7 @@ void ARMATURE_OT_roll_clear(wmOperatorType *ot) RNA_def_float_rotation(ot->srna, "roll", 0, - NULL, + nullptr, DEG2RADF(-360.0f), DEG2RADF(360.0f), "Roll", @@ -544,14 +544,14 @@ void ARMATURE_OT_roll_clear(wmOperatorType *ot) * \{ */ /* temporary data-structure for merge/fill bones */ -typedef struct EditBonePoint { +struct EditBonePoint { struct EditBonePoint *next, *prev; EditBone *head_owner; /* EditBone which uses this point as a 'head' point */ EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */ float vec[3]; /* the actual location of the point in local/EditMode space */ -} EditBonePoint; +}; /* find chain-tips (i.e. bones without children) */ static void chains_find_tips(ListBase *edbo, ListBase *list) @@ -560,12 +560,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list) LinkData *ld; /* NOTE: this is potentially very slow ... there's got to be a better way. */ - for (curBone = edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(edbo->first); curBone; curBone = curBone->next) { short stop = 0; /* is this bone contained within any existing chain? (skip if so) */ - for (ld = list->first; ld; ld = ld->next) { - for (ebo = ld->data; ebo; ebo = ebo->parent) { + for (ld = static_cast(list->first); ld; ld = ld->next) { + for (ebo = static_cast(ld->data); ebo; ebo = ebo->parent) { if (ebo == curBone) { stop = 1; break; @@ -584,7 +584,7 @@ static void chains_find_tips(ListBase *edbo, ListBase *list) /* is any existing chain part of the chain formed by this bone? */ stop = 0; for (ebo = curBone->parent; ebo; ebo = ebo->parent) { - for (ld = list->first; ld; ld = ld->next) { + for (ld = static_cast(list->first); ld; ld = ld->next) { if (ld->data == ebo) { ld->data = curBone; stop = 1; @@ -602,7 +602,7 @@ static void chains_find_tips(ListBase *edbo, ListBase *list) } /* add current bone to a new chain */ - ld = MEM_callocN(sizeof(LinkData), "BoneChain"); + ld = static_cast(MEM_callocN(sizeof(LinkData), "BoneChain")); ld->data = curBone; BLI_addtail(list, ld); } @@ -627,7 +627,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) copy_v3_v3(vec, ebo->head); } - for (ebp = points->first; ebp; ebp = ebp->next) { + for (ebp = static_cast(points->first); ebp; ebp = ebp->next) { if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) { @@ -650,7 +650,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) /* allocate a new point if no existing point was related */ if (found == 0) { - ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); + ebp = static_cast(MEM_callocN(sizeof(EditBonePoint), "EditBonePoint")); if (eb_tail) { copy_v3_v3(ebp->vec, ebo->tail); @@ -670,13 +670,13 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - ListBase points = {NULL, NULL}; - EditBone *newbone = NULL; + ListBase points = {nullptr, nullptr}; + EditBone *newbone = nullptr; int count; bool mixed_object_error = false; /* loop over all bones, and only consider if visible */ - bArmature *arm = NULL; + bArmature *arm = nullptr; CTX_DATA_BEGIN_WITH_ID (C, EditBone *, ebone, visible_bones, bArmature *, arm_iter) { bool check = false; if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL)) { @@ -715,7 +715,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Object *obedit = NULL; + Object *obedit = nullptr; { ViewLayer *view_layer = CTX_data_view_layer(C); FOREACH_OBJECT_IN_EDIT_MODE_BEGIN (scene, view_layer, v3d, ob_iter) { @@ -725,14 +725,14 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) } FOREACH_OBJECT_IN_MODE_END; } - BLI_assert(obedit != NULL); + BLI_assert(obedit != nullptr); if (count == 1) { EditBonePoint *ebp; float curs[3]; /* Get Points - selected joint */ - ebp = points.first; + ebp = static_cast(points.first); /* Get points - cursor (tail) */ invert_m4_m4(obedit->world_to_object, obedit->object_to_world); @@ -750,8 +750,8 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) ebp_a = (EditBonePoint *)points.first; ebp_b = ebp_a->next; - if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != NULL)) || - ((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL))) + if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != nullptr)) || + ((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != nullptr))) { BKE_report(op->reports, RPT_ERROR, "Same bone selected..."); BLI_freelistN(&points); @@ -884,12 +884,12 @@ static void armature_clear_swap_done_flags(bArmature *arm) { EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { ebone->flag &= ~BONE_TRANSFORM; } } -static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_switch_direction_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -899,9 +899,9 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); - ListBase chains = {NULL, NULL}; + ListBase chains = {nullptr, nullptr}; LinkData *chain; /* get chains of bones (ends on chains) */ @@ -920,11 +920,11 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) armature_clear_swap_done_flags(arm); /* loop over chains, only considering selected and visible bones */ - for (chain = chains.first; chain; chain = chain->next) { - EditBone *ebo, *child = NULL, *parent = NULL; + for (chain = static_cast(chains.first); chain; chain = chain->next) { + EditBone *ebo, *child = nullptr, *parent = nullptr; /* loop over bones in chain */ - for (ebo = chain->data; ebo; ebo = parent) { + for (ebo = static_cast(chain->data); ebo; ebo = parent) { /* parent is this bone's original parent * - we store this, as the next bone that is checked is this one * but the value of ebo->parent may change here... @@ -960,15 +960,15 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) * as it will be facing in opposite direction */ if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { - ebo->parent = NULL; + ebo->parent = nullptr; ebo->flag &= ~BONE_CONNECTED; } /* get next bones * - child will become new parent of next bone (not swapping occurred, - * so set to NULL to prevent infinite-loop) + * so set to nullptr to prevent infinite-loop) */ - child = NULL; + child = nullptr; } /* tag as done (to prevent double-swaps) */ @@ -1036,7 +1036,7 @@ static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone) { EditBone *selbone; - for (selbone = edbo->first; selbone; selbone = selbone->next) { + for (selbone = static_cast(edbo->first); selbone; selbone = selbone->next) { if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) { fix_connected_bone(selbone); fix_editbone_connected_children(edbo, selbone); @@ -1069,11 +1069,11 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_edit_object(C); bArmature *arm = (bArmature *)ob->data; EditBone *actbone = CTX_data_active_bone(C); - EditBone *actmirb = NULL; + EditBone *actmirb = nullptr; int num_selected_bones; /* there must be an active bone */ - if (actbone == NULL) { + if (actbone == nullptr) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); return OPERATOR_CANCELLED; } @@ -1087,7 +1087,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) * then just use actbone. Useful when doing upper arm to spine. */ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); - if (actmirb == NULL) { + if (actmirb == nullptr) { actmirb = actbone; } } @@ -1164,7 +1164,7 @@ void ARMATURE_OT_align(wmOperatorType *ot) /** \name Split Operator * \{ */ -static int armature_split_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_split_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1174,11 +1174,11 @@ static int armature_split_exec(bContext *C, wmOperator *UNUSED(op)) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); LISTBASE_FOREACH (EditBone *, bone, arm->edbo) { if (bone->parent && (bone->flag & BONE_SELECTED) != (bone->parent->flag & BONE_SELECTED)) { - bone->parent = NULL; + bone->parent = nullptr; bone->flag &= ~BONE_CONNECTED; } } @@ -1217,7 +1217,7 @@ void ARMATURE_OT_split(wmOperatorType *ot) static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p) { - bArmature *arm = arm_p; + bArmature *arm = static_cast(arm_p); EditBone *ebone; ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); @@ -1226,7 +1226,7 @@ static bool armature_delete_ebone_cb(const char *bone_name, void *arm_p) /* previously delete_armature */ /* only editmode! */ -static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_delete_selected_exec(bContext *C, wmOperator * /*op*/) { EditBone *curBone, *ebone_next; bool changed_multi = false; @@ -1243,19 +1243,19 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); bool changed = false; armature_select_mirrored(arm); BKE_pose_channels_remove(obedit, armature_delete_ebone_cb, arm); - for (curBone = arm->edbo->first; curBone; curBone = ebone_next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = ebone_next) { ebone_next = curBone->next; if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { if (curBone == arm->act_edbone) { - arm->act_edbone = NULL; + arm->act_edbone = nullptr; } ED_armature_ebone_remove(arm, curBone); changed = true; @@ -1302,14 +1302,14 @@ void ARMATURE_OT_delete(wmOperatorType *ot) static bool armature_dissolve_ebone_cb(const char *bone_name, void *arm_p) { - bArmature *arm = arm_p; + bArmature *arm = static_cast(arm_p); EditBone *ebone; ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); return (ebone && (ebone->flag & BONE_DONE)); } -static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_dissolve_selected_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1321,15 +1321,15 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); bool changed = false; /* store for mirror */ - GHash *ebone_flag_orig = NULL; + GHash *ebone_flag_orig = nullptr; int ebone_num = 0; - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - ebone->temp.p = NULL; + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { + ebone->temp.p = nullptr; ebone->flag &= ~BONE_DONE; ebone_num++; } @@ -1338,7 +1338,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) GHashIterator gh_iter; ebone_flag_orig = BLI_ghash_ptr_new_ex(__func__, ebone_num); - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { union { int flag; void *p; @@ -1350,16 +1350,16 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) armature_select_mirrored_ex(arm, BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); GHASH_ITER (gh_iter, ebone_flag_orig) { - union { + union Value { int flag; void *p; - } *val_p = (void *)BLI_ghashIterator_getValue_p(&gh_iter); - ebone = BLI_ghashIterator_getKey(&gh_iter); + } *val_p = (Value *)BLI_ghashIterator_getValue_p(&gh_iter); + ebone = static_cast(BLI_ghashIterator_getKey(&gh_iter)); val_p->flag = ebone->flag & ~val_p->flag; } } - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (ebone->parent && ebone->flag & BONE_CONNECTED) { if (ebone->parent->temp.ebone == ebone->parent) { /* ignore */ @@ -1376,30 +1376,30 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) } /* cleanup multiple used bones */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (ebone->temp.ebone == ebone) { - ebone->temp.ebone = NULL; + ebone->temp.ebone = nullptr; } } - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { /* break connections for unseen bones */ if (((arm->layer & ebone->layer) && (ED_armature_ebone_selectflag_get(ebone) & (BONE_TIPSEL | BONE_SELECTED))) == 0) { - ebone->temp.ebone = NULL; + ebone->temp.ebone = nullptr; } if (((arm->layer & ebone->layer) && (ED_armature_ebone_selectflag_get(ebone) & (BONE_ROOTSEL | BONE_SELECTED))) == 0) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { - ebone->parent->temp.ebone = NULL; + ebone->parent->temp.ebone = nullptr; } } } - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (ebone->parent && (ebone->parent->temp.ebone == ebone)) { ebone->flag |= BONE_DONE; @@ -1408,7 +1408,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) BKE_pose_channels_remove(obedit, armature_dissolve_ebone_cb, arm); - for (ebone = arm->edbo->first; ebone; ebone = ebone_next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone_next) { ebone_next = ebone->next; if (ebone->flag & BONE_DONE) { @@ -1422,18 +1422,18 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) } if (changed) { - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (ebone->parent && ebone->parent->temp.ebone && (ebone->flag & BONE_CONNECTED)) { ebone->rad_head = ebone->parent->rad_tail; } } if (arm->flag & ARM_MIRROR_EDIT) { - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - union { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { + union Value { int flag; void *p; - } *val_p = (void *)BLI_ghash_lookup_p(ebone_flag_orig, ebone); + } *val_p = (Value *)BLI_ghash_lookup_p(ebone_flag_orig, ebone); if (val_p && val_p->flag) { ebone->flag &= ~val_p->flag; } @@ -1442,7 +1442,7 @@ static int armature_dissolve_selected_exec(bContext *C, wmOperator *UNUSED(op)) } if (arm->flag & ARM_MIRROR_EDIT) { - BLI_ghash_free(ebone_flag_orig, NULL, NULL); + BLI_ghash_free(ebone_flag_orig, nullptr, nullptr); } if (changed) { @@ -1500,7 +1500,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -1560,7 +1560,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 246a1ebf97f..50ad041f216 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /* internal exports only */ struct wmOperatorType; @@ -331,3 +335,7 @@ int bone_looper(struct Object *ob, int (*bone_func)(struct Object *, struct Bone *, void *)); /** \} */ + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.cc similarity index 88% rename from source/blender/editors/armature/armature_naming.c rename to source/blender/editors/armature/armature_naming.cc index e7d7347dce0..ab537ed193d 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.cc @@ -58,10 +58,10 @@ /* NOTE: there's a ed_armature_bone_unique_name() too! */ static bool editbone_unique_check(void *arg, const char *name) { - struct { + struct Arg { ListBase *lb; void *bone; - } *data = arg; + } *data = static_cast(arg); EditBone *dupli = ED_armature_ebone_find_name(data->lb, name); return dupli && dupli != data->bone; } @@ -86,13 +86,13 @@ void ED_armature_ebone_unique_name(ListBase *ebones, char *name, EditBone *bone) static bool bone_unique_check(void *arg, const char *name) { - return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL; + return BKE_armature_find_bone_name((bArmature *)arg, name) != nullptr; } static void ed_armature_bone_unique_name(bArmature *arm, char *name) { BLI_uniquename_cb( - bone_unique_check, (void *)arm, DATA_("Bone"), '.', name, sizeof(((Bone *)NULL)->name)); + bone_unique_check, (void *)arm, DATA_("Bone"), '.', name, sizeof(((Bone *)nullptr)->name)); } /** \} */ @@ -110,12 +110,12 @@ static void constraint_bone_name_fix(Object *ob, bConstraint *curcon; bConstraintTarget *ct; - for (curcon = conlist->first; curcon; curcon = curcon->next) { - ListBase targets = {NULL, NULL}; + for (curcon = static_cast(conlist->first); curcon; curcon = curcon->next) { + ListBase targets = {nullptr, nullptr}; /* constraint targets */ if (BKE_constraint_targets_get(curcon, &targets)) { - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { if (ct->tar == ob) { if (STREQ(ct->subtarget, oldname)) { STRNCPY(ct->subtarget, newname); @@ -156,7 +156,7 @@ void ED_armature_bone_rename(Main *bmain, EditBone *eBone = ED_armature_ebone_find_name(arm->edbo, oldname); if (eBone) { - ED_armature_ebone_unique_name(arm->edbo, newname, NULL); + ED_armature_ebone_unique_name(arm->edbo, newname, nullptr); STRNCPY(eBone->name, newname); } else { @@ -171,7 +171,7 @@ void ED_armature_bone_rename(Main *bmain, if (arm->bonehash) { BLI_assert(BLI_ghash_haskey(arm->bonehash, bone->name)); - BLI_ghash_remove(arm->bonehash, bone->name, NULL, NULL); + BLI_ghash_remove(arm->bonehash, bone->name, nullptr, nullptr); } STRNCPY(bone->name, newname); @@ -189,7 +189,8 @@ void ED_armature_bone_rename(Main *bmain, DEG_id_tag_update(&arm->id, ID_RECALC_COPY_ON_WRITE); /* do entire dbase - objects */ - for (ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ob = static_cast(bmain->objects.first); ob; + ob = static_cast(ob->id.next)) { ModifierData *md; /* we have the object using the armature */ @@ -205,7 +206,7 @@ void ED_armature_bone_rename(Main *bmain, /* remove the old hash entry, and replace with the new name */ if (gh) { BLI_assert(BLI_ghash_haskey(gh, pchan->name)); - BLI_ghash_remove(gh, pchan->name, NULL, NULL); + BLI_ghash_remove(gh, pchan->name, nullptr, nullptr); } STRNCPY(pchan->name, newname); @@ -219,13 +220,16 @@ void ED_armature_bone_rename(Main *bmain, } /* Update any object constraints to use the new bone name */ - for (cob = bmain->objects.first; cob; cob = cob->id.next) { + for (cob = static_cast(bmain->objects.first); cob; + cob = static_cast(cob->id.next)) + { if (cob->constraints.first) { constraint_bone_name_fix(ob, &cob->constraints, oldname, newname); } if (cob->pose) { bPoseChannel *pchan; - for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(cob->pose->chanbase.first); pchan; + pchan = pchan->next) { constraint_bone_name_fix(ob, &pchan->constraints, oldname, newname); } } @@ -246,12 +250,12 @@ void ED_armature_bone_rename(Main *bmain, bDeformGroup *dg = BKE_object_defgroup_find_name(ob, oldname); if (dg) { STRNCPY(dg->name, newname); - DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY); + DEG_id_tag_update(static_cast(ob->data), ID_RECALC_GEOMETRY); } } /* fix modifiers that might be using this name */ - for (md = ob->modifiers.first; md; md = md->next) { + for (md = static_cast(ob->modifiers.first); md; md = md->next) { switch (md->type) { case eModifierType_Hook: { HookModifierData *hmd = (HookModifierData *)md; @@ -286,7 +290,7 @@ void ED_armature_bone_rename(Main *bmain, /* fix camera focus */ if (ob->type == OB_CAMERA) { Camera *cam = (Camera *)ob->data; - if ((cam->dof.focus_object != NULL) && (cam->dof.focus_object->data == arm)) { + if ((cam->dof.focus_object != nullptr) && (cam->dof.focus_object->data == arm)) { if (STREQ(cam->dof.focus_subtarget, oldname)) { STRNCPY(cam->dof.focus_subtarget, newname); DEG_id_tag_update(&cam->id, ID_RECALC_COPY_ON_WRITE); @@ -299,7 +303,7 @@ void ED_armature_bone_rename(Main *bmain, bGPdata *gpd = (bGPdata *)ob->data; LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { - if ((gpl->parent != NULL) && (gpl->parent->data == arm)) { + if ((gpl->parent != nullptr) && (gpl->parent->data == arm)) { if (STREQ(gpl->parsubstr, oldname)) { STRNCPY(gpl->parsubstr, newname); } @@ -314,7 +318,7 @@ void ED_armature_bone_rename(Main *bmain, bDeformGroup *dg = BKE_object_defgroup_find_name(ob, oldname); if (dg) { STRNCPY(dg->name, newname); - DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY); + DEG_id_tag_update(static_cast(ob->data), ID_RECALC_GEOMETRY); } } break; @@ -350,12 +354,14 @@ void ED_armature_bone_rename(Main *bmain, /* correct view locking */ { bScreen *screen; - for (screen = bmain->screens.first; screen; screen = screen->id.next) { + for (screen = static_cast(bmain->screens.first); screen; + screen = static_cast(screen->id.next)) + { ScrArea *area; /* add regions */ - for (area = screen->areabase.first; area; area = area->next) { + for (area = static_cast(screen->areabase.first); area; area = area->next) { SpaceLink *sl; - for (sl = area->spacedata.first; sl; sl = sl->next) { + for (sl = static_cast(area->spacedata.first); sl; sl = sl->next) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; if (v3d->ob_center && v3d->ob_center->data == arm) { @@ -377,18 +383,18 @@ void ED_armature_bone_rename(Main *bmain, /** \name Bone Flipping (Object & Edit Mode API) * \{ */ -typedef struct BoneFlipNameData { +struct BoneFlipNameData { struct BoneFlipNameData *next, *prev; char *name; char name_flip[MAXBONENAME]; -} BoneFlipNameData; +}; void ED_armature_bones_flip_names(Main *bmain, bArmature *arm, ListBase *bones_names, const bool do_strip_numbers) { - ListBase bones_names_conflicts = {NULL}; + ListBase bones_names_conflicts = {nullptr}; BoneFlipNameData *bfn; /* First pass: generate flip names, and blindly rename. @@ -396,7 +402,7 @@ void ED_armature_bones_flip_names(Main *bmain, * store both bone's name and expected flipped one into temp list for second pass. */ LISTBASE_FOREACH (LinkData *, link, bones_names) { char name_flip[MAXBONENAME]; - char *name = link->data; + char *name = static_cast(link->data); /* WARNING: if do_strip_numbers is set, expect completely mismatched names in cases like * Bone.R, Bone.R.001, Bone.R.002, etc. */ @@ -405,7 +411,7 @@ void ED_armature_bones_flip_names(Main *bmain, ED_armature_bone_rename(bmain, arm, name, name_flip); if (!STREQ(name, name_flip)) { - bfn = alloca(sizeof(BoneFlipNameData)); + bfn = static_cast(alloca(sizeof(BoneFlipNameData))); bfn->name = name; STRNCPY(bfn->name_flip, name_flip); BLI_addtail(&bones_names_conflicts, bfn); @@ -416,7 +422,7 @@ void ED_armature_bones_flip_names(Main *bmain, * Note that if the other bone was not selected, its name was not flipped, * so conflict remains and that second rename simply generates a new numbered alternative name. */ - for (bfn = bones_names_conflicts.first; bfn; bfn = bfn->next) { + for (bfn = static_cast(bones_names_conflicts.first); bfn; bfn = bfn->next) { ED_armature_bone_rename(bmain, arm, bfn->name, bfn->name_flip); } } @@ -441,14 +447,14 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); /* Paranoia check. */ - if (ob_active->pose == NULL) { + if (ob_active->pose == nullptr) { continue; } - ListBase bones_names = {NULL}; + ListBase bones_names = {nullptr}; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (EBONE_VISIBLE(arm, ebone)) { @@ -530,11 +536,11 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; /* Paranoia checks. */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { continue; } @@ -584,7 +590,7 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.cc similarity index 100% rename from source/blender/editors/armature/armature_ops.c rename to source/blender/editors/armature/armature_ops.cc diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.cc similarity index 88% rename from source/blender/editors/armature/armature_relations.c rename to source/blender/editors/armature/armature_relations.cc index 8d7ec96e72f..bfa1d0d89d7 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.cc @@ -68,13 +68,13 @@ static void joined_armature_fix_links_constraints(Main *bmain, bConstraint *con; bool changed = false; - for (con = lb->first; con; con = con->next) { - ListBase targets = {NULL, NULL}; + for (con = static_cast(lb->first); con; con = con->next) { + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; /* constraint targets */ if (BKE_constraint_targets_get(con, &targets)) { - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { if (ct->tar == srcArm) { if (ct->subtarget[0] == '\0') { ct->tar = tarArm; @@ -93,7 +93,7 @@ static void joined_armature_fix_links_constraints(Main *bmain, /* action constraint? (pose constraints only) */ if (con->type == CONSTRAINT_TYPE_ACTION) { - bActionConstraint *data = con->data; + bActionConstraint *data = static_cast(con->data); if (data->act) { BKE_action_fix_paths_rename( @@ -110,14 +110,14 @@ static void joined_armature_fix_links_constraints(Main *bmain, } /* userdata for joined_armature_fix_animdata_cb() */ -typedef struct tJoinArmature_AdtFixData { +struct tJoinArmature_AdtFixData { Main *bmain; Object *srcArm; Object *tarArm; GHash *names_map; -} tJoinArmature_AdtFixData; +}; /* Callback to pass to BKE_animdata_main_cb() for fixing driver ID's to point to the new ID. */ /* FIXME: For now, we only care about drivers here. @@ -136,8 +136,8 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data /* Fix paths - If this is the target object, it will have some "dirty" paths */ if ((id == src_id) && strstr(fcu->rna_path, "pose.bones[")) { GHASH_ITER (gh_iter, afd->names_map) { - const char *old_name = BLI_ghashIterator_getKey(&gh_iter); - const char *new_name = BLI_ghashIterator_getValue(&gh_iter); + const char *old_name = static_cast(BLI_ghashIterator_getKey(&gh_iter)); + const char *new_name = static_cast(BLI_ghashIterator_getValue(&gh_iter)); /* only remap if changed; this still means there will be some * waste if there aren't many drivers/keys */ @@ -166,7 +166,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data driver->flag &= ~DRIVER_FLAG_INVALID; /* Fix driver references to invalid ID's */ - for (dvar = driver->variables.first; dvar; dvar = dvar->next) { + for (dvar = static_cast(driver->variables.first); dvar; dvar = dvar->next) { /* only change the used targets, since the others will need fixing manually anyway */ DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) { /* change the ID's used... */ @@ -181,8 +181,9 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data */ if ((dtar->rna_path && strstr(dtar->rna_path, "pose.bones[")) || (dtar->pchan_name[0])) { GHASH_ITER (gh_iter, afd->names_map) { - const char *old_name = BLI_ghashIterator_getKey(&gh_iter); - const char *new_name = BLI_ghashIterator_getValue(&gh_iter); + const char *old_name = static_cast(BLI_ghashIterator_getKey(&gh_iter)); + const char *new_name = static_cast( + BLI_ghashIterator_getValue(&gh_iter)); /* only remap if changed */ if (!STREQ(old_name, new_name)) { @@ -220,11 +221,13 @@ static void joined_armature_fix_links( bPoseChannel *pchant; /* let's go through all objects in database */ - for (ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ob = static_cast(bmain->objects.first); ob; + ob = static_cast(ob->id.next)) { /* do some object-type specific things */ if (ob->type == OB_ARMATURE) { pose = ob->pose; - for (pchant = pose->chanbase.first; pchant; pchant = pchant->next) { + for (pchant = static_cast(pose->chanbase.first); pchant; + pchant = pchant->next) { joined_armature_fix_links_constraints( bmain, ob, tarArm, srcArm, pchan, curbone, &pchant->constraints); } @@ -259,7 +262,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob_active = CTX_data_active_object(C); - bArmature *arm = (ob_active) ? ob_active->data : NULL; + bArmature *arm = static_cast((ob_active) ? ob_active->data : nullptr); bPose *pose, *opose; bPoseChannel *pchan, *pchann; EditBone *curbone; @@ -301,8 +304,8 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { if ((ob_iter->type == OB_ARMATURE) && (ob_iter != ob_active)) { - tJoinArmature_AdtFixData afd = {NULL}; - bArmature *curarm = ob_iter->data; + tJoinArmature_AdtFixData afd = {nullptr}; + bArmature *curarm = static_cast(ob_iter->data); /* we assume that each armature datablock is only used in a single place */ BLI_assert(ob_active->data != ob_iter->data); @@ -314,7 +317,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) afd.names_map = BLI_ghash_str_new("join_armature_adt_fix"); /* Make a list of edit-bones in current armature */ - ED_armature_to_edit(ob_iter->data); + ED_armature_to_edit(static_cast(ob_iter->data)); /* Get Pose of current armature */ opose = ob_iter->pose; @@ -325,12 +328,12 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) mul_m4_m4m4(mat, oimat, ob_iter->object_to_world); /* Copy bones and posechannels from the object to the edit armature */ - for (pchan = opose->chanbase.first; pchan; pchan = pchann) { + for (pchan = static_cast(opose->chanbase.first); pchan; pchan = pchann) { pchann = pchan->next; curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name); /* Get new name */ - ED_armature_ebone_unique_name(arm->edbo, curbone->name, NULL); + ED_armature_ebone_unique_name(arm->edbo, curbone->name, nullptr); BLI_ghash_insert(afd.names_map, BLI_strdup(pchan->name), curbone->name); /* Transform the bone */ @@ -389,14 +392,14 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) /* Fix all the drivers (and animation data) */ BKE_fcurves_main_cb(bmain, joined_armature_fix_animdata_cb, &afd); - BLI_ghash_free(afd.names_map, MEM_freeN, NULL); + BLI_ghash_free(afd.names_map, MEM_freeN, nullptr); /* Only copy over animdata now, after all the remapping has been done, * so that we don't have to worry about ambiguities re which armature * a bone came from! */ if (ob_iter->adt) { - if (ob_active->adt == NULL) { + if (ob_active->adt == nullptr) { /* no animdata, so just use a copy of the whole thing */ ob_active->adt = BKE_animdata_copy(bmain, ob_iter->adt, 0); } @@ -408,7 +411,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) } if (curarm->adt) { - if (arm->adt == NULL) { + if (arm->adt == nullptr) { /* no animdata, so just use a copy of the whole thing */ arm->adt = BKE_animdata_copy(bmain, curarm->adt, 0); } @@ -455,17 +458,19 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n npchans = &newArm->pose->chanbase; /* let's go through all objects in database */ - for (ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ob = static_cast(bmain->objects.first); ob; + ob = static_cast(ob->id.next)) { /* do some object-type specific things */ if (ob->type == OB_ARMATURE) { - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - for (con = pchan->constraints.first; con; con = con->next) { - ListBase targets = {NULL, NULL}; + for (pchan = static_cast(ob->pose->chanbase.first); pchan; + pchan = pchan->next) { + for (con = static_cast(pchan->constraints.first); con; con = con->next) { + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; /* constraint targets */ if (BKE_constraint_targets_get(con, &targets)) { - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { /* Any targets which point to original armature * are redirected to the new one only if: * - The target isn't origArm/newArm itself. @@ -493,13 +498,13 @@ static void separated_armature_fix_links(Main *bmain, Object *origArm, Object *n /* fix object-level constraints */ if (ob != origArm) { - for (con = ob->constraints.first; con; con = con->next) { - ListBase targets = {NULL, NULL}; + for (con = static_cast(ob->constraints.first); con; con = con->next) { + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; /* constraint targets */ if (BKE_constraint_targets_get(con, &targets)) { - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm @@ -552,7 +557,7 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec ED_armature_to_edit(arm); /* go through pose-channels, checking if a bone should be removed */ - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchann) { pchann = pchan->next; curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name); @@ -562,9 +567,9 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec /* Clear the bone->parent var of any bone that had this as its parent. */ LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { if (ebo->parent == curbone) { - ebo->parent = NULL; + ebo->parent = nullptr; /* this is needed to prevent random crashes with in ED_armature_from_edit */ - ebo->temp.p = NULL; + ebo->temp.p = nullptr; ebo->flag &= ~BONE_CONNECTED; } } @@ -572,13 +577,13 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec /* clear the pchan->parent var of any pchan that had this as its parent */ LISTBASE_FOREACH (bPoseChannel *, pchn, &ob->pose->chanbase) { if (pchn->parent == pchan) { - pchn->parent = NULL; + pchn->parent = nullptr; } if (pchn->bbone_next == pchan) { - pchn->bbone_next = NULL; + pchn->bbone_next = nullptr; } if (pchn->bbone_prev == pchan) { - pchn->bbone_prev = NULL; + pchn->bbone_prev = nullptr; } } @@ -594,8 +599,8 @@ static void separate_armature_bones(Main *bmain, Object *ob, const bool is_selec /* Exit edit-mode (recalculates pose-channels too). */ ED_armature_edit_deselect_all(ob); - ED_armature_from_edit(bmain, ob->data); - ED_armature_edit_free(ob->data); + ED_armature_from_edit(bmain, static_cast(ob->data)); + ED_armature_edit_free(static_cast(ob->data)); } /* separate selected bones into their armature */ @@ -618,7 +623,7 @@ static int separate_armature_exec(bContext *C, wmOperator *op) Object *ob_old = base_old->object; { - bArmature *arm_old = ob_old->data; + bArmature *arm_old = static_cast(ob_old->data); bool has_selected_bone = false; bool has_selected_any = false; LISTBASE_FOREACH (EditBone *, ebone, arm_old->edbo) { @@ -654,15 +659,16 @@ static int separate_armature_exec(bContext *C, wmOperator *op) /* 1) store starting settings and exit edit-mode */ ob_old->mode &= ~OB_MODE_POSE; - ED_armature_from_edit(bmain, ob_old->data); - ED_armature_edit_free(ob_old->data); + ED_armature_from_edit(bmain, static_cast(ob_old->data)); + ED_armature_edit_free(static_cast(ob_old->data)); /* 2) duplicate base */ /* Only duplicate linked armature but take into account * user preferences for duplicating actions. */ short dupflag = USER_DUP_ARM | (U.dupflag & USER_DUP_ACT); - Base *base_new = ED_object_add_duplicate(bmain, scene, view_layer, base_old, dupflag); + Base *base_new = ED_object_add_duplicate( + bmain, scene, view_layer, base_old, eDupli_ID_Flags(dupflag)); Object *ob_new = base_new->object; DEG_relations_tag_update(bmain); @@ -678,8 +684,8 @@ static int separate_armature_exec(bContext *C, wmOperator *op) DEG_id_tag_update(&ob_new->id, ID_RECALC_GEOMETRY); /* this is the separated one */ /* 5) restore original conditions */ - ED_armature_to_edit(ob_old->data); - ED_armature_edit_refresh_layer_used(ob_old->data); + ED_armature_to_edit(static_cast(ob_old->data)); + ED_armature_edit_refresh_layer_used(static_cast(ob_old->data)); /* parents tips remain selected when connected children are removed. */ ED_armature_edit_deselect_all(ob_old); @@ -759,7 +765,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, /* in actbone tree we cannot have a loop */ for (ebone = actbone->parent; ebone; ebone = ebone->parent) { if (ebone->parent == selbone) { - ebone->parent = NULL; + ebone->parent = nullptr; ebone->flag &= ~BONE_CONNECTED; } } @@ -775,7 +781,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, add_v3_v3(selbone->tail, offset); /* offset for all its children */ - for (ebone = edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(edbo->first); ebone; ebone = ebone->next) { EditBone *par; for (par = ebone->parent; par; par = par->parent) { @@ -796,7 +802,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, static const EnumPropertyItem prop_editarm_make_parent_types[] = { {ARM_PAR_CONNECT, "CONNECTED", 0, "Connected", ""}, {ARM_PAR_OFFSET, "OFFSET", 0, "Keep Offset", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static int armature_parent_set_exec(bContext *C, wmOperator *op) @@ -804,11 +810,11 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_edit_object(C); bArmature *arm = (bArmature *)ob->data; EditBone *actbone = CTX_data_active_bone(C); - EditBone *actmirb = NULL; + EditBone *actmirb = nullptr; short val = RNA_enum_get(op->ptr, "type"); /* there must be an active bone */ - if (actbone == NULL) { + if (actbone == nullptr) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); return OPERATOR_CANCELLED; } @@ -821,7 +827,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) * then just use actbone. Useful when doing upper arm to spine. */ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); - if (actmirb == NULL) { + if (actmirb == nullptr) { actmirb = actbone; } } @@ -888,9 +894,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int armature_parent_set_invoke(bContext *C, - wmOperator *UNUSED(op), - const wmEvent *UNUSED(event)) +static int armature_parent_set_invoke(bContext *C, wmOperator * /*op*/, const wmEvent * /*event*/) { /* False when all selected bones are parented to the active bone. */ bool enable_offset = false; @@ -898,7 +902,7 @@ static int armature_parent_set_invoke(bContext *C, bool enable_connect = false; { Object *ob = CTX_data_edit_object(C); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); EditBone *actbone = arm->act_edbone; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (!EBONE_EDITABLE(ebone) || !(ebone->flag & BONE_SELECTED)) { @@ -925,11 +929,11 @@ static int armature_parent_set_invoke(bContext *C, uiLayout *row_offset = uiLayoutRow(layout, false); uiLayoutSetEnabled(row_offset, enable_offset); - uiItemEnumO(row_offset, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET); + uiItemEnumO(row_offset, "ARMATURE_OT_parent_set", nullptr, 0, "type", ARM_PAR_OFFSET); uiLayout *row_connect = uiLayoutRow(layout, false); uiLayoutSetEnabled(row_connect, enable_connect); - uiItemEnumO(row_connect, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT); + uiItemEnumO(row_connect, "ARMATURE_OT_parent_set", nullptr, 0, "type", ARM_PAR_CONNECT); UI_popup_menu_end(C, pup); @@ -958,7 +962,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot) static const EnumPropertyItem prop_editarm_clear_parent_types[] = { {ARM_PAR_CLEAR, "CLEAR", 0, "Clear Parent", ""}, {ARM_PAR_CLEAR_DISCONNECT, "DISCONNECT", 0, "Disconnect Bone", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static void editbone_clear_parent(EditBone *ebone, int mode) @@ -969,7 +973,7 @@ static void editbone_clear_parent(EditBone *ebone, int mode) } if (mode == 1) { - ebone->parent = NULL; + ebone->parent = nullptr; } ebone->flag &= ~BONE_CONNECTED; } @@ -990,7 +994,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -1015,8 +1019,8 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) } static int armature_parent_clear_invoke(bContext *C, - wmOperator *UNUSED(op), - const wmEvent *UNUSED(event)) + wmOperator * /*op*/, + const wmEvent * /*event*/) { /* False when no selected bones are connected to the active bone. */ bool enable_disconnect = false; @@ -1024,12 +1028,12 @@ static int armature_parent_clear_invoke(bContext *C, bool enable_clear = false; { Object *ob = CTX_data_edit_object(C); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (!EBONE_EDITABLE(ebone) || !(ebone->flag & BONE_SELECTED)) { continue; } - if (ebone->parent == NULL) { + if (ebone->parent == nullptr) { continue; } enable_clear = true; @@ -1047,12 +1051,12 @@ static int armature_parent_clear_invoke(bContext *C, uiLayout *row_clear = uiLayoutRow(layout, false); uiLayoutSetEnabled(row_clear, enable_clear); - uiItemEnumO(row_clear, "ARMATURE_OT_parent_clear", NULL, 0, "type", ARM_PAR_CLEAR); + uiItemEnumO(row_clear, "ARMATURE_OT_parent_clear", nullptr, 0, "type", ARM_PAR_CLEAR); uiLayout *row_disconnect = uiLayoutRow(layout, false); uiLayoutSetEnabled(row_disconnect, enable_disconnect); uiItemEnumO( - row_disconnect, "ARMATURE_OT_parent_clear", NULL, 0, "type", ARM_PAR_CLEAR_DISCONNECT); + row_disconnect, "ARMATURE_OT_parent_clear", nullptr, 0, "type", ARM_PAR_CLEAR_DISCONNECT); UI_popup_menu_end(C, pup); diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.cc similarity index 91% rename from source/blender/editors/armature/armature_select.c rename to source/blender/editors/armature/armature_select.cc index 996befac76c..02641503a43 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.cc @@ -58,8 +58,8 @@ Base *ED_armature_base_and_ebone_from_select_buffer(Base **bases, EditBone **r_ebone) { const uint hit_object = select_id & 0xFFFF; - Base *base = NULL; - EditBone *ebone = NULL; + Base *base = nullptr; + EditBone *ebone = nullptr; /* TODO(@ideasman42): optimize, eg: sort & binary search. */ for (uint base_index = 0; base_index < bases_len; base_index++) { if (bases[base_index]->object->runtime.select_id == hit_object) { @@ -67,10 +67,10 @@ Base *ED_armature_base_and_ebone_from_select_buffer(Base **bases, break; } } - if (base != NULL) { + if (base != nullptr) { const uint hit_bone = (select_id & ~BONESEL_ANY) >> 16; - bArmature *arm = base->object->data; - ebone = BLI_findlink(arm->edbo, hit_bone); + bArmature *arm = static_cast(base->object->data); + ebone = static_cast(BLI_findlink(arm->edbo, hit_bone)); } *r_ebone = ebone; return base; @@ -82,8 +82,8 @@ Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects, EditBone **r_ebone) { const uint hit_object = select_id & 0xFFFF; - Object *ob = NULL; - EditBone *ebone = NULL; + Object *ob = nullptr; + EditBone *ebone = nullptr; /* TODO(@ideasman42): optimize, eg: sort & binary search. */ for (uint ob_index = 0; ob_index < objects_len; ob_index++) { if (objects[ob_index]->runtime.select_id == hit_object) { @@ -91,10 +91,10 @@ Object *ED_armature_object_and_ebone_from_select_buffer(Object **objects, break; } } - if (ob != NULL) { + if (ob != nullptr) { const uint hit_bone = (select_id & ~BONESEL_ANY) >> 16; - bArmature *arm = ob->data; - ebone = BLI_findlink(arm->edbo, hit_bone); + bArmature *arm = static_cast(ob->data); + ebone = static_cast(BLI_findlink(arm->edbo, hit_bone)); } *r_ebone = ebone; return ob; @@ -106,8 +106,8 @@ Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases, bPoseChannel **r_pchan) { const uint hit_object = select_id & 0xFFFF; - Base *base = NULL; - bPoseChannel *pchan = NULL; + Base *base = nullptr; + bPoseChannel *pchan = nullptr; /* TODO(@ideasman42): optimize, eg: sort & binary search. */ for (uint base_index = 0; base_index < bases_len; base_index++) { if (bases[base_index]->object->runtime.select_id == hit_object) { @@ -115,11 +115,11 @@ Base *ED_armature_base_and_pchan_from_select_buffer(Base **bases, break; } } - if (base != NULL) { - if (base->object->pose != NULL) { + if (base != nullptr) { + if (base->object->pose != nullptr) { const uint hit_bone = (select_id & ~BONESEL_ANY) >> 16; - /* pchan may be NULL. */ - pchan = BLI_findlink(&base->object->pose->chanbase, hit_bone); + /* pchan may be nullptr. */ + pchan = static_cast(BLI_findlink(&base->object->pose->chanbase, hit_bone)); } } *r_pchan = pchan; @@ -131,9 +131,9 @@ Base *ED_armature_base_and_bone_from_select_buffer(Base **bases, const uint select_id, Bone **r_bone) { - bPoseChannel *pchan = NULL; + bPoseChannel *pchan = nullptr; Base *base = ED_armature_base_and_pchan_from_select_buffer(bases, bases_len, select_id, &pchan); - *r_bone = pchan ? pchan->bone : NULL; + *r_bone = pchan ? pchan->bone : nullptr; return base; } @@ -161,8 +161,8 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode { bPoseChannel *pchan; EditBone *ebone; - void *firstunSel = NULL, *firstSel = NULL, *data; - Base *firstunSel_base = NULL, *firstSel_base = NULL; + void *firstunSel = nullptr, *firstSel = nullptr, *data; + Base *firstunSel_base = nullptr, *firstSel_base = nullptr; uint hitresult; bool takeNext = false; int minsel = 0xffffffff, minunsel = 0xffffffff; @@ -171,14 +171,14 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode hitresult = buffer[i].id; if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */ - Base *base = NULL; + Base *base = nullptr; bool sel; hitresult &= ~BONESEL_ANY; /* Determine what the current bone is */ if (is_editmode == false) { base = ED_armature_base_and_pchan_from_select_buffer(bases, bases_len, hitresult, &pchan); - if (pchan != NULL) { + if (pchan != nullptr) { if (findunsel) { sel = (pchan->bone->flag & BONE_SELECTED); } @@ -189,7 +189,7 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode data = pchan; } else { - data = NULL; + data = nullptr; sel = 0; } } @@ -262,8 +262,8 @@ EditBone *ED_armature_pick_ebone_from_selectbuffer(Base **bases, Base **r_base) { const bool is_editmode = true; - return ed_armature_pick_bone_from_selectbuffer_impl( - is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base); + return static_cast(ed_armature_pick_bone_from_selectbuffer_impl( + is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base)); } bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(Base **bases, @@ -275,8 +275,8 @@ bPoseChannel *ED_armature_pick_pchan_from_selectbuffer(Base **bases, Base **r_base) { const bool is_editmode = false; - return ed_armature_pick_bone_from_selectbuffer_impl( - is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base); + return static_cast(ed_armature_pick_bone_from_selectbuffer_impl( + is_editmode, bases, bases_len, buffer, hits, findunsel, do_nearest, r_base)); } Bone *ED_armature_pick_bone_from_selectbuffer(Base **bases, @@ -289,7 +289,7 @@ Bone *ED_armature_pick_bone_from_selectbuffer(Base **bases, { bPoseChannel *pchan = ED_armature_pick_pchan_from_selectbuffer( bases, bases_len, buffer, hits, findunsel, do_nearest, r_base); - return pchan ? pchan->bone : NULL; + return pchan ? pchan->bone : nullptr; } /** \} */ @@ -318,7 +318,7 @@ static void *ed_armature_pick_bone_impl( short hits; ED_view3d_viewcontext_init(C, &vc, depsgraph); - BLI_assert((vc.obedit != NULL) == is_editmode); + BLI_assert((vc.obedit != nullptr) == is_editmode); BLI_rcti_init_pt_radius(&rect, xy, 0); @@ -333,13 +333,13 @@ static void *ed_armature_pick_bone_impl( VIEW3D_SELECT_FILTER_NOP, select_id_ignore); - *r_base = NULL; + *r_base = nullptr; if (hits > 0) { uint bases_len = 0; Base **bases; - if (vc.obedit != NULL) { + if (vc.obedit != nullptr) { bases = BKE_view_layer_array_from_bases_in_edit_mode( vc.scene, vc.view_layer, vc.v3d, &bases_len); } @@ -354,25 +354,27 @@ static void *ed_armature_pick_bone_impl( return bone; } - return NULL; + return nullptr; } EditBone *ED_armature_pick_ebone(bContext *C, const int xy[2], bool findunsel, Base **r_base) { const bool is_editmode = true; - return ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base); + return static_cast( + ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base)); } bPoseChannel *ED_armature_pick_pchan(bContext *C, const int xy[2], bool findunsel, Base **r_base) { const bool is_editmode = false; - return ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base); + return static_cast( + ed_armature_pick_bone_impl(is_editmode, C, xy, findunsel, r_base)); } Bone *ED_armature_pick_bone(bContext *C, const int xy[2], bool findunsel, Base **r_base) { bPoseChannel *pchan = ED_armature_pick_pchan(C, xy, findunsel, r_base); - return pchan ? pchan->bone : NULL; + return pchan ? pchan->bone : nullptr; } /** \} */ @@ -393,7 +395,7 @@ Bone *ED_armature_pick_bone(bContext *C, const int xy[2], bool findunsel, Base * static bool armature_select_linked_impl(Object *ob, const bool select, const bool all_forks) { bool changed = false; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); /* Implementation note, this flood-fills selected bones with the 'TOUCH' flag, * even though this is a loop-within a loop, walking up the parent chain only touches new bones. @@ -407,6 +409,7 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo }; #define CHECK_PARENT(ebone) \ +\ (((ebone)->flag & BONE_CONNECTED) && \ ((ebone)->parent ? EBONE_SELECTABLE(arm, (ebone)->parent) : false)) @@ -426,7 +429,8 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo ebone_iter->temp.i |= TOUCH | LINK; /* We have an un-touched link. */ - for (EditBone *ebone = ebone_iter; ebone; ebone = CHECK_PARENT(ebone) ? ebone->parent : NULL) { + for (EditBone *ebone = ebone_iter; ebone; + ebone = CHECK_PARENT(ebone) ? ebone->parent : nullptr) { ED_armature_ebone_select_set(ebone, select); changed = true; @@ -454,8 +458,9 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo } /* First check if we're marked. */ - EditBone *ebone_touched_parent = NULL; - for (EditBone *ebone = ebone_iter; ebone; ebone = CHECK_PARENT(ebone) ? ebone->parent : NULL) { + EditBone *ebone_touched_parent = nullptr; + for (EditBone *ebone = ebone_iter; ebone; + ebone = CHECK_PARENT(ebone) ? ebone->parent : nullptr) { if (ebone->temp.i & TOUCH) { ebone_touched_parent = ebone; break; @@ -463,7 +468,7 @@ static bool armature_select_linked_impl(Object *ob, const bool select, const boo ebone->temp.i |= TOUCH; } - if ((ebone_touched_parent != NULL) && (ebone_touched_parent->temp.i & LINK)) { + if ((ebone_touched_parent != nullptr) && (ebone_touched_parent->temp.i & LINK)) { for (EditBone *ebone = ebone_iter; ebone != ebone_touched_parent; ebone = ebone->parent) { if ((ebone->temp.i & LINK) == 0) { ebone->temp.i |= LINK; @@ -503,7 +508,7 @@ static int armature_select_linked_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool found = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -563,14 +568,14 @@ static int armature_select_linked_pick_invoke(bContext *C, wmOperator *op, const view3d_operator_needs_opengl(C); BKE_object_update_select_id(CTX_data_main(C)); - Base *base = NULL; + Base *base = nullptr; EditBone *ebone_active = ED_armature_pick_ebone(C, event->mval, true, &base); - if (ebone_active == NULL) { + if (ebone_active == nullptr) { return OPERATOR_CANCELLED; } - bArmature *arm = base->object->data; + bArmature *arm = static_cast(base->object->data); if (!EBONE_SELECTABLE(arm, ebone_active)) { return OPERATOR_CANCELLED; } @@ -620,7 +625,7 @@ void ARMATURE_OT_select_linked_pick(wmOperatorType *ot) * \{ */ /* utility function for get_nearest_editbonepoint */ -static int selectbuffer_ret_hits_12(GPUSelectResult *UNUSED(buffer), const int hits12) +static int selectbuffer_ret_hits_12(GPUSelectResult * /*buffer*/, const int hits12) { return hits12; } @@ -638,20 +643,26 @@ static EditBone *get_nearest_editbonepoint( ViewContext *vc, bool findunsel, bool use_cycle, Base **r_base, int *r_selmask) { GPUSelectResult buffer[MAXPICKELEMS]; - struct { + struct Result { uint hitresult; Base *base; EditBone *ebone; - } *result = NULL, - - result_cycle = {.hitresult = -1, .base = NULL, .ebone = NULL}, - result_bias = {.hitresult = -1, .base = NULL, .ebone = NULL}; + }; + Result *result = nullptr; + Result result_cycle{}; + result_cycle.hitresult = -1; + result_cycle.base = nullptr; + result_cycle.ebone = nullptr; + Result result_bias{}; + result_bias.hitresult = -1; + result_bias.base = nullptr; + result_bias.ebone = nullptr; /* find the bone after the current active bone, so as to bump up its chances in selection. * this way overlapping bones will cycle selection state as with objects. */ Object *obedit_orig = vc->obedit; EditBone *ebone_active_orig = ((bArmature *)obedit_orig->data)->act_edbone; - if (ebone_active_orig == NULL) { + if (ebone_active_orig == nullptr) { use_cycle = false; } @@ -675,8 +686,13 @@ static EditBone *get_nearest_editbonepoint( rcti rect; BLI_rcti_init_pt_radius(&rect, vc->mval, 12); - const int hits12 = view3d_opengl_select_with_id_filter( - vc, buffer, ARRAY_SIZE(buffer), &rect, select_mode, select_filter, select_id_ignore); + const int hits12 = view3d_opengl_select_with_id_filter(vc, + buffer, + ARRAY_SIZE(buffer), + &rect, + eV3DSelectMode(select_mode), + select_filter, + select_id_ignore); if (hits12 == 1) { hits = selectbuffer_ret_hits_12(buffer, hits12); @@ -691,7 +707,7 @@ static EditBone *get_nearest_editbonepoint( buffer + ofs, ARRAY_SIZE(buffer) - ofs, &rect, - select_mode, + eV3DSelectMode(select_mode), select_filter, select_id_ignore); @@ -749,7 +765,7 @@ cache_end: } cycle_order; if (use_cycle) { - bArmature *arm = obedit_orig->data; + bArmature *arm = static_cast(obedit_orig->data); int ob_index = obedit_orig->runtime.select_id & 0xFFFF; int bone_index = BLI_findindex(arm->edbo, ebone_active_orig); /* Offset from the current active bone, so we cycle onto the next. */ @@ -762,7 +778,7 @@ cache_end: for (int i = 0; i < hits; i++) { const uint hitresult = buffer[i].id; - Base *base = NULL; + Base *base = nullptr; EditBone *ebone; base = ED_armature_base_and_ebone_from_select_buffer(bases, bases_len, hitresult, &ebone); /* If this fails, selection code is setting the selection ID's incorrectly. */ @@ -863,9 +879,9 @@ cache_end: } } *r_selmask = 0; - *r_base = NULL; + *r_base = nullptr; MEM_freeN(bases); - return NULL; + return nullptr; } /** \} */ @@ -876,7 +892,7 @@ cache_end: bool ED_armature_edit_deselect_all(Object *obedit) { - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) { @@ -889,7 +905,7 @@ bool ED_armature_edit_deselect_all(Object *obedit) bool ED_armature_edit_deselect_all_visible(Object *obedit) { - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { /* first and foremost, bone must be visible and selected */ @@ -959,7 +975,7 @@ bool ED_armature_edit_select_pick_bone(bContext *C, bool found = false; if (ebone) { - bArmature *arm = basact->object->data; + bArmature *arm = static_cast(basact->object->data); if (EBONE_SELECTABLE(arm, ebone)) { found = true; } @@ -983,7 +999,7 @@ bool ED_armature_edit_select_pick_bone(bContext *C, if (found) { BLI_assert(BKE_object_is_in_editmode(basact->object)); - bArmature *arm = basact->object->data; + bArmature *arm = static_cast(basact->object->data); /* By definition the non-root connected bones have no root point drawn, * so a root selection needs to be delivered to the parent tip. */ @@ -1129,9 +1145,9 @@ bool ED_armature_edit_select_pick(bContext *C, { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; - EditBone *nearBone = NULL; + EditBone *nearBone = nullptr; int selmask; - Base *basact = NULL; + Base *basact = nullptr; ED_view3d_viewcontext_init(C, &vc, depsgraph); vc.mval[0] = mval[0]; @@ -1261,7 +1277,8 @@ bool ED_armature_edit_select_op_from_tagged(bArmature *arm, const int sel_op) is_inside_flag &= ~BONESEL_BONE; } - changed |= armature_edit_select_op_apply(arm, ebone, sel_op, is_ignore_flag, is_inside_flag); + changed |= armature_edit_select_op_apply( + arm, ebone, eSelectOp(sel_op), is_ignore_flag, is_inside_flag); } } @@ -1371,7 +1388,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) ED_outliner_select_sync_from_edit_bone_tag(C); - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, nullptr); /* Tagging only one object to refresh drawing. */ Object *obedit = CTX_data_edit_object(C); @@ -1429,7 +1446,7 @@ static void armature_select_more(bArmature *arm, EditBone *ebone) } } -static void armature_select_less(bArmature *UNUSED(arm), EditBone *ebone) +static void armature_select_less(bArmature * /*arm*/, EditBone *ebone) { if ((EBONE_PREV_FLAG_GET(ebone) & (BONE_ROOTSEL | BONE_TIPSEL)) != (BONE_ROOTSEL | BONE_TIPSEL)) { @@ -1458,12 +1475,12 @@ static void armature_select_more_less(Object *ob, bool more) ED_armature_edit_sync_selection(arm->edbo); /* count bones & store selection state */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { EBONE_PREV_FLAG_SET(ebone, ED_armature_ebone_selectflag_get(ebone)); } /* do selection */ - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (more) { armature_select_more(arm, ebone); @@ -1474,7 +1491,7 @@ static void armature_select_more_less(Object *ob, bool more) } } - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (more == false) { if (ebone->flag & BONE_SELECTED) { @@ -1482,7 +1499,7 @@ static void armature_select_more_less(Object *ob, bool more) } } } - ebone->temp.p = NULL; + ebone->temp.p = nullptr; } ED_armature_edit_sync_selection(arm->edbo); @@ -1494,7 +1511,7 @@ static void armature_select_more_less(Object *ob, bool more) /** \name Select More Operator * \{ */ -static int armature_de_select_more_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_de_select_more_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1534,7 +1551,7 @@ void ARMATURE_OT_select_more(wmOperatorType *ot) /** \name Select Less Operator * \{ */ -static int armature_de_select_less_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_de_select_less_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -1598,7 +1615,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMEDBONE_LAYER, "LAYER", 0, "Layer", ""}, {SIMEDBONE_GROUP, "GROUP", 0, "Group", ""}, {SIMEDBONE_SHAPE, "SHAPE", 0, "Shape", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static float bone_length_squared_worldspace_get(Object *ob, EditBone *ebone) @@ -1626,7 +1643,7 @@ static void select_similar_length(bContext *C, const float thresh) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -1675,7 +1692,7 @@ static void select_similar_direction(bContext *C, const float thresh) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -1710,7 +1727,7 @@ static void select_similar_layer(bContext *C) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { @@ -1750,7 +1767,7 @@ static void select_similar_prefix(bContext *C) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; /* Find matches */ @@ -1793,7 +1810,7 @@ static void select_similar_suffix(bContext *C) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bool changed = false; /* Find matches */ @@ -1820,14 +1837,14 @@ static void select_similar_suffix(bContext *C) static void select_similar_data_pchan(bContext *C, const size_t bytes_size, const int offset) { Object *obedit = CTX_data_edit_object(C); - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); EditBone *ebone_act = CTX_data_active_bone(C); const bPoseChannel *pchan_active = BKE_pose_channel_find_name(obedit->pose, ebone_act->name); /* This will mostly happen for corner cases where the user tried to access this * before having any valid pose data for the armature. */ - if (pchan_active == NULL) { + if (pchan_active == nullptr) { return; } @@ -1850,11 +1867,11 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons static void is_ancestor(EditBone *bone, EditBone *ancestor) { - if (ELEM(bone->temp.ebone, ancestor, NULL)) { + if (ELEM(bone->temp.ebone, ancestor, nullptr)) { return; } - if (!ELEM(bone->temp.ebone->temp.ebone, NULL, ancestor)) { + if (!ELEM(bone->temp.ebone->temp.ebone, nullptr, ancestor)) { is_ancestor(bone->temp.ebone, ancestor); } @@ -1864,7 +1881,7 @@ static void is_ancestor(EditBone *bone, EditBone *ancestor) static void select_similar_children(bContext *C) { Object *obedit = CTX_data_edit_object(C); - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); EditBone *ebone_act = CTX_data_active_bone(C); LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { @@ -1886,7 +1903,7 @@ static void select_similar_children(bContext *C) static void select_similar_children_immediate(bContext *C) { Object *obedit = CTX_data_edit_object(C); - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); EditBone *ebone_act = CTX_data_active_bone(C); LISTBASE_FOREACH (EditBone *, ebone_iter, arm->edbo) { @@ -1902,10 +1919,10 @@ static void select_similar_children_immediate(bContext *C) static void select_similar_siblings(bContext *C) { Object *obedit = CTX_data_edit_object(C); - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); EditBone *ebone_act = CTX_data_active_bone(C); - if (ebone_act->parent == NULL) { + if (ebone_act->parent == nullptr) { return; } @@ -1926,13 +1943,14 @@ static int armature_select_similar_exec(bContext *C, wmOperator *op) float thresh = RNA_float_get(op->ptr, "threshold"); /* Check for active bone */ - if (CTX_data_active_bone(C) == NULL) { + if (CTX_data_active_bone(C) == nullptr) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); return OPERATOR_CANCELLED; } #define STRUCT_SIZE_AND_OFFSET(_struct, _member) \ - sizeof(((_struct *)NULL)->_member), offsetof(_struct, _member) +\ + sizeof(((_struct *)nullptr)->_member), offsetof(_struct, _member) switch (type) { case SIMEDBONE_CHILDREN: @@ -2012,7 +2030,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) bArmature *arm = (bArmature *)ob->data; ebone_active = arm->act_edbone; - if (ebone_active == NULL) { + if (ebone_active == nullptr) { return OPERATOR_CANCELLED; } @@ -2035,12 +2053,14 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) } } else { /* BONE_SELECT_CHILD */ - EditBone *ebone_iter, *ebone_child = NULL; + EditBone *ebone_iter, *ebone_child = nullptr; int pass; /* first pass, only connected bones (the logical direct child) */ - for (pass = 0; pass < 2 && (ebone_child == NULL); pass++) { - for (ebone_iter = arm->edbo->first; ebone_iter; ebone_iter = ebone_iter->next) { + for (pass = 0; pass < 2 && (ebone_child == nullptr); pass++) { + for (ebone_iter = static_cast(arm->edbo->first); ebone_iter; + ebone_iter = ebone_iter->next) + { /* possible we have multiple children, some invisible */ if (EBONE_SELECTABLE(arm, ebone_iter)) { if (ebone_iter->parent == ebone_active) { @@ -2084,7 +2104,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) static const EnumPropertyItem direction_items[] = { {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -2125,16 +2145,16 @@ static int armature_select_mirror_exec(bContext *C, wmOperator *op) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); - EditBone *ebone, *ebone_mirror_act = NULL; + EditBone *ebone, *ebone_mirror_act = nullptr; - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { const int flag = ED_armature_ebone_selectflag_get(ebone); EBONE_PREV_FLAG_SET(ebone, flag); } - for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(arm->edbo->first); ebone; ebone = ebone->next) { if (EBONE_SELECTABLE(arm, ebone)) { EditBone *ebone_mirror; int flag_new = extend ? EBONE_PREV_FLAG_GET(ebone) : 0; @@ -2232,12 +2252,12 @@ static bool armature_shortest_path_select( static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Object *obedit = CTX_data_edit_object(C); - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); EditBone *ebone_src, *ebone_dst; - EditBone *ebone_isect_parent = NULL; + EditBone *ebone_isect_parent = nullptr; EditBone *ebone_isect_child[2]; bool changed; - Base *base_dst = NULL; + Base *base_dst = nullptr; view3d_operator_needs_opengl(C); BKE_object_update_select_id(CTX_data_main(C)); @@ -2246,7 +2266,7 @@ static int armature_shortest_path_pick_invoke(bContext *C, wmOperator *op, const ebone_dst = ED_armature_pick_ebone(C, event->mval, false, &base_dst); /* fallback to object selection */ - if (ELEM(NULL, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) { + if (ELEM(nullptr, ebone_src, ebone_dst) || (ebone_src == ebone_dst)) { return OPERATOR_PASS_THROUGH; } diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.cc similarity index 87% rename from source/blender/editors/armature/armature_skinning.c rename to source/blender/editors/armature/armature_skinning.cc index 6b866b99215..4b667e5c75f 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.cc @@ -42,7 +42,7 @@ /* ******************************* Bone Skinning *********************************************** */ -static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap) +static int bone_skinnable_cb(Object * /*ob*/, Bone *bone, void *datap) { /* Bones that are deforming * are regarded to be "skinnable" and are eligible for @@ -68,12 +68,12 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap) */ Bone ***hbone; int a, segments; - struct { + struct Arg { Object *armob; void *list; int heat; bool is_weight_paint; - } *data = datap; + } *data = static_cast(datap); if (!(data->is_weight_paint) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { @@ -85,7 +85,7 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap) segments = 1; } - if (data->list != NULL) { + if (data->list != nullptr) { hbone = (Bone ***)&data->list; for (a = 0; a < segments; a++) { @@ -99,7 +99,7 @@ static int bone_skinnable_cb(Object *UNUSED(ob), Bone *bone, void *datap) return 0; } -static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) +static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void * /*ptr*/) { /* This group creates a vertex group to ob that has the * same name as bone (provided the bone is skinnable). @@ -139,15 +139,15 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) * pointers to bDeformGroups, all with names * of skinnable bones. */ - bDeformGroup ***hgroup, *defgroup = NULL; + bDeformGroup ***hgroup, *defgroup = nullptr; int a, segments; - struct { + struct Arg { Object *armob; void *list; int heat; bool is_weight_paint; - } *data = datap; - bArmature *arm = data->armob->data; + } *data = static_cast(datap); + bArmature *arm = static_cast(data->armob->data); if (!data->is_weight_paint || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { @@ -165,11 +165,11 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) } else if (defgroup->flag & DG_LOCK_WEIGHT) { /* In case vgroup already exists and is locked, do not modify it here. See #43814. */ - defgroup = NULL; + defgroup = nullptr; } } - if (data->list != NULL) { + if (data->list != nullptr) { hgroup = (bDeformGroup ***)&data->list; for (a = 0; a < segments; a++) { @@ -216,7 +216,7 @@ static void envelope_bone_weighting(Object *ob, continue; } - int iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1; + int iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, nullptr, i, use_topology) : -1; /* for each skinnable bone */ for (int j = 0; j < numbones; j++) { @@ -258,7 +258,7 @@ static void envelope_bone_weighting(Object *ob, static void add_verts_to_dgroups(ReportList *reports, Depsgraph *depsgraph, - Scene *UNUSED(scene), + Scene * /*scene*/, Object *ob, Object *par, int heat, @@ -276,13 +276,13 @@ static void add_verts_to_dgroups(ReportList *reports, * when parenting, or simply the original mesh coords. */ - bArmature *arm = par->data; + bArmature *arm = static_cast(par->data); Bone **bonelist, *bone; bDeformGroup **dgrouplist, **dgroupflip; bDeformGroup *dgroup; bPoseChannel *pchan; Mesh *mesh; - Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = NULL; + Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = nullptr; float(*root)[3], (*tip)[3], (*verts)[3]; int *selected; int numbones, vertsfilled = 0, segments = 0; @@ -296,40 +296,43 @@ static void add_verts_to_dgroups(ReportList *reports, looper_data.armob = par; looper_data.heat = heat; - looper_data.list = NULL; + looper_data.list = nullptr; looper_data.is_weight_paint = wpmode; /* count the number of skinnable bones */ - numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); + numbones = bone_looper( + ob, static_cast(arm->bonebase.first), &looper_data, bone_skinnable_cb); if (numbones == 0) { return; } - if (BKE_object_defgroup_data_create(ob->data) == NULL) { + if (BKE_object_defgroup_data_create(static_cast(ob->data)) == nullptr) { return; } /* create an array of pointer to bones that are skinnable * and fill it with all of the skinnable bones */ - bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist"); + bonelist = static_cast(MEM_callocN(numbones * sizeof(Bone *), "bonelist")); looper_data.list = bonelist; - bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); + bone_looper(ob, static_cast(arm->bonebase.first), &looper_data, bone_skinnable_cb); /* create an array of pointers to the deform groups that * correspond to the skinnable bones (creating them * as necessary. */ - dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist"); - dgroupflip = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip"); + dgrouplist = static_cast( + MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist")); + dgroupflip = static_cast( + MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip")); looper_data.list = dgrouplist; - bone_looper(ob, arm->bonebase.first, &looper_data, dgroup_skinnable_cb); + bone_looper(ob, static_cast(arm->bonebase.first), &looper_data, dgroup_skinnable_cb); /* create an array of root and tip positions transformed into * global coords */ - root = MEM_callocN(sizeof(float[3]) * numbones, "root"); - tip = MEM_callocN(sizeof(float[3]) * numbones, "tip"); - selected = MEM_callocN(sizeof(int) * numbones, "selected"); + root = static_cast(MEM_callocN(sizeof(float[3]) * numbones, "root")); + tip = static_cast(MEM_callocN(sizeof(float[3]) * numbones, "tip")); + selected = static_cast(MEM_callocN(sizeof(int) * numbones, "selected")); for (int j = 0; j < numbones; j++) { bone = bonelist[j]; @@ -339,7 +342,7 @@ static void add_verts_to_dgroups(ReportList *reports, if (heat) { if (segments == 0) { segments = 1; - bbone = NULL; + bbone = nullptr; if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) { if (bone->segments > 1) { @@ -392,7 +395,8 @@ static void add_verts_to_dgroups(ReportList *reports, /* create verts */ mesh = (Mesh *)ob->data; - verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts"); + verts = static_cast( + MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts")); if (wpmode) { /* if in weight paint mode, use final verts from evaluated mesh */ @@ -422,7 +426,7 @@ static void add_verts_to_dgroups(ReportList *reports, /* compute the weights based on gathered vertices and bones */ if (heat) { - const char *error = NULL; + const char *error = nullptr; heat_bone_weighting( ob, mesh, verts, numbones, dgrouplist, dgroupflip, root, tip, selected, &error); @@ -468,7 +472,7 @@ void ED_object_vgroup_calc_from_armature(ReportList *reports, /* Lets try to create some vertex groups * based on the bones of the parent armature. */ - bArmature *arm = par->data; + bArmature *arm = static_cast(par->data); if (mode == ARM_GROUPS_NAME) { const int defbase_tot = BKE_object_defgroup_count(ob); @@ -476,12 +480,13 @@ void ED_object_vgroup_calc_from_armature(ReportList *reports, /* Traverse the bone list, trying to create empty vertex * groups corresponding to the bone. */ - defbase_add = bone_looper(ob, arm->bonebase.first, NULL, vgroup_add_unique_bone_cb); + defbase_add = bone_looper( + ob, static_cast(arm->bonebase.first), nullptr, vgroup_add_unique_bone_cb); if (defbase_add) { /* It's possible there are DWeights outside the range of the current * object's deform groups. In this case the new groups won't be empty #33889. */ - ED_vgroup_data_clamp_range(ob->data, defbase_tot); + ED_vgroup_data_clamp_range(static_cast(ob->data), defbase_tot); } } else if (ELEM(mode, ARM_GROUPS_ENVELOPE, ARM_GROUPS_AUTO)) { diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.cc similarity index 88% rename from source/blender/editors/armature/armature_utils.c rename to source/blender/editors/armature/armature_utils.cc index 3e640311eb9..bdeea017523 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.cc @@ -38,7 +38,7 @@ void ED_armature_edit_sync_selection(ListBase *edbo) { EditBone *ebo; - for (ebo = edbo->first; ebo; ebo = ebo->next) { + for (ebo = static_cast(edbo->first); ebo; ebo = ebo->next) { /* if bone is not selectable, we shouldn't alter this setting... */ if ((ebo->flag & BONE_UNSELECTABLE) == 0) { if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) { @@ -66,7 +66,7 @@ void ED_armature_edit_validate_active(bArmature *arm) if (ebone) { if (ebone->flag & BONE_HIDDEN_A) { - arm->act_edbone = NULL; + arm->act_edbone = nullptr; } } } @@ -100,7 +100,7 @@ int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, B count += bone_func(ob, bone, data); /* try to execute bone_func for the first child */ - count += bone_looper(ob, bone->childbase.first, data, bone_func); + count += bone_looper(ob, static_cast(bone->childbase.first), data, bone_func); /* try to execute bone_func for the next bone at this * depth of the recursion. @@ -120,7 +120,7 @@ int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, B void bone_free(bArmature *arm, EditBone *bone) { if (arm->act_edbone == bone) { - arm->act_edbone = NULL; + arm->act_edbone = nullptr; } if (bone->prop) { @@ -130,10 +130,10 @@ void bone_free(bArmature *arm, EditBone *bone) /* Clear references from other edit bones. */ LISTBASE_FOREACH (EditBone *, ebone, arm->edbo) { if (ebone->bbone_next == bone) { - ebone->bbone_next = NULL; + ebone->bbone_next = nullptr; } if (ebone->bbone_prev == bone) { - ebone->bbone_prev = NULL; + ebone->bbone_prev = nullptr; } } @@ -145,7 +145,7 @@ void ED_armature_ebone_remove_ex(bArmature *arm, EditBone *exBone, bool clear_co EditBone *curBone; /* Find any bones that refer to this bone */ - for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = curBone->next) { if (curBone->parent == exBone) { curBone->parent = exBone->parent; if (clear_connected) { @@ -201,7 +201,7 @@ EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const ui #undef EBONE_TEMP_UINT - return NULL; + return nullptr; } void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3]) @@ -261,7 +261,7 @@ void ED_armature_ebone_from_mat4(EditBone *ebone, const float mat[4][4]) EditBone *ED_armature_ebone_find_name(const ListBase *edbo, const char *name) { - return BLI_findstring(edbo, name, offsetof(EditBone, name)); + return static_cast(BLI_findstring(edbo, name, offsetof(EditBone, name))); } /** \} */ @@ -274,8 +274,8 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo) { char name_flip[MAXBONENAME]; - if (ebo == NULL) { - return NULL; + if (ebo == nullptr) { + return nullptr; } BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip)); @@ -284,7 +284,7 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo) return ED_armature_ebone_find_name(edbo, name_flip); } - return NULL; + return nullptr; } /* ------------------------------------- */ @@ -296,7 +296,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag) if (arm->flag & ARM_MIRROR_EDIT) { EditBone *curBone, *ebone_mirr; - for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & flag) { ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); @@ -319,13 +319,13 @@ void armature_tag_select_mirrored(bArmature *arm) EditBone *curBone; /* always untag */ - for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = curBone->next) { curBone->flag &= ~BONE_DONE; } /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { - for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) { EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); @@ -336,7 +336,7 @@ void armature_tag_select_mirrored(bArmature *arm) } } - for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); @@ -349,7 +349,7 @@ void armature_tag_unselect(bArmature *arm) { EditBone *curBone; - for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(arm->edbo->first); curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { curBone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL | BONE_DONE); } @@ -390,7 +390,8 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo /* Also move connected children, in case children's name aren't mirrored properly. */ EditBone *children; - for (children = arm->edbo->first; children; children = children->next) { + for (children = static_cast(arm->edbo->first); children; + children = children->next) { if (children->parent == eboflip && children->flag & BONE_CONNECTED) { copy_v3_v3(children->head, eboflip->tail); children->rad_head = ebo->rad_tail; @@ -436,7 +437,7 @@ void ED_armature_ebone_transform_mirror_update(bArmature *arm, EditBone *ebo, bo void ED_armature_edit_transform_mirror_update(Object *obedit) { - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); LISTBASE_FOREACH (EditBone *, ebo, arm->edbo) { ED_armature_ebone_transform_mirror_update(arm, ebo, true); } @@ -455,12 +456,12 @@ static EditBone *make_boneList_recursive(ListBase *edbo, Bone *actBone) { EditBone *eBone; - EditBone *eBoneAct = NULL; - EditBone *eBoneTest = NULL; + EditBone *eBoneAct = nullptr; + EditBone *eBoneTest = nullptr; Bone *curBone; - for (curBone = bones->first; curBone; curBone = curBone->next) { - eBone = MEM_callocN(sizeof(EditBone), "make_editbone"); + for (curBone = static_cast(bones->first); curBone; curBone = curBone->next) { + eBone = static_cast(MEM_callocN(sizeof(EditBone), "make_editbone")); eBone->temp.bone = curBone; /* Copy relevant data from bone to eBone @@ -550,7 +551,7 @@ static EditBone *make_boneList_recursive(ListBase *edbo, static EditBone *find_ebone_link(ListBase *edbo, Bone *link) { - if (link != NULL) { + if (link != nullptr) { LISTBASE_FOREACH (EditBone *, ebone, edbo) { if (ebone->temp.bone == link) { return ebone; @@ -558,14 +559,14 @@ static EditBone *find_ebone_link(ListBase *edbo, Bone *link) } } - return NULL; + return nullptr; } EditBone *make_boneList(ListBase *edbo, ListBase *bones, Bone *actBone) { BLI_assert(!edbo->first && !edbo->last); - EditBone *active = make_boneList_recursive(edbo, bones, NULL, actBone); + EditBone *active = make_boneList_recursive(edbo, bones, nullptr, actBone); LISTBASE_FOREACH (EditBone *, ebone, edbo) { Bone *bone = ebone->temp.bone; @@ -595,7 +596,7 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis Bone *curBone; EditBone *ebone; - for (curBone = bonelist->first; curBone; curBone = curBone->next) { + for (curBone = static_cast(bonelist->first); curBone; curBone = curBone->next) { /* Set bone's local head/tail. * Note that it's important to use final parent's restpose (arm_mat) here, * instead of setting those values from editbone's matrix (see #46010). */ @@ -621,7 +622,7 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis BKE_armature_where_is_bone(curBone, curBone->parent, false); /* Find the associated editbone */ - for (ebone = editbonelist->first; ebone; ebone = ebone->next) { + for (ebone = static_cast(editbonelist->first); ebone; ebone = ebone->next) { if (ebone->temp.bone == curBone) { float premat[3][3]; float postmat[3][3]; @@ -637,12 +638,12 @@ static void armature_finalize_restpose(ListBase *bonelist, ListBase *editbonelis mul_m3_m3m3(difmat, imat, postmat); -#if 0 - printf("Bone %s\n", curBone->name); - print_m4("premat", premat); - print_m4("postmat", postmat); - print_m4("difmat", difmat); - printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); +#if 0 +printf("Bone %s\n", curBone->name); +print_m4("premat", premat); +print_m4("postmat", postmat); +print_m4("difmat", difmat); +printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); #endif curBone->roll = -atan2f(difmat[2][0], difmat[2][2]); @@ -667,10 +668,10 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) /* armature bones */ BKE_armature_bone_hash_free(arm); BKE_armature_bonelist_free(&arm->bonebase, true); - arm->act_bone = NULL; + arm->act_bone = nullptr; /* Remove zero sized bones, this gives unstable rest-poses. */ - for (eBone = arm->edbo->first; eBone; eBone = neBone) { + for (eBone = static_cast(arm->edbo->first); eBone; eBone = neBone) { float len_sq = len_squared_v3v3(eBone->head, eBone->tail); neBone = eBone->next; /* TODO(sergey): How to ensure this is a `constexpr`? */ @@ -678,7 +679,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) EditBone *fBone; /* Find any bones that refer to this bone */ - for (fBone = arm->edbo->first; fBone; fBone = fBone->next) { + for (fBone = static_cast(arm->edbo->first); fBone; fBone = fBone->next) { if (fBone->parent == eBone) { fBone->parent = eBone->parent; } @@ -691,8 +692,8 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) } /* Copy the bones from the edit-data into the armature. */ - for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { - newBone = MEM_callocN(sizeof(Bone), "bone"); + for (eBone = static_cast(arm->edbo->first); eBone; eBone = eBone->next) { + newBone = static_cast(MEM_callocN(sizeof(Bone), "bone")); eBone->temp.bone = newBone; /* Associate the real Bones with the EditBones */ STRNCPY(newBone->name, eBone->name); @@ -751,7 +752,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) * Do not set bone->head/tail here anymore, * using EditBone data for that is not OK since our later fiddling with parent's arm_mat * (for roll conversion) may have some small but visible impact on locations (#46010). */ - for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + for (eBone = static_cast(arm->edbo->first); eBone; eBone = eBone->next) { newBone = eBone->temp.bone; if (eBone->parent) { newBone->parent = eBone->parent->temp.bone; @@ -777,7 +778,9 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) BKE_armature_bone_hash_make(arm); /* so all users of this armature should get rebuilt */ - for (obt = bmain->objects.first; obt; obt = obt->id.next) { + for (obt = static_cast(bmain->objects.first); obt; + obt = static_cast(obt->id.next)) + { if (obt->data == arm) { BKE_pose_rebuild(bmain, obt, arm, true); } @@ -793,7 +796,7 @@ void ED_armature_edit_free(bArmature *arm) /* Clear the edit-bones list. */ if (arm->edbo) { if (arm->edbo->first) { - for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + for (eBone = static_cast(arm->edbo->first); eBone; eBone = eBone->next) { if (eBone->prop) { IDP_FreeProperty(eBone->prop); } @@ -802,15 +805,15 @@ void ED_armature_edit_free(bArmature *arm) BLI_freelistN(arm->edbo); } MEM_freeN(arm->edbo); - arm->edbo = NULL; - arm->act_edbone = NULL; + arm->edbo = nullptr; + arm->act_edbone = nullptr; } } void ED_armature_to_edit(bArmature *arm) { ED_armature_edit_free(arm); - arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature"); + arm->edbo = static_cast(MEM_callocN(sizeof(ListBase), "edbo armature")); arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, arm->act_bone); } @@ -824,7 +827,7 @@ void ED_armature_ebone_listbase_free(ListBase *lb, const bool do_id_user) { EditBone *ebone, *ebone_next; - for (ebone = lb->first; ebone; ebone = ebone_next) { + for (ebone = static_cast(lb->first); ebone; ebone = ebone_next) { ebone_next = ebone->next; if (ebone->prop) { @@ -844,8 +847,9 @@ void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const b BLI_assert(BLI_listbase_is_empty(lb_dst)); - for (ebone_src = lb_src->first; ebone_src; ebone_src = ebone_src->next) { - ebone_dst = MEM_dupallocN(ebone_src); + for (ebone_src = static_cast(lb_src->first); ebone_src; ebone_src = ebone_src->next) + { + ebone_dst = static_cast(MEM_dupallocN(ebone_src)); if (ebone_dst->prop) { ebone_dst->prop = IDP_CopyProperty_ex(ebone_dst->prop, do_id_user ? 0 : LIB_ID_CREATE_NO_USER_REFCOUNT); @@ -855,7 +859,8 @@ void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src, const b } /* set pointers */ - for (ebone_dst = lb_dst->first; ebone_dst; ebone_dst = ebone_dst->next) { + for (ebone_dst = static_cast(lb_dst->first); ebone_dst; ebone_dst = ebone_dst->next) + { if (ebone_dst->parent) { ebone_dst->parent = ebone_dst->parent->temp.ebone; } @@ -872,8 +877,8 @@ void ED_armature_ebone_listbase_temp_clear(ListBase *lb) { EditBone *ebone; /* be sure they don't hang ever */ - for (ebone = lb->first; ebone; ebone = ebone->next) { - ebone->temp.p = NULL; + for (ebone = static_cast(lb->first); ebone; ebone = ebone->next) { + ebone->temp.p = nullptr; } } diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.cc similarity index 92% rename from source/blender/editors/armature/pose_edit.c rename to source/blender/editors/armature/pose_edit.cc index 70eaad8233d..73e4a13198e 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.cc @@ -110,7 +110,7 @@ bool ED_object_posemode_enter(bContext *C, Object *ob) } bool ok = ED_object_posemode_enter_ex(bmain, ob); if (ok) { - WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, nullptr); } return ok; } @@ -133,7 +133,7 @@ bool ED_object_posemode_exit(bContext *C, Object *ob) Main *bmain = CTX_data_main(C); bool ok = ED_object_posemode_exit_ex(bmain, ob); if (ok) { - WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, nullptr); } return ok; } @@ -157,7 +157,7 @@ static eAnimvizCalcRange pose_path_convert_range(ePosePathCalcRange range) void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, ePosePathCalcRange range) { /* Transform doesn't always have context available to do update. */ - if (C == NULL) { + if (C == nullptr) { return; } @@ -167,12 +167,12 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, ePosePathC Depsgraph *depsgraph; bool free_depsgraph = false; - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; /* set flag to force recalc, then grab the relevant bones to target */ ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS; animviz_get_object_motionpaths(ob, &targets); - /* recalculate paths, then free */ +/* recalculate paths, then free */ #ifdef DEBUG_TIME TIMEIT_START(pose_path_calc); #endif @@ -212,11 +212,11 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, ePosePathC } /* show popup to determine settings */ -static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -225,7 +225,7 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEven bAnimVizSettings *avs = &ob->pose->avs; PointerRNA avs_ptr; - RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr); + RNA_pointer_create(nullptr, &RNA_AnimVizMotionPaths, avs, &avs_ptr); RNA_enum_set(op->ptr, "display_type", RNA_enum_get(&avs_ptr, "type")); RNA_enum_set(op->ptr, "range", RNA_enum_get(&avs_ptr, "range")); RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location")); @@ -244,7 +244,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); Scene *scene = CTX_data_scene(C); - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -257,7 +257,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) avs->path_range = RNA_enum_get(op->ptr, "range"); animviz_motionpath_compute_range(ob, scene); - RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr); + RNA_pointer_create(nullptr, &RNA_AnimVizMotionPaths, avs, &avs_ptr); RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location")); } @@ -340,7 +340,7 @@ static int pose_update_paths_exec(bContext *C, wmOperator *op) Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); Scene *scene = CTX_data_scene(C); - if (ELEM(NULL, ob, scene)) { + if (ELEM(nullptr, ob, scene)) { return OPERATOR_CANCELLED; } animviz_motionpath_compute_range(ob, scene); @@ -384,16 +384,16 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected) bPoseChannel *pchan; bool skipped = false; - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return; } /* free the motionpath blocks for all bones - This is easier for users to quickly clear all */ - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) { if (pchan->mpath) { if ((only_selected == false) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) { animviz_free_motionpath(pchan->mpath); - pchan->mpath = NULL; + pchan->mpath = nullptr; } else { skipped = true; @@ -417,7 +417,7 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op) bool only_selected = RNA_boolean_get(op->ptr, "only_selected"); /* only continue if there's an object */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -430,8 +430,8 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static char *pose_clear_paths_description(bContext *UNUSED(C), - wmOperatorType *UNUSED(ot), +static char *pose_clear_paths_description(bContext * /*C*/, + wmOperatorType * /*ot*/, PointerRNA *ptr) { const bool only_selected = RNA_boolean_get(ptr, "only_selected"); @@ -466,12 +466,12 @@ void POSE_OT_paths_clear(wmOperatorType *ot) /* --------- */ -static int pose_update_paths_range_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_update_paths_range_exec(bContext *C, wmOperator * /*op*/) { Scene *scene = CTX_data_scene(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - if (ELEM(NULL, scene, ob, ob->pose)) { + if (ELEM(nullptr, scene, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -512,8 +512,8 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op) const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers"); FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) { - bArmature *arm = ob->data; - ListBase bones_names = {NULL}; + bArmature *arm = static_cast(ob->data); + ListBase bones_names = {nullptr}; FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob, pchan) { BLI_addtail(&bones_names, BLI_genericNodeN(pchan->name)); @@ -564,11 +564,11 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); char newname[MAXBONENAME]; short axis = RNA_enum_get(op->ptr, "axis"); - Object *ob_prev = NULL; + Object *ob_prev = nullptr; /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); STRNCPY(newname, pchan->name); if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) { ED_armature_bone_rename(bmain, arm, pchan->name, newname); @@ -594,7 +594,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot) {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -621,7 +621,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot) static int pose_bone_rotmode_exec(bContext *C, wmOperator *op) { const int mode = RNA_enum_get(op->ptr, "type"); - Object *prev_ob = NULL; + Object *prev_ob = nullptr; /* Set rotation mode of selected bones. */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { @@ -675,17 +675,17 @@ static bool armature_layers_poll(bContext *C) static bArmature *armature_layers_get_data(Object **ob) { - bArmature *arm = NULL; + bArmature *arm = nullptr; /* Sanity checking and handling of posemode. */ if (*ob) { Object *tob = BKE_object_pose_armature_get(*ob); if (tob) { *ob = tob; - arm = (*ob)->data; + arm = static_cast((*ob)->data); } else if ((*ob)->type == OB_ARMATURE) { - arm = (*ob)->data; + arm = static_cast((*ob)->data); } } @@ -704,7 +704,7 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) bool layers[32] = {false}; /* sanity checking */ - if (arm == NULL) { + if (arm == nullptr) { return OPERATOR_CANCELLED; } @@ -759,7 +759,7 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev bool layers[32]; /* sanity checking */ - if (arm == NULL) { + if (arm == nullptr) { return OPERATOR_CANCELLED; } @@ -782,7 +782,7 @@ static int armature_layers_exec(bContext *C, wmOperator *op) /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ bool layers[32]; - if (arm == NULL) { + if (arm == nullptr) { return OPERATOR_CANCELLED; } @@ -817,7 +817,7 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) /* properties */ RNA_def_boolean_layer_member( - ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible"); + ot->srna, "layers", 32, nullptr, "Layer", "Armature layers to make visible"); } /* ------------------- */ @@ -856,19 +856,19 @@ static int pose_bone_layers_exec(bContext *C, wmOperator *op) /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); - Object *prev_ob = NULL; + Object *prev_ob = nullptr; /* Make sure that the pose bone data is up to date. * (May not always be the case after undo/redo e.g.). */ Main *bmain = CTX_data_main(C); wmWindow *win = CTX_wm_window(C); - View3D *v3d = CTX_wm_view3d(C); /* This may be NULL in a lot of cases. */ + View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */ const Scene *scene = WM_window_get_active_scene(win); ViewLayer *view_layer = WM_window_get_active_view_layer(win); FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) { - bArmature *arm = ob_iter->data; + bArmature *arm = static_cast(ob_iter->data); BKE_pose_ensure(bmain, ob_iter, arm, true); } FOREACH_OBJECT_IN_MODE_END; @@ -907,7 +907,7 @@ void POSE_OT_bone_layers(wmOperatorType *ot) /* properties */ RNA_def_boolean_layer_member( - ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); + ot->srna, "layers", 32, nullptr, "Layer", "Armature layers that bone belongs to"); } /* ------------------- */ @@ -957,7 +957,7 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - ED_armature_edit_refresh_layer_used(ob->data); + ED_armature_edit_refresh_layer_used(static_cast(ob->data)); /* NOTE: notifier might evolve. */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -983,7 +983,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) /* properties */ RNA_def_boolean_layer_member( - ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); + ot->srna, "layers", 32, nullptr, "Layer", "Armature layers that bone belongs to"); } /* ********************************************** */ @@ -991,7 +991,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); const bool hide_select = (bool)POINTER_AS_INT(ptr); int count = 0; if (arm->layer & bone->layer) { @@ -1000,7 +1000,7 @@ static int hide_pose_bone_fn(Object *ob, Bone *bone, void *ptr) /* only needed when 'hide_select' is true, but harmless. */ bone->flag &= ~BONE_SELECTED; if (arm->act_bone == bone) { - arm->act_bone = NULL; + arm->act_bone = nullptr; } count += 1; } @@ -1023,10 +1023,12 @@ static int pose_hide_exec(bContext *C, wmOperator *op) for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob_iter = objects[ob_index]; - bArmature *arm = ob_iter->data; + bArmature *arm = static_cast(ob_iter->data); - bool changed = bone_looper(ob_iter, arm->bonebase.first, hide_select_p, hide_pose_bone_fn) != - 0; + bool changed = bone_looper(ob_iter, + static_cast(arm->bonebase.first), + hide_select_p, + hide_pose_bone_fn) != 0; if (changed) { changed_multi = true; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter); @@ -1060,7 +1062,7 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *data) { const bool select = POINTER_AS_INT(data); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); int count = 0; if (arm->layer & bone->layer) { if (bone->flag & BONE_HIDDEN_P) { @@ -1089,9 +1091,10 @@ static int pose_reveal_exec(bContext *C, wmOperator *op) for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob_iter = objects[ob_index]; - bArmature *arm = ob_iter->data; + bArmature *arm = static_cast(ob_iter->data); - bool changed = bone_looper(ob_iter, arm->bonebase.first, select_p, show_pose_bone_cb); + bool changed = bone_looper( + ob_iter, static_cast(arm->bonebase.first), select_p, show_pose_bone_cb); if (changed) { changed_multi = true; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob_iter); @@ -1123,10 +1126,10 @@ void POSE_OT_reveal(wmOperatorType *ot) /* ********************************************** */ /* Flip Quats */ -static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_flip_quats_exec(bContext *C, wmOperator * /*op*/) { Scene *scene = CTX_data_scene(C); - KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); + KeyingSet *ks = ANIM_builtin_keyingset_get_named(nullptr, ANIM_KS_LOC_ROT_SCALE_ID); bool changed_multi = false; diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.cc similarity index 86% rename from source/blender/editors/armature/pose_group.c rename to source/blender/editors/armature/pose_group.cc index dc12437bf58..f3bcc330e44 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.cc @@ -56,17 +56,17 @@ static bool pose_group_poll(bContext *C) return true; } -static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_group_add_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object and pose */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } /* for now, just call the API function for this */ - BKE_pose_add_group(ob->pose, NULL); + BKE_pose_add_group(ob->pose, nullptr); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -89,12 +89,12 @@ void POSE_OT_group_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_group_remove_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object and pose */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -126,7 +126,7 @@ void POSE_OT_group_remove(wmOperatorType *ot) /* ------------ */ /* invoke callback which presents a list of bone-groups for the user to choose from */ -static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Object *ob = ED_pose_object_from_context(C); bPose *pose; @@ -138,7 +138,7 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U int i; /* only continue if there's an object, and a pose there too */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } pose = ob->pose; @@ -169,7 +169,8 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U } /* add entries for each group */ - for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) { + for (grp = static_cast(pose->agroups.first), i = 1; grp; grp = grp->next, i++) + { uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); } @@ -192,7 +193,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op) bool done = false; /* only continue if there's an object, and a pose there too */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -203,7 +204,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op) */ pose->active_group = RNA_int_get(op->ptr, "type"); if (pose->active_group == 0) { - BKE_pose_add_group(ob->pose, NULL); + BKE_pose_add_group(ob->pose, nullptr); } /* add selected bones to group then */ @@ -243,13 +244,13 @@ void POSE_OT_group_assign(wmOperatorType *ot) RNA_def_int(ot->srna, "type", 0, 0, INT_MAX, "Bone Group Index", "", 0, 10); } -static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_group_unassign_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_pose_object_from_context(C); bool done = false; /* only continue if there's an object, and a pose there too */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -291,12 +292,12 @@ void POSE_OT_group_unassign(wmOperatorType *ot) static int group_move_exec(bContext *C, wmOperator *op) { Object *ob = ED_pose_object_from_context(C); - bPose *pose = (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : nullptr; bPoseChannel *pchan; bActionGroup *grp; int dir = RNA_enum_get(op->ptr, "direction"); - if (ELEM(NULL, ob, pose)) { + if (ELEM(nullptr, ob, pose)) { return OPERATOR_CANCELLED; } if (pose->active_group <= 0) { @@ -304,8 +305,8 @@ static int group_move_exec(bContext *C, wmOperator *op) } /* get group to move */ - grp = BLI_findlink(&pose->agroups, pose->active_group - 1); - if (grp == NULL) { + grp = static_cast(BLI_findlink(&pose->agroups, pose->active_group - 1)); + if (grp == nullptr) { return OPERATOR_CANCELLED; } @@ -316,7 +317,8 @@ static int group_move_exec(bContext *C, wmOperator *op) pose->active_group += dir; /* fix changed bone group indices in bones (swap grpIndexA with grpIndexB) */ - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { if (pchan->agrp_index == grpIndexB) { pchan->agrp_index = grpIndexA; } @@ -337,7 +339,7 @@ void POSE_OT_group_move(wmOperatorType *ot) static const EnumPropertyItem group_slot_move[] = { {-1, "UP", 0, "Up", ""}, {1, "DOWN", 0, "Down", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -361,29 +363,29 @@ void POSE_OT_group_move(wmOperatorType *ot) } /* bone group sort element */ -typedef struct tSortActionGroup { +struct tSortActionGroup { bActionGroup *agrp; int index; -} tSortActionGroup; +}; /* compare bone groups by name */ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) { - const tSortActionGroup *sgrp_a = sgrp_a_ptr; - const tSortActionGroup *sgrp_b = sgrp_b_ptr; + const tSortActionGroup *sgrp_a = static_cast(sgrp_a_ptr); + const tSortActionGroup *sgrp_b = static_cast(sgrp_b_ptr); return strcmp(sgrp_a->agrp->name, sgrp_b->agrp->name); } -static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) +static int group_sort_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_pose_object_from_context(C); - bPose *pose = (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : nullptr; bPoseChannel *pchan; tSortActionGroup *agrp_array; bActionGroup *agrp; - if (ELEM(NULL, ob, pose)) { + if (ELEM(nullptr, ob, pose)) { return OPERATOR_CANCELLED; } if (pose->active_group <= 0) { @@ -392,9 +394,11 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) /* create temporary array with bone groups and indices */ int agrp_count = BLI_listbase_count(&pose->agroups); - agrp_array = MEM_mallocN(sizeof(tSortActionGroup) * agrp_count, "sort bone groups"); + agrp_array = static_cast( + MEM_mallocN(sizeof(tSortActionGroup) * agrp_count, "sort bone groups")); int i; - for (agrp = pose->agroups.first, i = 0; agrp; agrp = agrp->next, i++) { + for (agrp = static_cast(pose->agroups.first), i = 0; agrp; + agrp = agrp->next, i++) { BLI_assert(i < agrp_count); agrp_array[i].agrp = agrp; agrp_array[i].index = i + 1; @@ -410,7 +414,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) } /* Fix changed bone group indices in bones. */ - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) { for (i = 0; i < agrp_count; i++) { if (pchan->agrp_index == agrp_array[i].index) { pchan->agrp_index = i + 1; @@ -465,19 +469,19 @@ static void pose_group_select(Object *ob, bool select) FOREACH_PCHAN_VISIBLE_IN_OBJECT_END; } -static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_group_select_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } pose_group_select(ob, 1); /* notifiers for updates */ - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); ED_outliner_select_sync_from_pose_bone_tag(C); @@ -500,19 +504,19 @@ void POSE_OT_group_select(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_group_deselect_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_pose_object_from_context(C); /* only continue if there's an object, and a pose there too */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } pose_group_select(ob, 0); /* notifiers for updates */ - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); DEG_id_tag_update(&arm->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); ED_outliner_select_sync_from_pose_bone_tag(C); diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.cc similarity index 90% rename from source/blender/editors/armature/pose_lib_2.c rename to source/blender/editors/armature/pose_lib_2.cc index e5077864d5f..15cd7f2bb98 100644 --- a/source/blender/editors/armature/pose_lib_2.c +++ b/source/blender/editors/armature/pose_lib_2.cc @@ -46,15 +46,15 @@ #include "armature_intern.h" -typedef enum ePoseBlendState { +enum ePoseBlendState { POSE_BLEND_INIT, POSE_BLEND_BLENDING, POSE_BLEND_ORIGINAL, POSE_BLEND_CONFIRM, POSE_BLEND_CANCEL, -} ePoseBlendState; +}; -typedef struct PoseBlendData { +struct PoseBlendData { ePoseBlendState state; bool needs_redraw; @@ -85,7 +85,7 @@ typedef struct PoseBlendData { /** Info-text to print in header. */ char headerstr[UI_MAX_DRAW_STR]; -} PoseBlendData; +}; /** * Return the bAction that should be blended. @@ -118,8 +118,9 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd) } AnimData *adt = BKE_animdata_from_id(&pbd->ob->id); - if (adt != NULL && adt->action != NULL && - !BKE_id_is_editable(CTX_data_main(C), &adt->action->id)) { + if (adt != nullptr && adt->action != nullptr && + !BKE_id_is_editable(CTX_data_main(C), &adt->action->id)) + { /* Changes to linked-in Actions are not allowed. */ return; } @@ -128,14 +129,14 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd) bAction *act = poselib_action_to_blend(pbd); KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); - ListBase dsources = {NULL, NULL}; + ListBase dsources = {nullptr, nullptr}; /* start tagging/keying */ - const bArmature *armature = pbd->ob->data; + const bArmature *armature = static_cast(pbd->ob->data); LISTBASE_FOREACH (bActionGroup *, agrp, &act->groups) { /* Only for selected bones unless there aren't any selected, in which case all are included. */ bPoseChannel *pchan = BKE_pose_channel_find_name(pose, agrp->name); - if (pchan == NULL) { + if (pchan == nullptr) { continue; } @@ -150,11 +151,11 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, PoseBlendData *pbd) } /* Perform actual auto-keying. */ - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); + ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); BLI_freelistN(&dsources); /* send notifiers for this */ - WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, nullptr); } /* Apply the relevant changes to the pose */ @@ -211,9 +212,9 @@ static void poselib_set_flipped(PoseBlendData *pbd, const bool new_flipped) } /* Return operator return value. */ -static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const wmEvent *event) +static int poselib_blend_handle_event(bContext * /*C*/, wmOperator *op, const wmEvent *event) { - PoseBlendData *pbd = op->customdata; + PoseBlendData *pbd = static_cast(op->customdata); ED_slider_modal(pbd->slider, event); const float factor = ED_slider_factor_get(pbd->slider); @@ -270,8 +271,8 @@ static int poselib_blend_handle_event(bContext *UNUSED(C), wmOperator *op, const static Object *get_poselib_object(bContext *C) { - if (C == NULL) { - return NULL; + if (C == nullptr) { + return nullptr; } return BKE_object_pose_armature_get(CTX_data_active_object(C)); } @@ -288,7 +289,7 @@ static bAction *poselib_blend_init_get_action(bContext *C, wmOperator *op) /* Poll callback should check. */ BLI_assert(asset_handle_valid); - PoseBlendData *pbd = op->customdata; + PoseBlendData *pbd = static_cast(op->customdata); pbd->temp_id_consumer = ED_asset_temp_id_consumer_create(&asset_handle); return (bAction *)ED_asset_temp_id_consumer_ensure_local_id( @@ -297,7 +298,8 @@ static bAction *poselib_blend_init_get_action(bContext *C, wmOperator *op) static bAction *flip_pose(bContext *C, Object *ob, bAction *action) { - bAction *action_copy = (bAction *)BKE_id_copy_ex(NULL, &action->id, NULL, LIB_ID_COPY_LOCALIZE); + bAction *action_copy = (bAction *)BKE_id_copy_ex( + nullptr, &action->id, nullptr, LIB_ID_COPY_LOCALIZE); /* Lock the window manager while flipping the pose. Flipping requires temporarily modifying the * pose, which can cause unwanted visual glitches. */ @@ -314,21 +316,22 @@ static bAction *flip_pose(bContext *C, Object *ob, bAction *action) /* Return true on success, false if the context isn't suitable. */ static bool poselib_blend_init_data(bContext *C, wmOperator *op, const wmEvent *event) { - op->customdata = NULL; + op->customdata = nullptr; /* check if valid poselib */ Object *ob = get_poselib_object(C); - if (ELEM(NULL, ob, ob->pose, ob->data)) { + if (ELEM(nullptr, ob, ob->pose, ob->data)) { BKE_report(op->reports, RPT_ERROR, TIP_("Pose lib is only for armatures in pose mode")); return false; } /* Set up blend state info. */ PoseBlendData *pbd; - op->customdata = pbd = MEM_callocN(sizeof(PoseBlendData), "PoseLib Preview Data"); + op->customdata = pbd = static_cast( + MEM_callocN(sizeof(PoseBlendData), "PoseLib Preview Data")); pbd->act = poselib_blend_init_get_action(C, op); - if (pbd->act == NULL) { + if (pbd->act == nullptr) { return false; } @@ -336,7 +339,7 @@ static bool poselib_blend_init_data(bContext *C, wmOperator *op, const wmEvent * pbd->blend_factor = RNA_float_get(op->ptr, "blend_factor"); /* Only construct the flipped pose if there is a chance it's actually needed. */ - const bool is_interactive = (event != NULL); + const bool is_interactive = (event != nullptr); if (is_interactive || pbd->is_flipped) { pbd->act_flipped = flip_pose(C, ob, pbd->act); } @@ -391,12 +394,12 @@ static bool poselib_blend_init_data(bContext *C, wmOperator *op, const wmEvent * static void poselib_blend_cleanup(bContext *C, wmOperator *op) { - PoseBlendData *pbd = op->customdata; + PoseBlendData *pbd = static_cast(op->customdata); wmWindow *win = CTX_wm_window(C); /* Redraw the header so that it doesn't show any of our stuff anymore. */ - ED_area_status_text(pbd->area, NULL); - ED_workspace_status_text(C, NULL); + ED_area_status_text(pbd->area, nullptr); + ED_workspace_status_text(C, nullptr); if (pbd->slider) { ED_slider_destroy(C, pbd->slider); @@ -437,26 +440,26 @@ static void poselib_blend_cleanup(bContext *C, wmOperator *op) static void poselib_blend_free(wmOperator *op) { - PoseBlendData *pbd = op->customdata; - if (pbd == NULL) { + PoseBlendData *pbd = static_cast(op->customdata); + if (pbd == nullptr) { return; } if (pbd->act_flipped) { - BKE_id_free(NULL, pbd->act_flipped); + BKE_id_free(nullptr, pbd->act_flipped); } poselib_tempload_exit(pbd); /* Free temp data for operator */ BKE_pose_backup_free(pbd->pose_backup); - pbd->pose_backup = NULL; + pbd->pose_backup = nullptr; MEM_SAFE_FREE(op->customdata); } static int poselib_blend_exit(bContext *C, wmOperator *op) { - PoseBlendData *pbd = op->customdata; + PoseBlendData *pbd = static_cast(op->customdata); const ePoseBlendState exit_state = pbd->state; poselib_blend_cleanup(C, op); @@ -474,7 +477,7 @@ static int poselib_blend_exit(bContext *C, wmOperator *op) /* Cancel previewing operation (called when exiting Blender) */ static void poselib_blend_cancel(bContext *C, wmOperator *op) { - PoseBlendData *pbd = op->customdata; + PoseBlendData *pbd = static_cast(op->customdata); pbd->state = POSE_BLEND_CANCEL; poselib_blend_exit(C, op); } @@ -484,7 +487,7 @@ static int poselib_blend_modal(bContext *C, wmOperator *op, const wmEvent *event { const int operator_result = poselib_blend_handle_event(C, op, event); - const PoseBlendData *pbd = op->customdata; + const PoseBlendData *pbd = static_cast(op->customdata); if (ELEM(pbd->state, POSE_BLEND_CONFIRM, POSE_BLEND_CANCEL)) { return poselib_blend_exit(C, op); } @@ -533,14 +536,14 @@ static int poselib_blend_invoke(bContext *C, wmOperator *op, const wmEvent *even /* Single-shot apply. */ static int poselib_blend_exec(bContext *C, wmOperator *op) { - if (!poselib_blend_init_data(C, op, NULL)) { + if (!poselib_blend_init_data(C, op, nullptr)) { poselib_blend_free(op); return OPERATOR_CANCELLED; } poselib_blend_apply(C, op); - PoseBlendData *pbd = op->customdata; + PoseBlendData *pbd = static_cast(op->customdata); pbd->state = POSE_BLEND_CONFIRM; return poselib_blend_exit(C, op); } @@ -558,7 +561,7 @@ static bool poselib_asset_in_context(bContext *C) static bool poselib_blend_poll(bContext *C) { Object *ob = get_poselib_object(C); - if (ELEM(NULL, ob, ob->pose, ob->data)) { + if (ELEM(nullptr, ob, ob->pose, ob->data)) { /* Pose lib is only for armatures in pose mode. */ return false; } diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.cc similarity index 88% rename from source/blender/editors/armature/pose_select.c rename to source/blender/editors/armature/pose_select.cc index 14813d86dca..7cd391abd84 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.cc @@ -81,7 +81,7 @@ static void pose_do_bone_select(bPoseChannel *pchan, const int select_mode) void ED_pose_bone_select_tag_update(Object *ob) { BLI_assert(ob->type == OB_ARMATURE); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); WM_main_add_notifier(NC_OBJECT | ND_BONE_SELECT, ob); WM_main_add_notifier(NC_GEOM | ND_DATA, ob); @@ -99,11 +99,11 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select, bool chan /* sanity checks */ /* XXX: actually, we can probably still get away with no object - at most we have no updates */ - if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone)) { + if (ELEM(nullptr, ob, ob->pose, pchan, pchan->bone)) { return; } - arm = ob->data; + arm = static_cast(ob->data); /* can only change selection state if bone can be modified */ if (PBONE_SELECTABLE(arm, pchan->bone)) { @@ -117,7 +117,7 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select, bool chan else { pchan->bone->flag &= ~BONE_SELECTED; if (change_active) { - arm->act_bone = NULL; + arm->act_bone = nullptr; } } @@ -166,17 +166,18 @@ bool ED_armature_pose_select_pick_bone(const Scene *scene, if (found) { BKE_view_layer_synced_ensure(scene, view_layer); Object *ob_act = BKE_view_layer_active_object_get(view_layer); - BLI_assert(BKE_view_layer_edit_object_get(view_layer) == NULL); + BLI_assert(BKE_view_layer_edit_object_get(view_layer) == nullptr); /* If the bone cannot be affected, don't do anything. */ - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); /* Since we do unified select, we don't shift+select a bone if the * armature object was not active yet. * NOTE(@ideasman42): special exception for armature mode so we can do multi-select * we could check for multi-select explicitly but think its fine to * always give predictable behavior in weight paint mode. */ - if ((ob_act == NULL) || ((ob_act != ob) && (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) == 0)) { + if ((ob_act == nullptr) || ((ob_act != ob) && (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) == 0)) + { /* When we are entering into posemode via toggle-select, * from another active object - always select the bone. */ if (params->sel_op == SEL_OP_SET) { @@ -267,7 +268,7 @@ bool ED_armature_pose_select_pick_with_buffer(const Scene *scene, } /* Callers happen to already get the active base */ - Base *base_dummy = NULL; + Base *base_dummy = nullptr; nearBone = ED_armature_pick_bone_from_selectbuffer( &base, 1, buffer, hits, 1, do_nearest, &base_dummy); @@ -291,10 +292,10 @@ void ED_armature_pose_select_in_wpaint_mode(const Scene *scene, if (md->type == eGpencilModifierType_Armature) { ArmatureGpencilModifierData *agmd = (ArmatureGpencilModifierData *)md; Object *ob_arm = agmd->object; - if (ob_arm != NULL) { + if (ob_arm != nullptr) { Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); - if ((base_arm != NULL) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED)) - { + if ((base_arm != nullptr) && (base_arm != base_select) && + (base_arm->flag & BASE_SELECTED)) { ED_object_base_select(base_arm, BA_DESELECT); } } @@ -308,10 +309,10 @@ void ED_armature_pose_select_in_wpaint_mode(const Scene *scene, if (md->type == eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData *)md; Object *ob_arm = amd->object; - if (ob_arm != NULL) { + if (ob_arm != nullptr) { Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm); - if ((base_arm != NULL) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED)) - { + if ((base_arm != nullptr) && (base_arm != base_select) && + (base_arm->flag & BASE_SELECTED)) { ED_object_base_select(base_arm, BA_DESELECT); } } @@ -325,18 +326,19 @@ void ED_armature_pose_select_in_wpaint_mode(const Scene *scene, bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bPoseChannel *pchan; /* we call this from outliner too */ - if (ob->pose == NULL) { + if (ob->pose == nullptr) { return false; } /* Determine if we're selecting or deselecting */ if (select_mode == SEL_TOGGLE) { select_mode = SEL_SELECT; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) { select_mode = SEL_DESELECT; @@ -348,7 +350,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil /* Set the flags accordingly */ bool changed = false; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) { /* ignore the pchan if it isn't visible or if its selection cannot be changed */ if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) { int flag_prev = pchan->bone->flag; @@ -361,7 +363,7 @@ bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); LISTBASE_FOREACH (bPoseChannel *, pchan, &ob->pose->chanbase) { if (ignore_visibility || PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) { @@ -438,7 +440,7 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) bone->flag |= BONE_SELECTED; } - for (curBone = bone->childbase.first; curBone; curBone = curBone->next) { + for (curBone = static_cast(bone->childbase.first); curBone; curBone = curBone->next) { selectconnected_posebonechildren(ob, curBone, extend); } } @@ -447,12 +449,12 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) /* previously known as "selectconnected_posearmature" */ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - Bone *bone, *curBone, *next = NULL; + Bone *bone, *curBone, *next = nullptr; const bool extend = RNA_boolean_get(op->ptr, "extend"); view3d_operator_needs_opengl(C); - Base *base = NULL; + Base *base = nullptr; bone = ED_armature_pick_bone(C, event->mval, !extend, &base); if (!bone) { @@ -474,16 +476,16 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve next = curBone->parent; } else { - next = NULL; + next = nullptr; } } else { - next = NULL; + next = nullptr; } } /* Select children */ - for (curBone = bone->childbase.first; curBone; curBone = curBone->next) { + for (curBone = static_cast(bone->childbase.first); curBone; curBone = curBone->next) { selectconnected_posebonechildren(base->object, curBone, extend); } @@ -525,16 +527,16 @@ void POSE_OT_select_linked_pick(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } -static int pose_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_select_linked_exec(bContext *C, wmOperator * /*op*/) { - Bone *curBone, *next = NULL; + Bone *curBone, *next = nullptr; CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { if ((pchan->bone->flag & BONE_SELECTED) == 0) { continue; } - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); /* Select parents */ for (curBone = pchan->bone; curBone; curBone = next) { @@ -545,16 +547,17 @@ static int pose_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) next = curBone->parent; } else { - next = NULL; + next = nullptr; } } else { - next = NULL; + next = nullptr; } } /* Select children */ - for (curBone = pchan->bone->childbase.first; curBone; curBone = curBone->next) { + for (curBone = static_cast(pchan->bone->childbase.first); curBone; + curBone = curBone->next) { selectconnected_posebonechildren(ob, curBone, false); } ED_pose_bone_select_tag_update(ob); @@ -594,11 +597,11 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT; } - Object *ob_prev = NULL; + Object *ob_prev = nullptr; /* Set the flags. */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); pose_do_bone_select(pchan, action); if (ob_prev != ob) { @@ -615,7 +618,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) ED_outliner_select_sync_from_pose_bone_tag(C); - WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, nullptr); return OPERATOR_FINISHED; } @@ -639,7 +642,7 @@ void POSE_OT_select_all(wmOperatorType *ot) /* -------------------------------------- */ -static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_select_parent_exec(bContext *C, wmOperator * /*op*/) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm = (bArmature *)ob->data; @@ -684,23 +687,23 @@ void POSE_OT_select_parent(wmOperatorType *ot) /* -------------------------------------- */ -static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_select_constraint_target_exec(bContext *C, wmOperator * /*op*/) { bConstraint *con; int found = 0; CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { if (pchan->bone->flag & BONE_SELECTED) { - for (con = pchan->constraints.first; con; con = con->next) { - ListBase targets = {NULL, NULL}; + for (con = static_cast(pchan->constraints.first); con; con = con->next) { + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; if (BKE_constraint_targets_get(con, &targets)) { - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { Object *ob = ct->tar; /* Any armature that is also in pose mode should be selected. */ - if ((ct->subtarget[0] != '\0') && (ob != NULL) && (ob->type == OB_ARMATURE) && + if ((ct->subtarget[0] != '\0') && (ob != nullptr) && (ob->type == OB_ARMATURE) && (ob->mode == OB_MODE_POSE)) { bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget); @@ -750,14 +753,14 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot) static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bPoseChannel *pchan_act; int direction = RNA_enum_get(op->ptr, "direction"); const bool add_to_sel = RNA_boolean_get(op->ptr, "extend"); bool changed = false; pchan_act = BKE_pose_channel_active_if_layer_visible(ob); - if (pchan_act == NULL) { + if (pchan_act == nullptr) { return OPERATOR_CANCELLED; } @@ -779,12 +782,14 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) } else { /* direction == BONE_SELECT_CHILD */ bPoseChannel *pchan_iter; - Bone *bone_child = NULL; + Bone *bone_child = nullptr; int pass; /* first pass, only connected bones (the logical direct child) */ - for (pass = 0; pass < 2 && (bone_child == NULL); pass++) { - for (pchan_iter = ob->pose->chanbase.first; pchan_iter; pchan_iter = pchan_iter->next) { + for (pass = 0; pass < 2 && (bone_child == nullptr); pass++) { + for (pchan_iter = static_cast(ob->pose->chanbase.first); pchan_iter; + pchan_iter = pchan_iter->next) + { /* possible we have multiple children, some invisible */ if (PBONE_SELECTABLE(arm, pchan_iter->bone)) { if (pchan_iter->parent == pchan_act) { @@ -825,7 +830,7 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) static const EnumPropertyItem direction_items[] = { {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -860,10 +865,10 @@ static bool pose_select_same_group(bContext *C, bool extend) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); bool *group_flags_array; - bool *group_flags = NULL; + bool *group_flags = nullptr; int groups_len = 0; bool changed = false, tagged = false; - Object *ob_prev = NULL; + Object *ob_prev = nullptr; uint ob_index; uint objects_len = 0; @@ -872,11 +877,11 @@ static bool pose_select_same_group(bContext *C, bool extend) for (ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = BKE_object_pose_armature_get(objects[ob_index]); - bArmature *arm = (ob) ? ob->data : NULL; - bPose *pose = (ob) ? ob->pose : NULL; + bArmature *arm = static_cast((ob) ? ob->data : nullptr); + bPose *pose = (ob) ? ob->pose : nullptr; /* Sanity checks. */ - if (ELEM(NULL, ob, pose, arm)) { + if (ELEM(nullptr, ob, pose, arm)) { continue; } @@ -895,12 +900,12 @@ static bool pose_select_same_group(bContext *C, bool extend) * - size is (groups_len + 1), since (index = 0) is used for no-group */ groups_len++; - group_flags_array = MEM_callocN(objects_len * groups_len * sizeof(bool), - "pose_select_same_group"); + group_flags_array = static_cast( + MEM_callocN(objects_len * groups_len * sizeof(bool), "pose_select_same_group")); - group_flags = NULL; + group_flags = nullptr; ob_index = -1; - ob_prev = NULL; + ob_prev = nullptr; CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { if (ob != ob_prev) { ob_index++; @@ -923,9 +928,9 @@ static bool pose_select_same_group(bContext *C, bool extend) /* small optimization: only loop through bones a second time if there are any groups tagged */ if (tagged) { - group_flags = NULL; + group_flags = nullptr; ob_index = -1; - ob_prev = NULL; + ob_prev = nullptr; /* only if group matches (and is not selected or current bone) */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { if (ob != ob_prev) { @@ -964,8 +969,8 @@ static bool pose_select_same_layer(bContext *C, bool extend) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - int *layers_array, *layers = NULL; - Object *ob_prev = NULL; + int *layers_array, *layers = nullptr; + Object *ob_prev = nullptr; uint ob_index; bool changed = false; @@ -978,11 +983,12 @@ static bool pose_select_same_layer(bContext *C, bool extend) ob->id.tag &= ~LIB_TAG_DOIT; } - layers_array = MEM_callocN(objects_len * sizeof(*layers_array), "pose_select_same_layer"); + layers_array = static_cast( + MEM_callocN(objects_len * sizeof(*layers_array), "pose_select_same_layer")); /* Figure out what bones are selected. */ - layers = NULL; - ob_prev = NULL; + layers = nullptr; + ob_prev = nullptr; ob_index = -1; CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { if (ob != ob_prev) { @@ -1015,7 +1021,7 @@ static bool pose_select_same_layer(bContext *C, bool extend) } /* Select bones that are on same layers as layers flag. */ - ob_prev = NULL; + ob_prev = nullptr; ob_index = -1; CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { if (ob != ob_prev) { @@ -1056,12 +1062,12 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex KS_Path *ksp; /* sanity checks: validate Keying Set and object */ - if (ks == NULL) { + if (ks == nullptr) { BKE_report(reports, RPT_ERROR, "No active Keying Set to use"); return false; } - if (ANIM_validate_keyingset(C, NULL, ks) != 0) { - if (ks->paths.first == NULL) { + if (ANIM_validate_keyingset(C, nullptr, ks) != 0) { + if (ks->paths.first == nullptr) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { BKE_report(reports, RPT_ERROR, @@ -1091,22 +1097,22 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = BKE_object_pose_armature_get(objects[ob_index]); - bArmature *arm = (ob) ? ob->data : NULL; - bPose *pose = (ob) ? ob->pose : NULL; + bArmature *arm = static_cast((ob) ? ob->data : nullptr); + bPose *pose = (ob) ? ob->pose : nullptr; bool changed = false; /* Sanity checks. */ - if (ELEM(NULL, ob, pose, arm)) { + if (ELEM(nullptr, ob, pose, arm)) { continue; } /* iterate over elements in the Keying Set, setting selection depending on whether * that bone is visible or not... */ - for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + for (ksp = static_cast(ks->paths.first); ksp; ksp = ksp->next) { /* only items related to this object will be relevant */ - if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) { - bPoseChannel *pchan = NULL; + if ((ksp->id == &ob->id) && (ksp->rna_path != nullptr)) { + bPoseChannel *pchan = nullptr; char boneName[sizeof(pchan->name)]; if (!BLI_str_quoted_substr(ksp->rna_path, "bones[", boneName, sizeof(boneName))) { continue; @@ -1136,12 +1142,12 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool ex static int pose_select_grouped_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - const ePose_SelectSame_Mode type = RNA_enum_get(op->ptr, "type"); + const ePose_SelectSame_Mode type = ePose_SelectSame_Mode(RNA_enum_get(op->ptr, "type")); const bool extend = RNA_boolean_get(op->ptr, "extend"); bool changed = false; /* sanity check */ - if (ob->pose == NULL) { + if (ob->pose == nullptr) { return OPERATOR_CANCELLED; } @@ -1160,7 +1166,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) break; default: - printf("pose_select_grouped() - Unknown selection type %u\n", type); + printf("pose_select_grouped() - Unknown selection type %d\n", type); break; } @@ -1183,7 +1189,7 @@ void POSE_OT_select_grouped(wmOperatorType *ot) 0, "Keying Set", "All bones affected by active Keying Set"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -1229,15 +1235,17 @@ static int pose_select_mirror_exec(bContext *C, wmOperator *op) for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - bArmature *arm = ob->data; - bPoseChannel *pchan, *pchan_mirror_act = NULL; + bArmature *arm = static_cast(ob->data); + bPoseChannel *pchan, *pchan_mirror_act = nullptr; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { const int flag = (pchan->bone->flag & BONE_SELECTED); PBONE_PREV_FLAG_SET(pchan, flag); } - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { if (PBONE_SELECTABLE(arm, pchan->bone)) { bPoseChannel *pchan_mirror; int flag_new = extend ? PBONE_PREV_FLAG_GET(pchan) : 0; diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.cc similarity index 94% rename from source/blender/editors/armature/pose_slide.c rename to source/blender/editors/armature/pose_slide.cc index 979c8f0b03e..3927fcee1bd 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.cc @@ -90,14 +90,14 @@ /* A) Push & Relax, Breakdowner */ /** Axis Locks. */ -typedef enum ePoseSlide_AxisLock { +enum ePoseSlide_AxisLock { PS_LOCK_X = (1 << 0), PS_LOCK_Y = (1 << 1), PS_LOCK_Z = (1 << 2), -} ePoseSlide_AxisLock; +}; /** Pose Sliding Modes. */ -typedef enum ePoseSlide_Modes { +enum ePoseSlide_Modes { /** Exaggerate the pose. */ POSESLIDE_PUSH = 0, /** soften the pose. */ @@ -107,10 +107,10 @@ typedef enum ePoseSlide_Modes { POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST, POSESLIDE_BLEND, -} ePoseSlide_Modes; +}; /** Transforms/Channels to Affect. */ -typedef enum ePoseSlide_Channels { +enum ePoseSlide_Channels { PS_TFM_ALL = 0, /* All transforms and properties */ PS_TFM_LOC, /* Loc/Rot/Scale */ @@ -120,10 +120,10 @@ typedef enum ePoseSlide_Channels { PS_TFM_BBONE_SHAPE, /* Bendy Bones */ PS_TFM_PROPS, /* Custom Properties */ -} ePoseSlide_Channels; +}; /** Temporary data shared between these operators. */ -typedef struct tPoseSlideOp { +struct tPoseSlideOp { /** current scene */ Scene *scene; /** area that we're operating in (needed for modal()) */ @@ -165,9 +165,9 @@ typedef struct tPoseSlideOp { NumInput num; struct tPoseSlideObject *ob_data_array; -} tPoseSlideOp; +}; -typedef struct tPoseSlideObject { +struct tPoseSlideObject { /** Active object that Pose Info comes from. */ Object *ob; /** `prev_frame`, but in local action time (for F-Curve look-ups to work). */ @@ -175,7 +175,7 @@ typedef struct tPoseSlideObject { /** `next_frame`, but in local action time (for F-Curve look-ups to work). */ float next_frame; bool valid; -} tPoseSlideObject; +}; /** Property enum for #ePoseSlide_Channels. */ static const EnumPropertyItem prop_channels_types[] = { @@ -189,7 +189,7 @@ static const EnumPropertyItem prop_channels_types[] = { {PS_TFM_SIZE, "SIZE", 0, "Scale", "Scale only"}, {PS_TFM_BBONE_SHAPE, "BBONE", 0, "Bendy Bone", "Bendy Bone shape properties"}, {PS_TFM_PROPS, "CUSTOM", 0, "Custom Properties", "Custom properties"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* Property enum for ePoseSlide_AxisLock */ @@ -197,9 +197,8 @@ static const EnumPropertyItem prop_axis_lock_types[] = { {0, "FREE", 0, "Free", "All axes are affected"}, {PS_LOCK_X, "X", 0, "X", "Only X-axis transforms are affected"}, {PS_LOCK_Y, "Y", 0, "Y", "Only Y-axis transforms are affected"}, - {PS_LOCK_Z, "Z", 0, "Z", "Only Z-axis transforms are affected"}, - /* TODO: Combinations? */ - {0, NULL, 0, NULL, NULL}, + {PS_LOCK_Z, "Z", 0, "Z", "Only Z-axis transforms are affected"}, /* TODO: Combinations? */ + {0, nullptr, 0, nullptr, nullptr}, }; /* ------------------------------------ */ @@ -210,7 +209,8 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) tPoseSlideOp *pso; /* Init slide-op data. */ - pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); + pso = static_cast( + op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp")); /* Get info from context. */ pso->scene = CTX_data_scene(C); @@ -225,8 +225,8 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) pso->next_frame = RNA_int_get(op->ptr, "next_frame"); /* Get the set of properties/axes that can be operated on. */ - pso->channels = RNA_enum_get(op->ptr, "channels"); - pso->axislock = RNA_enum_get(op->ptr, "axis_lock"); + pso->channels = ePoseSlide_Channels(RNA_enum_get(op->ptr, "channels")); + pso->axislock = ePoseSlide_AxisLock(RNA_enum_get(op->ptr, "axis_lock")); pso->slider = ED_slider_create(C); ED_slider_factor_set(pso->slider, RNA_float_get(op->ptr, "factor")); @@ -240,15 +240,15 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) CTX_wm_view3d(C), &pso->objects_len, OB_MODE_POSE); - pso->ob_data_array = MEM_callocN(pso->objects_len * sizeof(tPoseSlideObject), - "pose slide objects data"); + pso->ob_data_array = static_cast( + MEM_callocN(pso->objects_len * sizeof(tPoseSlideObject), "pose slide objects data")); for (uint ob_index = 0; ob_index < pso->objects_len; ob_index++) { tPoseSlideObject *ob_data = &pso->ob_data_array[ob_index]; Object *ob_iter = poseAnim_object_get(objects[ob_index]); /* Ensure validity of the settings from the context. */ - if (ob_iter == NULL) { + if (ob_iter == nullptr) { continue; } @@ -287,13 +287,13 @@ static int pose_slide_init(bContext *C, wmOperator *op, ePoseSlide_Modes mode) */ static void pose_slide_exit(bContext *C, wmOperator *op) { - tPoseSlideOp *pso = op->customdata; + tPoseSlideOp *pso = static_cast(op->customdata); ED_slider_destroy(C, pso->slider); /* Hide Bone Overlay. */ if (pso->area) { - View3D *v3d = pso->area->spacedata.first; + View3D *v3d = static_cast(pso->area->spacedata.first); v3d->overlay.flag = pso->overlay_flag; } @@ -303,7 +303,7 @@ static void pose_slide_exit(bContext *C, wmOperator *op) /* Free RB-BST for keyframes (if it contained data). */ ED_keylist_free(pso->keylist); - if (pso->ob_data_array != NULL) { + if (pso->ob_data_array != nullptr) { MEM_freeN(pso->ob_data_array); } @@ -311,7 +311,7 @@ static void pose_slide_exit(bContext *C, wmOperator *op) MEM_freeN(pso); /* Cleanup. */ - op->customdata = NULL; + op->customdata = nullptr; } /* ------------------------------------ */ @@ -443,8 +443,8 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, float vec[3], const char propName[]) { - LinkData *ld = NULL; - char *path = NULL; + LinkData *ld = nullptr; + char *path = nullptr; /* Get the path to use. */ path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName); @@ -477,23 +477,23 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, const char prop_prefix[]) { - PointerRNA ptr = {NULL}; + PointerRNA ptr = {nullptr}; LinkData *ld; int len = strlen(pfl->pchan_path); /* Setup pointer RNA for resolving paths. */ - RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr); + RNA_pointer_create(nullptr, &RNA_PoseBone, pfl->pchan, &ptr); /* - custom properties are just denoted using ["..."][etc.] after the end of the base path, * so just check for opening pair after the end of the path * - bbone properties are similar, but they always start with a prefix "bbone_*", * so a similar method should work here for those too */ - for (ld = pfl->fcurves.first; ld; ld = ld->next) { + for (ld = static_cast(pfl->fcurves.first); ld; ld = ld->next) { FCurve *fcu = (FCurve *)ld->data; const char *bPtr, *pPtr; - if (fcu->rna_path == NULL) { + if (fcu->rna_path == nullptr) { continue; } @@ -605,10 +605,10 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, */ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) { - FCurve *fcu_w = NULL, *fcu_x = NULL, *fcu_y = NULL, *fcu_z = NULL; + FCurve *fcu_w = nullptr, *fcu_x = nullptr, *fcu_y = nullptr, *fcu_z = nullptr; bPoseChannel *pchan = pfl->pchan; - LinkData *ld = NULL; - char *path = NULL; + LinkData *ld = nullptr; + char *path = nullptr; float prev_frame, next_frame; if (!pose_frame_range_from_object_get(pso, pfl->ob, &prev_frame, &next_frame)) { @@ -776,7 +776,7 @@ static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso) tPChanFCurveLink *pfl; /* For each link, handle each set of transforms. */ - for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { + for (pfl = static_cast(pso->pfLinks.first); pfl; pfl = pfl->next) { /* Valid transforms for each #bPoseChannel should have been noted already. * - Sliding the pose should be a straightforward exercise for location+rotation, * but rotations get more complicated since we may want to use quaternion blending @@ -856,7 +856,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) } /* For each link, handle each set of transforms. */ - for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { + for (pfl = static_cast(pso->pfLinks.first); pfl; pfl = pfl->next) { /* Valid transforms for each #bPoseChannel should have been noted already * - sliding the pose should be a straightforward exercise for location+rotation, * but rotations get more complicated since we may want to use quaternion blending @@ -1029,16 +1029,16 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent * tPChanFCurveLink *pfl; wmWindow *win = CTX_wm_window(C); - tPoseSlideOp *pso = op->customdata; + tPoseSlideOp *pso = static_cast(op->customdata); ED_slider_init(pso->slider, event); /* For each link, add all its keyframes to the search tree. */ - for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { + for (pfl = static_cast(pso->pfLinks.first); pfl; pfl = pfl->next) { LinkData *ld; /* Do this for each F-Curve. */ - for (ld = pfl->fcurves.first; ld; ld = ld->next) { + for (ld = static_cast(pfl->fcurves.first); ld; ld = ld->next) { FCurve *fcu = (FCurve *)ld->data; fcurve_to_keylist(pfl->ob->adt, fcu, pso->keylist, 0); } @@ -1057,7 +1057,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent * /* Firstly, check if the current frame is a keyframe. */ const ActKeyColumn *ak = ED_keylist_find_exact(pso->keylist, current_frame); - if (ak == NULL) { + if (ak == nullptr) { /* Current frame is not a keyframe, so search. */ const ActKeyColumn *pk = ED_keylist_find_prev(pso->keylist, current_frame); const ActKeyColumn *nk = ED_keylist_find_next(pso->keylist, current_frame); @@ -1113,7 +1113,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, const wmEvent * WM_event_add_modal_handler(C, op); /* Save current bone visibility. */ - View3D *v3d = pso->area->spacedata.first; + View3D *v3d = static_cast(pso->area->spacedata.first); pso->overlay_flag = v3d->overlay.flag; return OPERATOR_RUNNING_MODAL; @@ -1138,7 +1138,7 @@ static void pose_slide_toggle_channels_mode(wmOperator *op, RNA_enum_set(op->ptr, "channels", pso->channels); /* Reset axis limits too for good measure */ - pso->axislock = 0; + pso->axislock = ePoseSlide_AxisLock(0); RNA_enum_set(op->ptr, "axis_lock", pso->axislock); } @@ -1151,7 +1151,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, { /* Axis can only be set when a transform is set - it doesn't make sense otherwise */ if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE, PS_TFM_PROPS)) { - pso->axislock = 0; + pso->axislock = ePoseSlide_AxisLock(0); RNA_enum_set(op->ptr, "axis_lock", pso->axislock); return false; } @@ -1159,7 +1159,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, /* Turn on or off? */ if (pso->axislock == axis) { /* Already limiting on this axis, so turn off */ - pso->axislock = 0; + pso->axislock = ePoseSlide_AxisLock(0); } else { /* Only this axis */ @@ -1176,7 +1176,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, */ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) { - tPoseSlideOp *pso = op->customdata; + tPoseSlideOp *pso = static_cast(op->customdata); wmWindow *win = CTX_wm_window(C); bool do_pose_update = false; @@ -1190,8 +1190,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case EVT_PADENTER: { if (event->val == KM_PRESS) { /* Return to normal cursor and header status. */ - ED_workspace_status_text(C, NULL); - ED_area_status_text(pso->area, NULL); + ED_workspace_status_text(C, nullptr); + ED_area_status_text(pso->area, nullptr); WM_cursor_modal_restore(win); /* Depsgraph updates + redraws. Redraw needed to remove UI. */ @@ -1211,8 +1211,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: { if (event->val == KM_PRESS) { /* Return to normal cursor and header status. */ - ED_workspace_status_text(C, NULL); - ED_area_status_text(pso->area, NULL); + ED_workspace_status_text(C, nullptr); + ED_area_status_text(pso->area, nullptr); WM_cursor_modal_restore(win); /* Reset transforms back to original state. */ @@ -1317,7 +1317,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Toggle Bone visibility. */ case EVT_HKEY: { - View3D *v3d = pso->area->spacedata.first; + View3D *v3d = static_cast(pso->area->spacedata.first); v3d->overlay.flag ^= V3D_OVERLAY_HIDE_BONES; ED_region_tag_redraw(pso->region); } @@ -1475,7 +1475,7 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - pso = op->customdata; + pso = static_cast(op->customdata); /* Do common exec work. */ return pose_slide_exec_common(C, op, pso); @@ -1532,7 +1532,7 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - pso = op->customdata; + pso = static_cast(op->customdata); /* Do common exec work. */ return pose_slide_exec_common(C, op, pso); @@ -1588,7 +1588,7 @@ static int pose_slide_push_rest_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - pso = op->customdata; + pso = static_cast(op->customdata); /* Do common exec work. */ return pose_slide_exec_common(C, op, pso); @@ -1645,7 +1645,7 @@ static int pose_slide_relax_rest_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - pso = op->customdata; + pso = static_cast(op->customdata); /* Do common exec work. */ return pose_slide_exec_common(C, op, pso); @@ -1702,7 +1702,7 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - pso = op->customdata; + pso = static_cast(op->customdata); /* Do common exec work. */ return pose_slide_exec_common(C, op, pso); @@ -1752,7 +1752,7 @@ static int pose_slide_blend_to_neighbors_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - pso = op->customdata; + pso = static_cast(op->customdata); /* Do common exec work. */ return pose_slide_exec_common(C, op, pso); @@ -1783,7 +1783,7 @@ void POSE_OT_blend_to_neighbors(wmOperatorType *ot) /* B) Pose Propagate */ /* "termination conditions" - i.e. when we stop */ -typedef enum ePosePropagate_Termination { +enum ePosePropagate_Termination { /** Only do on the last keyframe. */ POSE_PROPAGATE_LAST_KEY = 0, /** Stop after the next keyframe. */ @@ -1797,14 +1797,14 @@ typedef enum ePosePropagate_Termination { POSE_PROPAGATE_SELECTED_KEYS, /** Only do on the frames where markers are selected. */ POSE_PROPAGATE_SELECTED_MARKERS, -} ePosePropagate_Termination; +}; /* --------------------------------- */ -typedef struct FrameLink { +struct FrameLink { struct FrameLink *next, *prev; float frame; -} FrameLink; +}; static void propagate_curve_values(ListBase /*tPChanFCurveLink*/ *pflinks, const float source_frame, @@ -1859,10 +1859,10 @@ static float find_last_key(ListBase *pflinks) static void get_selected_marker_positions(Scene *scene, ListBase /*FrameLink*/ *target_frames) { - ListBase selected_markers = {NULL, NULL}; + ListBase selected_markers = {nullptr, nullptr}; ED_markers_make_cfra_list(&scene->markers, &selected_markers, SELECT); LISTBASE_FOREACH (CfraElem *, marker, &selected_markers) { - FrameLink *link = MEM_callocN(sizeof(FrameLink), "Marker Key Link"); + FrameLink *link = static_cast(MEM_callocN(sizeof(FrameLink), "Marker Key Link")); link->frame = marker->cfra; BLI_addtail(target_frames, link); } @@ -1878,7 +1878,7 @@ static void get_keyed_frames_in_range(ListBase *pflinks, LISTBASE_FOREACH (tPChanFCurveLink *, pfl, pflinks) { LISTBASE_FOREACH (LinkData *, ld, &pfl->fcurves) { FCurve *fcu = (FCurve *)ld->data; - fcurve_to_keylist(NULL, fcu, keylist, 0); + fcurve_to_keylist(nullptr, fcu, keylist, 0); } } LISTBASE_FOREACH (ActKeyColumn *, column, ED_keylist_listbase(keylist)) { @@ -1888,7 +1888,7 @@ static void get_keyed_frames_in_range(ListBase *pflinks, if (column->cfra > end_frame) { break; } - FrameLink *link = MEM_callocN(sizeof(FrameLink), "Marker Key Link"); + FrameLink *link = static_cast(MEM_callocN(sizeof(FrameLink), "Marker Key Link")); link->frame = column->cfra; BLI_addtail(target_frames, link); } @@ -1901,14 +1901,14 @@ static void get_selected_frames(ListBase *pflinks, ListBase /*FrameLink*/ *targe LISTBASE_FOREACH (tPChanFCurveLink *, pfl, pflinks) { LISTBASE_FOREACH (LinkData *, ld, &pfl->fcurves) { FCurve *fcu = (FCurve *)ld->data; - fcurve_to_keylist(NULL, fcu, keylist, 0); + fcurve_to_keylist(nullptr, fcu, keylist, 0); } } LISTBASE_FOREACH (ActKeyColumn *, column, ED_keylist_listbase(keylist)) { if (!column->sel) { continue; } - FrameLink *link = MEM_callocN(sizeof(FrameLink), "Marker Key Link"); + FrameLink *link = static_cast(MEM_callocN(sizeof(FrameLink), "Marker Key Link")); link->frame = column->cfra; BLI_addtail(target_frames, link); } @@ -1923,7 +1923,7 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); - ListBase pflinks = {NULL, NULL}; + ListBase pflinks = {nullptr, nullptr}; const int mode = RNA_enum_get(op->ptr, "mode"); @@ -1941,12 +1941,12 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) const float end_frame = RNA_float_get(op->ptr, "end_frame"); const float current_frame = BKE_scene_frame_get(scene); - ListBase target_frames = {NULL, NULL}; + ListBase target_frames = {nullptr, nullptr}; switch (mode) { case POSE_PROPAGATE_NEXT_KEY: { float target_frame = find_next_key(&pflinks, current_frame); - FrameLink *link = MEM_callocN(sizeof(FrameLink), "Next Key Link"); + FrameLink *link = static_cast(MEM_callocN(sizeof(FrameLink), "Next Key Link")); link->frame = target_frame; BLI_addtail(&target_frames, link); propagate_curve_values(&pflinks, current_frame, &target_frames); @@ -1955,7 +1955,7 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) case POSE_PROPAGATE_LAST_KEY: { float target_frame = find_last_key(&pflinks); - FrameLink *link = MEM_callocN(sizeof(FrameLink), "Last Key Link"); + FrameLink *link = static_cast(MEM_callocN(sizeof(FrameLink), "Last Key Link")); link->frame = target_frame; BLI_addtail(&target_frames, link); propagate_curve_values(&pflinks, current_frame, &target_frames); @@ -2035,7 +2035,7 @@ void POSE_OT_propagate(wmOperatorType *ot) "On Selected Markers", "Propagate pose to all keyframes occurring on frames with Scene Markers after the current " "frame"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.cc similarity index 95% rename from source/blender/editors/armature/pose_transform.c rename to source/blender/editors/armature/pose_transform.cc index 42617580963..c7f430bcee5 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.cc @@ -83,7 +83,8 @@ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Objec Object workob, *ob; /* go through all objects in database */ - for (ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ob = static_cast(bmain->objects.first); ob; + ob = static_cast(ob->id.next)) { /* if parent is bone in this armature, apply corrections */ if ((ob->parent == armob) && (ob->partype == PARBONE)) { /* apply current transform from parent (not yet destroyed), @@ -192,16 +193,16 @@ static void applyarmature_adjust_edit_position(bArmature *arm, } /* Data about parent position for Apply To Selected mode. */ -typedef struct ApplyArmature_ParentState { +struct ApplyArmature_ParentState { Bone *bone; /* New rest position of the bone with scale included. */ float new_rest_mat[4][4]; /* New arm_mat of the bone == new_rest_mat without scale. */ float new_arm_mat[4][4]; -} ApplyArmature_ParentState; +}; -/* Recursive walk for Apply To Selected mode; pstate NULL unless child of an applied bone. */ +/* Recursive walk for Apply To Selected mode; pstate nullptr unless child of an applied bone. */ static void applyarmature_process_selected_recursive(bArmature *arm, bPose *pose, bPose *pose_eval, @@ -216,7 +217,8 @@ static void applyarmature_process_selected_recursive(bArmature *arm, return; } - ApplyArmature_ParentState new_pstate = {.bone = bone}; + ApplyArmature_ParentState new_pstate{}; + new_pstate.bone = bone; if (BLI_findptr(selected, pchan, offsetof(CollectionPointerLink, ptr.data))) { /* SELECTED BONE: Snap to final pose transform minus un-applied parent effects. @@ -364,8 +366,10 @@ static void applyarmature_reset_bone_constraints(const bPoseChannel *pchan) * applied. */ static void applyarmature_reset_constraints(bPose *pose, const bool use_selected) { - for (bPoseChannel *pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - BLI_assert(pchan->bone != NULL); + for (bPoseChannel *pchan = static_cast(pose->chanbase.first); pchan; + pchan = pchan->next) + { + BLI_assert(pchan->bone != nullptr); if (use_selected && (pchan->bone->flag & BONE_SELECTED) == 0) { continue; } @@ -426,17 +430,18 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) /* The selected only mode requires a recursive walk to handle parent-child relations. */ LISTBASE_FOREACH (Bone *, bone, &arm->bonebase) { applyarmature_process_selected_recursive( - arm, pose, ob_eval->pose, bone, &selected_bones, NULL); + arm, pose, ob_eval->pose, bone, &selected_bones, nullptr); } BLI_freelistN(&selected_bones); } else { - for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(pose->chanbase.first); pchan; pchan = pchan->next) { const bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); EditBone *curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name); - applyarmature_set_edit_position(curbone, pchan_eval->pose_mat, pchan_eval->pose_tail, NULL); + applyarmature_set_edit_position( + curbone, pchan_eval->pose_mat, pchan_eval->pose_tail, nullptr); applyarmature_transfer_properties(curbone, pchan, pchan_eval); } } @@ -469,7 +474,7 @@ static void apply_armature_pose2bones_ui(bContext *C, wmOperator *op) RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - uiItemR(layout, &ptr, "selected", 0, NULL, ICON_NONE); + uiItemR(layout, &ptr, "selected", 0, nullptr, ICON_NONE); } void POSE_OT_armature_apply(wmOperatorType *ot) @@ -501,7 +506,7 @@ void POSE_OT_armature_apply(wmOperatorType *ot) * \{ */ /* set the current pose as the restpose */ -static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_visual_transform_apply_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -511,16 +516,17 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) CTX_data_ensure_evaluated_depsgraph(C); FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) { - const bArmature *arm = ob->data; + const bArmature *arm = static_cast(ob->data); int chanbase_len = BLI_listbase_count(&ob->pose->chanbase); /* Storage for the calculated matrices to prevent reading from modified values. * NOTE: this could be avoided if children were always calculated before parents * however ensuring this is involved and doesn't give any significant advantage. */ - struct { + struct XFormArray { float matrix[4][4]; bool is_set; - } *pchan_xform_array = MEM_mallocN(sizeof(*pchan_xform_array) * chanbase_len, __func__); + } *pchan_xform_array = static_cast( + MEM_mallocN(sizeof(*pchan_xform_array) * chanbase_len, __func__)); bool changed = false; int i; @@ -592,11 +598,11 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot) */ static void set_pose_keys(Object *ob) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bPoseChannel *chan; if (ob->pose) { - for (chan = ob->pose->chanbase.first; chan; chan = chan->next) { + for (chan = static_cast(ob->pose->chanbase.first); chan; chan = chan->next) { Bone *bone = chan->bone; if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) { chan->flag |= POSE_KEY; @@ -615,7 +621,7 @@ static void set_pose_keys(Object *ob) * \param chan: Bone that pose to paste comes from * \param selOnly: Only paste on selected bones * \param flip: Flip on x-axis - * \return The channel of the bone that was pasted to, or NULL if no paste was performed. + * \return The channel of the bone that was pasted to, or nullptr if no paste was performed. */ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, @@ -638,11 +644,11 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, * only selected bones get pasted on, allowing making both sides symmetrical. */ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, name); - if (pchan == NULL) { - return NULL; + if (pchan == nullptr) { + return nullptr; } if (selOnly && (pchan->bone->flag & BONE_SELECTED) == 0) { - return NULL; + return nullptr; } /* only loc rot size @@ -770,7 +776,7 @@ static int pose_copy_exec(bContext *C, wmOperator *op) Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); char filepath[FILE_MAX]; /* Sanity checking. */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { BKE_report(op->reports, RPT_ERROR, "No pose to copy"); return OPERATOR_CANCELLED; } @@ -787,10 +793,10 @@ static int pose_copy_exec(bContext *C, wmOperator *op) Main *temp_bmain = BKE_main_new(); STRNCPY(temp_bmain->filepath, BKE_main_blendfile_path_from_global()); - Object ob_copy = *ob; - ob_copy.adt = NULL; + Object ob_copy = blender::dna::shallow_copy(*ob); + ob_copy.adt = nullptr; bArmature arm_copy = *((bArmature *)ob->data); - arm_copy.adt = NULL; + arm_copy.adt = nullptr; ob_copy.data = &arm_copy; BLI_addtail(&temp_bmain->objects, &ob_copy); BLI_addtail(&temp_bmain->armatures, &arm_copy); @@ -848,7 +854,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); /* Sanity checks. */ - if (ELEM(NULL, ob, ob->pose)) { + if (ELEM(nullptr, ob, ob->pose)) { return OPERATOR_CANCELLED; } @@ -870,9 +876,9 @@ static int pose_paste_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Object *object_from = temp_bmain->objects.first; + Object *object_from = static_cast(temp_bmain->objects.first); bPose *pose_from = object_from->pose; - if (pose_from == NULL) { + if (pose_from == nullptr) { BKE_report(op->reports, RPT_ERROR, "Internal clipboard has no pose"); BKE_main_free(temp_bmain); return OPERATOR_CANCELLED; @@ -891,11 +897,11 @@ static int pose_paste_exec(bContext *C, wmOperator *op) /* Safely merge all of the channels in the buffer pose into any * existing pose. */ - for (chan = pose_from->chanbase.first; chan; chan = chan->next) { + for (chan = static_cast(pose_from->chanbase.first); chan; chan = chan->next) { if (chan->flag & POSE_KEY) { /* Try to perform paste on this bone. */ bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip); - if (pchan != NULL) { + if (pchan != nullptr) { /* Keyframing tagging for successful paste, */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); } @@ -979,7 +985,7 @@ static void pchan_clear_scale_with_mirrored(const bPose *pose, bPoseChannel *pch { if (pose->flag & POSE_MIRROR_EDIT) { bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(pose, pchan->name); - if (pchan_mirror != NULL) { + if (pchan_mirror != nullptr) { pchan_clear_scale(pchan_mirror); } } @@ -1005,7 +1011,7 @@ static void pchan_clear_loc_with_mirrored(const bPose *pose, bPoseChannel *pchan { if (pose->flag & POSE_MIRROR_EDIT) { bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(pose, pchan->name); - if (pchan_mirror != NULL) { + if (pchan_mirror != nullptr) { pchan_clear_loc(pchan_mirror); } } @@ -1144,7 +1150,7 @@ static void pchan_clear_rot_with_mirrored(const bPose *pose, bPoseChannel *pchan { if (pose->flag & POSE_MIRROR_EDIT) { bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(pose, pchan->name); - if (pchan_mirror != NULL) { + if (pchan_mirror != nullptr) { pchan_clear_rot(pchan_mirror); } } @@ -1172,7 +1178,7 @@ static int pose_clear_transform_generic_exec(bContext *C, bool changed_multi = false; /* sanity checks */ - if (ELEM(NULL, clear_func, default_ksName)) { + if (ELEM(nullptr, clear_func, default_ksName)) { BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name"); @@ -1185,7 +1191,7 @@ static int pose_clear_transform_generic_exec(bContext *C, FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) { /* XXX: UGLY HACK (for auto-key + clear transforms). */ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); - ListBase dsources = {NULL, NULL}; + ListBase dsources = {nullptr, nullptr}; bool changed = false; FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN (ob_iter, pchan) { @@ -1215,7 +1221,8 @@ static int pose_clear_transform_generic_exec(bContext *C, KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName); /* insert keyframes */ - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); + ANIM_apply_keyingset( + C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, (float)scene->r.cfra); /* now recalculate paths */ if (ob_iter->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) { @@ -1366,8 +1373,8 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) /* XXX: this is just like this to avoid contaminating anything else; * just pose values should change, so this should be fine */ - bPose *dummyPose = NULL; - Object workob = {{NULL}}; + bPose *dummyPose = nullptr; + Object workob{}; bPoseChannel *pchan; /* execute animation step for current frame using a dummy copy of the pose */ @@ -1383,12 +1390,14 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) &workob.id, workob.adt, &anim_eval_context, ADT_RECALC_ANIM, false); /* Copy back values, but on selected bones only. */ - for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(dummyPose->chanbase.first); pchan; + pchan = pchan->next) { pose_bone_do_paste(ob, pchan, only_select, 0); } /* free temp data - free manually as was copied without constraints */ - for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(dummyPose->chanbase.first); pchan; + pchan = pchan->next) { if (pchan->prop) { IDP_FreeProperty(pchan->prop); } diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.cc similarity index 88% rename from source/blender/editors/armature/pose_utils.c rename to source/blender/editors/armature/pose_utils.cc index 8ff8e0b856d..e135b967945 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.cc @@ -55,7 +55,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, bAction *act, bPoseChannel *pchan) { - ListBase curves = {NULL, NULL}; + ListBase curves = {nullptr, nullptr}; int transFlags = action_get_item_transforms(act, ob, pchan, &curves); pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE); @@ -63,7 +63,8 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, /* check if any transforms found... */ if (transFlags) { /* make new linkage data */ - tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink"); + tPChanFCurveLink *pfl = static_cast( + MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink")); PointerRNA ptr; pfl->ob = ob; @@ -122,10 +123,10 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *poseAnim_object_get(Object *ob_) { Object *ob = BKE_object_pose_armature_get(ob_); - if (!ELEM(NULL, ob, ob->data, ob->adt, ob->adt->action)) { + if (!ELEM(nullptr, ob, ob->data, ob->adt, ob->adt->action)) { return ob; } - return NULL; + return nullptr; } void poseAnim_mapping_get(bContext *C, ListBase *pfLinks) @@ -135,15 +136,15 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks) */ Object *prev_ob, *ob_pose_armature; - prev_ob = NULL; - ob_pose_armature = NULL; + prev_ob = nullptr; + ob_pose_armature = nullptr; CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { if (ob != prev_ob) { prev_ob = ob; ob_pose_armature = poseAnim_object_get(ob); } - if (ob_pose_armature == NULL) { + if (ob_pose_armature == nullptr) { continue; } @@ -155,15 +156,15 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks) * i.e. if nothing selected, do whole pose */ if (BLI_listbase_is_empty(pfLinks)) { - prev_ob = NULL; - ob_pose_armature = NULL; + prev_ob = nullptr; + ob_pose_armature = nullptr; CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) { if (ob != prev_ob) { prev_ob = ob; ob_pose_armature = poseAnim_object_get(ob); } - if (ob_pose_armature == NULL) { + if (ob_pose_armature == nullptr) { continue; } @@ -175,10 +176,10 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks) void poseAnim_mapping_free(ListBase *pfLinks) { - tPChanFCurveLink *pfl, *pfln = NULL; + tPChanFCurveLink *pfl, *pfln = nullptr; /* free the temp pchan links and their data */ - for (pfl = pfLinks->first; pfl; pfl = pfln) { + for (pfl = static_cast(pfLinks->first); pfl; pfl = pfln) { pfln = pfl->next; /* free custom properties */ @@ -199,7 +200,7 @@ void poseAnim_mapping_free(ListBase *pfLinks) /* ------------------------- */ -void poseAnim_mapping_refresh(bContext *C, Scene *UNUSED(scene), Object *ob) +void poseAnim_mapping_refresh(bContext *C, Scene * /*scene*/, Object *ob) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -215,7 +216,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks) tPChanFCurveLink *pfl; /* iterate over each pose-channel affected, restoring all channels to their original values */ - for (pfl = pfLinks->first; pfl; pfl = pfl->next) { + for (pfl = static_cast(pfLinks->first); pfl; pfl = pfl->next) { bPoseChannel *pchan = pfl->pchan; /* just copy all the values over regardless of whether they changed or not */ @@ -257,7 +258,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, ob = poseAnim_object_get(ob); /* Ensure validity of the settings from the context. */ - if (ob == NULL) { + if (ob == nullptr) { continue; } @@ -274,14 +275,14 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, /* Insert keyframes as necessary if auto-key-framing. */ KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); - ListBase dsources = {NULL, NULL}; + ListBase dsources = {nullptr, nullptr}; tPChanFCurveLink *pfl; /* iterate over each pose-channel affected, tagging bones to be keyed */ /* XXX: here we already have the information about what transforms exist, though * it might be easier to just overwrite all using normal mechanisms */ - for (pfl = pfLinks->first; pfl; pfl = pfl->next) { + for (pfl = static_cast(pfLinks->first); pfl; pfl = pfl->next) { bPoseChannel *pchan = pfl->pchan; if ((pfl->ob->id.tag & LIB_TAG_DOIT) == 0) { @@ -293,7 +294,7 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, } /* insert keyframes for all relevant bones in one go */ - ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cframe); + ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, cframe); BLI_freelistN(&dsources); /* do the bone paths @@ -316,7 +317,9 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, ListBase *pfLinks, LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path) { - LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL; + LinkData *first = static_cast((prev) ? prev->next : + (fcuLinks) ? fcuLinks->first : + nullptr); LinkData *ld; /* check each link to see if the linked F-Curve has a matching path */ @@ -330,7 +333,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con } /* none found */ - return NULL; + return nullptr; } /* *********************************************** */ diff --git a/source/blender/editors/lattice/CMakeLists.txt b/source/blender/editors/lattice/CMakeLists.txt index 40d595b3eab..713d1b59704 100644 --- a/source/blender/editors/lattice/CMakeLists.txt +++ b/source/blender/editors/lattice/CMakeLists.txt @@ -20,10 +20,10 @@ set(INC_SYS ) set(SRC - editlattice_select.c - editlattice_tools.c - editlattice_undo.c - lattice_ops.c + editlattice_select.cc + editlattice_tools.cc + editlattice_undo.cc + lattice_ops.cc lattice_intern.h ) diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.cc similarity index 93% rename from source/blender/editors/lattice/editlattice_select.c rename to source/blender/editors/lattice/editlattice_select.cc index d8659d8d458..f151ec92326 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.cc @@ -67,7 +67,7 @@ bool ED_lattice_deselect_all_multi_ex(Base **bases, const uint bases_len) Base *base_iter = bases[base_index]; Object *ob_iter = base_iter->object; changed_multi |= ED_lattice_flags_set(ob_iter, 0); - DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(ob_iter->data), ID_RECALC_SELECT); } return changed_multi; } @@ -114,7 +114,7 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op) int a = lt->pntsu * lt->pntsv * lt->pntsw; int elem_map_len = 0; - BPoint **elem_map = MEM_mallocN(sizeof(*elem_map) * a, __func__); + BPoint **elem_map = static_cast(MEM_mallocN(sizeof(*elem_map) * a, __func__)); BPoint *bp = lt->def; while (a--) { @@ -135,7 +135,7 @@ static int lattice_select_random_exec(bContext *C, wmOperator *op) lt->actbp = LT_ACTBP_NONE; } - DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(obedit->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } MEM_freeN(objects); @@ -224,7 +224,7 @@ static int lattice_select_mirror_exec(bContext *C, wmOperator *op) } /* TODO: only notify changes. */ - DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(obedit->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } MEM_freeN(objects); @@ -317,7 +317,7 @@ static int lattice_select_more_less(bContext *C, const bool select) MEM_freeN(selpoints); changed = true; - DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(obedit->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } MEM_freeN(objects); @@ -325,12 +325,12 @@ static int lattice_select_more_less(bContext *C, const bool select) return changed ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static int lattice_select_more_exec(bContext *C, wmOperator *UNUSED(op)) +static int lattice_select_more_exec(bContext *C, wmOperator * /*op*/) { return lattice_select_more_less(C, true); } -static int lattice_select_less_exec(bContext *C, wmOperator *UNUSED(op)) +static int lattice_select_less_exec(bContext *C, wmOperator * /*op*/) { return lattice_select_more_less(C, false); } @@ -373,7 +373,7 @@ void LATTICE_OT_select_less(wmOperatorType *ot) bool ED_lattice_flags_set(Object *obedit, int flag) { - Lattice *lt = obedit->data; + Lattice *lt = static_cast(obedit->data); BPoint *bp; int a; bool changed = false; @@ -413,7 +413,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) action = SEL_SELECT; for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *obedit = objects[ob_index]; - Lattice *lt = obedit->data; + Lattice *lt = static_cast(obedit->data); if (BKE_lattice_is_any_selected(lt->editlatt->latt)) { action = SEL_DESELECT; break; @@ -437,7 +437,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) changed = ED_lattice_flags_set(obedit, 0); break; case SEL_INVERT: - lt = obedit->data; + lt = static_cast(obedit->data); bp = lt->editlatt->latt->def; a = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; lt->editlatt->latt->actbp = LT_ACTBP_NONE; @@ -453,7 +453,7 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) } if (changed) { changed_multi = true; - DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(obedit->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } } @@ -505,7 +505,7 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op) BPoint *bp; int a, tot; - if (BLI_listbase_is_empty(<->vertex_group_names) || lt->dvert == NULL) { + if (BLI_listbase_is_empty(<->vertex_group_names) || lt->dvert == nullptr) { continue; } @@ -518,14 +518,14 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op) for (a = 0, bp = lt->def; a < tot; a++, bp++, dv++) { if (bp->hide == 0) { - if (dv->dw == NULL) { + if (dv->dw == nullptr) { bp->f1 |= SELECT; } } } changed = true; - DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(obedit->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } MEM_freeN(objects); @@ -574,7 +574,7 @@ struct NearestLatticeVert_UserData { static void findnearestLattvert__doClosest(void *user_data, BPoint *bp, const float screen_co[2]) { - struct NearestLatticeVert_UserData *data = user_data; + struct NearestLatticeVert_UserData *data = static_cast(user_data); float dist_test = len_manhattan_v2v2(data->mval_fl, screen_co); if ((bp->f1 & SELECT) && data->select) { @@ -590,7 +590,7 @@ static void findnearestLattvert__doClosest(void *user_data, BPoint *bp, const fl static BPoint *findnearestLattvert(ViewContext *vc, bool select, Base **r_base) { - struct NearestLatticeVert_UserData data = {NULL}; + struct NearestLatticeVert_UserData data = {nullptr}; data.dist = ED_view3d_select_dist_px(); data.select = select; @@ -621,8 +621,8 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], const struct SelectP { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; - BPoint *bp = NULL; - Base *basact = NULL; + BPoint *bp = nullptr; + Base *basact = nullptr; bool changed = false; ED_view3d_viewcontext_init(C, &vc, depsgraph); @@ -630,7 +630,7 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], const struct SelectP vc.mval[1] = mval[1]; bp = findnearestLattvert(&vc, true, &basact); - bool found = (bp != NULL); + bool found = (bp != nullptr); if (params->sel_op == SEL_OP_SET) { if ((found && params->select_passthrough) && (bp->f1 & SELECT)) { @@ -644,7 +644,7 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], const struct SelectP for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; if (ED_lattice_flags_set(ob, 0)) { - DEG_id_tag_update(ob->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(ob->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); } } @@ -692,7 +692,7 @@ bool ED_lattice_select_pick(bContext *C, const int mval[2], const struct SelectP ED_object_base_activate(C, basact); } - DEG_id_tag_update(vc.obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(vc.obedit->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); changed = true; diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.cc similarity index 94% rename from source/blender/editors/lattice/editlattice_tools.c rename to source/blender/editors/lattice/editlattice_tools.cc index 820b43bfdb4..329f0a78075 100644 --- a/source/blender/editors/lattice/editlattice_tools.c +++ b/source/blender/editors/lattice/editlattice_tools.cc @@ -48,12 +48,12 @@ static bool make_regular_poll(bContext *C) return (ob && ob->type == OB_LATTICE); } -static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) +static int make_regular_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); - const bool is_editmode = CTX_data_edit_object(C) != NULL; + const bool is_editmode = CTX_data_edit_object(C) != nullptr; if (is_editmode) { uint objects_len; @@ -61,13 +61,13 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) scene, view_layer, CTX_wm_view3d(C), &objects_len); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob = objects[ob_index]; - Lattice *lt = ob->data; + Lattice *lt = static_cast(ob->data); - if (lt->editlatt->latt == NULL) { + if (lt->editlatt->latt == nullptr) { continue; } - BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, nullptr); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); @@ -80,8 +80,8 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) continue; } - Lattice *lt = ob->data; - BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + Lattice *lt = static_cast(ob->data); + BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, nullptr); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); @@ -201,7 +201,7 @@ static int lattice_flip_exec(bContext *C, wmOperator *op) ViewLayer *view_layer = CTX_data_view_layer(C); uint objects_len; bool changed = false; - const eLattice_FlipAxes axis = RNA_enum_get(op->ptr, "axis"); + const eLattice_FlipAxes axis = eLattice_FlipAxes(RNA_enum_get(op->ptr, "axis")); Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( scene, view_layer, CTX_wm_view3d(C), &objects_len); @@ -238,7 +238,7 @@ static int lattice_flip_exec(bContext *C, wmOperator *op) break; default: - printf("lattice_flip(): Unknown flipping axis (%u)\n", axis); + printf("lattice_flip(): Unknown flipping axis (%d)\n", axis); return OPERATOR_CANCELLED; } @@ -334,7 +334,7 @@ void LATTICE_OT_flip(wmOperatorType *ot) {LATTICE_FLIP_U, "U", 0, "U (X) Axis", ""}, {LATTICE_FLIP_V, "V", 0, "V (Y) Axis", ""}, {LATTICE_FLIP_W, "W", 0, "W (Z) Axis", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.cc similarity index 84% rename from source/blender/editors/lattice/editlattice_undo.c rename to source/blender/editors/lattice/editlattice_undo.cc index 379e53dc61c..b4c71217af9 100644 --- a/source/blender/editors/lattice/editlattice_undo.c +++ b/source/blender/editors/lattice/editlattice_undo.cc @@ -50,7 +50,7 @@ static CLG_LogRef LOG = {"ed.undo.lattice"}; * \{ */ /* TODO(@ideasman42): this could contain an entire 'Lattice' struct. */ -typedef struct UndoLattice { +struct UndoLattice { BPoint *def; int pntsu, pntsv, pntsw, actbp; char typeu, typev, typew; @@ -58,7 +58,7 @@ typedef struct UndoLattice { float du, dv, dw; MDeformVert *dvert; size_t undo_size; -} UndoLattice; +}; static void undolatt_to_editlatt(UndoLattice *ult, EditLatt *editlatt) { @@ -66,7 +66,7 @@ static void undolatt_to_editlatt(UndoLattice *ult, EditLatt *editlatt) const int len_dst = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw; if (len_src != len_dst) { MEM_freeN(editlatt->latt->def); - editlatt->latt->def = MEM_dupallocN(ult->def); + editlatt->latt->def = static_cast(MEM_dupallocN(ult->def)); } else { memcpy(editlatt->latt->def, ult->def, sizeof(BPoint) * len_src); @@ -76,7 +76,8 @@ static void undolatt_to_editlatt(UndoLattice *ult, EditLatt *editlatt) * relations to #MDeformWeight might have changed. */ if (editlatt->latt->dvert && ult->dvert) { BKE_defvert_array_free(editlatt->latt->dvert, len_dst); - editlatt->latt->dvert = MEM_mallocN(sizeof(MDeformVert) * len_src, "Lattice MDeformVert"); + editlatt->latt->dvert = static_cast( + MEM_mallocN(sizeof(MDeformVert) * len_src, "Lattice MDeformVert")); BKE_defvert_array_copy(editlatt->latt->dvert, ult->dvert, len_src); } @@ -101,7 +102,7 @@ static void *undolatt_from_editlatt(UndoLattice *ult, EditLatt *editlatt) { BLI_assert(BLI_array_is_zeroed(ult, 1)); - ult->def = MEM_dupallocN(editlatt->latt->def); + ult->def = static_cast(MEM_dupallocN(editlatt->latt->def)); ult->pntsu = editlatt->latt->pntsu; ult->pntsv = editlatt->latt->pntsv; ult->pntsw = editlatt->latt->pntsw; @@ -120,7 +121,8 @@ static void *undolatt_from_editlatt(UndoLattice *ult, EditLatt *editlatt) if (editlatt->latt->dvert) { const int tot = ult->pntsu * ult->pntsv * ult->pntsw; - ult->dvert = MEM_mallocN(sizeof(MDeformVert) * tot, "Undo Lattice MDeformVert"); + ult->dvert = static_cast( + MEM_mallocN(sizeof(MDeformVert) * tot, "Undo Lattice MDeformVert")); BKE_defvert_array_copy(ult->dvert, editlatt->latt->dvert, tot); ult->undo_size += sizeof(*ult->dvert) * tot; } @@ -137,18 +139,18 @@ static void undolatt_free_data(UndoLattice *ult) } if (ult->dvert) { BKE_defvert_array_free(ult->dvert, ult->pntsu * ult->pntsv * ult->pntsw); - ult->dvert = NULL; + ult->dvert = nullptr; } } #if 0 static int validate_undoLatt(void *data, void *edata) { - UndoLattice *ult = (UndoLattice *)data; - EditLatt *editlatt = (EditLatt *)edata; +UndoLattice *ult = (UndoLattice *)data; +EditLatt *editlatt = (EditLatt *)edata; - return (ult->pntsu == editlatt->latt->pntsu && ult->pntsv == editlatt->latt->pntsv && - ult->pntsw == editlatt->latt->pntsw); +return (ult->pntsu == editlatt->latt->pntsu && ult->pntsv == editlatt->latt->pntsv && +ult->pntsw == editlatt->latt->pntsw); } #endif @@ -159,13 +161,13 @@ static Object *editlatt_object_from_context(bContext *C) BKE_view_layer_synced_ensure(scene, view_layer); Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obedit && obedit->type == OB_LATTICE) { - Lattice *lt = obedit->data; - if (lt->editlatt != NULL) { + Lattice *lt = static_cast(obedit->data); + if (lt->editlatt != nullptr) { return obedit; } } - return NULL; + return nullptr; } /** \} */ @@ -176,20 +178,20 @@ static Object *editlatt_object_from_context(bContext *C) * \note This is similar for all edit-mode types. * \{ */ -typedef struct LatticeUndoStep_Elem { +struct LatticeUndoStep_Elem { UndoRefID_Object obedit_ref; UndoLattice data; -} LatticeUndoStep_Elem; +}; -typedef struct LatticeUndoStep { +struct LatticeUndoStep { UndoStep step; LatticeUndoStep_Elem *elems; uint elems_len; -} LatticeUndoStep; +}; static bool lattice_undosys_poll(bContext *C) { - return editlatt_object_from_context(C) != NULL; + return editlatt_object_from_context(C) != nullptr; } static bool lattice_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p) @@ -203,7 +205,8 @@ static bool lattice_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p uint objects_len = 0; Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len); - us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__); + us->elems = static_cast( + MEM_callocN(sizeof(*us->elems) * objects_len, __func__)); us->elems_len = objects_len; for (uint i = 0; i < objects_len; i++) { @@ -211,7 +214,7 @@ static bool lattice_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p LatticeUndoStep_Elem *elem = &us->elems[i]; elem->obedit_ref.ptr = ob; - Lattice *lt = ob->data; + Lattice *lt = static_cast(ob->data); undolatt_from_editlatt(&elem->data, lt->editlatt); lt->editlatt->needs_flush_to_id = 1; us->step.data_size += elem->data.undo_size; @@ -223,11 +226,8 @@ static bool lattice_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p return true; } -static void lattice_undosys_step_decode(bContext *C, - Main *bmain, - UndoStep *us_p, - const eUndoStepDir UNUSED(dir), - bool UNUSED(is_final)) +static void lattice_undosys_step_decode( + bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/) { LatticeUndoStep *us = (LatticeUndoStep *)us_p; @@ -239,8 +239,8 @@ static void lattice_undosys_step_decode(bContext *C, for (uint i = 0; i < us->elems_len; i++) { LatticeUndoStep_Elem *elem = &us->elems[i]; Object *obedit = elem->obedit_ref.ptr; - Lattice *lt = obedit->data; - if (lt->editlatt == NULL) { + Lattice *lt = static_cast(obedit->data); + if (lt->editlatt == nullptr) { /* Should never fail, may not crash but can give odd behavior. */ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid", @@ -262,7 +262,7 @@ static void lattice_undosys_step_decode(bContext *C, bmain->is_memfile_undo_flush_needed = true; - WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, nullptr); } static void lattice_undosys_step_free(UndoStep *us_p) diff --git a/source/blender/editors/lattice/lattice_intern.h b/source/blender/editors/lattice/lattice_intern.h index d6432b5fa3b..3854d3f995c 100644 --- a/source/blender/editors/lattice/lattice_intern.h +++ b/source/blender/editors/lattice/lattice_intern.h @@ -8,6 +8,10 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + /* editlattice_select.c */ void LATTICE_OT_select_all(struct wmOperatorType *ot); @@ -21,3 +25,7 @@ void LATTICE_OT_select_mirror(struct wmOperatorType *ot); void LATTICE_OT_make_regular(struct wmOperatorType *ot); void LATTICE_OT_flip(struct wmOperatorType *ot); + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/editors/lattice/lattice_ops.c b/source/blender/editors/lattice/lattice_ops.cc similarity index 100% rename from source/blender/editors/lattice/lattice_ops.c rename to source/blender/editors/lattice/lattice_ops.cc diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index bfb570fabf5..efc07c3725c 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -28,36 +28,36 @@ set(INC set(SRC editface.cc - editmesh_add.c - editmesh_add_gizmo.c + editmesh_add.cc + editmesh_add_gizmo.cc editmesh_attribute.cc - editmesh_automerge.c - editmesh_bevel.c - editmesh_bisect.c - editmesh_extrude.c - editmesh_extrude_screw.c - editmesh_extrude_spin.c - editmesh_extrude_spin_gizmo.c - editmesh_inset.c - editmesh_intersect.c - editmesh_knife.c + editmesh_automerge.cc + editmesh_bevel.cc + editmesh_bisect.cc + editmesh_extrude.cc + editmesh_extrude_screw.cc + editmesh_extrude_spin.cc + editmesh_extrude_spin_gizmo.cc + editmesh_inset.cc + editmesh_intersect.cc + editmesh_knife.cc editmesh_knife_project.cc - editmesh_loopcut.c + editmesh_loopcut.cc editmesh_mask_extract.cc - editmesh_path.c - editmesh_polybuild.c - editmesh_preselect_edgering.c - editmesh_preselect_elem.c - editmesh_rip.c - editmesh_rip_edge.c + editmesh_path.cc + editmesh_polybuild.cc + editmesh_preselect_edgering.cc + editmesh_preselect_elem.cc + editmesh_rip.cc + editmesh_rip_edge.cc editmesh_select.cc - editmesh_select_similar.c + editmesh_select_similar.cc editmesh_tools.cc editmesh_undo.cc editmesh_utils.cc mesh_data.cc mesh_mirror.cc - mesh_ops.c + mesh_ops.cc meshtools.cc mesh_intern.h diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.cc similarity index 93% rename from source/blender/editors/mesh/editmesh_add.c rename to source/blender/editors/mesh/editmesh_add.cc index 21d5ffe2cba..d274fc804df 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.cc @@ -33,10 +33,10 @@ /* ********* add primitive operators ************* */ -typedef struct MakePrimitiveData { +struct MakePrimitiveData { float mat[4][4]; bool was_editmode; -} MakePrimitiveData; +}; static Object *make_prim_init(bContext *C, const char *idname, @@ -51,7 +51,7 @@ static Object *make_prim_init(bContext *C, Object *obedit = CTX_data_edit_object(C); r_creation_data->was_editmode = false; - if (obedit == NULL || obedit->type != OB_MESH) { + if (obedit == nullptr || obedit->type != OB_MESH) { obedit = ED_object_add_type(C, OB_MESH, idname, loc, rot, false, local_view_bits); ED_object_editmode_enter_ex(bmain, scene, obedit, 0); @@ -76,12 +76,11 @@ static void make_prim_finish(bContext *C, EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); /* only recalc editmode tessface if we are staying in editmode */ - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = !exit_editmode, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = !exit_editmode; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); /* userdef */ if (exit_editmode) { @@ -102,19 +101,19 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Plane"), loc, rot, - NULL, + nullptr, local_view_bits, &creation_data); em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf( @@ -168,7 +167,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cube"), loc, @@ -180,7 +179,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf(em, @@ -224,7 +223,7 @@ static const EnumPropertyItem fill_type_items[] = { {0, "NOTHING", 0, "Nothing", "Don't fill at all"}, {1, "NGON", 0, "N-Gon", "Use n-gons"}, {2, "TRIFAN", 0, "Triangle Fan", "Use triangle fans"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static int add_primitive_circle_exec(bContext *C, wmOperator *op) @@ -243,19 +242,19 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Circle"), loc, rot, - NULL, + nullptr, local_view_bits, &creation_data); em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf( @@ -317,7 +316,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cylinder"), loc, @@ -328,7 +327,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf(em, @@ -394,7 +393,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Cone"), loc, @@ -405,7 +404,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf(em, @@ -471,18 +470,18 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Grid"), loc, rot, - NULL, + nullptr, local_view_bits, &creation_data); em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf( @@ -545,13 +544,13 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Y', loc, rot, NULL, &enter_editmode, &local_view_bits, NULL); + C, op, 'Y', loc, rot, nullptr, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Suzanne"), loc, rot, - NULL, + nullptr, local_view_bits, &creation_data); dia = RNA_float_get(op->ptr, "size") / 2.0f; @@ -560,7 +559,7 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf(em, @@ -611,7 +610,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Sphere"), loc, @@ -622,7 +621,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf( @@ -680,7 +679,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) WM_operator_view3d_unit_defaults(C, op); ED_object_add_generic_get_opts( - C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, NULL); + C, op, 'Z', loc, rot, scale, &enter_editmode, &local_view_bits, nullptr); obedit = make_prim_init(C, CTX_DATA_(BLT_I18NCONTEXT_ID_MESH, "Icosphere"), loc, @@ -691,7 +690,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) em = BKE_editmesh_from_object(obedit); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf( diff --git a/source/blender/editors/mesh/editmesh_add_gizmo.c b/source/blender/editors/mesh/editmesh_add_gizmo.cc similarity index 79% rename from source/blender/editors/mesh/editmesh_add_gizmo.c rename to source/blender/editors/mesh/editmesh_add_gizmo.cc index f1be614a010..a18f8c5c996 100644 --- a/source/blender/editors/mesh/editmesh_add_gizmo.c +++ b/source/blender/editors/mesh/editmesh_add_gizmo.cc @@ -58,7 +58,7 @@ static void calc_initial_placement_point_from_view(bContext *C, Scene *scene = CTX_data_scene(C); ARegion *region = CTX_wm_region(C); - RegionView3D *rv3d = region->regiondata; + RegionView3D *rv3d = static_cast(region->regiondata); bool use_mouse_project = true; /* TODO: make optional */ @@ -104,14 +104,14 @@ static void calc_initial_placement_point_from_view(bContext *C, /** \name Placement Gizmo * \{ */ -typedef struct GizmoPlacementGroup { +struct GizmoPlacementGroup { wmGizmo *cage; struct { bContext *context; wmOperator *op; PropertyRNA *prop_matrix; } data; -} GizmoPlacementGroup; +}; /** * \warning Calling redo from property updates is not great. @@ -130,9 +130,9 @@ static void gizmo_mesh_placement_update_from_op(GizmoPlacementGroup *ggd) { wmOperator *op = ggd->data.op; UNUSED_VARS(op); - /* For now don't read back from the operator. */ +/* For now don't read back from the operator. */ #if 0 - RNA_property_float_get_array(op->ptr, ggd->data.prop_matrix, &ggd->cage->matrix_offset[0][0]); +RNA_property_float_get_array(op->ptr, ggd->data.prop_matrix, &ggd->cage->matrix_offset[0][0]); #endif } @@ -141,14 +141,15 @@ static void gizmo_placement_prop_matrix_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoPlacementGroup *ggd = gz->parent_gzgroup->customdata; + GizmoPlacementGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 16); UNUSED_VARS_NDEBUG(gz_prop); if (value_p != ggd->cage->matrix_offset) { - mul_m4_m4m4(value_p, ggd->cage->matrix_basis, ggd->cage->matrix_offset); + mul_m4_m4m4( + static_cast(value_p), ggd->cage->matrix_basis, ggd->cage->matrix_offset); RNA_property_float_get_array(op->ptr, ggd->data.prop_matrix, value); } } @@ -157,14 +158,14 @@ static void gizmo_placement_prop_matrix_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value) { - GizmoPlacementGroup *ggd = gz->parent_gzgroup->customdata; + GizmoPlacementGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 16); UNUSED_VARS_NDEBUG(gz_prop); float mat[4][4]; - mul_m4_m4m4(mat, ggd->cage->matrix_basis, value); + mul_m4_m4m4(mat, ggd->cage->matrix_basis, static_cast(value)); if (is_negative_m4(mat)) { negate_mat3_m4(mat); @@ -183,7 +184,7 @@ static bool gizmo_mesh_placement_poll(const bContext *C, wmGizmoGroupType *gzgt) static void gizmo_mesh_placement_modal_from_setup(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoPlacementGroup *ggd = gzgroup->customdata; + GizmoPlacementGroup *ggd = static_cast(gzgroup->customdata); /* Initial size. */ { @@ -206,13 +207,11 @@ static void gizmo_mesh_placement_modal_from_setup(const bContext *C, wmGizmoGrou { float mat3[3][3]; float location[3]; - calc_initial_placement_point_from_view((bContext *)C, - (float[2]){ - win->eventstate->xy[0] - region->winrct.xmin, - win->eventstate->xy[1] - region->winrct.ymin, - }, - location, - mat3); + float mval[2] = { + float(win->eventstate->xy[0] - region->winrct.xmin), + float(win->eventstate->xy[1] - region->winrct.ymin), + }; + calc_initial_placement_point_from_view((bContext *)C, mval, location, mat3); copy_m4_m3(gz->matrix_basis, mat3); copy_v3_v3(gz->matrix_basis[3], location); } @@ -232,16 +231,17 @@ static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *gzgroup) { wmOperator *op = WM_operator_last_redo(C); - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) { + if (op == nullptr || !STREQ(op->type->idname, "MESH_OT_primitive_cube_add_gizmo")) { return; } - GizmoPlacementGroup *ggd = MEM_callocN(sizeof(GizmoPlacementGroup), __func__); + GizmoPlacementGroup *ggd = static_cast( + MEM_callocN(sizeof(GizmoPlacementGroup), __func__)); gzgroup->customdata = ggd; const wmGizmoType *gzt_cage = WM_gizmotype_find("GIZMO_GT_cage_3d", true); - ggd->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, NULL); + ggd->cage = WM_gizmo_new_ptr(gzt_cage, gzgroup, nullptr); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, ggd->cage->color); @@ -260,22 +260,20 @@ static void gizmo_mesh_placement_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Setup property callbacks */ { - WM_gizmo_target_property_def_func(ggd->cage, - "matrix", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_placement_prop_matrix_get, - .value_set_fn = gizmo_placement_prop_matrix_set, - .range_get_fn = NULL, - .user_data = NULL, - }); + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_placement_prop_matrix_get; + params.value_set_fn = gizmo_placement_prop_matrix_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->cage, "matrix", ¶ms); } gizmo_mesh_placement_modal_from_setup(C, gzgroup); } -static void gizmo_mesh_placement_draw_prepare(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) +static void gizmo_mesh_placement_draw_prepare(const bContext * /*C*/, wmGizmoGroup *gzgroup) { - GizmoPlacementGroup *ggd = gzgroup->customdata; + GizmoPlacementGroup *ggd = static_cast(gzgroup->customdata); if (ggd->data.op->next) { ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context); } @@ -330,7 +328,7 @@ static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op) const bool calc_uvs = RNA_boolean_get(op->ptr, "calc_uvs"); if (calc_uvs) { - ED_mesh_uv_ensure(obedit->data, NULL); + ED_mesh_uv_ensure(static_cast(obedit->data), nullptr); } if (!EDBM_op_call_and_selectf(em, @@ -346,19 +344,16 @@ static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op) } EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); return OPERATOR_FINISHED; } -static int add_primitive_cube_gizmo_invoke(bContext *C, - wmOperator *op, - const wmEvent *UNUSED(event)) +static int add_primitive_cube_gizmo_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { View3D *v3d = CTX_wm_view3d(C); @@ -397,7 +392,7 @@ void MESH_OT_primitive_cube_add_gizmo(wmOperatorType *ot) /* hidden props */ PropertyRNA *prop = RNA_def_float_matrix( - ot->srna, "matrix", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); + ot->srna, "matrix", 4, 4, nullptr, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); WM_gizmogrouptype_append(MESH_GGT_add_bounds); diff --git a/source/blender/editors/mesh/editmesh_automerge.c b/source/blender/editors/mesh/editmesh_automerge.cc similarity index 84% rename from source/blender/editors/mesh/editmesh_automerge.c rename to source/blender/editors/mesh/editmesh_automerge.cc index b691178f256..176ee59827a 100644 --- a/source/blender/editors/mesh/editmesh_automerge.c +++ b/source/blender/editors/mesh/editmesh_automerge.cc @@ -60,13 +60,12 @@ void EDBM_automerge(Object *obedit, bool update, const char hflag, const float d BMO_op_finish(bm, &findop); BMO_op_finish(bm, &weldop); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; if ((totvert_prev != bm->totvert) && update) { - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBM_update(static_cast(obedit->data), ¶ms); } } @@ -79,7 +78,7 @@ void EDBM_automerge(Object *obedit, bool update, const char hflag, const float d * \{ */ void EDBM_automerge_and_split(Object *obedit, - const bool UNUSED(split_edges), + const bool /*split_edges*/, const bool split_faces, const bool update, const char hflag, @@ -124,12 +123,11 @@ void EDBM_automerge_and_split(Object *obedit, #endif if (LIKELY(ok) && update) { - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.cc similarity index 93% rename from source/blender/editors/mesh/editmesh_bevel.c rename to source/blender/editors/mesh/editmesh_bevel.cc index 5e121e4670e..24ce5879229 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.cc @@ -231,7 +231,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) } op->customdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator"); - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); uint objects_used_len = 0; opdata->max_obj_scale = FLT_MIN; @@ -242,7 +242,8 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) uint ob_store_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( scene, view_layer, v3d, &ob_store_len); - opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__); + opdata->ob_store = static_cast( + MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__)); for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) { Object *obedit = objects[ob_index]; float scale = mat4_to_scale(obedit->object_to_world); @@ -301,7 +302,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) static bool edbm_bevel_calc(wmOperator *op) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); BMOperator bmop; bool changed = false; @@ -334,7 +335,7 @@ static bool edbm_bevel_calc(wmOperator *op) const int material = CLAMPIS(material_init, -1, obedit->totcol - 1); - Mesh *me = obedit->data; + Mesh *me = static_cast(obedit->data); if (harden_normals && !(me->flag & ME_AUTOSMOOTH)) { /* harden_normals only has a visible effect if autosmooth is on, so turn it on */ @@ -385,12 +386,11 @@ static bool edbm_bevel_calc(wmOperator *op) continue; } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); changed = true; } return changed; @@ -398,11 +398,11 @@ static bool edbm_bevel_calc(wmOperator *op) static void edbm_bevel_exit(bContext *C, wmOperator *op) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); ScrArea *area = CTX_wm_area(C); if (area) { - ED_area_status_text(area, NULL); + ED_area_status_text(area, nullptr); } for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { @@ -424,23 +424,23 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) } MEM_SAFE_FREE(opdata->ob_store); MEM_SAFE_FREE(op->customdata); - op->customdata = NULL; + op->customdata = nullptr; } static void edbm_bevel_cancel(bContext *C, wmOperator *op) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); if (opdata->is_modal) { for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { Object *obedit = opdata->ob_store[ob_index].ob; BMEditMesh *em = BKE_editmesh_from_object(obedit); EDBM_redo_state_restore_and_free(&opdata->ob_store[ob_index].mesh_backup, em, true); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = true, - .is_destructive = true, - }); + + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } } @@ -469,7 +469,7 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op) static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, bool mode_changed) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); const float mlen[2] = { opdata->mcenter[0] - event->mval[0], opdata->mcenter[1] - event->mval[1], @@ -499,7 +499,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type); @@ -523,7 +523,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (!edbm_bevel_calc(op)) { edbm_bevel_cancel(C, op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_CANCELLED; } @@ -534,7 +534,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); int vmode = opdata->value_mode; const float mdiff[2] = { @@ -573,7 +573,7 @@ static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event) static void edbm_bevel_numinput_set_value(wmOperator *op) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); int vmode = opdata->value_mode; float value = (vmode == SEGMENTS_VALUE) ? opdata->segments : @@ -645,14 +645,14 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf) 0, "Change Intersection Method", "Cycle through intersection methods"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Bevel Modal Map"); /* This function is called for each space-type, only needs to add map once. */ if (keymap && keymap->modal_items) { - return NULL; + return nullptr; } keymap = WM_modalkeymap_ensure(keyconf, "Bevel Modal Map", modal_items); @@ -664,7 +664,7 @@ wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf) static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) { - BevelData *opdata = op->customdata; + BevelData *opdata = static_cast(op->customdata); const bool has_numinput = hasNumInput(&opdata->num_input[opdata->value_mode]); bool handled = false; short etype = event->type; @@ -711,13 +711,13 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (eval) { case BEV_MODAL_CANCEL: edbm_bevel_cancel(C, op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_CANCELLED; case BEV_MODAL_CONFIRM: edbm_bevel_calc(op); edbm_bevel_exit(C, op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_FINISHED; case BEV_MODAL_SEGMENTS_UP: @@ -910,20 +910,20 @@ static void edbm_bevel_ui(bContext *C, wmOperator *op) uiLayoutSetPropDecorate(layout, false); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "affect", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemS(layout); - uiItemR(layout, op->ptr, "offset_type", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "offset_type", 0, nullptr, ICON_NONE); if (offset_type == BEVEL_AMT_PERCENT) { - uiItemR(layout, op->ptr, "offset_pct", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "offset_pct", 0, nullptr, ICON_NONE); } else { - uiItemR(layout, op->ptr, "offset", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "offset", 0, nullptr, ICON_NONE); } - uiItemR(layout, op->ptr, "segments", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "segments", 0, nullptr, ICON_NONE); if (ELEM(profile_type, BEVEL_PROFILE_SUPERELLIPSE, BEVEL_PROFILE_CUSTOM)) { uiItemR(layout, op->ptr, @@ -932,12 +932,12 @@ static void edbm_bevel_ui(bContext *C, wmOperator *op) (profile_type == BEVEL_PROFILE_SUPERELLIPSE) ? IFACE_("Shape") : IFACE_("Miter Shape"), ICON_NONE); } - uiItemR(layout, op->ptr, "material", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "material", 0, nullptr, ICON_NONE); col = uiLayoutColumn(layout, true); - uiItemR(col, op->ptr, "harden_normals", 0, NULL, ICON_NONE); - uiItemR(col, op->ptr, "clamp_overlap", 0, NULL, ICON_NONE); - uiItemR(col, op->ptr, "loop_slide", 0, NULL, ICON_NONE); + uiItemR(col, op->ptr, "harden_normals", 0, nullptr, ICON_NONE); + uiItemR(col, op->ptr, "clamp_overlap", 0, nullptr, ICON_NONE); + uiItemR(col, op->ptr, "loop_slide", 0, nullptr, ICON_NONE); col = uiLayoutColumnWithHeading(layout, true, IFACE_("Mark")); uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES); @@ -951,7 +951,7 @@ static void edbm_bevel_ui(bContext *C, wmOperator *op) uiItemR(col, op->ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE); uiItemR(col, op->ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE); if (RNA_enum_get(op->ptr, "miter_inner") == BEVEL_MITER_ARC) { - uiItemR(col, op->ptr, "spread", 0, NULL, ICON_NONE); + uiItemR(col, op->ptr, "spread", 0, nullptr, ICON_NONE); } uiItemS(layout); @@ -965,7 +965,7 @@ static void edbm_bevel_ui(bContext *C, wmOperator *op) uiItemS(layout); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "profile_type", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); if (profile_type == BEVEL_PROFILE_CUSTOM) { /* Get an RNA pointer to ToolSettings to give to the curve profile template code. */ Scene *scene = CTX_data_scene(C); @@ -992,7 +992,7 @@ void MESH_OT_bevel(wmOperatorType *ot) 0, "Absolute", "Amount is absolute distance along adjacent edge"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem prop_profile_type_items[] = { @@ -1006,7 +1006,7 @@ void MESH_OT_bevel(wmOperatorType *ot) 0, "Custom", "The profile can be any arbitrary path between its endpoints"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem face_strength_mode_items[] = { @@ -1018,20 +1018,20 @@ void MESH_OT_bevel(wmOperatorType *ot) "Affected", "Set face strength on new and modified faces only"}, {BEVEL_FACE_STRENGTH_ALL, "ALL", 0, "All", "Set face strength on all faces"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem miter_outer_items[] = { {BEVEL_MITER_SHARP, "SHARP", 0, "Sharp", "Outside of miter is sharp"}, {BEVEL_MITER_PATCH, "PATCH", 0, "Patch", "Outside of miter is squared-off patch"}, {BEVEL_MITER_ARC, "ARC", 0, "Arc", "Outside of miter is arc"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem miter_inner_items[] = { {BEVEL_MITER_SHARP, "SHARP", 0, "Sharp", "Inside of miter is sharp"}, {BEVEL_MITER_ARC, "ARC", 0, "Arc", "Inside of miter is arc"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static EnumPropertyItem vmesh_method_items[] = { @@ -1041,13 +1041,13 @@ void MESH_OT_bevel(wmOperatorType *ot) 0, "Cutoff", "A cutoff at each profile's end before the intersection"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem prop_affect_items[] = { {BEVEL_AFFECT_VERTICES, "VERTICES", 0, "Vertices", "Affect only vertices"}, {BEVEL_AFFECT_EDGES, "EDGES", 0, "Edges", "Affect only edges"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.cc similarity index 84% rename from source/blender/editors/mesh/editmesh_bisect.c rename to source/blender/editors/mesh/editmesh_bisect.cc index fd8fce1a838..37c404b35de 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.cc @@ -47,17 +47,17 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op); /* -------------------------------------------------------------------- */ /* Model Helpers */ -typedef struct { +struct BisectData { /* modal only */ /* Aligned with objects array. */ - struct { + struct BisectDataBackup { BMBackup mesh_backup; bool is_valid; bool is_dirty; } * backup; int backup_len; -} BisectData; +}; static void mesh_bisect_interactive_calc(bContext *C, wmOperator *op, @@ -66,7 +66,7 @@ static void mesh_bisect_interactive_calc(bContext *C, { View3D *v3d = CTX_wm_view3d(C); ARegion *region = CTX_wm_region(C); - RegionView3D *rv3d = region->regiondata; + RegionView3D *rv3d = static_cast(region->regiondata); int x_start = RNA_int_get(op->ptr, "xstart"); int y_start = RNA_int_get(op->ptr, "ystart"); @@ -76,7 +76,9 @@ static void mesh_bisect_interactive_calc(bContext *C, /* reference location (some point in front of the view) for finding a point on a plane */ const float *co_ref = rv3d->ofs; - float co_a_ss[2] = {x_start, y_start}, co_b_ss[2] = {x_end, y_end}, co_delta_ss[2]; + float co_a_ss[2] = {float(x_start), float(y_start)}; + float co_b_ss[2] = {float(x_end), float(y_end)}; + float co_delta_ss[2]; float co_a[3], co_b[3]; const float zfac = ED_view3d_calc_zfac(rv3d, co_ref); @@ -106,8 +108,8 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* If the properties are set or there is no rv3d, * skip modal and exec immediately. */ - if ((CTX_wm_region_view3d(C) == NULL) || (RNA_struct_property_is_set(op->ptr, "plane_co") && - RNA_struct_property_is_set(op->ptr, "plane_no"))) + if ((CTX_wm_region_view3d(C) == nullptr) || (RNA_struct_property_is_set(op->ptr, "plane_co") && + RNA_struct_property_is_set(op->ptr, "plane_no"))) { return mesh_bisect_exec(C, op); } @@ -143,14 +145,15 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event) } if (ret & OPERATOR_RUNNING_MODAL) { - wmGesture *gesture = op->customdata; + wmGesture *gesture = static_cast(op->customdata); BisectData *opdata; - opdata = MEM_mallocN(sizeof(BisectData), "inset_operator_data"); + opdata = static_cast(MEM_mallocN(sizeof(BisectData), "inset_operator_data")); gesture->user_data.data = opdata; opdata->backup_len = objects_len; - opdata->backup = MEM_callocN(sizeof(*opdata->backup) * objects_len, __func__); + opdata->backup = static_cast( + MEM_callocN(sizeof(*opdata->backup) * objects_len, __func__)); /* Store the mesh backups. */ for (uint ob_index = 0; ob_index < objects_len; ob_index++) { @@ -187,8 +190,8 @@ static void edbm_bisect_exit(BisectData *opdata) static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) { - wmGesture *gesture = op->customdata; - BisectData *opdata = gesture->user_data.data; + wmGesture *gesture = static_cast(op->customdata); + BisectData *opdata = static_cast(gesture->user_data.data); BisectData opdata_back = *opdata; /* annoyance, WM_gesture_straightline_modal, frees */ int ret; @@ -200,7 +203,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_workspace_status_text(C, TIP_("LMB: Release to confirm cut line")); } else { - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); } } @@ -228,7 +231,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - /* both can be NULL, fallbacks values are used */ + /* both can be nullptr, fallbacks values are used */ RegionView3D *rv3d = ED_view3d_context_rv3d(C); int ret = OPERATOR_CANCELLED; @@ -270,13 +273,14 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) RNA_property_float_set_array(op->ptr, prop_plane_no, plane_no); } - wmGesture *gesture = op->customdata; - BisectData *opdata = (gesture != NULL) ? gesture->user_data.data : NULL; + wmGesture *gesture = static_cast(op->customdata); + BisectData *opdata = static_cast((gesture != nullptr) ? gesture->user_data.data : + nullptr); /* -------------------------------------------------------------------- */ /* Modal support */ /* NOTE: keep this isolated, exec can work without this. */ - if (opdata != NULL) { + if (opdata != nullptr) { mesh_bisect_interactive_calc(C, op, plane_co, plane_no); /* Write back to the props. */ RNA_property_float_set_array(op->ptr, prop_plane_no, plane_no); @@ -294,7 +298,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; - if (opdata != NULL) { + if (opdata != nullptr) { if (opdata->backup[ob_index].is_dirty) { EDBM_redo_state_restore(&opdata->backup[ob_index].mesh_backup, em, false); opdata->backup[ob_index].is_dirty = false; @@ -305,7 +309,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) continue; } - if (opdata != NULL) { + if (opdata != nullptr) { if (opdata->backup[ob_index].is_valid) { opdata->backup[ob_index].is_dirty = true; } @@ -378,12 +382,11 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op) bm, bmop.slots_out, "geom_cut.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true); if (EDBM_op_finish(em, &bmop, op, true)) { - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); EDBM_selectmode_flush(em); ret = OPERATOR_FINISHED; } @@ -418,7 +421,7 @@ void MESH_OT_bisect(wmOperatorType *ot) prop = RNA_def_float_vector_xyz(ot->srna, "plane_co", 3, - NULL, + nullptr, -1e12f, 1e12f, "Plane Point", @@ -429,7 +432,7 @@ void MESH_OT_bisect(wmOperatorType *ot) prop = RNA_def_float_vector(ot->srna, "plane_no", 3, - NULL, + nullptr, -1.0f, 1.0f, "Plane Normal", @@ -471,7 +474,7 @@ void MESH_OT_bisect(wmOperatorType *ot) /** \name Bisect Gizmo * \{ */ -typedef struct GizmoGroup { +struct GizmoGroup { /* Arrow to change plane depth. */ wmGizmo *translate_z; /* Translate XYZ */ @@ -489,7 +492,7 @@ typedef struct GizmoGroup { float rotate_axis[3]; float rotate_up[3]; } data; -} GizmoGroup; +}; /** * XXX. calling redo from property updates is not great. @@ -539,9 +542,9 @@ static void gizmo_mesh_bisect_update_from_op(GizmoGroup *ggd) /* depth callbacks */ static void gizmo_bisect_prop_depth_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *ggd = gz->parent_gzgroup->customdata; + GizmoGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -557,9 +560,9 @@ static void gizmo_bisect_prop_depth_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *ggd = gz->parent_gzgroup->customdata; + GizmoGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - const float *value = value_p; + const float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -584,26 +587,27 @@ static void gizmo_bisect_prop_translate_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *ggd = gz->parent_gzgroup->customdata; + GizmoGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 3); UNUSED_VARS_NDEBUG(gz_prop); - RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_co, value_p); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_co, static_cast(value_p)); } static void gizmo_bisect_prop_translate_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *ggd = gz->parent_gzgroup->customdata; + GizmoGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 3); UNUSED_VARS_NDEBUG(gz_prop); - RNA_property_float_set_array(op->ptr, ggd->data.prop_plane_co, value_p); + RNA_property_float_set_array( + op->ptr, ggd->data.prop_plane_co, static_cast(value_p)); gizmo_bisect_exec(ggd); } @@ -611,9 +615,9 @@ static void gizmo_bisect_prop_translate_set(const wmGizmo *gz, /* angle callbacks */ static void gizmo_bisect_prop_angle_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *ggd = gz->parent_gzgroup->customdata; + GizmoGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -639,9 +643,9 @@ static void gizmo_bisect_prop_angle_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *ggd = gz->parent_gzgroup->customdata; + GizmoGroup *ggd = static_cast(gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - const float *value = value_p; + const float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -679,20 +683,20 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) { wmOperator *op = WM_operator_last_redo(C); - if (op == NULL || !STREQ(op->type->idname, "MESH_OT_bisect")) { + if (op == nullptr || !STREQ(op->type->idname, "MESH_OT_bisect")) { return; } - GizmoGroup *ggd = MEM_callocN(sizeof(GizmoGroup), __func__); + GizmoGroup *ggd = static_cast(MEM_callocN(sizeof(GizmoGroup), __func__)); gzgroup->customdata = ggd; const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true); const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); - ggd->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); - ggd->translate_c = WM_gizmo_new_ptr(gzt_move, gzgroup, NULL); - ggd->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + ggd->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, nullptr); + ggd->translate_c = WM_gizmo_new_ptr(gzt_move, gzgroup, nullptr); + ggd->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, nullptr); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, ggd->translate_z->color); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, ggd->translate_c->color); @@ -715,38 +719,38 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Setup property callbacks */ { - WM_gizmo_target_property_def_func(ggd->translate_z, - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_bisect_prop_depth_get, - .value_set_fn = gizmo_bisect_prop_depth_set, - .range_get_fn = NULL, - .user_data = NULL, - }); + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_bisect_prop_depth_get; + params.value_set_fn = gizmo_bisect_prop_depth_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->translate_z, "offset", ¶ms); + } - WM_gizmo_target_property_def_func(ggd->translate_c, - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_bisect_prop_translate_get, - .value_set_fn = gizmo_bisect_prop_translate_set, - .range_get_fn = NULL, - .user_data = NULL, - }); + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_bisect_prop_translate_get; + params.value_set_fn = gizmo_bisect_prop_translate_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->translate_c, "offset", ¶ms); + } - WM_gizmo_target_property_def_func(ggd->rotate_c, - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_bisect_prop_angle_get, - .value_set_fn = gizmo_bisect_prop_angle_set, - .range_get_fn = NULL, - .user_data = NULL, - }); + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_bisect_prop_angle_get; + params.value_set_fn = gizmo_bisect_prop_angle_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->rotate_c, "offset", ¶ms); + } } } -static void gizmo_mesh_bisect_draw_prepare(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) +static void gizmo_mesh_bisect_draw_prepare(const bContext * /*C*/, wmGizmoGroup *gzgroup) { - GizmoGroup *ggd = gzgroup->customdata; + GizmoGroup *ggd = static_cast(gzgroup->customdata); if (ggd->data.op->next) { ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context); } diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.cc similarity index 92% rename from source/blender/editors/mesh/editmesh_extrude.c rename to source/blender/editors/mesh/editmesh_extrude.cc index a86f0e0c320..1fe4dc0a798 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.cc @@ -45,7 +45,7 @@ static void edbm_extrude_edge_exclude_mirror( /* If a mirror modifier with clipping is on, we need to adjust some * of the cases above to handle edges on the line of symmetry. */ - for (md = obedit->modifiers.first; md; md = md->next) { + for (md = static_cast(obedit->modifiers.first); md; md = md->next) { if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData *)md; @@ -269,11 +269,12 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) if (!RNA_property_is_set(op->ptr, prop)) { RegionView3D *rv3d = CTX_wm_region_view3d(C); - if (rv3d != NULL) { + if (rv3d != nullptr) { normalize_v3_v3(offset, rv3d->persinv[2]); } else { - copy_v3_v3(offset, (const float[3]){0, 0, 1}); + const float up[3] = {0, 0, 1}; + copy_v3_v3(offset, up); } RNA_property_float_set_array(op->ptr, prop, offset); } @@ -305,12 +306,11 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) em->bm, BMO_FLAG_DEFAULTS, "translate vec=%v verts=%hv", offset_local, BM_ELEM_SELECT); } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); @@ -334,8 +334,16 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) /* props */ RNA_def_int(ot->srna, "steps", 10, 0, 1000000, "Steps", "", 0, 180); - PropertyRNA *prop = RNA_def_float_vector_xyz( - ot->srna, "offset", 3, NULL, -100000, 100000, "Offset", "Offset vector", -1000.0f, 1000.0f); + PropertyRNA *prop = RNA_def_float_vector_xyz(ot->srna, + "offset", + 3, + nullptr, + -100000, + 100000, + "Offset", + "Offset vector", + -1000.0f, + 1000.0f); RNA_def_property_flag(prop, PROP_SKIP_SAVE); RNA_def_float(ot->srna, "scale_offset", 1.0f, 0.0f, 1e12f, "Scale Offset", "", 0.0f, 100.0f); } @@ -439,12 +447,11 @@ static int edbm_extrude_region_exec(bContext *C, wmOperator *op) } /* This normally happens when pushing undo but modal operators * like this one don't push undo data until after modal mode is done. */ - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); return OPERATOR_FINISHED; @@ -498,12 +505,11 @@ static int edbm_extrude_context_exec(bContext *C, wmOperator *op) /* This normally happens when pushing undo but modal operators * like this one don't push undo data until after modal mode is done. */ - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); return OPERATOR_FINISHED; @@ -551,12 +557,11 @@ static int edbm_extrude_verts_exec(bContext *C, wmOperator *op) edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); @@ -605,12 +610,11 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op) edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, use_normal_flip); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); @@ -659,12 +663,11 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); @@ -899,12 +902,11 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w /* This normally happens when pushing undo but modal operators * like this one don't push undo data until after modal mode is done. */ - EDBM_update(vc.obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(vc.obedit->data), ¶ms); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); diff --git a/source/blender/editors/mesh/editmesh_extrude_screw.c b/source/blender/editors/mesh/editmesh_extrude_screw.cc similarity index 90% rename from source/blender/editors/mesh/editmesh_extrude_screw.c rename to source/blender/editors/mesh/editmesh_extrude_screw.cc index 6336b18a471..5f8d29a0aa6 100644 --- a/source/blender/editors/mesh/editmesh_extrude_screw.c +++ b/source/blender/editors/mesh/editmesh_extrude_screw.cc @@ -73,8 +73,8 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) } /* find two vertices with valence count == 1, more or less is wrong */ - v1 = NULL; - v2 = NULL; + v1 = nullptr; + v2 = nullptr; BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { valence = 0; @@ -85,20 +85,20 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) } if (valence == 1) { - if (v1 == NULL) { + if (v1 == nullptr) { v1 = eve; } - else if (v2 == NULL) { + else if (v2 == nullptr) { v2 = eve; } else { - v1 = NULL; + v1 = nullptr; break; } } } - if (v1 == NULL || v2 == NULL) { + if (v1 == nullptr || v2 == nullptr) { failed_verts_len++; continue; } @@ -142,12 +142,11 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) continue; } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); @@ -162,7 +161,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) } /* get center and axis, in global coords */ -static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int edbm_screw_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Scene *scene = CTX_data_scene(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); @@ -205,7 +204,7 @@ void MESH_OT_screw(wmOperatorType *ot) RNA_def_float_vector_xyz(ot->srna, "center", 3, - NULL, + nullptr, -1e12f, 1e12f, "Center", @@ -213,7 +212,7 @@ void MESH_OT_screw(wmOperatorType *ot) -1e4f, 1e4f); RNA_def_float_vector( - ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); + ot->srna, "axis", 3, nullptr, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); } /** \} */ diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.cc similarity index 93% rename from source/blender/editors/mesh/editmesh_extrude_spin.c rename to source/blender/editors/mesh/editmesh_extrude_spin.cc index 33edc869c82..87d3f4ace1f 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.cc @@ -95,12 +95,11 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) continue; } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); @@ -109,7 +108,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) } /* get center and axis, in global coords */ -static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); @@ -153,7 +152,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e return ret; } -static bool edbm_spin_poll_property(const bContext *UNUSED(C), +static bool edbm_spin_poll_property(const bContext * /*C*/, wmOperator *op, const PropertyRNA *prop) { @@ -213,7 +212,7 @@ void MESH_OT_spin(wmOperatorType *ot) RNA_def_float_vector_xyz(ot->srna, "center", 3, - NULL, + nullptr, -1e12f, 1e12f, "Center", @@ -221,7 +220,7 @@ void MESH_OT_spin(wmOperatorType *ot) -1e4f, 1e4f); RNA_def_float_vector( - ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); + ot->srna, "axis", 3, nullptr, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); WM_gizmogrouptype_append(MESH_GGT_spin); #ifdef USE_GIZMO diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc similarity index 83% rename from source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c rename to source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc index 7ec58b77dbf..ebcc4f1378b 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.cc @@ -55,7 +55,7 @@ static const float dial_angle_partial_margin = 0.92f; /** \name Spin Tool Gizmo * \{ */ -typedef struct GizmoGroupData_SpinInit { +struct GizmoGroupData_SpinInit { struct { wmGizmo *xyz_view[4]; wmGizmo *icon_button[3][2]; @@ -82,8 +82,7 @@ typedef struct GizmoGroupData_SpinInit { struct { int ortho_axis_active; } invoke; - -} GizmoGroupData_SpinInit; +}; /* Use dials only as a visualization when hovering over the icons. */ #define USE_DIAL_HOVER @@ -96,7 +95,7 @@ static const uchar shape_plus[] = { 0x8c, 0x8c, 0xc9, 0x73, 0xc9, 0x73, 0x8c, 0x36, 0x8c, 0x36, 0x73, 0x36, 0x73, }; -static void gizmo_mesh_spin_init_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) +static void gizmo_mesh_spin_init_setup(const bContext * /*C*/, wmGizmoGroup *gzgroup) { /* alpha values for normal/highlighted states */ const float alpha = 0.6f; @@ -104,14 +103,15 @@ static void gizmo_mesh_spin_init_setup(const bContext *UNUSED(C), wmGizmoGroup * const float scale_base = INIT_SCALE_BASE; const float scale_button = INIT_SCALE_BUTTON; - GizmoGroupData_SpinInit *ggd = MEM_callocN(sizeof(*ggd), __func__); + GizmoGroupData_SpinInit *ggd = static_cast( + MEM_callocN(sizeof(*ggd), __func__)); gzgroup->customdata = ggd; const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); const wmGizmoType *gzt_button = WM_gizmotype_find("GIZMO_GT_button_2d", true); for (int i = 0; i < 3; i++) { for (int j = 0; j < 2; j++) { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_button, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_button, gzgroup, nullptr); PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "shape"); RNA_property_string_set_bytes( gz->ptr, prop, (const char *)shape_plus, ARRAY_SIZE(shape_plus)); @@ -133,7 +133,7 @@ static void gizmo_mesh_spin_init_setup(const bContext *UNUSED(C), wmGizmoGroup * } for (int i = 0; i < ARRAY_SIZE(ggd->gizmos.xyz_view); i++) { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, nullptr); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_VALUE | WM_GIZMO_HIDDEN_SELECT, true); ggd->gizmos.xyz_view[i] = gz; @@ -187,26 +187,26 @@ static void gizmo_mesh_spin_init_refresh_axis_orientation(wmGizmoGroup *gzgroup, const float axis_vec[3], const float axis_tan[3]) { - GizmoGroupData_SpinInit *ggd = gzgroup->customdata; + GizmoGroupData_SpinInit *ggd = static_cast(gzgroup->customdata); wmGizmo *gz = ggd->gizmos.xyz_view[axis_index]; - if (axis_tan != NULL) { + if (axis_tan != nullptr) { WM_gizmo_set_matrix_rotation_from_yz_axis(gz, axis_tan, axis_vec); } else { WM_gizmo_set_matrix_rotation_from_z_axis(gz, axis_vec); } - /* Only for display, use icons to access. */ +/* Only for display, use icons to access. */ #ifndef USE_DIAL_HOVER { - PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, nullptr); RNA_float_set_array(ptr, "axis", axis_vec); } #endif if (axis_index < 3) { for (int j = 0; j < 2; j++) { gz = ggd->gizmos.icon_button[axis_index][j]; - PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, NULL); + PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, nullptr); float axis_vec_flip[3]; if (0 == j) { negate_v3_v3(axis_vec_flip, axis_vec); @@ -221,7 +221,7 @@ static void gizmo_mesh_spin_init_refresh_axis_orientation(wmGizmoGroup *gzgroup, static void gizmo_mesh_spin_init_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoGroupData_SpinInit *ggd = gzgroup->customdata; + GizmoGroupData_SpinInit *ggd = static_cast(gzgroup->customdata); RegionView3D *rv3d = CTX_wm_region_view3d(C); float viewinv_m3[3][3]; copy_m3_m4(viewinv_m3, rv3d->viewinv); @@ -244,11 +244,11 @@ static void gizmo_mesh_spin_init_draw_prepare(const bContext *C, wmGizmoGroup *g /* Refresh handled above when using view orientation. */ if (!equals_m3m3(viewinv_m3, ggd->prev.viewinv_m3)) { - gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, 3, rv3d->viewinv[2], NULL); + gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, 3, rv3d->viewinv[2], nullptr); copy_m3_m4(ggd->prev.viewinv_m3, rv3d->viewinv); } - /* Hack! highlight XYZ dials based on buttons */ +/* Hack! highlight XYZ dials based on buttons */ #ifdef USE_DIAL_HOVER { PointerRNA ptr; @@ -281,13 +281,13 @@ static void gizmo_mesh_spin_init_draw_prepare(const bContext *C, wmGizmoGroup *g #endif } -static void gizmo_mesh_spin_init_invoke_prepare(const bContext *UNUSED(C), +static void gizmo_mesh_spin_init_invoke_prepare(const bContext * /*C*/, wmGizmoGroup *gzgroup, wmGizmo *gz, - const wmEvent *UNUSED(event)) + const wmEvent * /*event*/) { /* Set the initial ortho axis. */ - GizmoGroupData_SpinInit *ggd = gzgroup->customdata; + GizmoGroupData_SpinInit *ggd = static_cast(gzgroup->customdata); ggd->invoke.ortho_axis_active = -1; for (int i = 0; i < 3; i++) { if (ELEM(gz, UNPACK2(ggd->gizmos.icon_button[i]))) { @@ -299,9 +299,9 @@ static void gizmo_mesh_spin_init_invoke_prepare(const bContext *UNUSED(C), static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - GizmoGroupData_SpinInit *ggd = gzgroup->customdata; + GizmoGroupData_SpinInit *ggd = static_cast(gzgroup->customdata); RegionView3D *rv3d = ED_view3d_context_rv3d((bContext *)C); - const float *gizmo_center = NULL; + const float *gizmo_center = nullptr; { Scene *scene = CTX_data_scene(C); const View3DCursor *cursor = &scene->cursor; @@ -340,7 +340,7 @@ static void gizmo_mesh_spin_init_refresh(const bContext *C, wmGizmoGroup *gzgrou } { - gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, 3, rv3d->viewinv[2], NULL); + gizmo_mesh_spin_init_refresh_axis_orientation(gzgroup, 3, rv3d->viewinv[2], nullptr); } #ifdef USE_SELECT_CENTER @@ -416,32 +416,25 @@ static void gizmo_mesh_spin_init_message_subscribe(const bContext *C, wmGizmoGroup *gzgroup, struct wmMsgBus *mbus) { - GizmoGroupData_SpinInit *ggd = gzgroup->customdata; + GizmoGroupData_SpinInit *ggd = static_cast(gzgroup->customdata); Scene *scene = CTX_data_scene(C); ARegion *region = CTX_wm_region(C); /* Subscribe to view properties */ - wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = { - .owner = region, - .user_data = gzgroup->parent_gzmap, - .notify = WM_gizmo_do_msg_notify_tag_refresh, - }; + wmMsgSubscribeValue msg_sub_value_gz_tag_refresh{}; + msg_sub_value_gz_tag_refresh.owner = region; + msg_sub_value_gz_tag_refresh.user_data = gzgroup->parent_gzmap; + msg_sub_value_gz_tag_refresh.notify = WM_gizmo_do_msg_notify_tag_refresh; PointerRNA cursor_ptr; RNA_pointer_create(&scene->id, &RNA_View3DCursor, &scene->cursor, &cursor_ptr); /* All cursor properties. */ - WM_msg_subscribe_rna(mbus, &cursor_ptr, NULL, &msg_sub_value_gz_tag_refresh, __func__); + WM_msg_subscribe_rna(mbus, &cursor_ptr, nullptr, &msg_sub_value_gz_tag_refresh, __func__); - WM_msg_subscribe_rna_params(mbus, - &(const wmMsgParams_RNA){ - .ptr = - (PointerRNA){ - .type = gzgroup->type->srna, - }, - .prop = ggd->data.gzgt_axis_prop, - }, - &msg_sub_value_gz_tag_refresh, - __func__); + wmMsgParams_RNA params{}; + params.ptr.type = gzgroup->type->srna; + params.prop = ggd->data.gzgt_axis_prop, + WM_msg_subscribe_rna_params(mbus, ¶ms, &msg_sub_value_gz_tag_refresh, __func__); } void MESH_GGT_spin(wmGizmoGroupType *gzgt) @@ -483,7 +476,7 @@ void MESH_GGT_spin(wmGizmoGroupType *gzgt) */ #define USE_ANGLE_Z_ORIENT -typedef struct GizmoGroupData_SpinRedo { +struct GizmoGroupData_SpinRedo { /* Translate XYZ. */ wmGizmo *translate_c; /* Spin angle */ @@ -526,7 +519,7 @@ typedef struct GizmoGroupData_SpinRedo { float orient_mat[3][3]; } data; -} GizmoGroupData_SpinRedo; +}; /** * XXX. calling redo from property updates is not great. @@ -612,9 +605,10 @@ static void gizmo_mesh_spin_redo_update_from_op(GizmoGroupData_SpinRedo *ggd) /* depth callbacks */ static void gizmo_spin_prop_depth_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -630,9 +624,10 @@ static void gizmo_spin_prop_depth_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - const float *value = value_p; + const float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -656,9 +651,10 @@ static void gizmo_spin_prop_translate_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 3); UNUSED_VARS_NDEBUG(gz_prop); @@ -670,13 +666,14 @@ static void gizmo_spin_prop_translate_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 3); UNUSED_VARS_NDEBUG(gz_prop); - RNA_property_float_set_array(op->ptr, ggd->data.prop_axis_co, value); + RNA_property_float_set_array(op->ptr, ggd->data.prop_axis_co, static_cast(value)); gizmo_spin_exec(ggd); } @@ -686,9 +683,10 @@ static void gizmo_spin_prop_axis_angle_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -717,9 +715,10 @@ static void gizmo_spin_prop_axis_angle_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - const float *value = value_p; + const float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -754,9 +753,10 @@ static void gizmo_spin_prop_axis_angle_set(const wmGizmo *gz, /* angle callbacks */ static void gizmo_spin_prop_angle_get(const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; - float *value = value_p; + float *value = static_cast(value_p); BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); @@ -767,11 +767,12 @@ static void gizmo_spin_prop_angle_set(const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroupData_SpinRedo *ggd = gz->parent_gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast( + gz->parent_gzgroup->customdata); wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); - const float *value = value_p; + const float *value = static_cast(value_p); RNA_property_float_set(op->ptr, ggd->data.prop_angle, value[0]); gizmo_spin_exec(ggd); @@ -790,7 +791,7 @@ static bool gizmo_mesh_spin_redo_poll(const bContext *C, wmGizmoGroupType *gzgt) static void gizmo_mesh_spin_redo_modal_from_setup(const bContext *C, wmGizmoGroup *gzgroup) { /* Start off dragging. */ - GizmoGroupData_SpinRedo *ggd = gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast(gzgroup->customdata); wmWindow *win = CTX_wm_window(C); wmGizmo *gz = ggd->angle_z; wmGizmoMap *gzmap = gzgroup->parent_gzmap; @@ -805,11 +806,12 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) wmOperatorType *ot = WM_operatortype_find("MESH_OT_spin", true); wmOperator *op = WM_operator_last_redo(C); - if ((op == NULL) || (op->type != ot)) { + if ((op == nullptr) || (op->type != ot)) { return; } - GizmoGroupData_SpinRedo *ggd = MEM_callocN(sizeof(*ggd), __func__); + GizmoGroupData_SpinRedo *ggd = static_cast( + MEM_callocN(sizeof(*ggd), __func__)); gzgroup->customdata = ggd; const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); @@ -818,7 +820,7 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Rotate View Axis (rotate_view) */ { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, nullptr); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); zero_v4(gz->color); copy_v3_fl(gz->color_hi, 1.0f); @@ -833,7 +835,7 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Translate Center (translate_c) */ { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_move, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_move, gzgroup, nullptr); UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color); gz->color[3] = 0.6f; RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_MOVE_STYLE_RING_2D); @@ -845,7 +847,7 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Spin Angle (angle_z) */ { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, nullptr); copy_v3_v3(gz->color, gz->color_hi); gz->color[3] = 0.5f; RNA_boolean_set(gz->ptr, "wrap_angle", false); @@ -860,7 +862,7 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Translate X/Y Tangents (translate_xy) */ for (int i = 0; i < 2; i++) { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_arrow, gzgroup, nullptr); UI_GetThemeColor3fv(TH_AXIS_X + i, gz->color); RNA_enum_set(gz->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL); RNA_enum_set(gz->ptr, "draw_options", 0); @@ -870,7 +872,7 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Rotate X/Y Tangents (rotate_xy) */ for (int i = 0; i < 2; i++) { - wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + wmGizmo *gz = WM_gizmo_new_ptr(gzt_dial, gzgroup, nullptr); UI_GetThemeColor3fv(TH_AXIS_X + i, gz->color); gz->color[3] = 0.6f; WM_gizmo_set_flag(gz, WM_GIZMO_DRAW_VALUE, true); @@ -901,7 +903,8 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) wmGizmoMap *gzmap = region->gizmo_map; wmGizmoGroup *gzgroup_init = WM_gizmomap_group_find(gzmap, "MESH_GGT_spin"); if (gzgroup_init) { - GizmoGroupData_SpinInit *ggd_init = gzgroup_init->customdata; + GizmoGroupData_SpinInit *ggd_init = static_cast( + gzgroup_init->customdata); copy_m3_m3(ggd->data.orient_mat, ggd_init->data.orient_mat); if (ggd_init->invoke.ortho_axis_active != -1) { copy_v3_v3(ggd->data.orient_axis_relative, @@ -951,51 +954,48 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) /* Setup property callbacks */ { - WM_gizmo_target_property_def_func(ggd->translate_c, - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_spin_prop_translate_get, - .value_set_fn = gizmo_spin_prop_translate_set, - .range_get_fn = NULL, - .user_data = NULL, - }); - - WM_gizmo_target_property_def_func(ggd->rotate_view, - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_spin_prop_axis_angle_get, - .value_set_fn = gizmo_spin_prop_axis_angle_set, - .range_get_fn = NULL, - .user_data = NULL, - }); - - for (int i = 0; i < 2; i++) { - WM_gizmo_target_property_def_func(ggd->rotate_xy[i], - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_spin_prop_axis_angle_get, - .value_set_fn = gizmo_spin_prop_axis_angle_set, - .range_get_fn = NULL, - .user_data = NULL, - }); - WM_gizmo_target_property_def_func(ggd->translate_xy[i], - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_spin_prop_depth_get, - .value_set_fn = gizmo_spin_prop_depth_set, - .range_get_fn = NULL, - .user_data = NULL, - }); + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_spin_prop_translate_get; + params.value_set_fn = gizmo_spin_prop_translate_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->translate_c, "offset", ¶ms); } - WM_gizmo_target_property_def_func(ggd->angle_z, - "offset", - &(const wmGizmoPropertyFnParams){ - .value_get_fn = gizmo_spin_prop_angle_get, - .value_set_fn = gizmo_spin_prop_angle_set, - .range_get_fn = NULL, - .user_data = NULL, - }); + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_spin_prop_axis_angle_get; + params.value_set_fn = gizmo_spin_prop_axis_angle_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->rotate_view, "offset", ¶ms); + } + + for (int i = 0; i < 2; i++) { + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_spin_prop_axis_angle_get, + params.value_set_fn = gizmo_spin_prop_axis_angle_set, params.range_get_fn = nullptr, + params.user_data = nullptr, + WM_gizmo_target_property_def_func(ggd->rotate_xy[i], "offset", ¶ms); + } + { + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_spin_prop_depth_get; + params.value_set_fn = gizmo_spin_prop_depth_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->translate_xy[i], "offset", ¶ms); + } + } + + wmGizmoPropertyFnParams params{}; + params.value_get_fn = gizmo_spin_prop_angle_get; + params.value_set_fn = gizmo_spin_prop_angle_set; + params.range_get_fn = nullptr; + params.user_data = nullptr; + WM_gizmo_target_property_def_func(ggd->angle_z, "offset", ¶ms); } wmWindow *win = CTX_wm_window(C); @@ -1011,9 +1011,9 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup) } } -static void gizmo_mesh_spin_redo_draw_prepare(const bContext *UNUSED(C), wmGizmoGroup *gzgroup) +static void gizmo_mesh_spin_redo_draw_prepare(const bContext * /*C*/, wmGizmoGroup *gzgroup) { - GizmoGroupData_SpinRedo *ggd = gzgroup->customdata; + GizmoGroupData_SpinRedo *ggd = static_cast(gzgroup->customdata); if (ggd->data.op->next) { ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context); } diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.cc similarity index 94% rename from source/blender/editors/mesh/editmesh_inset.c rename to source/blender/editors/mesh/editmesh_inset.cc index f8ee3b0b984..86c02af89f9 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.cc @@ -39,13 +39,13 @@ #include "mesh_intern.h" /* own include */ -typedef struct { +struct InsetObjectStore { /** Must have a valid edit-mesh. */ Object *ob; BMBackup mesh_backup; -} InsetObjectStore; +}; -typedef struct { +struct InsetData { float old_thickness; float old_depth; bool modify_depth; @@ -64,11 +64,11 @@ typedef struct { int launch_event; float mcenter[2]; void *draw_handle_pixel; -} InsetData; +}; static void edbm_inset_update_header(wmOperator *op, bContext *C) { - InsetData *opdata = op->customdata; + InsetData *opdata = static_cast(op->customdata); const char *str = TIP_( "Confirm: Enter/LClick, Cancel: (Esc/RClick), Thickness: %s, " @@ -124,7 +124,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) RNA_float_set(op->ptr, "depth", 0.0f); } - op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data"); + op->customdata = opdata = static_cast( + MEM_mallocN(sizeof(InsetData), "inset_operator_data")); uint objects_used_len = 0; @@ -134,7 +135,8 @@ static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal) uint ob_store_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data( scene, view_layer, CTX_wm_view3d(C), &ob_store_len); - opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__); + opdata->ob_store = static_cast( + MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__)); for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) { Object *obedit = objects[ob_index]; float scale = mat4_to_scale(obedit->object_to_world); @@ -184,7 +186,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) InsetData *opdata; ScrArea *area = CTX_wm_area(C); - opdata = op->customdata; + opdata = static_cast(op->customdata); if (opdata->is_modal) { ARegion *region = CTX_wm_region(C); @@ -196,7 +198,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) } if (area) { - ED_area_status_text(area, NULL); + ED_area_status_text(area, nullptr); } MEM_SAFE_FREE(opdata->ob_store); @@ -207,18 +209,17 @@ static void edbm_inset_cancel(bContext *C, wmOperator *op) { InsetData *opdata; - opdata = op->customdata; + opdata = static_cast(op->customdata); if (opdata->is_modal) { for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { Object *obedit = opdata->ob_store[ob_index].ob; BMEditMesh *em = BKE_editmesh_from_object(obedit); EDBM_redo_state_restore_and_free(&opdata->ob_store[ob_index].mesh_backup, em, true); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } } @@ -246,7 +247,7 @@ static bool edbm_inset_calc(wmOperator *op) const bool use_individual = RNA_boolean_get(op->ptr, "use_individual"); const bool use_interpolate = RNA_boolean_get(op->ptr, "use_interpolate"); - opdata = op->customdata; + opdata = static_cast(op->customdata); for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) { Object *obedit = opdata->ob_store[ob_index].ob; @@ -308,12 +309,11 @@ static bool edbm_inset_calc(wmOperator *op) continue; } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); changed = true; } return changed; @@ -345,7 +345,7 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - opdata = op->customdata; + opdata = static_cast(op->customdata); opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type); @@ -370,7 +370,7 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event) static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) { - InsetData *opdata = op->customdata; + InsetData *opdata = static_cast(op->customdata); const bool has_numinput = hasNumInput(&opdata->num_input); /* Modal numinput active, try to handle numeric inputs first... */ diff --git a/source/blender/editors/mesh/editmesh_intersect.c b/source/blender/editors/mesh/editmesh_intersect.cc similarity index 88% rename from source/blender/editors/mesh/editmesh_intersect.c rename to source/blender/editors/mesh/editmesh_intersect.cc index 7d3e4232ce0..b2799a57848 100644 --- a/source/blender/editors/mesh/editmesh_intersect.c +++ b/source/blender/editors/mesh/editmesh_intersect.cc @@ -47,7 +47,7 @@ /** * Compare selected with itself. */ -static int bm_face_isect_self(BMFace *f, void *UNUSED(user_data)) +static int bm_face_isect_self(BMFace *f, void * /*user_data*/) { if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { return 0; @@ -58,7 +58,7 @@ static int bm_face_isect_self(BMFace *f, void *UNUSED(user_data)) /** * Compare selected/unselected. */ -static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data)) +static int bm_face_isect_pair(BMFace *f, void * /*user_data*/) { if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { return -1; @@ -73,7 +73,7 @@ static int bm_face_isect_pair(BMFace *f, void *UNUSED(user_data)) * A flipped version of #bm_face_isect_pair * use for boolean 'difference', which depends on order. */ -static int bm_face_isect_pair_swap(BMFace *f, void *UNUSED(user_data)) +static int bm_face_isect_pair_swap(BMFace *f, void * /*user_data*/) { if (BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { return -1; @@ -105,12 +105,11 @@ static void edbm_intersect_select(BMEditMesh *em, struct Mesh *me, bool do_selec } } - EDBM_update(me, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(me, ¶ms); } /* -------------------------------------------------------------------- */ @@ -202,7 +201,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op) em->looptris, em->tottri, test_fn, - NULL, + nullptr, nshapes, use_self, use_separate_all, @@ -214,7 +213,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op) em->looptris, em->tottri, test_fn, - NULL, + nullptr, use_self, use_separate_all, true, @@ -231,7 +230,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op) em->bm, BM_elem_cb_check_hflag_enabled_simple(const BMFace *, BM_ELEM_SELECT)); } - edbm_intersect_select(em, obedit->data, has_isect); + edbm_intersect_select(em, static_cast(obedit->data), has_isect); if (!has_isect) { isect_len++; @@ -245,7 +244,7 @@ static int edbm_intersect_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void edbm_intersect_ui(bContext *UNUSED(C), wmOperator *op) +static void edbm_intersect_ui(bContext * /*C*/, wmOperator *op) { uiLayout *layout = op->layout; uiLayout *row; @@ -255,18 +254,18 @@ static void edbm_intersect_ui(bContext *UNUSED(C), wmOperator *op) uiLayoutSetPropSep(layout, true); uiLayoutSetPropDecorate(layout, false); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemS(layout); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "separate_mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "separate_mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemS(layout); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "solver", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemS(layout); if (!use_exact) { - uiItemR(layout, op->ptr, "threshold", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "threshold", 0, nullptr, ICON_NONE); } } @@ -279,7 +278,7 @@ void MESH_OT_intersect(wmOperatorType *ot) 0, "Selected/Unselected", "Intersect selected with unselected faces"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem isect_separate_items[] = { @@ -290,13 +289,13 @@ void MESH_OT_intersect(wmOperatorType *ot) "Cut", "Cut into geometry keeping each side separate (Selected/Unselected only)"}, {ISECT_SEPARATE_NONE, "NONE", 0, "Merge", "Merge all geometry from the intersection"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem isect_intersect_solver_items[] = { {ISECT_SOLVER_FAST, "FAST", 0, "Fast", "Faster solver, some limitations"}, {ISECT_SOLVER_EXACT, "EXACT", 0, "Exact", "Exact solver, slower, handles more cases"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -372,7 +371,7 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) em->looptris, em->tottri, test_fn, - NULL, + nullptr, 2, use_self, true, @@ -384,7 +383,7 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) em->looptris, em->tottri, test_fn, - NULL, + nullptr, false, false, true, @@ -395,7 +394,7 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) eps); } - edbm_intersect_select(em, obedit->data, has_isect); + edbm_intersect_select(em, static_cast(obedit->data), has_isect); if (!has_isect) { isect_len++; @@ -409,7 +408,7 @@ static int edbm_intersect_boolean_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static void edbm_intersect_boolean_ui(bContext *UNUSED(C), wmOperator *op) +static void edbm_intersect_boolean_ui(bContext * /*C*/, wmOperator *op) { uiLayout *layout = op->layout; uiLayout *row; @@ -420,17 +419,17 @@ static void edbm_intersect_boolean_ui(bContext *UNUSED(C), wmOperator *op) uiLayoutSetPropDecorate(layout, false); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "operation", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "operation", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemS(layout); row = uiLayoutRow(layout, false); - uiItemR(row, op->ptr, "solver", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + uiItemR(row, op->ptr, "solver", UI_ITEM_R_EXPAND, nullptr, ICON_NONE); uiItemS(layout); - uiItemR(layout, op->ptr, "use_swap", 0, NULL, ICON_NONE); - uiItemR(layout, op->ptr, "use_self", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "use_swap", 0, nullptr, ICON_NONE); + uiItemR(layout, op->ptr, "use_self", 0, nullptr, ICON_NONE); if (!use_exact) { - uiItemR(layout, op->ptr, "threshold", 0, NULL, ICON_NONE); + uiItemR(layout, op->ptr, "threshold", 0, nullptr, ICON_NONE); } } @@ -440,13 +439,13 @@ void MESH_OT_intersect_boolean(wmOperatorType *ot) {BMESH_ISECT_BOOLEAN_ISECT, "INTERSECT", 0, "Intersect", ""}, {BMESH_ISECT_BOOLEAN_UNION, "UNION", 0, "Union", ""}, {BMESH_ISECT_BOOLEAN_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem isect_boolean_solver_items[] = { {ISECT_SOLVER_FAST, "FAST", 0, "Fast", "Faster solver, some limitations"}, {ISECT_SOLVER_EXACT, "EXACT", 0, "Exact", "Exact solver, slower, handles more cases"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -494,8 +493,7 @@ void MESH_OT_intersect_boolean(wmOperatorType *ot) static void bm_face_split_by_edges(BMesh *bm, BMFace *f, - const char hflag, - /* reusable memory buffer */ + const char hflag, /* reusable memory buffer */ BLI_Buffer *edge_net_temp_buf) { const int f_index = BM_elem_index_get(f); @@ -533,7 +531,7 @@ static void bm_face_split_by_edges(BMesh *bm, /* now assign all */ /* pop free values into the next stack */ - while ((v = BLI_SMALLSTACK_POP_EX(vert_stack, vert_stack_next))) { + while ((v = static_cast(BLI_SMALLSTACK_POP_EX(vert_stack, vert_stack_next)))) { BMIter eiter; BMEdge *e_next; @@ -552,8 +550,12 @@ static void bm_face_split_by_edges(BMesh *bm, } } - BM_face_split_edgenet( - bm, f, edge_net_temp_buf->data, edge_net_temp_buf->count, &face_arr, &face_arr_len); + BM_face_split_edgenet(bm, + f, + static_cast(edge_net_temp_buf->data), + edge_net_temp_buf->count, + &face_arr, + &face_arr_len); BLI_buffer_clear(edge_net_temp_buf); @@ -607,15 +609,16 @@ static void ghash_insert_face_edge_link(GHash *gh, LinkNode *ls; if (!BLI_ghash_ensure_p(gh, f_key, &ls_base_p)) { - ls_base = *ls_base_p = BLI_memarena_alloc(mem_arena, sizeof(*ls_base)); - ls_base->list = NULL; + ls_base = static_cast(*ls_base_p = BLI_memarena_alloc(mem_arena, + sizeof(*ls_base))); + ls_base->list = nullptr; ls_base->list_len = 0; } else { - ls_base = *ls_base_p; + ls_base = static_cast(*ls_base_p); } - ls = BLI_memarena_alloc(mem_arena, sizeof(*ls)); + ls = static_cast(BLI_memarena_alloc(mem_arena, sizeof(*ls))); ls->next = ls_base->list; ls->link = e_val; ls_base->list = ls; @@ -639,11 +642,12 @@ static int bm_edge_sort_length_cb(const void *e_a_v, const void *e_b_v) static void bm_face_split_by_edges_island_connect( BMesh *bm, BMFace *f, LinkNode *e_link, const int e_link_len, MemArena *mem_arena_edgenet) { - BMEdge **edge_arr = BLI_memarena_alloc(mem_arena_edgenet, sizeof(*edge_arr) * e_link_len); + BMEdge **edge_arr = static_cast( + BLI_memarena_alloc(mem_arena_edgenet, sizeof(*edge_arr) * e_link_len)); int edge_arr_len = 0; while (e_link) { - edge_arr[edge_arr_len++] = e_link->link; + edge_arr[edge_arr_len++] = static_cast(e_link->link); e_link = e_link->next; } @@ -664,7 +668,7 @@ static void bm_face_split_by_edges_island_connect( } } - BM_face_split_edgenet(bm, f, edge_arr, edge_arr_len, NULL, NULL); + BM_face_split_edgenet(bm, f, edge_arr, edge_arr_len, nullptr, nullptr); for (int i = e_link_len; i < edge_arr_len; i++) { BM_edge_select_set(bm, edge_arr[i], true); @@ -700,7 +704,7 @@ static void bm_face_split_by_edges_island_connect( * in this case return the closest edge in \a f_a to the \a v_pivot. * * - \a v_pivot has only edges from the same face connected, - * in this case return NULL. This is the most common case - no action is needed. + * in this case return nullptr. This is the most common case - no action is needed. * * \return the edge to be split. * @@ -744,7 +748,7 @@ static BMEdge *bm_face_split_edge_find(BMEdge *e_a, } } while ((e_b = BM_DISK_EDGE_NEXT(e_b, v_pivot)) != v_pivot->e); - BMEdge *e_split = NULL; + BMEdge *e_split = nullptr; /* if we have no others or the other edge is outside this face, * we're an endpoint to connect to a boundary */ @@ -761,7 +765,7 @@ static BMEdge *bm_face_split_edge_find(BMEdge *e_a, interp_v3_v3v3(v_pivot_co_test, l_iter->e->v1->co, l_iter->e->v2->co, v_pivot_fac); float dist_test_sq = len_squared_v3v3(v_pivot_co_test, v_pivot->co); - if ((dist_test_sq < dist_best_sq) || (e_split == NULL)) { + if ((dist_test_sq < dist_best_sq) || (e_split == nullptr)) { bool ok = true; if (UNLIKELY(BM_edge_exists(v_pivot, l_iter->e->v1) || @@ -801,7 +805,7 @@ static BMEdge *bm_face_split_edge_find(BMEdge *e_a, { /* reset the flag, for future use */ BMFace *f; - while ((f = BLI_SMALLSTACK_POP(face_stack))) { + while ((f = static_cast(BLI_SMALLSTACK_POP(face_stack)))) { BM_elem_flag_disable(f, BM_ELEM_INTERNAL_TAG); } } @@ -811,7 +815,7 @@ static BMEdge *bm_face_split_edge_find(BMEdge *e_a, #endif /* USE_NET_ISLAND_CONNECT */ -static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) +static int edbm_face_split_by_edges_exec(bContext *C, wmOperator * /*op*/) { const char hflag = BM_ELEM_TAG; @@ -881,7 +885,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) BMLoop *l; uint loop_stack_len; - BMLoop *l_best = NULL; + BMLoop *l_best = nullptr; BLI_assert(BLI_SMALLSTACK_IS_EMPTY(loop_stack)); loop_stack_len = 0; @@ -897,7 +901,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) /* pass */ } else if (loop_stack_len == 1) { - l_best = BLI_SMALLSTACK_POP(loop_stack); + l_best = static_cast(BLI_SMALLSTACK_POP(loop_stack)); } else { /* complicated case, match the edge with a face-loop */ @@ -911,7 +915,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) sub_v3_v3v3(e_dir, v_other->co, v->co); normalize_v3(e_dir); - while ((l = BLI_SMALLSTACK_POP(loop_stack))) { + while ((l = static_cast(BLI_SMALLSTACK_POP(loop_stack)))) { float dot_test; /* Check dot first to save on expensive angle-comparison. @@ -962,12 +966,11 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) } #endif - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); #ifdef USE_NET_ISLAND_CONNECT /* we may have remaining isolated regions remaining, @@ -981,7 +984,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) { BMBVHTree *bmbvh = BKE_bmbvh_new( - bm, em->looptris, em->tottri, BMBVH_RESPECT_SELECT, NULL, false); + bm, em->looptris, em->tottri, BMBVH_RESPECT_SELECT, nullptr, false); BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { BM_elem_index_set(e, -1); /* set_dirty */ @@ -1012,12 +1015,13 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) GHashIterator gh_iter; GHASH_ITER (gh_iter, face_edge_map) { - BMFace *f = BLI_ghashIterator_getKey(&gh_iter); - struct LinkBase *e_ls_base = BLI_ghashIterator_getValue(&gh_iter); + BMFace *f = static_cast(BLI_ghashIterator_getKey(&gh_iter)); + struct LinkBase *e_ls_base = static_cast( + BLI_ghashIterator_getValue(&gh_iter)); LinkNode *e_link = e_ls_base->list; do { - e = e_link->link; + e = static_cast(e_link->link); for (int j = 0; j < 2; j++) { BMVert *v_pivot = (&e->v1)[j]; @@ -1055,8 +1059,9 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) GHashIterator gh_iter; GHASH_ITER (gh_iter, face_edge_map) { - BMFace *f = BLI_ghashIterator_getKey(&gh_iter); - struct LinkBase *e_ls_base = BLI_ghashIterator_getValue(&gh_iter); + BMFace *f = static_cast(BLI_ghashIterator_getKey(&gh_iter)); + struct LinkBase *e_ls_base = static_cast( + BLI_ghashIterator_getValue(&gh_iter)); bm_face_split_by_edges_island_connect( bm, f, e_ls_base->list, e_ls_base->list_len, mem_arena_edgenet); @@ -1069,14 +1074,13 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator *UNUSED(op)) BLI_memarena_free(mem_arena); - BLI_ghash_free(face_edge_map, NULL, NULL); + BLI_ghash_free(face_edge_map, nullptr, nullptr); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } BLI_stack_free(edges_loose); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.cc similarity index 92% rename from source/blender/editors/mesh/editmesh_knife.c rename to source/blender/editors/mesh/editmesh_knife.cc index 06c2cc70828..82d9cdc4687 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.cc @@ -84,7 +84,7 @@ #define KNIFE_MIN_ANGLE_SNAPPING_INCREMENT 0.0f #define KNIFE_MAX_ANGLE_SNAPPING_INCREMENT 180.0f -typedef struct KnifeColors { +struct KnifeColors { uchar line[3]; uchar edge[3]; uchar edge_extra[3]; @@ -96,13 +96,13 @@ typedef struct KnifeColors { uchar yaxis[3]; uchar zaxis[3]; uchar axis_extra[3]; -} KnifeColors; +}; /* Knife-tool Operator. */ -typedef struct KnifeVert { +struct KnifeVert { Object *ob; uint ob_index; - BMVert *v; /* Non-NULL if this is an original vert. */ + BMVert *v; /* Non-null if this is an original vert. */ ListBase edges; ListBase faces; @@ -111,32 +111,32 @@ typedef struct KnifeVert { bool is_cut; /* Along a cut created by user input (will draw too). */ bool is_invalid; bool is_splitting; /* Created when an edge was split. */ -} KnifeVert; +}; -typedef struct Ref { +struct Ref { struct Ref *next, *prev; void *ref; -} Ref; +}; -typedef struct KnifeEdge { +struct KnifeEdge { KnifeVert *v1, *v2; BMFace *basef; /* Face to restrict face fill to. */ ListBase faces; - BMEdge *e; /* Non-NULL if this is an original edge. */ + BMEdge *e; /* Non-null if this is an original edge. */ bool is_cut; /* Along a cut created by user input (will draw too). */ bool is_invalid; int splits; /* Number of times this edge has been split. */ -} KnifeEdge; +}; -typedef struct KnifeLineHit { +struct KnifeLineHit { float hit[3], cagehit[3]; float schit[2]; /* Screen coordinates for cagehit. */ float l; /* Lambda along cut line. */ float perc; /* Lambda along hit line. */ float m; /* Depth front-to-back. */ - /* Exactly one of kfe, v, or f should be non-NULL, + /* Exactly one of kfe, v, or f should be non-null, * saying whether cut line crosses and edge, * is snapped to a vert, or is in the middle of some face. */ KnifeEdge *kfe; @@ -144,13 +144,13 @@ typedef struct KnifeLineHit { BMFace *f; Object *ob; uint ob_index; -} KnifeLineHit; +}; -typedef struct KnifePosData { +struct KnifePosData { float co[3]; float cage[3]; - /* At most one of vert, edge, or bmface should be non-NULL, + /* At most one of vert, edge, or bmface should be non-null, * saying whether the point is snapped to a vertex, edge, or in a face. * If none are set, this point is in space and is_space should be true. */ KnifeVert *vert; @@ -163,23 +163,22 @@ typedef struct KnifePosData { bool is_space; float mval[2]; /* Mouse screen position (may be non-integral if snapped to something). */ -} KnifePosData; +}; -typedef struct KnifeMeasureData { +struct KnifeMeasureData { float cage[3]; float mval[2]; bool is_stored; -} KnifeMeasureData; +}; -typedef struct KnifeUndoFrame { +struct KnifeUndoFrame { int cuts; /* Line hits cause multiple edges/cuts to be created at once. */ int splits; /* Number of edges split. */ KnifePosData pos; /* Store previous KnifePosData. */ KnifeMeasureData mdata; +}; -} KnifeUndoFrame; - -typedef struct KnifeBVH { +struct KnifeBVH { BVHTree *tree; /* Knife Custom BVH Tree. */ BMLoop *(*looptris)[3]; /* Used by #knife_bvh_raycast_cb to store the intersecting looptri. */ float uv[2]; /* Used by #knife_bvh_raycast_cb to store the intersecting uv. */ @@ -188,11 +187,10 @@ typedef struct KnifeBVH { /* Use #bm_ray_cast_cb_elem_not_in_face_check. */ bool (*filter_cb)(BMFace *f, void *userdata); void *filter_data; - -} KnifeBVH; +}; /** Additional per-object data. */ -typedef struct KnifeObjectInfo { +struct KnifeObjectInfo { const float (*cagecos)[3]; /** @@ -205,10 +203,12 @@ typedef struct KnifeObjectInfo { /** Only assigned for convenient access. */ BMEditMesh *em; -} KnifeObjectInfo; +}; + +enum KnifeMode { MODE_IDLE, MODE_DRAGGING, MODE_CONNECT, MODE_PANNING }; /* struct for properties used while drawing */ -typedef struct KnifeTool_OpData { +struct KnifeTool_OpData { ARegion *region; /* Region that knifetool was activated in. */ void *draw_handle; /* For drawing preview loop. */ ViewContext vc; /* NOTE: _don't_ use 'mval', instead use the one we define below. */ @@ -284,7 +284,7 @@ typedef struct KnifeTool_OpData { float clipsta, clipend; - enum { MODE_IDLE, MODE_DRAGGING, MODE_CONNECT, MODE_PANNING } mode; + enum KnifeMode mode; bool is_drag_hold; int prevmode; @@ -318,7 +318,7 @@ typedef struct KnifeTool_OpData { bool is_drag_undo; bool depth_test; -} KnifeTool_OpData; +}; enum { KNF_MODAL_CANCEL = 1, @@ -376,7 +376,7 @@ static void knifetool_raycast_planes(const KnifeTool_OpData *kcd, float r_v1[3], { float planes[4][4]; planes_from_projmat( - kcd->vc.rv3d->persmat, planes[2], planes[0], planes[1], planes[3], NULL, NULL); + kcd->vc.rv3d->persmat, planes[2], planes[0], planes[1], planes[3], nullptr, nullptr); /* Ray-cast all planes. */ float ray_dir[3]; @@ -562,7 +562,7 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, const float end_ss[2], const float angle) { - const RegionView3D *rv3d = kcd->region->regiondata; + const RegionView3D *rv3d = static_cast(kcd->region->regiondata); const int arc_steps = 24; const float arc_size = 64.0f * UI_SCALE_FAC; const float bg_margin = 4.0f * UI_SCALE_FAC; @@ -699,9 +699,9 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) float angle = 0.0f; float *end; - kfe = ((Ref *)kfv->edges.first)->ref; - for (ref = kfv->edges.first; ref; ref = ref->next) { - tempkfe = ref->ref; + kfe = static_cast(((Ref *)kfv->edges.first)->ref); + for (ref = static_cast(kfv->edges.first); ref; ref = ref->next) { + tempkfe = static_cast(ref->ref); if (tempkfe->v1 != kfv) { tempkfv = tempkfe->v1; } @@ -782,9 +782,9 @@ static void knifetool_draw_visible_angles(const KnifeTool_OpData *kcd) } else { /* Choose minimum angle edge. */ - kfe = ((Ref *)kfv->edges.first)->ref; - for (ref = kfv->edges.first; ref; ref = ref->next) { - tempkfe = ref->ref; + kfe = static_cast(((Ref *)kfv->edges.first)->ref); + for (ref = static_cast(kfv->edges.first); ref; ref = ref->next) { + tempkfe = static_cast(ref->ref); if (tempkfe->v1 != kfv) { tempkfv = tempkfe->v1; } @@ -884,9 +884,9 @@ static void knifetool_draw_dist_angle(const KnifeTool_OpData *kcd) } /* Modal loop selection drawing callback. */ -static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), void *arg) +static void knifetool_draw(const bContext * /*C*/, ARegion * /*region*/, void *arg) { - const KnifeTool_OpData *kcd = arg; + const KnifeTool_OpData *kcd = static_cast(arg); GPU_depth_test(GPU_DEPTH_NONE); GPU_matrix_push_projection(); @@ -966,7 +966,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v GPUBatch *batch = immBeginBatchAtMost(GPU_PRIM_LINES, BLI_mempool_len(kcd->kedges) * 2); BLI_mempool_iternew(kcd->kedges, &iter); - for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { + for (kfe = static_cast(BLI_mempool_iterstep(&iter)); kfe; + kfe = static_cast(BLI_mempool_iterstep(&iter))) + { if (!kfe->is_cut || kfe->is_invalid) { continue; } @@ -991,7 +993,9 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v GPUBatch *batch = immBeginBatchAtMost(GPU_PRIM_POINTS, BLI_mempool_len(kcd->kverts)); BLI_mempool_iternew(kcd->kverts, &iter); - for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { + for (kfv = static_cast(BLI_mempool_iterstep(&iter)); kfv; + kfv = static_cast(BLI_mempool_iterstep(&iter))) + { if (!kfv->is_cut || kfv->is_invalid) { continue; } @@ -1036,7 +1040,7 @@ static void knifetool_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), v } } - GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vert, NULL, GPU_BATCH_OWNS_VBO); + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vert, nullptr, GPU_BATCH_OWNS_VBO); GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); /* Draw any snapped verts first. */ @@ -1098,6 +1102,7 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k int available_len = sizeof(buf); #define WM_MODALKEY(_id) \ +\ WM_modalkeymap_operator_items_to_string_buf( \ op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) @@ -1128,14 +1133,12 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k KNIFE_DEFAULT_ANGLE_SNAPPING_INCREMENT, kcd->angle_snapping ? ((kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_SCREEN) ? "Screen" : "Relative") : - "OFF", - /* TODO: Can this be simplified? */ + "OFF", /* TODO: Can this be simplified? */ (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? " - " : "", (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? WM_MODALKEY(KNF_MODAL_CYCLE_ANGLE_SNAP_EDGE) : "", - (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? ": cycle edge" : "", - /**/ + (kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? ": cycle edge" : "", /**/ WM_MODALKEY(KNF_MODAL_CUT_THROUGH_TOGGLE), WM_bool_as_string(kcd->cut_through), WM_MODALKEY(KNF_MODAL_PANNING), @@ -1234,7 +1237,7 @@ static void knife_bvh_init(KnifeTool_OpData *kcd) int tottri = 0; int ob_tottri = 0; BMLoop *(*looptris)[3]; - BMFace *f_test = NULL, *f_test_prev = NULL; + BMFace *f_test = nullptr, *f_test_prev = nullptr; bool test_fn_ret = false; /* Calculate tottri. */ @@ -1260,7 +1263,7 @@ static void knife_bvh_init(KnifeTool_OpData *kcd) kcd->bvh.tree = BLI_bvhtree_new(tottri, epsilon, 8, 8); - f_test_prev = NULL; + f_test_prev = nullptr; test_fn_ret = false; /* Add tri's for each object. @@ -1303,7 +1306,7 @@ static void knife_bvh_free(KnifeTool_OpData *kcd) { if (kcd->bvh.tree) { BLI_bvhtree_free(kcd->bvh.tree); - kcd->bvh.tree = NULL; + kcd->bvh.tree = nullptr; } } @@ -1316,7 +1319,7 @@ static void knife_bvh_raycast_cb(void *userdata, return; } - KnifeTool_OpData *kcd = userdata; + KnifeTool_OpData *kcd = static_cast(userdata); BMLoop **ltri; Object *ob; BMEditMesh *em; @@ -1353,7 +1356,7 @@ static void knife_bvh_raycast_cb(void *userdata, isect_ray_tri_watertight_v3( ray->origin, ray->isect_precalc, UNPACK3(tri_cos), &dist, uv)); #else - isect_ray_tri_v3(ray->origin, ray->direction, UNPACK3(tri_cos), &dist, uv); +isect_ray_tri_v3(ray->origin, ray->direction, UNPACK3(tri_cos), &dist, uv); #endif if (isect && dist < hit->dist) { @@ -1420,7 +1423,7 @@ static BMFace *knife_bvh_raycast(KnifeTool_OpData *kcd, return face; } - return NULL; + return nullptr; } /* `co` is expected to be in world space. */ @@ -1446,8 +1449,8 @@ static BMFace *knife_bvh_raycast_filter(KnifeTool_OpData *kcd, BLI_bvhtree_ray_cast(kcd->bvh.tree, co, dir, radius, &hit, knife_bvh_raycast_cb, kcd); - kcd->bvh.filter_cb = NULL; - kcd->bvh.filter_data = NULL; + kcd->bvh.filter_cb = nullptr; + kcd->bvh.filter_data = nullptr; /* Handle Hit */ if (hit.index != -1 && hit.dist != dist) { @@ -1474,7 +1477,7 @@ static BMFace *knife_bvh_raycast_filter(KnifeTool_OpData *kcd, return face; } - return NULL; + return nullptr; } /** \} */ @@ -1515,7 +1518,7 @@ static void UNUSED_FUNCTION(knifetool_recast_cageco)(KnifeTool_OpData *kcd, sub_v3_v3v3(ray, origin_ofs, origin); normalize_v3_v3(ray_normal, ray); - knife_bvh_raycast(kcd, origin, ray_normal, 0.0f, NULL, co, r_cage, NULL); + knife_bvh_raycast(kcd, origin, ray_normal, 0.0f, nullptr, co, r_cage, nullptr); } static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) @@ -1528,8 +1531,8 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) return false; } - l1 = v1->v ? BM_face_vert_share_loop(f, v1->v) : NULL; - l2 = v2->v ? BM_face_vert_share_loop(f, v2->v) : NULL; + l1 = v1->v ? BM_face_vert_share_loop(f, v1->v) : nullptr; + l2 = v2->v ? BM_face_vert_share_loop(f, v2->v) : nullptr; if ((l1 && l2) && BM_loop_is_adjacent(l1, l2)) { /* Boundary-case, always false to avoid edge-in-face checks below. */ @@ -1537,8 +1540,8 @@ static bool knife_verts_edge_in_face(KnifeVert *v1, KnifeVert *v2, BMFace *f) } /* Find out if v1 and v2, if set, are part of the face. */ - v1_inface = (l1 != NULL); - v2_inface = (l2 != NULL); + v1_inface = (l1 != nullptr); + v2_inface = (l2 != nullptr); /* BM_face_point_inside_test uses best-axis projection so this isn't most accurate test... */ v1_inside = v1_inface ? false : BM_face_point_inside_test(f, v1->co); @@ -1576,16 +1579,16 @@ static void knife_recalc_ortho(KnifeTool_OpData *kcd) static BMElem *bm_elem_from_knife_vert(KnifeVert *kfv, KnifeEdge **r_kfe) { BMElem *ele_test; - KnifeEdge *kfe = NULL; + KnifeEdge *kfe = nullptr; /* vert? */ ele_test = (BMElem *)kfv->v; - if (r_kfe || ele_test == NULL) { - if (kfv->v == NULL) { + if (r_kfe || ele_test == nullptr) { + if (kfv->v == nullptr) { Ref *ref; - for (ref = kfv->edges.first; ref; ref = ref->next) { - kfe = ref->ref; + for (ref = static_cast(kfv->edges.first); ref; ref = ref->next) { + kfe = static_cast(ref->ref); if (kfe->e) { if (r_kfe) { *r_kfe = kfe; @@ -1597,16 +1600,16 @@ static BMElem *bm_elem_from_knife_vert(KnifeVert *kfv, KnifeEdge **r_kfe) } /* edge? */ - if (ele_test == NULL) { + if (ele_test == nullptr) { if (kfe) { ele_test = (BMElem *)kfe->e; } } /* face? */ - if (ele_test == NULL) { + if (ele_test == nullptr) { if (BLI_listbase_is_single(&kfe->faces)) { - ele_test = ((Ref *)kfe->faces.first)->ref; + ele_test = static_cast(((Ref *)kfe->faces.first)->ref); } } @@ -1619,7 +1622,7 @@ static BMElem *bm_elem_from_knife_edge(KnifeEdge *kfe) ele_test = (BMElem *)kfe->e; - if (ele_test == NULL) { + if (ele_test == nullptr) { ele_test = (BMElem *)kfe->basef; } @@ -1636,7 +1639,7 @@ static ListBase *knife_empty_list(KnifeTool_OpData *kcd) { ListBase *list; - list = BLI_memarena_alloc(kcd->arena, sizeof(ListBase)); + list = static_cast(BLI_memarena_alloc(kcd->arena, sizeof(ListBase))); BLI_listbase_clear(list); return list; } @@ -1645,7 +1648,7 @@ static void knife_append_list(KnifeTool_OpData *kcd, ListBase *lst, void *elem) { Ref *ref; - ref = BLI_mempool_calloc(kcd->refs); + ref = static_cast(BLI_mempool_calloc(kcd->refs)); ref->ref = elem; BLI_addtail(lst, ref); } @@ -1654,13 +1657,13 @@ static Ref *find_ref(ListBase *lb, void *ref) { Ref *ref1; - for (ref1 = lb->first; ref1; ref1 = ref1->next) { + for (ref1 = static_cast(lb->first); ref1; ref1 = ref1->next) { if (ref1->ref == ref) { return ref1; } } - return NULL; + return nullptr; } static void knife_append_list_no_dup(KnifeTool_OpData *kcd, ListBase *lst, void *elem) @@ -1688,19 +1691,19 @@ static void knife_add_edge_faces_to_vert(KnifeTool_OpData *kcd, KnifeVert *kfv, } /* Find a face in common in the two faces lists. - * If more than one, return the first; if none, return NULL. */ + * If more than one, return the first; if none, return nullptr. */ static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2) { Ref *ref1, *ref2; - for (ref1 = faces1->first; ref1; ref1 = ref1->next) { - for (ref2 = faces2->first; ref2; ref2 = ref2->next) { + for (ref1 = static_cast(faces1->first); ref1; ref1 = ref1->next) { + for (ref2 = static_cast(faces2->first); ref2; ref2 = ref2->next) { if (ref1->ref == ref2->ref) { return (BMFace *)(ref1->ref); } } } - return NULL; + return nullptr; } /** \} */ @@ -1711,7 +1714,7 @@ static BMFace *knife_find_common_face(ListBase *faces1, ListBase *faces2) static KnifeVert *new_knife_vert(KnifeTool_OpData *kcd, const float co[3], const float cageco[3]) { - KnifeVert *kfv = BLI_mempool_calloc(kcd->kverts); + KnifeVert *kfv = static_cast(BLI_mempool_calloc(kcd->kverts)); kcd->totkvert++; @@ -1723,7 +1726,7 @@ static KnifeVert *new_knife_vert(KnifeTool_OpData *kcd, const float co[3], const static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd) { - KnifeEdge *kfe = BLI_mempool_calloc(kcd->kedges); + KnifeEdge *kfe = static_cast(BLI_mempool_calloc(kcd->kedges)); kcd->totkedge++; return kfe; } @@ -1731,7 +1734,7 @@ static KnifeEdge *new_knife_edge(KnifeTool_OpData *kcd) /* Get a KnifeVert wrapper for an existing BMVert. */ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v, Object *ob, uint ob_index) { - KnifeVert *kfv = BLI_ghash_lookup(kcd->origvertmap, v); + KnifeVert *kfv = static_cast(BLI_ghash_lookup(kcd->origvertmap, v)); const float *cageco; if (!kfv) { @@ -1765,7 +1768,7 @@ static KnifeVert *get_bm_knife_vert(KnifeTool_OpData *kcd, BMVert *v, Object *ob /* Get a KnifeEdge wrapper for an existing BMEdge. */ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e, Object *ob, uint ob_index) { - KnifeEdge *kfe = BLI_ghash_lookup(kcd->origedgemap, e); + KnifeEdge *kfe = static_cast(BLI_ghash_lookup(kcd->origedgemap, e)); if (!kfe) { BMIter bmiter; BMFace *f; @@ -1789,7 +1792,7 @@ static KnifeEdge *get_bm_knife_edge(KnifeTool_OpData *kcd, BMEdge *e, Object *ob static ListBase *knife_get_face_kedges(KnifeTool_OpData *kcd, Object *ob, uint ob_index, BMFace *f) { - ListBase *list = BLI_ghash_lookup(kcd->kedgefacemap, f); + ListBase *list = static_cast(BLI_ghash_lookup(kcd->kedgefacemap, f)); if (!list) { BMIter bmiter; @@ -1849,8 +1852,8 @@ static KnifeVert *knife_split_edge(KnifeTool_OpData *kcd, kfe->v1->is_splitting = true; BLI_addtail(&kfe->v1->edges, ref); - for (ref = kfe->faces.first; ref; ref = ref->next) { - knife_edge_append_face(kcd, newkfe, ref->ref); + for (ref = static_cast(kfe->faces.first); ref; ref = ref->next) { + knife_edge_append_face(kcd, newkfe, static_cast(ref->ref)); } knife_add_to_vert_edges(kcd, newkfe); @@ -1898,7 +1901,7 @@ static void knife_start_cut(KnifeTool_OpData *kcd) kcd->curr.is_space = 0; /* TODO: Why do we do this? */ kcd->mdata.is_stored = false; - if (kcd->prev.vert == NULL && kcd->prev.edge == NULL) { + if (kcd->prev.vert == nullptr && kcd->prev.edge == nullptr) { float ofs_local[3]; negate_v3_v3(ofs_local, kcd->vc.rv3d->ofs); ED_view3d_win_to_3d(kcd->vc.v3d, kcd->region, ofs_local, kcd->curr.mval, kcd->prev.cage); @@ -1925,8 +1928,8 @@ static void linehit_to_knifepos(KnifePosData *kpos, KnifeLineHit *lh) */ static int linehit_compare(const void *vlh1, const void *vlh2) { - const KnifeLineHit *lh1 = vlh1; - const KnifeLineHit *lh2 = vlh2; + const KnifeLineHit *lh1 = static_cast(vlh1); + const KnifeLineHit *lh2 = static_cast(vlh2); if (lh1->l < lh2->l) { return -1; @@ -1972,7 +1975,7 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) * Also remove all but one of a series of vertex hits for the same vertex. */ for (int i = 0; i < n; i++) { KnifeLineHit *lhi = &linehits[i]; - if (lhi->v == NULL) { + if (lhi->v == nullptr) { continue; } @@ -2036,7 +2039,7 @@ static void add_hit_to_facehits(KnifeTool_OpData *kcd, BMFace *f, KnifeLineHit *hit) { - ListBase *list = BLI_ghash_lookup(facehits, f); + ListBase *list = static_cast(BLI_ghash_lookup(facehits, f)); if (!list) { list = knife_empty_list(kcd); @@ -2166,8 +2169,9 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits) return; } - for (r = hits->first; r->next; r = r->next) { - knife_add_single_cut(kcd, r->ref, r->next->ref, f); + for (r = static_cast(hits->first); r->next; r = r->next) { + knife_add_single_cut( + kcd, static_cast(r->ref), static_cast(r->next->ref), f); } } @@ -2178,23 +2182,23 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li int edge_array_len = BLI_listbase_count(kfedges); int i; - BMEdge **edge_array = BLI_array_alloca(edge_array, edge_array_len); + BMEdge **edge_array = static_cast(BLI_array_alloca(edge_array, edge_array_len)); /* Point to knife edges we've created edges in, edge_array aligned. */ - KnifeEdge **kfe_array = BLI_array_alloca(kfe_array, edge_array_len); + KnifeEdge **kfe_array = static_cast(BLI_array_alloca(kfe_array, edge_array_len)); BLI_assert(BLI_gset_len(kcd->edgenet.edge_visit) == 0); i = 0; - for (ref = kfedges->first; ref; ref = ref->next) { + for (ref = static_cast(kfedges->first); ref; ref = ref->next) { bool is_new_edge = false; - kfe = ref->ref; + kfe = static_cast(ref->ref); if (kfe->is_invalid) { continue; } - if (kfe->e == NULL) { + if (kfe->e == nullptr) { if (kfe->v1->v && kfe->v2->v) { kfe->e = BM_edge_exists(kfe->v1->v, kfe->v2->v); } @@ -2207,14 +2211,14 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li } } else { - if (kfe->v1->v == NULL) { - kfe->v1->v = BM_vert_create(bm, kfe->v1->co, NULL, 0); + if (kfe->v1->v == nullptr) { + kfe->v1->v = BM_vert_create(bm, kfe->v1->co, nullptr, eBMCreateFlag(0)); } - if (kfe->v2->v == NULL) { - kfe->v2->v = BM_vert_create(bm, kfe->v2->co, NULL, 0); + if (kfe->v2->v == nullptr) { + kfe->v2->v = BM_vert_create(bm, kfe->v2->co, nullptr, eBMCreateFlag(0)); } - BLI_assert(kfe->e == NULL); - kfe->e = BM_edge_create(bm, kfe->v1->v, kfe->v2->v, NULL, 0); + BLI_assert(kfe->e == nullptr); + kfe->e = BM_edge_create(bm, kfe->v1->v, kfe->v2->v, nullptr, eBMCreateFlag(0)); if (kfe->e) { if (kcd->select_result || BM_elem_flag_test(f, BM_ELEM_SELECT)) { BM_edge_select_set(bm, kfe->e, true); @@ -2260,7 +2264,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li #endif { - BMFace **face_arr = NULL; + BMFace **face_arr = nullptr; int face_arr_len; BM_face_split_edgenet(bm, f, edge_array, edge_array_len, &face_arr, &face_arr_len); @@ -2272,12 +2276,12 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li /* Remove dangling edges, not essential - but nice for users. */ for (i = 0; i < edge_array_len_orig; i++) { - if (kfe_array[i] == NULL) { + if (kfe_array[i] == nullptr) { continue; } if (BM_edge_is_wire(kfe_array[i]->e)) { BM_edge_kill(bm, kfe_array[i]->e); - kfe_array[i]->e = NULL; + kfe_array[i]->e = nullptr; } } @@ -2286,14 +2290,14 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMesh *bm, BMFace *f, Li #endif } - BLI_gset_clear(kcd->edgenet.edge_visit, NULL); + BLI_gset_clear(kcd->edgenet.edge_visit, nullptr); } static int sort_verts_by_dist_cb(void *co_p, const void *cur_a_p, const void *cur_b_p) { - const KnifeVert *cur_a = ((const Ref *)cur_a_p)->ref; - const KnifeVert *cur_b = ((const Ref *)cur_b_p)->ref; - const float *co = co_p; + const KnifeVert *cur_a = static_cast(((const Ref *)cur_a_p)->ref); + const KnifeVert *cur_b = static_cast(((const Ref *)cur_b_p)->ref); + const float *co = static_cast(co_p); const float a_sq = len_squared_v3v3(co, cur_a->co); const float b_sq = len_squared_v3v3(co, cur_b->co); @@ -2328,7 +2332,9 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) /* Put list of cutting edges for a face into fhash, keyed by face. */ BLI_mempool_iternew(kcd->kedges, &iter); - for (kfe = BLI_mempool_iterstep(&iter); kfe; kfe = BLI_mempool_iterstep(&iter)) { + for (kfe = static_cast(BLI_mempool_iterstep(&iter)); kfe; + kfe = static_cast(BLI_mempool_iterstep(&iter))) + { if (kfe->is_invalid || kfe->v1->ob != ob) { continue; } @@ -2344,7 +2350,7 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) if (!f || kfe->e) { continue; } - list = BLI_smallhash_lookup(fhash, (uintptr_t)f); + list = static_cast(BLI_smallhash_lookup(fhash, (uintptr_t)f)); if (!list) { list = knife_empty_list(kcd); BLI_smallhash_insert(fhash, (uintptr_t)f, list); @@ -2354,17 +2360,19 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) /* Put list of splitting vertices for an edge into ehash, keyed by edge. */ BLI_mempool_iternew(kcd->kverts, &iter); - for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) { + for (kfv = static_cast(BLI_mempool_iterstep(&iter)); kfv; + kfv = static_cast(BLI_mempool_iterstep(&iter))) + { if (kfv->v || kfv->is_invalid || kfv->ob != ob) { continue; /* Already have a BMVert. */ } - for (ref = kfv->edges.first; ref; ref = ref->next) { - kfe = ref->ref; + for (ref = static_cast(kfv->edges.first); ref; ref = ref->next) { + kfe = static_cast(ref->ref); e = kfe->e; if (!e) { continue; } - list = BLI_smallhash_lookup(ehash, (uintptr_t)e); + list = static_cast(BLI_smallhash_lookup(ehash, (uintptr_t)e)); if (!list) { list = knife_empty_list(kcd); BLI_smallhash_insert(ehash, (uintptr_t)e, list); @@ -2377,13 +2385,13 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) } /* Split bmesh edges where needed. */ - for (list = BLI_smallhash_iternew(ehash, &hiter, (uintptr_t *)&e); list; - list = BLI_smallhash_iternext(&hiter, (uintptr_t *)&e)) + for (list = static_cast(BLI_smallhash_iternew(ehash, &hiter, (uintptr_t *)&e)); list; + list = static_cast(BLI_smallhash_iternext(&hiter, (uintptr_t *)&e))) { BLI_listbase_sort_r(list, sort_verts_by_dist_cb, e->v1->co); - for (ref = list->first; ref; ref = ref->next) { - kfv = ref->ref; + for (ref = static_cast(list->first); ref; ref = ref->next) { + kfv = static_cast(ref->ref); pct = line_point_factor_v3(kfv->co, e->v1->co, e->v2->co); kfv->v = BM_edge_split(bm, e, e->v1, &enew, pct); } @@ -2394,8 +2402,8 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) } /* Do cuts for each face. */ - for (list = BLI_smallhash_iternew(fhash, &hiter, (uintptr_t *)&f); list; - list = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) + for (list = static_cast(BLI_smallhash_iternew(fhash, &hiter, (uintptr_t *)&f)); list; + list = static_cast(BLI_smallhash_iternext(&hiter, (uintptr_t *)&f))) { knife_make_face_cuts(kcd, bm, f, list); } @@ -2406,7 +2414,7 @@ static void knife_make_cuts(KnifeTool_OpData *kcd, Object *ob) /* User has just left-clicked after the first time. * Add all knife cuts implied by line from prev to curr. - * If that line crossed edges then kcd->linehits will be non-NULL. + * If that line crossed edges then kcd->linehits will be non-null. * Make all of the KnifeVerts and KnifeEdges implied by this cut. */ static void knife_add_cut(KnifeTool_OpData *kcd) @@ -2420,7 +2428,7 @@ static void knife_add_cut(KnifeTool_OpData *kcd) /* Allocate new undo frame on stack, unless cut is being dragged. */ if (!kcd->is_drag_undo) { - kcd->undo = BLI_stack_push_r(kcd->undostack); + kcd->undo = static_cast(BLI_stack_push_r(kcd->undostack)); kcd->undo->pos = kcd->prev; kcd->undo->cuts = 0; kcd->undo->splits = 0; @@ -2454,13 +2462,13 @@ static void knife_add_cut(KnifeTool_OpData *kcd) add_hit_to_facehits(kcd, facehits, lh->f, lh); } if (lh->v) { - for (r = lh->v->faces.first; r; r = r->next) { - add_hit_to_facehits(kcd, facehits, r->ref, lh); + for (r = static_cast(lh->v->faces.first); r; r = r->next) { + add_hit_to_facehits(kcd, facehits, static_cast(r->ref), lh); } } if (lh->kfe) { - for (r = lh->kfe->faces.first; r; r = r->next) { - add_hit_to_facehits(kcd, facehits, r->ref, lh); + for (r = static_cast(lh->kfe->faces.first); r; r = r->next) { + add_hit_to_facehits(kcd, facehits, static_cast(r->ref), lh); } } } @@ -2468,7 +2476,7 @@ static void knife_add_cut(KnifeTool_OpData *kcd) /* NOTE: as following loop progresses, the 'v' fields of * the linehits will be filled in (as edges are split or * in-face verts are made), so it may be true that both - * the v and the kfe or f fields will be non-NULL. */ + * the v and the kfe or f fields will be non-null. */ GHASH_ITER (giter, facehits) { f = (BMFace *)BLI_ghashIterator_getKey(&giter); list = (ListBase *)BLI_ghashIterator_getValue(&giter); @@ -2482,7 +2490,7 @@ static void knife_add_cut(KnifeTool_OpData *kcd) /* Was "in face" but now we have a KnifeVert it is snapped to. */ KnifeLineHit *lh = &kcd->linehits[kcd->totlinehit - 1]; kcd->prev.vert = lh->v; - kcd->prev.bmface = NULL; + kcd->prev.bmface = nullptr; } if (kcd->is_drag_hold) { @@ -2490,9 +2498,9 @@ static void knife_add_cut(KnifeTool_OpData *kcd) linehit_to_knifepos(&kcd->prev, lh); } - BLI_ghash_free(facehits, NULL, NULL); + BLI_ghash_free(facehits, nullptr, nullptr); MEM_freeN(kcd->linehits); - kcd->linehits = NULL; + kcd->linehits = nullptr; kcd->totlinehit = 0; } @@ -2500,7 +2508,7 @@ static void knife_finish_cut(KnifeTool_OpData *kcd) { if (kcd->linehits) { MEM_freeN(kcd->linehits); - kcd->linehits = NULL; + kcd->linehits = nullptr; kcd->totlinehit = 0; } } @@ -2618,8 +2626,8 @@ static bool knife_ray_intersect_face(KnifeTool_OpData *kcd, interp_v3_v3v3v3_uv(hit_cageco, UNPACK3(tri_cos), ray_tri_uv); /* Now check that far enough away from verts and edges. */ list = knife_get_face_kedges(kcd, ob, ob_index, f); - for (ref = list->first; ref; ref = ref->next) { - kfe = ref->ref; + for (ref = static_cast(list->first); ref; ref = ref->next) { + kfe = static_cast(ref->ref); if (kfe->is_invalid) { continue; } @@ -2792,14 +2800,14 @@ static bool point_is_visible(KnifeTool_OpData *kcd, view, KNIFE_FLT_EPS, &dist, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, bm_ray_cast_cb_elem_not_in_face_check, ele_test); } else { - f_hit = knife_bvh_raycast(kcd, p_ofs, view, KNIFE_FLT_EPS, &dist, NULL, NULL, NULL); + f_hit = knife_bvh_raycast(kcd, p_ofs, view, KNIFE_FLT_EPS, &dist, nullptr, nullptr, nullptr); } if (f_hit) { @@ -2846,7 +2854,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) KnifeVert *v; ListBase *list; Ref *ref; - KnifeLineHit *linehits = NULL; + KnifeLineHit *linehits = nullptr; BLI_array_declare(linehits); SmallHashIter hiter; KnifeLineHit hit; @@ -2863,7 +2871,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) if (kcd->linehits) { MEM_freeN(kcd->linehits); - kcd->linehits = NULL; + kcd->linehits = nullptr; kcd->totlinehit = 0; } @@ -2953,13 +2961,13 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) if (BLI_smallhash_haskey(&faces, (uintptr_t)f)) { continue; } - /* Don't care what the value is except that it is non-NULL, for iterator. */ + /* Don't care what the value is except that it is non-null, for iterator. */ BLI_smallhash_insert(&faces, (uintptr_t)f, f); BLI_smallhash_insert(&fobs, (uintptr_t)f, (void *)(uintptr_t)ob_index); list = knife_get_face_kedges(kcd, ob, ob_index, f); - for (ref = list->first; ref; ref = ref->next) { - kfe = ref->ref; + for (ref = static_cast(list->first); ref; ref = ref->next) { + kfe = static_cast(ref->ref); if (kfe->is_invalid) { continue; } @@ -3001,7 +3009,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) for (val_p = BLI_smallhash_iternew_p(&kfvs, &hiter, (uintptr_t *)&v); val_p; val_p = BLI_smallhash_iternext_p(&hiter, (uintptr_t *)&v)) { - KnifeEdge *kfe_hit = NULL; + KnifeEdge *kfe_hit = nullptr; bool kfv_is_in_cut = false; if (ELEM(v, kcd->prev.vert, kcd->curr.vert)) { @@ -3045,7 +3053,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) /* This vertex isn't used so remove from `kfvs`. * This is useful to detect KnifeEdges that can be skipped. * And it optimizes smallhash_iternext a little bit. */ - *val_p = NULL; + *val_p = nullptr; } } @@ -3124,8 +3132,8 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) } /* Now face hits; don't add if a vertex or edge in face should have hit. */ - const bool use_hit_prev = (kcd->prev.vert == NULL) && (kcd->prev.edge == NULL); - const bool use_hit_curr = (kcd->curr.vert == NULL) && (kcd->curr.edge == NULL) && + const bool use_hit_prev = (kcd->prev.vert == nullptr) && (kcd->prev.edge == nullptr); + const bool use_hit_curr = (kcd->curr.vert == nullptr) && (kcd->curr.edge == nullptr) && !kcd->is_drag_hold; if (use_hit_prev || use_hit_curr) { for (val = BLI_smallhash_iternew(&faces, &hiter, (uintptr_t *)&f); val; @@ -3197,9 +3205,9 @@ static void knife_pos_data_clear(KnifePosData *kpd) { zero_v3(kpd->co); zero_v3(kpd->cage); - kpd->vert = NULL; - kpd->edge = NULL; - kpd->bmface = NULL; + kpd->vert = nullptr; + kpd->edge = nullptr; + kpd->bmface = nullptr; zero_v2(kpd->mval); } @@ -3227,10 +3235,10 @@ static BMFace *knife_find_closest_face(KnifeTool_OpData *kcd, sub_v3_v3v3(ray, origin_ofs, origin); normalize_v3_v3(ray_normal, ray); - f = knife_bvh_raycast(kcd, origin, ray_normal, 0.0f, NULL, r_co, r_cageco, r_ob_index); + f = knife_bvh_raycast(kcd, origin, ray_normal, 0.0f, nullptr, r_co, r_cageco, r_ob_index); if (f && kcd->only_select && BM_elem_flag_test(f, BM_ELEM_SELECT) == 0) { - f = NULL; + f = nullptr; } if (is_space) { @@ -3287,8 +3295,8 @@ static int knife_sample_screen_density_from_closest_face(KnifeTool_OpData *kcd, knife_project_v2(kcd, cageco, sco); list = knife_get_face_kedges(kcd, ob, ob_index, f); - for (ref = list->first; ref; ref = ref->next) { - KnifeEdge *kfe = ref->ref; + for (ref = static_cast(list->first); ref; ref = ref->next) { + KnifeEdge *kfe = static_cast(ref->ref); int i; if (kfe->is_invalid) { @@ -3411,7 +3419,7 @@ static KnifeEdge *knife_find_closest_edge_of_face( } const float maxdist_sq = maxdist * maxdist; - KnifeEdge *cure = NULL; + KnifeEdge *cure = nullptr; float cur_cagep[3]; ListBase *list; Ref *ref; @@ -3421,8 +3429,8 @@ static KnifeEdge *knife_find_closest_edge_of_face( /* Look through all edges associated with this face. */ list = knife_get_face_kedges(kcd, ob, ob_index, f); - for (ref = list->first; ref; ref = ref->next) { - KnifeEdge *kfe = ref->ref; + for (ref = static_cast(list->first); ref; ref = ref->next) { + KnifeEdge *kfe = static_cast(ref->ref); float kfv1_sco[2], kfv2_sco[2], test_cagep[3]; float lambda; @@ -3470,7 +3478,7 @@ static KnifeEdge *knife_find_closest_edge_of_face( } if (cure && !kcd->ignore_edge_snapping) { - KnifeVert *edgesnap = NULL; + KnifeVert *edgesnap = nullptr; if (kcd->snap_midpoints) { mid_v3_v3v3(p, cure->v1->co, cure->v2->co); @@ -3513,7 +3521,7 @@ static KnifeVert *knife_find_closest_vert_of_edge(KnifeTool_OpData *kcd, } const float maxdist_sq = maxdist * maxdist; - KnifeVert *curv = NULL; + KnifeVert *curv = nullptr; float cur_kfv_sco[2]; float dis_sq, curdis_sq = FLT_MAX; @@ -3650,7 +3658,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) normalize_v3_v3(curr_ray_normal, curr_ray); BMFace *fcurr = knife_bvh_raycast( - kcd, curr_origin, curr_ray_normal, 0.0f, NULL, curr_co, curr_cage, NULL); + kcd, curr_origin, curr_ray_normal, 0.0f, nullptr, curr_co, curr_cage, nullptr); if (!fcurr) { return false; @@ -3660,7 +3668,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) * If none exists then exit. */ if (kcd->prev.vert) { int count = 0; - for (ref = kcd->prev.vert->edges.first; ref; ref = ref->next) { + for (ref = static_cast(kcd->prev.vert->edges.first); ref; ref = ref->next) { kfe = ((KnifeEdge *)(ref->ref)); if (kfe->is_invalid) { continue; @@ -3691,9 +3699,9 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) } /* Choose best face for plane. */ - BMFace *fprev = NULL; + BMFace *fprev = nullptr; if (kcd->prev.vert && kcd->prev.vert->v) { - for (ref = kcd->prev.vert->faces.first; ref; ref = ref->next) { + for (ref = static_cast(kcd->prev.vert->faces.first); ref; ref = ref->next) { f = ((BMFace *)(ref->ref)); if (f == fcurr) { fprev = f; @@ -3701,7 +3709,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) } } else if (kcd->prev.edge) { - for (ref = kcd->prev.edge->faces.first; ref; ref = ref->next) { + for (ref = static_cast(kcd->prev.edge->faces.first); ref; ref = ref->next) { f = ((BMFace *)(ref->ref)); if (f == fcurr) { fprev = f; @@ -3722,7 +3730,7 @@ static bool knife_snap_angle_relative(KnifeTool_OpData *kcd) /* kcd->prev.face is usually not set. */ fprev = knife_bvh_raycast( - kcd, prev_origin, prev_ray_normal, 0.0f, NULL, prev_co, prev_cage, NULL); + kcd, prev_origin, prev_ray_normal, 0.0f, nullptr, prev_co, prev_cage, nullptr); } if (!fprev || fprev != fcurr) { @@ -3783,7 +3791,7 @@ static int knife_calculate_snap_ref_edges(KnifeTool_OpData *kcd) normalize_v3_v3(curr_ray_normal, curr_ray); BMFace *fcurr = knife_bvh_raycast( - kcd, curr_origin, curr_ray_normal, 0.0f, NULL, curr_co, curr_cage, NULL); + kcd, curr_origin, curr_ray_normal, 0.0f, nullptr, curr_co, curr_cage, nullptr); int count = 0; @@ -3792,7 +3800,7 @@ static int knife_calculate_snap_ref_edges(KnifeTool_OpData *kcd) } if (kcd->prev.vert) { - for (ref = kcd->prev.vert->edges.first; ref; ref = ref->next) { + for (ref = static_cast(kcd->prev.vert->edges.first); ref; ref = ref->next) { kfe = ((KnifeEdge *)(ref->ref)); if (kfe->is_invalid) { continue; @@ -3836,7 +3844,7 @@ static void knife_constrain_axis(KnifeTool_OpData *kcd) Scene *scene = kcd->scene; ViewLayer *view_layer = kcd->vc.view_layer; Object *obedit = (kcd->prev.ob) ? kcd->prev.ob : kcd->vc.obedit; - RegionView3D *rv3d = kcd->region->regiondata; + RegionView3D *rv3d = static_cast(kcd->region->regiondata); const short scene_orientation = BKE_scene_orientation_get_index(scene, SCE_ORIENT_DEFAULT); /* Scene orientation takes priority. */ const short orientation_type = scene_orientation ? scene_orientation : @@ -3932,7 +3940,7 @@ static bool knife_snap_update_from_mval(KnifeTool_OpData *kcd, const float mval[ kcd, kcd->curr.edge, kcd->curr.co, kcd->curr.cage); if (kcd->ignore_edge_snapping) { - kcd->curr.edge = NULL; + kcd->curr.edge = nullptr; } } } @@ -3950,12 +3958,12 @@ static void knifetool_undo(KnifeTool_OpData *kcd) { Ref *ref; KnifeEdge *kfe, *newkfe; - KnifeEdge *lastkfe = NULL; + KnifeEdge *lastkfe = nullptr; KnifeVert *v1, *v2; KnifeUndoFrame *undo; BLI_mempool_iter iterkfe; - undo = BLI_stack_peek(kcd->undostack); + undo = static_cast(BLI_stack_peek(kcd->undostack)); /* Undo edge splitting. */ for (int i = 0; i < undo->splits; i++) { @@ -3967,7 +3975,9 @@ static void knifetool_undo(KnifeTool_OpData *kcd) for (int i = 0; i < undo->cuts; i++) { BLI_mempool_iternew(kcd->kedges, &iterkfe); - for (kfe = BLI_mempool_iterstep(&iterkfe); kfe; kfe = BLI_mempool_iterstep(&iterkfe)) { + for (kfe = static_cast(BLI_mempool_iterstep(&iterkfe)); kfe; + kfe = static_cast(BLI_mempool_iterstep(&iterkfe))) + { if (!kfe->is_cut || kfe->is_invalid || kfe->splits) { continue; } @@ -3985,8 +3995,8 @@ static void knifetool_undo(KnifeTool_OpData *kcd) if (!v1->is_invalid && !v1->is_splitting) { v1->is_invalid = true; /* If the first vertex is touching any other cut edges don't remove it. */ - for (ref = v1->edges.first; ref; ref = ref->next) { - kfe = ref->ref; + for (ref = static_cast(v1->edges.first); ref; ref = ref->next) { + kfe = static_cast(ref->ref); if (kfe->is_cut && !kfe->is_invalid) { v1->is_invalid = false; break; @@ -3998,8 +4008,8 @@ static void knifetool_undo(KnifeTool_OpData *kcd) if (!v2->is_invalid && !v2->is_splitting) { v2->is_invalid = true; /* If the second vertex is touching any other cut edges don't remove it. */ - for (ref = v2->edges.first; ref; ref = ref->next) { - kfe = ref->ref; + for (ref = static_cast(v2->edges.first); ref; ref = ref->next) { + kfe = static_cast(ref->ref); if (kfe->is_cut && !kfe->is_invalid) { v2->is_invalid = false; break; @@ -4041,11 +4051,12 @@ static void knifetool_init_obinfo(KnifeTool_OpData *kcd, KnifeObjectInfo *obinfo = &kcd->objects_info[ob_index]; obinfo->em = em_eval; obinfo->cagecos = (const float(*)[3])BKE_editmesh_vert_coords_alloc( - kcd->vc.depsgraph, em_eval, scene_eval, obedit_eval, NULL); + kcd->vc.depsgraph, em_eval, scene_eval, obedit_eval, nullptr); if (use_tri_indices) { BMLoop *(*looptris)[3] = em_eval->looptris; - int(*tri_indices)[3] = MEM_mallocN(sizeof(int[3]) * em_eval->tottri, __func__); + int(*tri_indices)[3] = static_cast( + MEM_mallocN(sizeof(int[3]) * em_eval->tottri, __func__)); for (int i = 0; i < em_eval->tottri; i++) { BMLoop **tri = looptris[i]; tri_indices[i][0] = BM_elem_index_get(tri[0]->v); @@ -4127,7 +4138,8 @@ static void knifetool_init(ViewContext *vc, Object *ob; BMEditMesh *em; - kcd->objects_info = MEM_callocN(sizeof(*kcd->objects_info) * kcd->objects_len, "knife cagecos"); + kcd->objects_info = static_cast( + MEM_callocN(sizeof(*kcd->objects_info) * kcd->objects_len, "knife cagecos")); for (uint ob_index = 0; ob_index < kcd->objects_len; ob_index++) { ob = kcd->objects[ob_index]; em = BKE_editmesh_from_object(ob); @@ -4219,16 +4231,16 @@ static void knifetool_exit_ex(KnifeTool_OpData *kcd) BLI_stack_free(kcd->undostack); BLI_stack_free(kcd->splitstack); - BLI_ghash_free(kcd->origedgemap, NULL, NULL); - BLI_ghash_free(kcd->origvertmap, NULL, NULL); - BLI_ghash_free(kcd->kedgefacemap, NULL, NULL); - BLI_ghash_free(kcd->facetrimap, NULL, NULL); + BLI_ghash_free(kcd->origedgemap, nullptr, nullptr); + BLI_ghash_free(kcd->origvertmap, nullptr, nullptr); + BLI_ghash_free(kcd->kedgefacemap, nullptr, nullptr); + BLI_ghash_free(kcd->facetrimap, nullptr, nullptr); BLI_memarena_free(kcd->arena); #ifdef USE_NET_ISLAND_CONNECT BLI_memarena_free(kcd->edgenet.arena); #endif - BLI_gset_free(kcd->edgenet.edge_visit, NULL); + BLI_gset_free(kcd->edgenet.edge_visit, nullptr); /* Tag for redraw. */ ED_region_tag_redraw(kcd->region); @@ -4256,9 +4268,9 @@ static void knifetool_exit_ex(KnifeTool_OpData *kcd) static void knifetool_exit(wmOperator *op) { - KnifeTool_OpData *kcd = op->customdata; + KnifeTool_OpData *kcd = static_cast(op->customdata); knifetool_exit_ex(kcd); - op->customdata = NULL; + op->customdata = nullptr; } /** \} */ @@ -4308,7 +4320,7 @@ static void knifetool_update_mval(KnifeTool_OpData *kcd, const float mval[2]) static void knifetool_update_mval_i(KnifeTool_OpData *kcd, const int mval_i[2]) { - const float mval[2] = {UNPACK2(mval_i)}; + const float mval[2] = {float(mval_i[0]), float(mval_i[1])}; knifetool_update_mval(kcd, mval); } @@ -4327,16 +4339,15 @@ static void knifetool_finish_single_pre(KnifeTool_OpData *kcd, Object *ob) * A post version is needed to delay recalculating tessellation after making cuts. * Without this, knife-project can't use the BVH tree to select geometry after a cut, see: #98349. */ -static void knifetool_finish_single_post(KnifeTool_OpData *UNUSED(kcd), Object *ob) +static void knifetool_finish_single_post(KnifeTool_OpData * /*kcd*/, Object *ob) { BMEditMesh *em = BKE_editmesh_from_object(ob); EDBM_selectmode_flush(em); - EDBM_update(ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(ob->data), ¶ms); } /* Called on tool confirmation. */ @@ -4357,7 +4368,7 @@ static void knifetool_finish_ex(KnifeTool_OpData *kcd) static void knifetool_finish(wmOperator *op) { - KnifeTool_OpData *kcd = op->customdata; + KnifeTool_OpData *kcd = static_cast(op->customdata); knifetool_finish_ex(kcd); } @@ -4367,7 +4378,7 @@ static void knifetool_finish(wmOperator *op) /** \name Operator (#MESH_OT_knife_tool) * \{ */ -static void knifetool_cancel(bContext *UNUSED(C), wmOperator *op) +static void knifetool_cancel(bContext * /*C*/, wmOperator *op) { /* this is just a wrapper around exit() */ knifetool_exit(op); @@ -4403,14 +4414,14 @@ wmKeyMap *knifetool_modal_keymap(wmKeyConfig *keyconf) {KNF_MODAL_X_AXIS, "X_AXIS", 0, "X Axis Locking", ""}, {KNF_MODAL_Y_AXIS, "Y_AXIS", 0, "Y Axis Locking", ""}, {KNF_MODAL_Z_AXIS, "Z_AXIS", 0, "Z Axis Locking", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Knife Tool Modal Map"); /* This function is called for each space-type, only needs to add map once. */ if (keymap && keymap->modal_items) { - return NULL; + return nullptr; } keymap = WM_modalkeymap_ensure(keyconf, "Knife Tool Modal Map", modal_items); @@ -4438,12 +4449,12 @@ static void knifetool_disable_orientation_locking(KnifeTool_OpData *kcd) static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) { - KnifeTool_OpData *kcd = op->customdata; + KnifeTool_OpData *kcd = static_cast(op->customdata); bool do_refresh = false; if (!kcd->curr.ob || kcd->curr.ob->type != OB_MESH) { knifetool_exit(op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_FINISHED; } @@ -4452,7 +4463,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_view3d_init_mats_rv3d(kcd->curr.ob, kcd->vc.rv3d); /* Needed to initialize clipping. */ if (kcd->mode == MODE_PANNING) { - kcd->mode = kcd->prevmode; + kcd->mode = KnifeMode(kcd->prevmode); } bool handled = false; @@ -4490,7 +4501,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_region_tag_redraw(kcd->region); knifetool_exit(op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_CANCELLED; case KNF_MODAL_CONFIRM: { @@ -4500,7 +4511,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) knifetool_finish(op); knifetool_exit(op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); /* Cancel to prevent undo push for empty cuts. */ if (!changed) { @@ -4512,7 +4523,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (BLI_stack_is_empty(kcd->undostack)) { ED_region_tag_redraw(kcd->region); knifetool_exit(op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_CANCELLED; } knifetool_undo(kcd); @@ -4617,7 +4628,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) if (kcd->no_cuts) { ED_region_tag_redraw(kcd->region); knifetool_exit(op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_CANCELLED; } ED_region_tag_redraw(kcd->region); @@ -4691,7 +4702,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else { - kcd->mode = kcd->prevmode; + kcd->mode = KnifeMode(kcd->prevmode); } ED_region_tag_redraw(kcd->region); @@ -4819,11 +4830,12 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) em_setup_viewcontext(C, &vc); /* alloc new customdata */ - kcd = op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), __func__); + kcd = static_cast( + op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), __func__)); knifetool_init(&vc, kcd, - NULL, + nullptr, 0, only_select, cut_through, @@ -4863,11 +4875,11 @@ static int knifetool_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (wait_for_input == false) { /* Avoid copy-paste logic. */ - wmEvent event_modal = { - .prev_val = KM_NOTHING, - .type = EVT_MODAL_MAP, - .val = KNF_MODAL_ADD_CUT, - }; + wmEvent event_modal{}; + event_modal.prev_val = KM_NOTHING; + event_modal.type = EVT_MODAL_MAP; + event_modal.val = KNF_MODAL_ADD_CUT; + int ret = knifetool_modal(C, op, &event_modal); BLI_assert(ret == OPERATOR_RUNNING_MODAL); UNUSED_VARS_NDEBUG(ret); @@ -4901,7 +4913,7 @@ void MESH_OT_knife_tool(wmOperatorType *ot) {KNF_MEASUREMENT_BOTH, "BOTH", 0, "Both", "Show both distances and angles"}, {KNF_MEASUREMENT_DISTANCE, "DISTANCE", 0, "Distance", "Show just distance measurements"}, {KNF_MEASUREMENT_ANGLE, "ANGLE", 0, "Angle", "Show just angle measurements"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem angle_snapping_items[] = { @@ -4912,7 +4924,7 @@ void MESH_OT_knife_tool(wmOperatorType *ot) 0, "Relative", "Angle snapping relative to the previous cut edge"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; RNA_def_boolean(ot->srna, @@ -4966,7 +4978,7 @@ static bool edbm_mesh_knife_point_isect(LinkNode *polys, const float cent_ss[2]) int isect = 0; while (p) { - const float(*mval_fl)[2] = p->link; + const float(*mval_fl)[2] = static_cast(p->link); const int mval_tot = MEM_allocN_len(mval_fl) / sizeof(*mval_fl); isect += (int)isect_point_poly_v2(cent_ss, mval_fl, mval_tot - 1, false); p = p->next; @@ -4996,7 +5008,7 @@ void EDBM_mesh_knife(ViewContext *vc, const int angle_snapping = KNF_CONSTRAIN_ANGLE_MODE_NONE; const float angle_snapping_increment = KNIFE_DEFAULT_ANGLE_SNAPPING_INCREMENT; - kcd = MEM_callocN(sizeof(KnifeTool_OpData), __func__); + kcd = static_cast(MEM_callocN(sizeof(KnifeTool_OpData), __func__)); knifetool_init(vc, kcd, @@ -5021,7 +5033,7 @@ void EDBM_mesh_knife(ViewContext *vc, knife_recalc_ortho(kcd); while (p) { - const float(*mval_fl)[2] = p->link; + const float(*mval_fl)[2] = static_cast(p->link); const int mval_tot = MEM_allocN_len(mval_fl) / sizeof(*mval_fl); int i; @@ -5066,7 +5078,7 @@ void EDBM_mesh_knife(ViewContext *vc, BMIter iter; bool keep_search; - /* Use face-loop tag to store if we have intersected. */ +/* Use face-loop tag to store if we have intersected. */ #define F_ISECT_IS_UNKNOWN(f) BM_elem_flag_test(BM_FACE_FIRST_LOOP(f), BM_ELEM_TAG) #define F_ISECT_SET_UNKNOWN(f) BM_elem_flag_enable(BM_FACE_FIRST_LOOP(f), BM_ELEM_TAG) #define F_ISECT_SET_OUTSIDE(f) BM_elem_flag_disable(BM_FACE_FIRST_LOOP(f), BM_ELEM_TAG) @@ -5161,7 +5173,7 @@ void EDBM_mesh_knife(ViewContext *vc, } knifetool_exit_ex(kcd); - kcd = NULL; + kcd = nullptr; } } diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.cc similarity index 85% rename from source/blender/editors/mesh/editmesh_loopcut.c rename to source/blender/editors/mesh/editmesh_loopcut.cc index 9160b69d455..3ab916d528c 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.cc @@ -55,7 +55,7 @@ struct MeshCoordsCache { }; /* struct for properties used while drawing */ -typedef struct RingSelOpData { +struct RingSelOpData { ARegion *region; /* region that ringsel was activated in */ void *draw_handle; /* for drawing preview loop */ @@ -83,12 +83,12 @@ typedef struct RingSelOpData { float cuts; /* cuts as float so smooth mouse pan works in small increments */ float smoothness; -} RingSelOpData; +}; /* modal loop selection drawing callback */ -static void ringsel_draw(const bContext *UNUSED(C), ARegion *UNUSED(region), void *arg) +static void ringsel_draw(const bContext * /*C*/, ARegion * /*region*/, void *arg) { - RingSelOpData *lcd = arg; + RingSelOpData *lcd = static_cast(arg); EDBM_preselect_edgering_draw(lcd->presel_edgering, lcd->ob->object_to_world); } @@ -103,7 +103,7 @@ static void edgering_select(RingSelOpData *lcd) Object *ob_iter = lcd->bases[base_index]->object; BMEditMesh *em = BKE_editmesh_from_object(ob_iter); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(ob_iter->data), ID_RECALC_SELECT); WM_main_add_notifier(NC_GEOM | ND_SELECT, ob_iter->data); } } @@ -121,7 +121,9 @@ static void edgering_select(RingSelOpData *lcd) BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - for (eed = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) { + for (eed = static_cast(BMW_begin(&walker, eed_start)); eed; + eed = static_cast(BMW_step(&walker))) + { BM_edge_select_set(em->bm, eed, true); } BMW_end(&walker); @@ -136,7 +138,7 @@ static void ringsel_find_edge(RingSelOpData *lcd, const int previewlines) Object *ob_eval = DEG_get_evaluated_object(lcd->vc.depsgraph, lcd->ob); BMEditMesh *em_eval = BKE_editmesh_from_object(ob_eval); gcache->coords = BKE_editmesh_vert_coords_when_deformed( - lcd->vc.depsgraph, em_eval, scene_eval, ob_eval, NULL, &gcache->is_alloc); + lcd->vc.depsgraph, em_eval, scene_eval, ob_eval, nullptr, &gcache->is_alloc); gcache->is_init = true; } @@ -150,7 +152,7 @@ static void ringsel_find_edge(RingSelOpData *lcd, const int previewlines) static void ringsel_finish(bContext *C, wmOperator *op) { - RingSelOpData *lcd = op->customdata; + RingSelOpData *lcd = static_cast(op->customdata); const int cuts = RNA_int_get(op->ptr, "number_cuts"); const float smoothness = RNA_float_get(op->ptr, "smoothness"); const int smooth_falloff = RNA_enum_get(op->ptr, "falloff"); @@ -167,7 +169,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) edgering_select(lcd); if (lcd->do_cut) { - const bool is_macro = (op->opm != NULL); + const bool is_macro = (op->opm != nullptr); /* a single edge (rare, but better support) */ const bool is_edge_wire = BM_edge_is_wire(lcd->eed); const bool is_single = is_edge_wire || !BM_edge_is_any_face_len_test(lcd->eed, 4); @@ -195,12 +197,11 @@ static void ringsel_finish(bContext *C, wmOperator *op) /* when used in a macro the tessfaces will be recalculated anyway, * this is needed here because modifiers depend on updated tessellation, see #45920 */ - EDBM_update(lcd->ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(lcd->ob->data), ¶ms); if (is_single) { /* de-select endpoints */ @@ -238,16 +239,16 @@ static void ringsel_finish(bContext *C, wmOperator *op) } EDBM_selectmode_flush(lcd->em); - DEG_id_tag_update(lcd->ob->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(lcd->ob->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, lcd->ob->data); } } } /* called when modal loop selection is done... */ -static void ringsel_exit(bContext *UNUSED(C), wmOperator *op) +static void ringsel_exit(bContext * /*C*/, wmOperator *op) { - RingSelOpData *lcd = op->customdata; + RingSelOpData *lcd = static_cast(op->customdata); /* deactivate the extra drawing stuff in 3D-View */ ED_region_draw_cb_exit(lcd->region->type, lcd->draw_handle); @@ -268,7 +269,7 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op) /* free the custom data */ MEM_freeN(lcd); - op->customdata = NULL; + op->customdata = nullptr; } /* called when modal loop selection gets set up... */ @@ -278,7 +279,8 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) Scene *scene = CTX_data_scene(C); /* alloc new customdata */ - lcd = op->customdata = MEM_callocN(sizeof(RingSelOpData), "ringsel Modal Op Data"); + lcd = static_cast( + op->customdata = MEM_callocN(sizeof(RingSelOpData), "ringsel Modal Op Data")); em_setup_viewcontext(C, &lcd->vc); @@ -290,8 +292,8 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) lcd->region->type, ringsel_draw, lcd, REGION_DRAW_POST_VIEW); lcd->presel_edgering = EDBM_preselect_edgering_create(); /* Initialize once the cursor is over a mesh. */ - lcd->ob = NULL; - lcd->em = NULL; + lcd->ob = nullptr; + lcd->em = nullptr; lcd->extend = do_cut ? false : RNA_boolean_get(op->ptr, "extend"); lcd->do_cut = do_cut; lcd->cuts = RNA_int_get(op->ptr, "number_cuts"); @@ -328,9 +330,9 @@ static void loopcut_update_edge(RingSelOpData *lcd, lcd->em = lcd->vc.em; ringsel_find_edge(lcd, previewlines); } - else if (e == NULL) { - lcd->ob = NULL; - lcd->em = NULL; + else if (e == nullptr) { + lcd->ob = nullptr; + lcd->em = nullptr; lcd->base_index = UINT_MAX; } } @@ -342,13 +344,19 @@ static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines) BMEdge *eed; float dist; int base_index; - } best = { - .dist = ED_view3d_select_dist_px(), - }; + } best{}; + best.dist = ED_view3d_select_dist_px(); uint base_index; - BMEdge *eed_test = EDBM_edge_find_nearest_ex( - &lcd->vc, &best.dist, NULL, false, false, NULL, lcd->bases, lcd->bases_len, &base_index); + BMEdge *eed_test = EDBM_edge_find_nearest_ex(&lcd->vc, + &best.dist, + nullptr, + false, + false, + nullptr, + lcd->bases, + lcd->bases_len, + &base_index); if (eed_test) { best.ob = lcd->bases[base_index]->object; @@ -366,16 +374,15 @@ static void loopcut_mouse_move(RingSelOpData *lcd, const int previewlines) /* called by both init() and exec() */ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) { - const bool is_interactive = (event != NULL); + const bool is_interactive = (event != nullptr); /* Use for redo - intentionally wrap int to uint. */ - const struct { + struct { uint base_index; uint e_index; - } exec_data = { - .base_index = (uint)RNA_int_get(op->ptr, "object_index"), - .e_index = (uint)RNA_int_get(op->ptr, "edge_index"), - }; + } exec_data{}; + exec_data.base_index = (uint)RNA_int_get(op->ptr, "object_index"); + exec_data.e_index = (uint)RNA_int_get(op->ptr, "edge_index"); const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -425,11 +432,12 @@ static int loopcut_init(bContext *C, wmOperator *op, const wmEvent *event) WM_event_add_modal_handler(C, op); } - RingSelOpData *lcd = op->customdata; + RingSelOpData *lcd = static_cast(op->customdata); lcd->bases = bases; lcd->bases_len = bases_len; - lcd->geom_cache = MEM_callocN(sizeof(*lcd->geom_cache) * bases_len, __func__); + lcd->geom_cache = static_cast( + MEM_callocN(sizeof(*lcd->geom_cache) * bases_len, __func__)); if (is_interactive) { copy_v2_v2_int(lcd->vc.mval, event->mval); @@ -481,16 +489,16 @@ static int ringcut_invoke(bContext *C, wmOperator *op, const wmEvent *event) wmGizmoMap *gzmap = region->gizmo_map; wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "VIEW3D_GGT_mesh_preselect_edgering") : - NULL; - if ((gzgroup != NULL) && gzgroup->gizmos.first) { - wmGizmo *gz = gzgroup->gizmos.first; + nullptr; + if ((gzgroup != nullptr) && gzgroup->gizmos.first) { + wmGizmo *gz = static_cast(gzgroup->gizmos.first); const int object_index = RNA_int_get(gz->ptr, "object_index"); const int edge_index = RNA_int_get(gz->ptr, "edge_index"); if (object_index != -1 && edge_index != -1) { RNA_int_set(op->ptr, "object_index", object_index); RNA_int_set(op->ptr, "edge_index", edge_index); - return loopcut_init(C, op, NULL); + return loopcut_init(C, op, nullptr); } return OPERATOR_CANCELLED; } @@ -501,14 +509,14 @@ static int ringcut_invoke(bContext *C, wmOperator *op, const wmEvent *event) static int loopcut_exec(bContext *C, wmOperator *op) { - return loopcut_init(C, op, NULL); + return loopcut_init(C, op, nullptr); } static int loopcut_finish(RingSelOpData *lcd, bContext *C, wmOperator *op) { /* finish */ ED_region_tag_redraw(lcd->region); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); if (lcd->eed) { /* set for redo */ @@ -534,7 +542,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_PASS_THROUGH; } - RingSelOpData *lcd = op->customdata; + RingSelOpData *lcd = static_cast(op->customdata); float cuts = lcd->cuts; float smoothness = lcd->smoothness; bool show_cuts = false; @@ -569,14 +577,14 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case RIGHTMOUSE: /* abort */ /* XXX hardcoded */ ED_region_tag_redraw(lcd->region); ringsel_exit(C, op); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); return OPERATOR_CANCELLED; case EVT_ESCKEY: if (event->val == KM_RELEASE) { /* cancel */ ED_region_tag_redraw(lcd->region); - ED_workspace_status_text(C, NULL); + ED_workspace_status_text(C, nullptr); ringcut_cancel(C, op); return OPERATOR_CANCELLED; @@ -626,14 +634,14 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) handled = true; break; case MOUSEMOVE: { - /* mouse moved somewhere to select another loop */ +/* mouse moved somewhere to select another loop */ - /* This is normally disabled for all modal operators. - * This is an exception since mouse movement doesn't relate to numeric input. - * - * If numeric input changes we'll need to add this back see: D2973 */ +/* This is normally disabled for all modal operators. + * This is an exception since mouse movement doesn't relate to numeric input. + * + * If numeric input changes we'll need to add this back see: D2973 */ #if 0 - if (!has_numinput) +if (!has_numinput) #endif { lcd->vc.mval[0] = event->mval[0]; @@ -698,19 +706,19 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) void MESH_OT_edgering_select(wmOperatorType *ot) { - /* description */ - ot->name = "Edge Ring Select"; - ot->idname = "MESH_OT_edgering_select"; - ot->description = "Select an edge ring"; +/* description */ +ot->name = "Edge Ring Select"; +ot->idname = "MESH_OT_edgering_select"; +ot->description = "Select an edge ring"; - /* callbacks */ - ot->invoke = ringsel_invoke; - ot->poll = ED_operator_editmesh_region_view3d; +/* callbacks */ +ot->invoke = ringsel_invoke; +ot->poll = ED_operator_editmesh_region_view3d; - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +/* flags */ +ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); +RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); } #endif @@ -768,7 +776,7 @@ void MESH_OT_loopcut(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN); #ifdef USE_LOOPSLIDE_HACK - prop = RNA_def_boolean_array(ot->srna, "mesh_select_mode_init", 3, NULL, "", ""); + prop = RNA_def_boolean_array(ot->srna, "mesh_select_mode_init", 3, nullptr, "", ""); RNA_def_property_flag(prop, PROP_HIDDEN); #endif } diff --git a/source/blender/editors/mesh/editmesh_path.c b/source/blender/editors/mesh/editmesh_path.cc similarity index 83% rename from source/blender/editors/mesh/editmesh_path.c rename to source/blender/editors/mesh/editmesh_path.cc index e015c4b29e9..1062ec45f1c 100644 --- a/source/blender/editors/mesh/editmesh_path.c +++ b/source/blender/editors/mesh/editmesh_path.cc @@ -79,7 +79,7 @@ static void path_select_properties(wmOperatorType *ot) {EDGE_MODE_TAG_CREASE, "CREASE", 0, "Tag Crease", ""}, {EDGE_MODE_TAG_BEVEL, "BEVEL", 0, "Tag Bevel", ""}, {EDGE_MODE_TAG_FREESTYLE, "FREESTYLE", 0, "Tag Freestyle Edge Mark", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; RNA_def_enum(ot->srna, @@ -133,7 +133,7 @@ static void path_select_params_from_op(wmOperator *op, } static bool path_select_poll_property(const bContext *C, - wmOperator *UNUSED(op), + wmOperator * /*op*/, const PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); @@ -161,21 +161,21 @@ struct UserData { * \{ */ /* callbacks */ -static bool verttag_filter_cb(BMVert *v, void *UNUSED(user_data_v)) +static bool verttag_filter_cb(BMVert *v, void * /*user_data_v*/) { return !BM_elem_flag_test(v, BM_ELEM_HIDDEN); } -static bool verttag_test_cb(BMVert *v, void *UNUSED(user_data_v)) +static bool verttag_test_cb(BMVert *v, void * /*user_data_v*/) { return BM_elem_flag_test_bool(v, BM_ELEM_SELECT); } static void verttag_set_cb(BMVert *v, bool val, void *user_data_v) { - struct UserData *user_data = user_data_v; + struct UserData *user_data = static_cast(user_data_v); BM_vert_select_set(user_data->bm, v, val); } -static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), +static void mouse_mesh_shortest_path_vert(Scene * /*scene*/, Object *obedit, const struct PathSelectParams *op_params, BMVert *v_act, @@ -201,8 +201,8 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), break; } - struct UserData user_data = {bm, obedit->data, cd_offset, op_params}; - LinkNode *path = NULL; + struct UserData user_data = {bm, static_cast(obedit->data), cd_offset, op_params}; + LinkNode *path = nullptr; bool is_path_ordered = false; if (v_act && (v_act != v_dst)) { @@ -212,15 +212,10 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), } else { is_path_ordered = true; - path = BM_mesh_calc_path_vert(bm, - v_act, - v_dst, - &(const struct BMCalcPathParams){ - .use_topology_distance = op_params->use_topology_distance, - .use_step_face = op_params->use_face_step, - }, - verttag_filter_cb, - &user_data); + BMCalcPathParams params{}; + params.use_topology_distance = op_params->use_topology_distance; + params.use_step_face = op_params->use_face_step; + path = BM_mesh_calc_path_vert(bm, v_act, v_dst, ¶ms, verttag_filter_cb, &user_data); } if (path) { @@ -253,12 +248,12 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), { verttag_set_cb((BMVert *)node->link, !all_set, &user_data); if (is_path_ordered) { - v_dst_last = node->link; + v_dst_last = static_cast(node->link); } } } while ((void)depth++, (node = node->next)); - BLI_linklist_free(path, NULL); + BLI_linklist_free(path, nullptr); } else { const bool is_act = !verttag_test_cb(v_dst, &user_data); @@ -277,12 +272,11 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), } } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(obedit->data), ¶ms); } /** \} */ @@ -292,13 +286,13 @@ static void mouse_mesh_shortest_path_vert(Scene *UNUSED(scene), * \{ */ /* callbacks */ -static bool edgetag_filter_cb(BMEdge *e, void *UNUSED(user_data_v)) +static bool edgetag_filter_cb(BMEdge *e, void * /*user_data_v*/) { return !BM_elem_flag_test(e, BM_ELEM_HIDDEN); } static bool edgetag_test_cb(BMEdge *e, void *user_data_v) { - struct UserData *user_data = user_data_v; + struct UserData *user_data = static_cast(user_data_v); const char edge_mode = user_data->op_params->edge_mode; switch (edge_mode) { @@ -314,7 +308,8 @@ static bool edgetag_test_cb(BMEdge *e, void *user_data_v) #ifdef WITH_FREESTYLE case EDGE_MODE_TAG_FREESTYLE: { BMesh *bm = user_data->bm; - FreestyleEdge *fed = CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE); + FreestyleEdge *fed = static_cast( + CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE)); return (!fed) ? false : (fed->flag & FREESTYLE_EDGE_MARK) ? true : false; } #endif @@ -323,7 +318,7 @@ static bool edgetag_test_cb(BMEdge *e, void *user_data_v) } static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v) { - struct UserData *user_data = user_data_v; + struct UserData *user_data = static_cast(user_data_v); const char edge_mode = user_data->op_params->edge_mode; BMesh *bm = user_data->bm; @@ -344,7 +339,8 @@ static void edgetag_set_cb(BMEdge *e, bool val, void *user_data_v) #ifdef WITH_FREESTYLE case EDGE_MODE_TAG_FREESTYLE: { FreestyleEdge *fed; - fed = CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE); + fed = static_cast( + CustomData_bmesh_get(&bm->edata, e->head.data, CD_FREESTYLE_EDGE)); if (!val) { fed->flag &= ~FREESTYLE_EDGE_MARK; } @@ -413,11 +409,11 @@ static void mouse_mesh_shortest_path_edge(Scene *scene, break; } - struct UserData user_data = {bm, obedit->data, cd_offset, op_params}; - LinkNode *path = NULL; + struct UserData user_data = {bm, static_cast(obedit->data), cd_offset, op_params}; + LinkNode *path = nullptr; bool is_path_ordered = false; - edgetag_ensure_cd_flag(obedit->data, op_params->edge_mode); + edgetag_ensure_cd_flag(static_cast(obedit->data), op_params->edge_mode); if (e_act && (e_act != e_dst)) { if (op_params->use_fill) { @@ -426,15 +422,10 @@ static void mouse_mesh_shortest_path_edge(Scene *scene, } else { is_path_ordered = true; - path = BM_mesh_calc_path_edge(bm, - e_act, - e_dst, - &(const struct BMCalcPathParams){ - .use_topology_distance = op_params->use_topology_distance, - .use_step_face = op_params->use_face_step, - }, - edgetag_filter_cb, - &user_data); + BMCalcPathParams params{}; + params.use_topology_distance = op_params->use_topology_distance; + params.use_step_face = op_params->use_face_step; + path = BM_mesh_calc_path_edge(bm, e_act, e_dst, ¶ms, edgetag_filter_cb, &user_data); } if (path) { @@ -467,16 +458,16 @@ static void mouse_mesh_shortest_path_edge(Scene *scene, { edgetag_set_cb((BMEdge *)node->link, !all_set, &user_data); if (is_path_ordered) { - e_dst_last = node->link; + e_dst_last = static_cast(node->link); } } } while ((void)depth++, (node = node->next)); - BLI_linklist_free(path, NULL); + BLI_linklist_free(path, nullptr); } else { const bool is_act = !edgetag_test_cb(e_dst, &user_data); - edgetag_ensure_cd_flag(obedit->data, op_params->edge_mode); + edgetag_ensure_cd_flag(static_cast(obedit->data), op_params->edge_mode); edgetag_set_cb(e_dst, is_act, &user_data); /* switch the edge option */ } @@ -505,12 +496,11 @@ static void mouse_mesh_shortest_path_edge(Scene *scene, } } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(obedit->data), ¶ms); if (op_params->edge_mode == EDGE_MODE_TAG_SEAM) { ED_uvedit_live_unwrap(scene, &obedit, 1); @@ -524,23 +514,23 @@ static void mouse_mesh_shortest_path_edge(Scene *scene, * \{ */ /* callbacks */ -static bool facetag_filter_cb(BMFace *f, void *UNUSED(user_data_v)) +static bool facetag_filter_cb(BMFace *f, void * /*user_data_v*/) { return !BM_elem_flag_test(f, BM_ELEM_HIDDEN); } -// static bool facetag_test_cb(Scene *UNUSED(scene), BMesh *UNUSED(bm), BMFace *f) -static bool facetag_test_cb(BMFace *f, void *UNUSED(user_data_v)) +// static bool facetag_test_cb(Scene * /*scene*/, BMesh * /*bm*/, BMFace *f) +static bool facetag_test_cb(BMFace *f, void * /*user_data_v*/) { return BM_elem_flag_test_bool(f, BM_ELEM_SELECT); } -// static void facetag_set_cb(BMesh *bm, Scene *UNUSED(scene), BMFace *f, const bool val) +// static void facetag_set_cb(BMesh *bm, Scene * /*scene*/, BMFace *f, const bool val) static void facetag_set_cb(BMFace *f, bool val, void *user_data_v) { - struct UserData *user_data = user_data_v; + struct UserData *user_data = static_cast(user_data_v); BM_face_select_set(user_data->bm, f, val); } -static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene), +static void mouse_mesh_shortest_path_face(Scene * /*scene*/, Object *obedit, const struct PathSelectParams *op_params, BMFace *f_act, @@ -566,8 +556,8 @@ static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene), break; } - struct UserData user_data = {bm, obedit->data, cd_offset, op_params}; - LinkNode *path = NULL; + struct UserData user_data = {bm, static_cast(obedit->data), cd_offset, op_params}; + LinkNode *path = nullptr; bool is_path_ordered = false; if (f_act) { @@ -577,15 +567,10 @@ static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene), } else { is_path_ordered = true; - path = BM_mesh_calc_path_face(bm, - f_act, - f_dst, - &(const struct BMCalcPathParams){ - .use_topology_distance = op_params->use_topology_distance, - .use_step_face = op_params->use_face_step, - }, - facetag_filter_cb, - &user_data); + BMCalcPathParams params{}; + params.use_topology_distance = op_params->use_topology_distance; + params.use_step_face = op_params->use_face_step; + path = BM_mesh_calc_path_face(bm, f_act, f_dst, ¶ms, facetag_filter_cb, &user_data); } if (f_act != f_dst) { @@ -620,12 +605,12 @@ static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene), { facetag_set_cb((BMFace *)node->link, !all_set, &user_data); if (is_path_ordered) { - f_dst_last = node->link; + f_dst_last = static_cast(node->link); } } } while ((void)depth++, (node = node->next)); - BLI_linklist_free(path, NULL); + BLI_linklist_free(path, nullptr); } else { const bool is_act = !facetag_test_cb(f_dst, &user_data); @@ -645,12 +630,11 @@ static void mouse_mesh_shortest_path_face(Scene *UNUSED(scene), BM_mesh_active_face_set(bm, f_dst_last); } - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(obedit->data), ¶ms); } /** \} */ @@ -667,7 +651,7 @@ static bool edbm_shortest_path_pick_ex(Scene *scene, { bool ok = false; - if (ELEM(NULL, ele_src, ele_dst) || (ele_src->head.htype != ele_dst->head.htype)) { + if (ELEM(nullptr, ele_src, ele_dst) || (ele_src->head.htype != ele_dst->head.htype)) { /* pass */ } else if (ele_src->head.htype == BM_VERT) { @@ -684,7 +668,7 @@ static bool edbm_shortest_path_pick_ex(Scene *scene, } if (ok) { - DEG_id_tag_update(obedit->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(obedit->data), ID_RECALC_SELECT); WM_main_add_notifier(NC_GEOM | ND_SELECT, obedit->data); } @@ -708,14 +692,14 @@ static BMElem *edbm_elem_find_nearest(ViewContext *vc, const char htype) return (BMElem *)EDBM_face_find_nearest(vc, &dist); } - return NULL; + return nullptr; } static BMElem *edbm_elem_active_elem_or_face_get(BMesh *bm) { BMElem *ele = BM_mesh_active_elem_get(bm); - if ((ele == NULL) && bm->act_face && BM_elem_flag_test(bm->act_face, BM_ELEM_SELECT)) { + if ((ele == nullptr) && bm->act_face && BM_elem_flag_test(bm->act_face, BM_ELEM_SELECT)) { ele = (BMElem *)bm->act_face; } @@ -728,9 +712,9 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE return edbm_shortest_path_pick_exec(C, op); } - BMVert *eve = NULL; - BMEdge *eed = NULL; - BMFace *efa = NULL; + BMVert *eve = nullptr; + BMEdge *eed = nullptr; + BMFace *efa = nullptr; ViewContext vc; bool track_active = true; @@ -761,9 +745,8 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE /* TODO(dfelinto): right now we try to find the closest element twice. * The ideal is to refactor EDBM_select_pick so it doesn't * have to pick the nearest vert/edge/face again. */ - const struct SelectPick_Params params = { - .sel_op = SEL_OP_ADD, - }; + SelectPick_Params params{}; + params.sel_op = SEL_OP_ADD; EDBM_select_pick(C, event->mval, ¶ms); return OPERATOR_FINISHED; } @@ -778,7 +761,7 @@ static int edbm_shortest_path_pick_invoke(bContext *C, wmOperator *op, const wmE /* special case, toggle edge tags even when we don't have a path */ if (((em->selectmode & SCE_SELECT_EDGE) && (op_params.edge_mode != EDGE_MODE_SELECT)) && /* check if we only have a destination edge */ - ((ele_src == NULL) && (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE)))) + ((ele_src == nullptr) && (ele_dst = edbm_elem_find_nearest(&vc, BM_EDGE)))) { ele_src = ele_dst; track_active = false; @@ -885,28 +868,28 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) BMesh *bm = em->bm; BMIter iter; BMEditSelection *ese_src, *ese_dst; - BMElem *ele_src = NULL, *ele_dst = NULL, *ele; + BMElem *ele_src = nullptr, *ele_dst = nullptr, *ele; if ((em->bm->totvertsel == 0) && (em->bm->totedgesel == 0) && (em->bm->totfacesel == 0)) { continue; } /* first try to find vertices in edit selection */ - ese_src = bm->selected.last; + ese_src = static_cast(bm->selected.last); if (ese_src && (ese_dst = ese_src->prev) && (ese_src->htype == ese_dst->htype)) { ele_src = ese_src->ele; ele_dst = ese_dst->ele; } else { /* if selection history isn't available, find two selected elements */ - ele_src = ele_dst = NULL; + ele_src = ele_dst = nullptr; if ((em->selectmode & SCE_SELECT_VERTEX) && (bm->totvertsel >= 2)) { BM_ITER_MESH (ele, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { - if (ele_src == NULL) { + if (ele_src == nullptr) { ele_src = ele; } - else if (ele_dst == NULL) { + else if (ele_dst == nullptr) { ele_dst = ele; } else { @@ -916,14 +899,14 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) } } - if ((ele_dst == NULL) && (em->selectmode & SCE_SELECT_EDGE) && (bm->totedgesel >= 2)) { - ele_src = NULL; + if ((ele_dst == nullptr) && (em->selectmode & SCE_SELECT_EDGE) && (bm->totedgesel >= 2)) { + ele_src = nullptr; BM_ITER_MESH (ele, &iter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { - if (ele_src == NULL) { + if (ele_src == nullptr) { ele_src = ele; } - else if (ele_dst == NULL) { + else if (ele_dst == nullptr) { ele_dst = ele; } else { @@ -933,14 +916,14 @@ static int edbm_shortest_path_select_exec(bContext *C, wmOperator *op) } } - if ((ele_dst == NULL) && (em->selectmode & SCE_SELECT_FACE) && (bm->totfacesel >= 2)) { - ele_src = NULL; + if ((ele_dst == nullptr) && (em->selectmode & SCE_SELECT_FACE) && (bm->totfacesel >= 2)) { + ele_src = nullptr; BM_ITER_MESH (ele, &iter, bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) { - if (ele_src == NULL) { + if (ele_src == nullptr) { ele_src = ele; } - else if (ele_dst == NULL) { + else if (ele_dst == nullptr) { ele_dst = ele; } else { diff --git a/source/blender/editors/mesh/editmesh_polybuild.c b/source/blender/editors/mesh/editmesh_polybuild.cc similarity index 85% rename from source/blender/editors/mesh/editmesh_polybuild.c rename to source/blender/editors/mesh/editmesh_polybuild.cc index 6ea8655c5a0..8f29b287dbf 100644 --- a/source/blender/editors/mesh/editmesh_polybuild.c +++ b/source/blender/editors/mesh/editmesh_polybuild.cc @@ -69,7 +69,7 @@ static void edbm_flag_disable_all_multi(const Scene *scene, BMesh *bm_iter = em_iter->bm; if (bm_iter->totvertsel) { EDBM_flag_disable_all(em_iter, hflag); - DEG_id_tag_update(ob_iter->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(ob_iter->data), ID_RECALC_SELECT); } } MEM_freeN(objects); @@ -81,11 +81,11 @@ static bool edbm_preselect_or_active(bContext *C, const View3D *v3d, Base **r_ba ARegion *region = CTX_wm_region(C); const bool show_gizmo = !(v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)); - wmGizmoMap *gzmap = show_gizmo ? region->gizmo_map : NULL; + wmGizmoMap *gzmap = show_gizmo ? region->gizmo_map : nullptr; wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "VIEW3D_GGT_mesh_preselect_elem") : - NULL; - if (gzgroup != NULL) { - wmGizmo *gz = gzgroup->gizmos.first; + nullptr; + if (gzgroup != nullptr) { + wmGizmo *gz = static_cast(gzgroup->gizmos.first); ED_view3d_gizmo_mesh_preselect_get_active(C, gz, r_base, r_ele); } else { @@ -99,7 +99,7 @@ static bool edbm_preselect_or_active(bContext *C, const View3D *v3d, Base **r_ba *r_base = base; *r_ele = BM_mesh_active_elem_get(bm); } - return (*r_ele != NULL); + return (*r_ele != nullptr); } static bool edbm_preselect_or_active_init_viewcontext(bContext *C, @@ -116,12 +116,12 @@ static bool edbm_preselect_or_active_init_viewcontext(bContext *C, } static int edbm_polybuild_transform_at_cursor_invoke(bContext *C, - wmOperator *UNUSED(op), - const wmEvent *UNUSED(event)) + wmOperator * /*op*/, + const wmEvent * /*event*/) { ViewContext vc; - Base *basact = NULL; - BMElem *ele_act = NULL; + Base *basact = nullptr; + BMElem *ele_act = nullptr; edbm_preselect_or_active_init_viewcontext(C, &vc, &basact, &ele_act); BMEditMesh *em = vc.em; BMesh *bm = em->bm; @@ -147,13 +147,12 @@ static int edbm_polybuild_transform_at_cursor_invoke(bContext *C, BM_face_select_set(bm, (BMFace *)ele_act, true); } - EDBM_update(vc.obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); - if (basact != NULL) { + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(vc.obedit->data), ¶ms); + if (basact != nullptr) { BKE_view_layer_synced_ensure(vc.scene, vc.view_layer); if (BKE_view_layer_active_base_get(vc.view_layer) != basact) { ED_object_base_activate(C, basact); @@ -183,13 +182,13 @@ void MESH_OT_polybuild_transform_at_cursor(wmOperatorType *ot) static int edbm_polybuild_delete_at_cursor_invoke(bContext *C, wmOperator *op, - const wmEvent *UNUSED(event)) + const wmEvent * /*event*/) { bool changed = false; ViewContext vc; - Base *basact = NULL; - BMElem *ele_act = NULL; + Base *basact = nullptr; + BMElem *ele_act = nullptr; edbm_preselect_or_active_init_viewcontext(C, &vc, &basact, &ele_act); BMEditMesh *em = vc.em; BMesh *bm = em->bm; @@ -236,13 +235,12 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C, } if (changed) { - EDBM_update(vc.obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); - if (basact != NULL) { + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(vc.obedit->data), ¶ms); + if (basact != nullptr) { BKE_view_layer_synced_ensure(vc.scene, vc.view_layer); if (BKE_view_layer_active_base_get(vc.view_layer) != basact) { ED_object_base_activate(C, basact); @@ -283,8 +281,8 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con bool changed = false; ViewContext vc; - Base *basact = NULL; - BMElem *ele_act = NULL; + Base *basact = nullptr; + BMElem *ele_act = nullptr; edbm_preselect_or_active_init_viewcontext(C, &vc, &basact, &ele_act); BMEditMesh *em = vc.em; BMesh *bm = em->bm; @@ -294,14 +292,14 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); - if (ele_act == NULL || ele_act->head.htype == BM_FACE) { + if (ele_act == nullptr || ele_act->head.htype == BM_FACE) { /* Just add vert */ copy_v3_v3(center, vc.scene->cursor.location); mul_v3_m4v3(center, vc.obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); mul_m4_v3(vc.obedit->world_to_object, center); - BMVert *v_new = BM_vert_create(bm, center, NULL, BM_CREATE_NOP); + BMVert *v_new = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); edbm_flag_disable_all_multi(vc.scene, vc.view_layer, vc.v3d, BM_ELEM_SELECT); BM_vert_select_set(bm, v_new, true); BM_select_history_store(bm, v_new); @@ -309,7 +307,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con } else if (ele_act->head.htype == BM_EDGE) { BMEdge *e_act = (BMEdge *)ele_act; - BMFace *f_reference = e_act->l ? e_act->l->f : NULL; + BMFace *f_reference = e_act->l ? e_act->l->f : nullptr; mid_v3_v3v3(center, e_act->v1->co, e_act->v2->co); mul_m4_v3(vc.obedit->object_to_world, center); @@ -317,7 +315,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con mul_m4_v3(vc.obedit->world_to_object, center); if (f_reference->len == 3 && RNA_boolean_get(op->ptr, "create_quads")) { const float fac = line_point_factor_v3(center, e_act->v1->co, e_act->v2->co); - BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, NULL, CLAMPIS(fac, 0.0f, 1.0f)); + BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, nullptr, CLAMPIS(fac, 0.0f, 1.0f)); copy_v3_v3(v_new->co, center); edbm_flag_disable_all_multi(vc.scene, vc.view_layer, vc.v3d, BM_ELEM_SELECT); BM_vert_select_set(bm, v_new, true); @@ -327,7 +325,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMVert *v_tri[3]; v_tri[0] = e_act->v1; v_tri[1] = e_act->v2; - v_tri[2] = BM_vert_create(bm, center, NULL, BM_CREATE_NOP); + v_tri[2] = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); if (e_act->l && e_act->l->v == v_tri[0]) { SWAP(BMVert *, v_tri[0], v_tri[1]); } @@ -340,10 +338,10 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con } else if (ele_act->head.htype == BM_VERT) { BMVert *v_act = (BMVert *)ele_act; - BMEdge *e_pair[2] = {NULL}; + BMEdge *e_pair[2] = {nullptr}; - if (v_act->e != NULL) { - for (uint allow_wire = 0; allow_wire < 2 && (e_pair[1] == NULL); allow_wire++) { + if (v_act->e != nullptr) { + for (uint allow_wire = 0; allow_wire < 2 && (e_pair[1] == nullptr); allow_wire++) { int i = 0; BMEdge *e_iter = v_act->e; do { @@ -351,7 +349,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con (allow_wire ? BM_edge_is_wire(e_iter) : BM_edge_is_boundary(e_iter))) { if (i == 2) { - e_pair[0] = e_pair[1] = NULL; + e_pair[0] = e_pair[1] = nullptr; break; } e_pair[i++] = e_iter; @@ -360,13 +358,13 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con } } - if (e_pair[1] != NULL) { + if (e_pair[1] != nullptr) { /* Quad from edge pair. */ if (BM_edge_calc_length_squared(e_pair[0]) < BM_edge_calc_length_squared(e_pair[1])) { SWAP(BMEdge *, e_pair[0], e_pair[1]); } - BMFace *f_reference = e_pair[0]->l ? e_pair[0]->l->f : NULL; + BMFace *f_reference = e_pair[0]->l ? e_pair[0]->l->f : nullptr; mul_v3_m4v3(center, vc.obedit->object_to_world, v_act->co); ED_view3d_win_to_3d_int(vc.v3d, vc.region, center, event->mval, center); @@ -375,7 +373,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con BMVert *v_quad[4]; v_quad[0] = v_act; v_quad[1] = BM_edge_other_vert(e_pair[0], v_act); - v_quad[2] = BM_vert_create(bm, center, NULL, BM_CREATE_NOP); + v_quad[2] = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); v_quad[3] = BM_edge_other_vert(e_pair[1], v_act); if (e_pair[0]->l && e_pair[0]->l->v == v_quad[0]) { SWAP(BMVert *, v_quad[1], v_quad[3]); @@ -394,9 +392,9 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con ED_view3d_win_to_3d_int(vc.v3d, vc.region, v_act->co, event->mval, center); mul_m4_v3(vc.obedit->world_to_object, center); - BMVert *v_new = BM_vert_create(bm, center, NULL, BM_CREATE_NOP); + BMVert *v_new = BM_vert_create(bm, center, nullptr, BM_CREATE_NOP); - BM_edge_create(bm, v_act, v_new, NULL, BM_CREATE_NOP); + BM_edge_create(bm, v_act, v_new, nullptr, BM_CREATE_NOP); BM_vert_select_set(bm, v_new, true); BM_select_history_store(bm, v_new); @@ -405,14 +403,13 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con } if (changed) { - EDBM_update(vc.obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(vc.obedit->data), ¶ms); - if (basact != NULL) { + if (basact != nullptr) { BKE_view_layer_synced_ensure(vc.scene, vc.view_layer); if (BKE_view_layer_active_base_get(vc.view_layer) != basact) { ED_object_base_activate(C, basact); @@ -455,15 +452,15 @@ void MESH_OT_polybuild_face_at_cursor(wmOperatorType *ot) * \{ */ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, - wmOperator *UNUSED(op), + wmOperator * /*op*/, const wmEvent *event) { float center[3]; bool changed = false; ViewContext vc; - Base *basact = NULL; - BMElem *ele_act = NULL; + Base *basact = nullptr; + BMElem *ele_act = nullptr; edbm_preselect_or_active_init_viewcontext(C, &vc, &basact, &ele_act); BMEditMesh *em = vc.em; BMesh *bm = em->bm; @@ -473,7 +470,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, edbm_selectmode_ensure(vc.scene, vc.em, SCE_SELECT_VERTEX); - if (ele_act == NULL || ele_act->head.hflag == BM_FACE) { + if (ele_act == nullptr || ele_act->head.hflag == BM_FACE) { return OPERATOR_PASS_THROUGH; } if (ele_act->head.htype == BM_EDGE) { @@ -484,7 +481,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, mul_m4_v3(vc.obedit->world_to_object, center); const float fac = line_point_factor_v3(center, e_act->v1->co, e_act->v2->co); - BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, NULL, CLAMPIS(fac, 0.0f, 1.0f)); + BMVert *v_new = BM_edge_split(bm, e_act, e_act->v1, nullptr, CLAMPIS(fac, 0.0f, 1.0f)); copy_v3_v3(v_new->co, center); edbm_flag_disable_all_multi(vc.scene, vc.view_layer, vc.v3d, BM_ELEM_SELECT); @@ -498,12 +495,11 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C, } if (changed) { - EDBM_update(vc.obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(vc.obedit->data), ¶ms); WM_event_add_mousemove(vc.win); @@ -542,18 +538,18 @@ void MESH_OT_polybuild_split_at_cursor(wmOperatorType *ot) static int edbm_polybuild_dissolve_at_cursor_invoke(bContext *C, wmOperator *op, - const wmEvent *UNUSED(event)) + const wmEvent * /*event*/) { bool changed = false; ViewContext vc; - Base *basact = NULL; - BMElem *ele_act = NULL; + Base *basact = nullptr; + BMElem *ele_act = nullptr; edbm_preselect_or_active_init_viewcontext(C, &vc, &basact, &ele_act); BMEditMesh *em = vc.em; BMesh *bm = em->bm; - if (ele_act == NULL) { + if (ele_act == nullptr) { /* pass */ } else if (ele_act->head.htype == BM_EDGE) { @@ -594,12 +590,8 @@ static int edbm_polybuild_dissolve_at_cursor_invoke(bContext *C, if (changed) { edbm_flag_disable_all_multi(vc.scene, vc.view_layer, vc.v3d, BM_ELEM_SELECT); - EDBM_update(vc.obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + EDBM_update(static_cast(vc.obedit->data), ¶ms); BKE_view_layer_synced_ensure(vc.scene, vc.view_layer); if (BKE_view_layer_active_base_get(vc.view_layer) != basact) { diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.cc similarity index 92% rename from source/blender/editors/mesh/editmesh_preselect_edgering.c rename to source/blender/editors/mesh/editmesh_preselect_edgering.cc index aa70771f576..9f3bbe3df33 100644 --- a/source/blender/editors/mesh/editmesh_preselect_edgering.c +++ b/source/blender/editors/mesh/editmesh_preselect_edgering.cc @@ -124,7 +124,8 @@ struct EditMesh_PreSelEdgeRing { struct EditMesh_PreSelEdgeRing *EDBM_preselect_edgering_create(void) { - struct EditMesh_PreSelEdgeRing *psel = MEM_callocN(sizeof(*psel), __func__); + struct EditMesh_PreSelEdgeRing *psel = static_cast( + MEM_callocN(sizeof(*psel), __func__)); return psel; } @@ -206,7 +207,7 @@ void EDBM_preselect_edgering_draw(struct EditMesh_PreSelEdgeRing *psel, const fl static void view3d_preselect_mesh_edgering_update_verts_from_edge( struct EditMesh_PreSelEdgeRing *psel, - BMesh *UNUSED(bm), + BMesh * /*bm*/, BMEdge *eed_start, int previewlines, const float (*coords)[3]) @@ -215,7 +216,7 @@ static void view3d_preselect_mesh_edgering_update_verts_from_edge( float(*verts)[3]; int i, tot = 0; - verts = MEM_mallocN(sizeof(*psel->verts) * previewlines, __func__); + verts = static_cast(MEM_mallocN(sizeof(*psel->verts) * previewlines, __func__)); edgering_vcos_get_pair(&eed_start->v1, v_cos, coords); @@ -238,8 +239,8 @@ static void view3d_preselect_mesh_edgering_update_edges_from_edge( { BMWalker walker; BMEdge *eed, *eed_last; - BMVert *v[2][2] = {{NULL}}, *eve_last; - float(*edges)[2][3] = NULL; + BMVert *v[2][2] = {{nullptr}}, *eve_last; + float(*edges)[2][3] = nullptr; BLI_Stack *edge_stack; int i, tot = 0; @@ -255,20 +256,22 @@ static void view3d_preselect_mesh_edgering_update_edges_from_edge( edge_stack = BLI_stack_new(sizeof(BMEdge *), __func__); - eed_last = NULL; - for (eed = eed_last = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) { + eed_last = nullptr; + for (eed = eed_last = static_cast(BMW_begin(&walker, eed_start)); eed; + eed = static_cast(BMW_step(&walker))) + { BLI_stack_push(edge_stack, &eed); } BMW_end(&walker); eed_start = *(BMEdge **)BLI_stack_peek(edge_stack); - edges = MEM_mallocN((sizeof(*edges) * (BLI_stack_count(edge_stack) + (eed_last != eed_start))) * - previewlines, - __func__); + edges = static_cast(MEM_mallocN( + (sizeof(*edges) * (BLI_stack_count(edge_stack) + (eed_last != eed_start))) * previewlines, + __func__)); - eve_last = NULL; - eed_last = NULL; + eve_last = nullptr; + eed_last = nullptr; while (!BLI_stack_is_empty(edge_stack)) { BLI_stack_pop(edge_stack, &eed); diff --git a/source/blender/editors/mesh/editmesh_preselect_elem.c b/source/blender/editors/mesh/editmesh_preselect_elem.cc similarity index 87% rename from source/blender/editors/mesh/editmesh_preselect_elem.c rename to source/blender/editors/mesh/editmesh_preselect_elem.cc index 411eb7461f2..65ffa78f760 100644 --- a/source/blender/editors/mesh/editmesh_preselect_elem.c +++ b/source/blender/editors/mesh/editmesh_preselect_elem.cc @@ -85,7 +85,8 @@ eEditMesh_PreSelPreviewAction EDBM_preselect_action_get(struct EditMesh_PreSelEl struct EditMesh_PreSelElem *EDBM_preselect_elem_create(void) { - struct EditMesh_PreSelElem *psel = MEM_callocN(sizeof(*psel), __func__); + struct EditMesh_PreSelElem *psel = static_cast( + MEM_callocN(sizeof(*psel), __func__)); psel->preview_action = PRESELECT_ACTION_TRANSFORM; return psel; } @@ -196,22 +197,22 @@ void EDBM_preselect_elem_draw(struct EditMesh_PreSelElem *psel, const float matr } static void view3d_preselect_mesh_elem_update_from_vert(struct EditMesh_PreSelElem *psel, - BMesh *UNUSED(bm), + BMesh * /*bm*/, BMVert *eve, const float (*coords)[3]) { - float(*verts)[3] = MEM_mallocN(sizeof(*psel->verts), __func__); + float(*verts)[3] = static_cast(MEM_mallocN(sizeof(*psel->verts), __func__)); vcos_get(eve, verts[0], coords); psel->verts = verts; psel->verts_len = 1; } static void view3d_preselect_mesh_elem_update_from_edge(struct EditMesh_PreSelElem *psel, - BMesh *UNUSED(bm), + BMesh * /*bm*/, BMEdge *eed, const float (*coords)[3]) { - float(*edges)[2][3] = MEM_mallocN(sizeof(*psel->edges), __func__); + float(*edges)[2][3] = static_cast(MEM_mallocN(sizeof(*psel->edges), __func__)); vcos_get_pair(&eed->v1, edges[0], coords); psel->edges = edges; psel->edges_len = 1; @@ -219,16 +220,16 @@ static void view3d_preselect_mesh_elem_update_from_edge(struct EditMesh_PreSelEl static void view3d_preselect_update_preview_triangle_from_vert(struct EditMesh_PreSelElem *psel, ViewContext *vc, - BMesh *UNUSED(bm), + BMesh * /*bm*/, BMVert *eed, const int mval[2]) { BMVert *v_act = eed; - BMEdge *e_pair[2] = {NULL}; + BMEdge *e_pair[2] = {nullptr}; float center[3]; - if (v_act->e != NULL) { - for (uint allow_wire = 0; allow_wire < 2 && (e_pair[1] == NULL); allow_wire++) { + if (v_act->e != nullptr) { + for (uint allow_wire = 0; allow_wire < 2 && (e_pair[1] == nullptr); allow_wire++) { int i = 0; BMEdge *e_iter = v_act->e; do { @@ -236,7 +237,7 @@ static void view3d_preselect_update_preview_triangle_from_vert(struct EditMesh_P (allow_wire ? BM_edge_is_wire(e_iter) : BM_edge_is_boundary(e_iter))) { if (i == 2) { - e_pair[0] = e_pair[1] = NULL; + e_pair[0] = e_pair[1] = nullptr; break; } e_pair[i++] = e_iter; @@ -245,13 +246,15 @@ static void view3d_preselect_update_preview_triangle_from_vert(struct EditMesh_P } } - if (e_pair[1] != NULL) { + if (e_pair[1] != nullptr) { mul_v3_m4v3(center, vc->obedit->object_to_world, v_act->co); ED_view3d_win_to_3d_int(vc->v3d, vc->region, center, mval, center); mul_m4_v3(vc->obedit->world_to_object, center); - psel->preview_tris = MEM_mallocN(sizeof(*psel->preview_tris) * 2, __func__); - psel->preview_lines = MEM_mallocN(sizeof(*psel->preview_lines) * 4, __func__); + psel->preview_tris = static_cast( + MEM_mallocN(sizeof(*psel->preview_tris) * 2, __func__)); + psel->preview_lines = static_cast( + MEM_mallocN(sizeof(*psel->preview_lines) * 4, __func__)); copy_v3_v3(psel->preview_tris[0][0], e_pair[0]->v1->co); copy_v3_v3(psel->preview_tris[0][1], e_pair[0]->v2->co); @@ -288,17 +291,18 @@ static void view3d_preselect_update_preview_triangle_from_vert(struct EditMesh_P } static void view3d_preselect_update_preview_triangle_from_face(struct EditMesh_PreSelElem *psel, - ViewContext *UNUSED(vc), - BMesh *UNUSED(bm), + ViewContext * /*vc*/, + BMesh * /*bm*/, BMFace *efa, - const int UNUSED(mval[2])) + const int /*mval*/[2]) { - float(*preview_lines)[2][3] = MEM_mallocN(sizeof(*psel->edges) * efa->len, __func__); + float(*preview_lines)[2][3] = static_cast( + MEM_mallocN(sizeof(*psel->edges) * efa->len, __func__)); BMLoop *l_iter, *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(efa); int i = 0; do { - vcos_get_pair(&l_iter->e->v1, preview_lines[i++], NULL); + vcos_get_pair(&l_iter->e->v1, preview_lines[i++], nullptr); } while ((l_iter = l_iter->next) != l_first); psel->preview_lines = preview_lines; psel->preview_lines_len = efa->len; @@ -306,13 +310,15 @@ static void view3d_preselect_update_preview_triangle_from_face(struct EditMesh_P static void view3d_preselect_update_preview_triangle_from_edge(struct EditMesh_PreSelElem *psel, ViewContext *vc, - BMesh *UNUSED(bm), + BMesh * /*bm*/, BMEdge *eed, const int mval[2]) { float center[3]; - psel->preview_tris = MEM_mallocN(sizeof(*psel->preview_tris), __func__); - psel->preview_lines = MEM_mallocN(sizeof(*psel->preview_lines) * 3, __func__); + psel->preview_tris = static_cast( + MEM_mallocN(sizeof(*psel->preview_tris), __func__)); + psel->preview_lines = static_cast( + MEM_mallocN(sizeof(*psel->preview_lines) * 3, __func__)); mid_v3_v3v3(center, eed->v1->co, eed->v2->co); mul_m4_v3(vc->obedit->object_to_world, center); ED_view3d_win_to_3d_int(vc->v3d, vc->region, center, mval, center); @@ -335,11 +341,12 @@ static void view3d_preselect_update_preview_triangle_from_edge(struct EditMesh_P } static void view3d_preselect_mesh_elem_update_from_face(struct EditMesh_PreSelElem *psel, - BMesh *UNUSED(bm), + BMesh * /*bm*/, BMFace *efa, const float (*coords)[3]) { - float(*edges)[2][3] = MEM_mallocN(sizeof(*psel->edges) * efa->len, __func__); + float(*edges)[2][3] = static_cast( + MEM_mallocN(sizeof(*psel->edges) * efa->len, __func__)); BMLoop *l_iter, *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(efa); int i = 0; diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.cc similarity index 94% rename from source/blender/editors/mesh/editmesh_rip.c rename to source/blender/editors/mesh/editmesh_rip.cc index 2005919f279..2fe1f4555a8 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.cc @@ -72,15 +72,14 @@ static float edbm_rip_edgedist_squared(ARegion *region, } #if 0 -static float edbm_rip_linedist( - ARegion *region, float mat[4][4], const float co1[3], const float co2[3], const float mvalf[2]) +static float edbm_rip_linedist( ARegion *region, float mat[4][4], const float co1[3], const float co2[3], const float mvalf[2]) { - float vec1[2], vec2[2]; +float vec1[2], vec2[2]; - ED_view3d_project_float_v2_m4(region, co1, vec1, mat); - ED_view3d_project_float_v2_m4(region, co2, vec2, mat); +ED_view3d_project_float_v2_m4(region, co1, vec1, mat); +ED_view3d_project_float_v2_m4(region, co2, vec2, mat); - return dist_to_line_v2(mvalf, vec1, vec2); +return dist_to_line_v2(mvalf, vec1, vec2); } #endif @@ -204,7 +203,7 @@ static BMEdge *edbm_ripsel_edge_mark_step(BMVert *v, const int uid) return e; } } - return NULL; + return nullptr; } typedef struct EdgeLoopPair { @@ -224,7 +223,7 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm) int uid_end; int uid = bm->totedge; /* can start anywhere */ - EdgeLoopPair *eloop_pairs = NULL; + EdgeLoopPair *eloop_pairs = nullptr; BLI_array_declare(eloop_pairs); EdgeLoopPair *lp; @@ -246,7 +245,7 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm) BMEdge *e_first; BMEdge *e_last; - e_first = NULL; + e_first = nullptr; BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (IS_VISIT_POSSIBLE(e) && !IS_VISIT_DONE(e)) { e_first = e; @@ -254,14 +253,14 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm) } } - if (e_first == NULL) { + if (e_first == nullptr) { break; } /* Initialize. */ e_first = e; v_step = e_first->v1; - e_step = NULL; /* quiet warning, will never remain this value */ + e_step = nullptr; /* quiet warning, will never remain this value */ uid_start = uid; while ((e = edbm_ripsel_edge_mark_step(v_step, uid))) { @@ -298,13 +297,13 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm) UNUSED_VARS_NDEBUG(tot); #if 0 - printf("%s: found contiguous edge loop of (%d)\n", __func__, uid_end - uid_start); +printf("%s: found contiguous edge loop of (%d)\n", __func__, uid_end - uid_start); #endif } /* null terminate */ lp = BLI_array_append_ret(eloop_pairs); - lp->l_a = lp->l_b = NULL; + lp->l_a = lp->l_b = nullptr; return eloop_pairs; } @@ -324,7 +323,7 @@ static BMEdge *edbm_ripsel_edge_uid_step(BMEdge *e_orig, BMVert **v_prev) return e; } } - return NULL; + return nullptr; } static BMVert *edbm_ripsel_edloop_pair_start_vert(BMEdge *e) @@ -403,7 +402,8 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm) } if (total_tag) { - UnorderedLoopPair *uloop_pairs = MEM_mallocN(total_tag * sizeof(UnorderedLoopPair), __func__); + UnorderedLoopPair *uloop_pairs = static_cast( + MEM_mallocN(total_tag * sizeof(UnorderedLoopPair), __func__)); UnorderedLoopPair *ulp = uloop_pairs; BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { @@ -425,7 +425,7 @@ static UnorderedLoopPair *edbm_tagged_loop_pairs_to_fill(BMesh *bm) return uloop_pairs; } - return NULL; + return nullptr; } static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *uloop_pairs) @@ -442,7 +442,7 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u BMLoop *l_iter; BMVert *f_verts[4]; - if (v_shared == NULL) { + if (v_shared == nullptr) { /* quad */ f_verts[0] = ulp->l_pair[0]->e->v1; f_verts[1] = ulp->l_pair[1]->e->v1; @@ -461,7 +461,7 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u f_verts[0] = v_shared; f_verts[1] = BM_edge_other_vert(ulp->l_pair[0]->e, v_shared); f_verts[2] = BM_edge_other_vert(ulp->l_pair[1]->e, v_shared); - f_verts[3] = NULL; + f_verts[3] = nullptr; /* don't use the flip flags */ if (v_shared == ulp->l_pair[0]->v) { @@ -503,7 +503,7 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u */ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obedit, bool do_fill) { - UnorderedLoopPair *fill_uloop_pairs = NULL; + UnorderedLoopPair *fill_uloop_pairs = nullptr; ARegion *region = CTX_wm_region(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -514,7 +514,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed BMVert *v; const int totvert_orig = bm->totvert; int i; - float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]}; + float projectMat[4][4], fmval[3] = {float(event->mval[0]), float(event->mval[1])}; float dist_sq = FLT_MAX; float d; bool is_wire, is_manifold_region; @@ -529,7 +529,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed v = (BMVert *)ese.ele; } else { - ese.ele = NULL; + ese.ele = nullptr; BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { @@ -538,15 +538,15 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed } } - /* (v == NULL) should be impossible */ - if ((v == NULL) || (v->e == NULL)) { + /* (v == nullptr) should be impossible */ + if ((v == nullptr) || (v->e == nullptr)) { return OPERATOR_CANCELLED; } is_wire = BM_vert_is_wire(v); is_manifold_region = BM_vert_is_manifold_region(v); - e_best = NULL; + e_best = nullptr; { BMEdge *e; @@ -559,7 +559,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed if ((is_manifold_region == false) || BM_edge_is_manifold(e)) { d = edbm_rip_edgedist_squared( region, projectMat, e->v1->co, e->v2->co, fmval, INSET_DEFAULT); - if ((e_best == NULL) || (d < dist_sq)) { + if ((e_best == nullptr) || (d < dist_sq)) { dist_sq = d; e_best = e; } @@ -586,7 +586,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed } if (do_fill) { - BM_edge_create(bm, v, v_new, NULL, BM_CREATE_NOP); + BM_edge_create(bm, v, v_new, nullptr, BM_CREATE_NOP); } return OPERATOR_FINISHED; @@ -610,18 +610,18 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed l = l_all[i1]; edbm_calc_loop_co(l, l_mid_co); d = edbm_rip_edgedist_squared(region, projectMat, l->v->co, l_mid_co, fmval, INSET_DEFAULT); - if ((e_best == NULL) || (d < dist_sq)) { + if ((e_best == nullptr) || (d < dist_sq)) { dist_sq = d; /* find the edge that is not in this loop */ - e_best = NULL; + e_best = nullptr; for (i2 = 0; i2 < 3; i2++) { if (!BM_edge_in_loop(e_all[i2], l)) { e_best = e_all[i2]; break; } } - BLI_assert(e_best != NULL); + BLI_assert(e_best != nullptr); } } } @@ -724,7 +724,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed if (do_fill) { /* match extrude vert-order */ - BM_edge_create(bm, vout[1], vout[0], NULL, BM_CREATE_NOP); + BM_edge_create(bm, vout[1], vout[0], nullptr, BM_CREATE_NOP); } MEM_freeN(vout); @@ -797,7 +797,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed v_rip = BM_face_loop_separate_multi(bm, larr, larr_len); } else { - v_rip = NULL; + v_rip = nullptr; } if (v_rip) { @@ -813,7 +813,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed { /* --- select which vert --- */ - BMVert *v_best = NULL; + BMVert *v_best = nullptr; float l_corner_co[3]; dist_sq = FLT_MAX; @@ -829,7 +829,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed edbm_calc_loop_co(l, l_corner_co); d = edbm_rip_edgedist_squared( region, projectMat, l->v->co, l_corner_co, fmval, INSET_DEFAULT); - if ((v_best == NULL) || (d < dist_sq)) { + if ((v_best == nullptr) || (d < dist_sq)) { v_best = v; dist_sq = d; } @@ -862,7 +862,7 @@ static int edbm_rip_invoke__vert(bContext *C, const wmEvent *event, Object *obed */ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obedit, bool do_fill) { - UnorderedLoopPair *fill_uloop_pairs = NULL; + UnorderedLoopPair *fill_uloop_pairs = nullptr; ARegion *region = CTX_wm_region(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -873,7 +873,7 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed BMVert *v; const int totvert_orig = bm->totvert; const int totedge_orig = bm->totedge; - float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]}; + float projectMat[4][4], fmval[3] = {float(event->mval[0]), float(event->mval[1])}; EdgeLoopPair *eloop_pairs; @@ -889,7 +889,7 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed int totedge_manifold; /* manifold, visible edges */ int i; - e_best = NULL; + e_best = nullptr; i = 0; totedge_manifold = 0; all_manifold = true; @@ -1023,7 +1023,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (bm->totfacesel) { /* highly nifty but hard to support since the operator can fail and we're left * with modified selection */ - // WM_operator_name_call(C, "MESH_OT_region_to_loop", WM_OP_INVOKE_DEFAULT, NULL, event); + // WM_operator_name_call(C, "MESH_OT_region_to_loop", WM_OP_INVOKE_DEFAULT, nullptr, event); continue; } error_face_selected = false; @@ -1072,12 +1072,11 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event) } error_rip_failed = false; - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = true, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = true; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } MEM_freeN(objects); diff --git a/source/blender/editors/mesh/editmesh_rip_edge.c b/source/blender/editors/mesh/editmesh_rip_edge.cc similarity index 93% rename from source/blender/editors/mesh/editmesh_rip_edge.c rename to source/blender/editors/mesh/editmesh_rip_edge.cc index 02774969b1a..394312b8995 100644 --- a/source/blender/editors/mesh/editmesh_rip_edge.c +++ b/source/blender/editors/mesh/editmesh_rip_edge.cc @@ -33,7 +33,7 @@ /* uses total number of selected edges around a vertex to choose how to extend */ #define USE_TRICKY_EXTEND -static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) +static int edbm_rip_edge_invoke(bContext *C, wmOperator * /*op*/, const wmEvent *event) { ARegion *region = CTX_wm_region(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -50,7 +50,7 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve BMIter viter; BMVert *v; - const float mval_fl[2] = {UNPACK2(event->mval)}; + const float mval_fl[2] = {float(event->mval[0]), float(event->mval[1])}; float cent_sco[2]; int cent_tot; bool changed = false; @@ -124,7 +124,7 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve if (BM_elem_flag_test(v, BM_ELEM_SELECT) && BM_elem_flag_test(v, BM_ELEM_TAG) == false) { /* Rules for */ float angle_best = FLT_MAX; - BMEdge *e_best = NULL; + BMEdge *e_best = nullptr; #ifdef USE_TRICKY_EXTEND /* first check if we can select the edge to split based on selection-only */ @@ -139,7 +139,7 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve } } if (tot_sel != 1) { - e_best = NULL; + e_best = nullptr; } /* only one edge selected, operate on that */ @@ -211,12 +211,11 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator *UNUSED(op), const wmEve BM_mesh_select_mode_flush(bm); - EDBM_update(obedit->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = true, - .calc_normals = false, - .is_destructive = true, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = true; + params.calc_normals = false; + params.is_destructive = true; + EDBM_update(static_cast(obedit->data), ¶ms); } } diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.cc similarity index 90% rename from source/blender/editors/mesh/editmesh_select_similar.c rename to source/blender/editors/mesh/editmesh_select_similar.cc index ee77aa30e70..722e37db3a0 100644 --- a/source/blender/editors/mesh/editmesh_select_similar.c +++ b/source/blender/editors/mesh/editmesh_select_similar.cc @@ -46,8 +46,7 @@ static const EnumPropertyItem prop_similar_compare_types[] = { {SIM_CMP_EQ, "EQUAL", 0, "Equal", ""}, {SIM_CMP_GT, "GREATER", 0, "Greater", ""}, {SIM_CMP_LT, "LESS", 0, "Less", ""}, - - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static const EnumPropertyItem prop_similar_types[] = { @@ -56,7 +55,6 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""}, {SIMVERT_EDGE, "EDGE", 0, "Amount of Connecting Edges", ""}, {SIMVERT_CREASE, "VCREASE", 0, "Vertex Crease", ""}, - {SIMEDGE_LENGTH, "LENGTH", 0, "Length", ""}, {SIMEDGE_DIR, "DIR", 0, "Direction", ""}, {SIMEDGE_FACE, "FACE", 0, "Amount of Faces Around an Edge", ""}, @@ -80,7 +78,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMFACE_FREESTYLE, "FREESTYLE_FACE", 0, "Freestyle Face Marks", ""}, #endif - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static int mesh_select_similar_compare_int(const int delta, const int compare) @@ -172,10 +170,10 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - KDTree_1d *tree_1d = NULL; - KDTree_3d *tree_3d = NULL; - KDTree_4d *tree_4d = NULL; - GSet *gset = NULL; + KDTree_1d *tree_1d = nullptr; + KDTree_3d *tree_3d = nullptr; + KDTree_4d *tree_4d = nullptr; + GSet *gset = nullptr; int face_data_value = SIMFACE_DATA_NONE; switch (type) { @@ -200,7 +198,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) Object *ob = objects[ob_index]; BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; - Material ***material_array = NULL; + Material ***material_array = nullptr; invert_m4_m4(ob->world_to_object, ob->object_to_world); if (bm->totfacesel == 0) { @@ -238,7 +236,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) break; case SIMFACE_MATERIAL: { Material *material = (*material_array)[face->mat_nr]; - if (material != NULL) { + if (material != nullptr) { BLI_gset_add(gset, material); } break; @@ -275,8 +273,9 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) } case SIMFACE_FREESTYLE: { FreestyleFace *fface; - fface = CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE); - if ((fface == NULL) || ((fface->flag & FREESTYLE_FACE_MARK) == 0)) { + fface = static_cast( + CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE)); + if ((fface == nullptr) || ((fface->flag & FREESTYLE_FACE_MARK) == 0)) { face_data_value |= SIMFACE_DATA_FALSE; } else { @@ -294,15 +293,15 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BLI_assert((type != SIMFACE_FREESTYLE) || (face_data_value != SIMFACE_DATA_NONE)); - if (tree_1d != NULL) { + if (tree_1d != nullptr) { BLI_kdtree_1d_deduplicate(tree_1d); BLI_kdtree_1d_balance(tree_1d); } - if (tree_3d != NULL) { + if (tree_3d != nullptr) { BLI_kdtree_3d_deduplicate(tree_3d); BLI_kdtree_3d_balance(tree_3d); } - if (tree_4d != NULL) { + if (tree_4d != nullptr) { BLI_kdtree_4d_deduplicate(tree_4d); BLI_kdtree_4d_balance(tree_4d); } @@ -312,7 +311,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(ob); BMesh *bm = em->bm; bool changed = false; - Material ***material_array = NULL; + Material ***material_array = nullptr; float ob_m3[3][3]; copy_m3_m4(ob_m3, ob->object_to_world); @@ -357,13 +356,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) } case SIMFACE_MATERIAL: { const Material *material = (*material_array)[face->mat_nr]; - if (material == NULL) { + if (material == nullptr) { continue; } GSetIterator gs_iter; GSET_ITER (gs_iter, gset) { - const Material *material_iter = BLI_gsetIterator_getKey(&gs_iter); + const Material *material_iter = static_cast( + BLI_gsetIterator_getKey(&gs_iter)); if (material == material_iter) { select = true; break; @@ -373,14 +373,16 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) } case SIMFACE_AREA: { float area = BM_face_calc_area_with_mat3(face, ob_m3); - if (ED_select_similar_compare_float_tree(tree_1d, area, thresh, compare)) { + if (ED_select_similar_compare_float_tree(tree_1d, area, thresh, eSimilarCmp(compare))) + { select = true; } break; } case SIMFACE_PERIMETER: { float perimeter = BM_face_calc_perimeter_with_mat3(face, ob_m3); - if (ED_select_similar_compare_float_tree(tree_1d, perimeter, thresh, compare)) { + if (ED_select_similar_compare_float_tree( + tree_1d, perimeter, thresh, eSimilarCmp(compare))) { select = true; } break; @@ -432,8 +434,9 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) break; } - fface = CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE); - if (((fface != NULL) && (fface->flag & FREESTYLE_FACE_MARK)) == + fface = static_cast( + CustomData_bmesh_get(&bm->pdata, face->head.data, CD_FREESTYLE_FACE)); + if (((fface != nullptr) && (fface->flag & FREESTYLE_FACE_MARK)) == ((face_data_value & SIMFACE_DATA_TRUE) != 0)) { select = true; @@ -451,12 +454,11 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) if (changed) { EDBM_selectmode_flush(em); - EDBM_update(ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(ob->data), ¶ms); } } @@ -478,12 +480,11 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) } } EDBM_selectmode_flush(em); - EDBM_update(ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(ob->data), ¶ms); } } @@ -491,8 +492,8 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) BLI_kdtree_1d_free(tree_1d); BLI_kdtree_3d_free(tree_3d); BLI_kdtree_4d_free(tree_4d); - if (gset != NULL) { - BLI_gset_free(gset, NULL); + if (gset != nullptr) { + BLI_gset_free(gset, nullptr); } return OPERATOR_FINISHED; @@ -602,9 +603,9 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - KDTree_1d *tree_1d = NULL; - KDTree_3d *tree_3d = NULL; - GSet *gset = NULL; + KDTree_1d *tree_1d = nullptr; + KDTree_3d *tree_3d = nullptr; + GSet *gset = nullptr; int edge_data_value = SIMEDGE_DATA_NONE; switch (type) { @@ -642,14 +643,16 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } case SIMEDGE_CREASE: { if (!CustomData_has_layer_named(&bm->edata, CD_PROP_FLOAT, "crease_edge")) { - BLI_kdtree_1d_insert(tree_1d, tree_index++, (float[1]){0.0f}); + float pos = 0.0f; + BLI_kdtree_1d_insert(tree_1d, tree_index++, &pos); continue; } break; } case SIMEDGE_BEVEL: { if (!CustomData_has_layer_named(&bm->edata, CD_PROP_FLOAT, "bevel_weight_edge")) { - BLI_kdtree_1d_insert(tree_1d, tree_index++, (float[1]){0.0f}); + float pos = 0.0f; + BLI_kdtree_1d_insert(tree_1d, tree_index++, &pos); continue; } break; @@ -710,8 +713,9 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) break; case SIMEDGE_FREESTYLE: { FreestyleEdge *fedge; - fedge = CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE); - if ((fedge == NULL) || ((fedge->flag & FREESTYLE_EDGE_MARK) == 0)) { + fedge = static_cast( + CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE)); + if ((fedge == nullptr) || ((fedge->flag & FREESTYLE_EDGE_MARK) == 0)) { edge_data_value |= SIMEDGE_DATA_FALSE; } else { @@ -735,11 +739,11 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) BLI_assert((type != SIMEDGE_FREESTYLE) || (edge_data_value != SIMEDGE_DATA_NONE)); - if (tree_1d != NULL) { + if (tree_1d != nullptr) { BLI_kdtree_1d_deduplicate(tree_1d); BLI_kdtree_1d_balance(tree_1d); } - if (tree_3d != NULL) { + if (tree_3d != nullptr) { BLI_kdtree_3d_deduplicate(tree_3d); BLI_kdtree_3d_balance(tree_3d); } @@ -771,7 +775,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) /* Proceed only if we have to select all the edges that have custom data value of 0.0f. * In this case we will just select all the edges. * Otherwise continue the for loop. */ - if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, compare)) { + if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, eSimilarCmp(compare))) { continue; } } @@ -829,7 +833,8 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } case SIMEDGE_LENGTH: { float length = edge_length_squared_worldspace_get(ob, edge); - if (ED_select_similar_compare_float_tree(tree_1d, length, thresh, compare)) { + if (ED_select_similar_compare_float_tree( + tree_1d, length, thresh, eSimilarCmp(compare))) { select = true; } break; @@ -864,8 +869,9 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) break; } - fedge = CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE); - if (((fedge != NULL) && (fedge->flag & FREESTYLE_EDGE_MARK)) == + fedge = static_cast( + CustomData_bmesh_get(&bm->edata, edge->head.data, CD_FREESTYLE_EDGE)); + if (((fedge != nullptr) && (fedge->flag & FREESTYLE_EDGE_MARK)) == ((edge_data_value & SIMEDGE_DATA_TRUE) != 0)) { select = true; @@ -880,7 +886,8 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } const float *value = BM_ELEM_CD_GET_FLOAT_P(edge, custom_data_offset); - if (ED_select_similar_compare_float_tree(tree_1d, *value, thresh, compare)) { + if (ED_select_similar_compare_float_tree( + tree_1d, *value, thresh, eSimilarCmp(compare))) { select = true; } break; @@ -896,12 +903,11 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) if (changed) { EDBM_selectmode_flush(em); - EDBM_update(ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(ob->data), ¶ms); } } @@ -923,20 +929,19 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) } } EDBM_selectmode_flush(em); - EDBM_update(ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(ob->data), ¶ms); } } MEM_freeN(objects); BLI_kdtree_1d_free(tree_1d); BLI_kdtree_3d_free(tree_3d); - if (gset != NULL) { - BLI_gset_free(gset, NULL); + if (gset != nullptr) { + BLI_gset_free(gset, nullptr); } return OPERATOR_FINISHED; @@ -976,9 +981,9 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - KDTree_3d *tree_3d = NULL; - KDTree_1d *tree_1d = NULL; - GSet *gset = NULL; + KDTree_3d *tree_3d = nullptr; + KDTree_1d *tree_1d = nullptr; + GSet *gset = nullptr; switch (type) { case SIMVERT_NORMAL: @@ -1004,7 +1009,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BMesh *bm = em->bm; int cd_dvert_offset = -1; int cd_crease_offset = -1; - BLI_bitmap *defbase_selected = NULL; + BLI_bitmap *defbase_selected = nullptr; int defbase_len = 0; invert_m4_m4(ob->world_to_object, ob->object_to_world); @@ -1026,7 +1031,8 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } else if (type == SIMVERT_CREASE) { if (!CustomData_has_layer_named(&bm->vdata, CD_PROP_FLOAT, "crease_vert")) { - BLI_kdtree_1d_insert(tree_1d, tree_1d_index++, (float[1]){0.0f}); + float pos = 0.0f; + BLI_kdtree_1d_insert(tree_1d, tree_1d_index++, &pos); continue; } cd_crease_offset = CustomData_get_offset_named(&bm->vdata, CD_PROP_FLOAT, "crease_vert"); @@ -1054,7 +1060,8 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) break; } case SIMVERT_VGROUP: { - MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(vert, cd_dvert_offset); + MDeformVert *dvert = static_cast( + BM_ELEM_CD_GET_VOID_P(vert, cd_dvert_offset)); MDeformWeight *dw = dvert->dw; for (int i = 0; i < dvert->totweight; i++, dw++) { @@ -1099,11 +1106,11 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) } /* Remove duplicated entries. */ - if (tree_1d != NULL) { + if (tree_1d != nullptr) { BLI_kdtree_1d_deduplicate(tree_1d); BLI_kdtree_1d_balance(tree_1d); } - if (tree_3d != NULL) { + if (tree_3d != nullptr) { BLI_kdtree_3d_deduplicate(tree_3d); BLI_kdtree_3d_balance(tree_3d); } @@ -1117,7 +1124,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) bool has_crease_layer = false; int cd_dvert_offset = -1; int cd_crease_offset = -1; - BLI_bitmap *defbase_selected = NULL; + BLI_bitmap *defbase_selected = nullptr; int defbase_len = 0; if (type == SIMVERT_VGROUP) { @@ -1138,7 +1145,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) bool found_any = false; GSetIterator gs_iter; GSET_ITER (gs_iter, gset) { - const char *name = BLI_gsetIterator_getKey(&gs_iter); + const char *name = static_cast(BLI_gsetIterator_getKey(&gs_iter)); int vgroup_id = BLI_findstringindex(defbase, name, offsetof(bDeformGroup, name)); if (vgroup_id != -1) { BLI_BITMAP_ENABLE(defbase_selected, vgroup_id); @@ -1157,7 +1164,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) /* Proceed only if we have to select all the vertices that have custom data value of 0.0f. * In this case we will just select all the vertices. * Otherwise continue the for loop. */ - if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, compare)) { + if (!ED_select_similar_compare_float_tree(tree_1d, 0.0f, thresh, eSimilarCmp(compare))) { continue; } } @@ -1213,7 +1220,8 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) break; } case SIMVERT_VGROUP: { - MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(vert, cd_dvert_offset); + MDeformVert *dvert = static_cast( + BM_ELEM_CD_GET_VOID_P(vert, cd_dvert_offset)); MDeformWeight *dw = dvert->dw; for (int i = 0; i < dvert->totweight; i++, dw++) { @@ -1234,7 +1242,8 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) break; } const float *value = BM_ELEM_CD_GET_FLOAT_P(vert, cd_crease_offset); - if (ED_select_similar_compare_float_tree(tree_1d, *value, thresh, compare)) { + if (ED_select_similar_compare_float_tree( + tree_1d, *value, thresh, eSimilarCmp(compare))) { select = true; } break; @@ -1254,20 +1263,19 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) if (changed) { EDBM_selectmode_flush(em); - EDBM_update(ob->data, - &(const struct EDBMUpdate_Params){ - .calc_looptri = false, - .calc_normals = false, - .is_destructive = false, - }); + EDBMUpdate_Params params{}; + params.calc_looptri = false; + params.calc_normals = false; + params.is_destructive = false; + EDBM_update(static_cast(ob->data), ¶ms); } } MEM_freeN(objects); BLI_kdtree_1d_free(tree_1d); BLI_kdtree_3d_free(tree_3d); - if (gset != NULL) { - BLI_gset_free(gset, NULL); + if (gset != nullptr) { + BLI_gset_free(gset, nullptr); } return OPERATOR_FINISHED; @@ -1303,8 +1311,8 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *select_similar_type_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { Object *obedit; @@ -1316,7 +1324,7 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C, obedit = CTX_data_edit_object(C); if (obedit && obedit->type == OB_MESH) { - EnumPropertyItem *item = NULL; + EnumPropertyItem *item = nullptr; int a, totitem = 0; BMEditMesh *em = BKE_editmesh_from_object(obedit); @@ -1350,7 +1358,7 @@ static const EnumPropertyItem *select_similar_type_itemf(bContext *C, return prop_similar_types; } -static bool edbm_select_similar_poll_property(const bContext *UNUSED(C), +static bool edbm_select_similar_poll_property(const bContext * /*C*/, wmOperator *op, const PropertyRNA *prop) { diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.cc similarity index 98% rename from source/blender/editors/mesh/mesh_ops.c rename to source/blender/editors/mesh/mesh_ops.cc index 04324ecabc5..0c4ea564fc6 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.cc @@ -320,7 +320,7 @@ void ED_operatormacros_mesh(void) ot = WM_operatortype_append_macro("MESH_OT_polybuild_face_at_cursor_move", "Face at Cursor Move", - NULL, + nullptr, OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_polybuild_face_at_cursor"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -329,7 +329,7 @@ void ED_operatormacros_mesh(void) ot = WM_operatortype_append_macro("MESH_OT_polybuild_split_at_cursor_move", "Split at Cursor Move", - NULL, + nullptr, OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_polybuild_split_at_cursor"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -338,7 +338,7 @@ void ED_operatormacros_mesh(void) ot = WM_operatortype_append_macro("MESH_OT_polybuild_transform_at_cursor_move", "Transform at Cursor Move", - NULL, + nullptr, OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_polybuild_transform_at_cursor"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -347,7 +347,7 @@ void ED_operatormacros_mesh(void) ot = WM_operatortype_append_macro("MESH_OT_polybuild_extrude_at_cursor_move", "Extrude at Cursor Move", - NULL, + nullptr, OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_polybuild_transform_at_cursor"); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv"); diff --git a/source/blender/editors/metaball/CMakeLists.txt b/source/blender/editors/metaball/CMakeLists.txt index 226c6c8aea7..bb302a1ae70 100644 --- a/source/blender/editors/metaball/CMakeLists.txt +++ b/source/blender/editors/metaball/CMakeLists.txt @@ -21,9 +21,9 @@ set(INC_SYS ) set(SRC - editmball_undo.c - mball_edit.c - mball_ops.c + editmball_undo.cc + mball_edit.cc + mball_ops.cc mball_intern.h ) diff --git a/source/blender/editors/metaball/editmball_undo.c b/source/blender/editors/metaball/editmball_undo.cc similarity index 82% rename from source/blender/editors/metaball/editmball_undo.c rename to source/blender/editors/metaball/editmball_undo.cc index efba045e56e..60f5ab47671 100644 --- a/source/blender/editors/metaball/editmball_undo.c +++ b/source/blender/editors/metaball/editmball_undo.cc @@ -46,22 +46,22 @@ static CLG_LogRef LOG = {"ed.undo.mball"}; /** \name Undo Conversion * \{ */ -typedef struct UndoMBall { +struct UndoMBall { ListBase editelems; int lastelem_index; size_t undo_size; -} UndoMBall; +}; /* free all MetaElems from ListBase */ static void freeMetaElemlist(ListBase *lb) { MetaElem *ml; - if (lb == NULL) { + if (lb == nullptr) { return; } - while ((ml = BLI_pophead(lb))) { + while ((ml = static_cast(BLI_pophead(lb)))) { MEM_freeN(ml); } } @@ -69,12 +69,14 @@ static void freeMetaElemlist(ListBase *lb) static void undomball_to_editmball(UndoMBall *umb, MetaBall *mb) { freeMetaElemlist(mb->editelems); - mb->lastelem = NULL; + mb->lastelem = nullptr; /* copy 'undo' MetaElems to 'edit' MetaElems */ int index = 0; - for (MetaElem *ml_undo = umb->editelems.first; ml_undo; ml_undo = ml_undo->next, index += 1) { - MetaElem *ml_edit = MEM_dupallocN(ml_undo); + for (MetaElem *ml_undo = static_cast(umb->editelems.first); ml_undo; + ml_undo = ml_undo->next, index += 1) + { + MetaElem *ml_edit = static_cast(MEM_dupallocN(ml_undo)); BLI_addtail(mb->editelems, ml_edit); if (index == umb->lastelem_index) { mb->lastelem = ml_edit; @@ -91,8 +93,10 @@ static void *editmball_from_undomball(UndoMBall *umb, MetaBall *mb) /* copy contents of current ListBase to the undo ListBase */ int index = 0; - for (MetaElem *ml_edit = mb->editelems->first; ml_edit; ml_edit = ml_edit->next, index += 1) { - MetaElem *ml_undo = MEM_dupallocN(ml_edit); + for (MetaElem *ml_edit = static_cast(mb->editelems->first); ml_edit; + ml_edit = ml_edit->next, index += 1) + { + MetaElem *ml_undo = static_cast(MEM_dupallocN(ml_edit)); BLI_addtail(&umb->editelems, ml_undo); if (ml_edit == mb->lastelem) { umb->lastelem_index = index; @@ -116,12 +120,12 @@ static Object *editmball_object_from_context(bContext *C) BKE_view_layer_synced_ensure(scene, view_layer); Object *obedit = BKE_view_layer_edit_object_get(view_layer); if (obedit && obedit->type == OB_MBALL) { - MetaBall *mb = obedit->data; - if (mb->editelems != NULL) { + MetaBall *mb = static_cast(obedit->data); + if (mb->editelems != nullptr) { return obedit; } } - return NULL; + return nullptr; } /** \} */ @@ -132,20 +136,20 @@ static Object *editmball_object_from_context(bContext *C) * \note This is similar for all edit-mode types. * \{ */ -typedef struct MBallUndoStep_Elem { +struct MBallUndoStep_Elem { UndoRefID_Object obedit_ref; UndoMBall data; -} MBallUndoStep_Elem; +}; -typedef struct MBallUndoStep { +struct MBallUndoStep { UndoStep step; MBallUndoStep_Elem *elems; uint elems_len; -} MBallUndoStep; +}; static bool mball_undosys_poll(bContext *C) { - return editmball_object_from_context(C) != NULL; + return editmball_object_from_context(C) != nullptr; } static bool mball_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p) @@ -159,7 +163,8 @@ static bool mball_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p) uint objects_len = 0; Object **objects = ED_undo_editmode_objects_from_view_layer(scene, view_layer, &objects_len); - us->elems = MEM_callocN(sizeof(*us->elems) * objects_len, __func__); + us->elems = static_cast( + MEM_callocN(sizeof(*us->elems) * objects_len, __func__)); us->elems_len = objects_len; for (uint i = 0; i < objects_len; i++) { @@ -167,7 +172,7 @@ static bool mball_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p) MBallUndoStep_Elem *elem = &us->elems[i]; elem->obedit_ref.ptr = ob; - MetaBall *mb = ob->data; + MetaBall *mb = static_cast(ob->data); editmball_from_undomball(&elem->data, mb); mb->needs_flush_to_id = 1; us->step.data_size += elem->data.undo_size; @@ -179,11 +184,8 @@ static bool mball_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p) return true; } -static void mball_undosys_step_decode(bContext *C, - Main *bmain, - UndoStep *us_p, - const eUndoStepDir UNUSED(dir), - bool UNUSED(is_final)) +static void mball_undosys_step_decode( + bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir /*dir*/, bool /*is_final*/) { MBallUndoStep *us = (MBallUndoStep *)us_p; @@ -195,8 +197,8 @@ static void mball_undosys_step_decode(bContext *C, for (uint i = 0; i < us->elems_len; i++) { MBallUndoStep_Elem *elem = &us->elems[i]; Object *obedit = elem->obedit_ref.ptr; - MetaBall *mb = obedit->data; - if (mb->editelems == NULL) { + MetaBall *mb = static_cast(obedit->data); + if (mb->editelems == nullptr) { /* Should never fail, may not crash but can give odd behavior. */ CLOG_ERROR(&LOG, "name='%s', failed to enter edit-mode for object '%s', undo state invalid", @@ -218,7 +220,7 @@ static void mball_undosys_step_decode(bContext *C, bmain->is_memfile_undo_flush_needed = true; - WM_event_add_notifier(C, NC_GEOM | ND_DATA, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, nullptr); } static void mball_undosys_step_free(UndoStep *us_p) diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.cc similarity index 92% rename from source/blender/editors/metaball/mball_edit.c rename to source/blender/editors/metaball/mball_edit.cc index fac06d51115..9ba181141e8 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.cc @@ -53,8 +53,8 @@ void ED_mball_editmball_free(Object *obedit) { MetaBall *mb = (MetaBall *)obedit->data; - mb->editelems = NULL; - mb->lastelem = NULL; + mb->editelems = nullptr; + mb->lastelem = nullptr; } void ED_mball_editmball_make(Object *obedit) @@ -62,7 +62,7 @@ void ED_mball_editmball_make(Object *obedit) MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; /*, *newml;*/ - ml = mb->elems.first; + ml = static_cast(mb->elems.first); while (ml) { if (ml->flag & SELECT) { @@ -74,7 +74,7 @@ void ED_mball_editmball_make(Object *obedit) mb->editelems = &mb->elems; } -void ED_mball_editmball_load(Object *UNUSED(obedit)) {} +void ED_mball_editmball_load(Object * /*obedit*/) {} /** \} */ @@ -102,13 +102,13 @@ bool ED_mball_deselect_all_multi(bContext *C) * \{ */ MetaElem *ED_mball_add_primitive( - bContext *UNUSED(C), Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type) + bContext * /*C*/, Object *obedit, bool obedit_is_new, float mat[4][4], float dia, int type) { MetaBall *mball = (MetaBall *)obedit->data; MetaElem *ml; /* Deselect all existing metaelems */ - ml = mball->editelems->first; + ml = static_cast(mball->editelems->first); while (ml) { ml->flag &= ~SELECT; ml = ml->next; @@ -213,7 +213,7 @@ static const EnumPropertyItem prop_similar_types[] = { {SIMMBALL_RADIUS, "RADIUS", 0, "Radius", ""}, {SIMMBALL_STIFFNESS, "STIFFNESS", 0, "Stiffness", ""}, {SIMMBALL_ROTATION, "ROTATION", 0, "Rotation", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static void mball_select_similar_type_get( @@ -222,7 +222,7 @@ static void mball_select_similar_type_get( float tree_entry[3] = {0.0f, 0.0f, 0.0f}; MetaElem *ml; int tree_index = 0; - for (ml = mb->editelems->first; ml; ml = ml->next) { + for (ml = static_cast(mb->editelems->first); ml; ml = ml->next) { if (ml->flag & SELECT) { switch (type) { case SIMMBALL_RADIUS: { @@ -269,7 +269,7 @@ static bool mball_select_similar_type(Object *obedit, { MetaElem *ml; bool changed = false; - for (ml = mb->editelems->first; ml; ml = ml->next) { + for (ml = static_cast(mb->editelems->first); ml; ml = ml->next) { bool select = false; switch (type) { case SIMMBALL_RADIUS: { @@ -339,8 +339,8 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op) tot_mball_selected_all = BKE_mball_select_count_multi(bases, bases_len); short type_ref = 0; - KDTree_1d *tree_1d = NULL; - KDTree_3d *tree_3d = NULL; + KDTree_1d *tree_1d = nullptr; + KDTree_3d *tree_3d = nullptr; switch (type) { case SIMMBALL_RADIUS: @@ -360,7 +360,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op) switch (type) { case SIMMBALL_TYPE: { MetaElem *ml; - for (ml = mb->editelems->first; ml; ml = ml->next) { + for (ml = static_cast(mb->editelems->first); ml; ml = ml->next) { if (ml->flag & SELECT) { short mball_type = 1 << (ml->type + 1); type_ref |= mball_type; @@ -379,11 +379,11 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op) } } - if (tree_1d != NULL) { + if (tree_1d != nullptr) { BLI_kdtree_1d_deduplicate(tree_1d); BLI_kdtree_1d_balance(tree_1d); } - if (tree_3d != NULL) { + if (tree_3d != nullptr) { BLI_kdtree_3d_deduplicate(tree_3d); BLI_kdtree_3d_balance(tree_3d); } @@ -396,7 +396,7 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op) switch (type) { case SIMMBALL_TYPE: { MetaElem *ml; - for (ml = mb->editelems->first; ml; ml = ml->next) { + for (ml = static_cast(mb->editelems->first); ml; ml = ml->next) { short mball_type = 1 << (ml->type + 1); if (mball_type & type_ref) { ml->flag |= SELECT; @@ -422,10 +422,10 @@ static int mball_select_similar_exec(bContext *C, wmOperator *op) } MEM_freeN(bases); - if (tree_1d != NULL) { + if (tree_1d != nullptr) { BLI_kdtree_1d_free(tree_1d); } - if (tree_3d != NULL) { + if (tree_3d != nullptr) { BLI_kdtree_3d_free(tree_3d); } return OPERATOR_FINISHED; @@ -529,7 +529,7 @@ void MBALL_OT_select_random_metaelems(wmOperatorType *ot) * \{ */ /* Duplicate selected MetaElements */ -static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) +static int duplicate_metaelems_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -545,11 +545,11 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) continue; } - ml = mb->editelems->last; + ml = static_cast(mb->editelems->last); if (ml) { while (ml) { if (ml->flag & SELECT) { - newml = MEM_dupallocN(ml); + newml = static_cast(MEM_dupallocN(ml)); BLI_addtail(mb->editelems, newml); mb->lastelem = newml; ml->flag &= ~SELECT; @@ -557,7 +557,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) ml = ml->prev; } WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); - DEG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(static_cast(obedit->data), 0); } } MEM_freeN(objects); @@ -587,7 +587,7 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) * Delete all selected MetaElems (not MetaBall). * \{ */ -static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) +static int delete_metaelems_exec(bContext *C, wmOperator * /*op*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -603,13 +603,13 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) continue; } - ml = mb->editelems->first; + ml = static_cast(mb->editelems->first); if (ml) { while (ml) { next = ml->next; if (ml->flag & SELECT) { if (mb->lastelem == ml) { - mb->lastelem = NULL; + mb->lastelem = nullptr; } BLI_remlink(mb->editelems, ml); MEM_freeN(ml); @@ -617,7 +617,7 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) ml = next; } WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); - DEG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(static_cast(obedit->data), 0); } } MEM_freeN(objects); @@ -654,7 +654,7 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op) MetaElem *ml; const bool invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; - ml = mb->editelems->first; + ml = static_cast(mb->editelems->first); if (ml) { while (ml) { @@ -664,7 +664,7 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op) ml = ml->next; } WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); - DEG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(static_cast(obedit->data), 0); } return OPERATOR_FINISHED; @@ -711,7 +711,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op) } if (changed) { WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); - DEG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(static_cast(obedit->data), 0); } return OPERATOR_FINISHED; @@ -747,8 +747,8 @@ Base *ED_mball_base_and_elem_from_select_buffer(Base **bases, MetaElem **r_ml) { const uint hit_object = select_id & 0xFFFF; - Base *base = NULL; - MetaElem *ml = NULL; + Base *base = nullptr; + MetaElem *ml = nullptr; /* TODO(@ideasman42): optimize, eg: sort & binary search. */ for (uint base_index = 0; base_index < bases_len; base_index++) { if (bases[base_index]->object->runtime.select_id == hit_object) { @@ -756,10 +756,10 @@ Base *ED_mball_base_and_elem_from_select_buffer(Base **bases, break; } } - if (base != NULL) { + if (base != nullptr) { const uint hit_elem = (select_id & ~MBALLSEL_ANY) >> 16; - MetaBall *mb = base->object->data; - ml = BLI_findlink(mb->editelems, hit_elem); + MetaBall *mb = static_cast(base->object->data); + ml = static_cast(BLI_findlink(mb->editelems, hit_elem)); } *r_ml = ml; return base; @@ -835,7 +835,7 @@ static bool ed_mball_findnearest_metaelem(bContext *C, MetaElem *ml; Base *base = ED_mball_base_and_elem_from_select_buffer(bases, bases_len, select_id, &ml); - if (ml == NULL) { + if (ml == nullptr) { continue; } *r_base = base; @@ -852,8 +852,8 @@ static bool ed_mball_findnearest_metaelem(bContext *C, bool ED_mball_select_pick(bContext *C, const int mval[2], const struct SelectPick_Params *params) { - Base *base = NULL; - MetaElem *ml = NULL; + Base *base = nullptr; + MetaElem *ml = nullptr; uint selmask = 0; bool changed = false; diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.cc similarity index 100% rename from source/blender/editors/metaball/mball_ops.c rename to source/blender/editors/metaball/mball_ops.cc diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 90e3638c837..7f1f403381a 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -39,28 +39,28 @@ set(SRC object_bake.cc object_bake_api.cc object_bake_simulation.cc - object_collection.c - object_constraint.c - object_data_transfer.c + object_collection.cc + object_constraint.cc + object_data_transfer.cc object_data_transform.cc object_edit.cc - object_gpencil_modifier.c - object_hook.c + object_gpencil_modifier.cc + object_hook.cc object_light_linking_ops.cc object_modes.cc object_modifier.cc - object_ops.c - object_random.c - object_relations.c + object_ops.cc + object_random.cc + object_relations.cc object_remesh.cc - object_select.c - object_shader_fx.c - object_shapekey.c + object_select.cc + object_shader_fx.cc + object_shapekey.cc object_transform.cc - object_utils.c + object_utils.cc object_vgroup.cc - object_volume.c - object_warp.c + object_volume.cc + object_warp.cc object_intern.h ) diff --git a/source/blender/editors/object/object_collection.c b/source/blender/editors/object/object_collection.cc similarity index 91% rename from source/blender/editors/object/object_collection.c rename to source/blender/editors/object/object_collection.cc index 96cd819210d..b254963f725 100644 --- a/source/blender/editors/object/object_collection.c +++ b/source/blender/editors/object/object_collection.cc @@ -43,19 +43,19 @@ /********************* 3d view operators ***********************/ -/* can be called with C == NULL */ +/* can be called with C == nullptr */ static const EnumPropertyItem *collection_object_active_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob; - EnumPropertyItem *item = NULL, item_tmp = {0}; + EnumPropertyItem *item = nullptr, item_tmp = {0}; int totitem = 0; - if (C == NULL) { + if (C == nullptr) { return DummyRNA_NULL_items; } @@ -67,20 +67,20 @@ static const EnumPropertyItem *collection_object_active_itemf(bContext *C, int i = 0, count = 0; /* if 2 or more collections, add option to add to all collections */ - collection = NULL; + collection = nullptr; while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) { count++; } if (count >= 2) { item_tmp.identifier = item_tmp.name = "All Collections"; - item_tmp.value = INT_MAX; /* this will give NULL on lookup */ + item_tmp.value = INT_MAX; /* this will give nullptr on lookup */ RNA_enum_item_add(&item, &totitem, &item_tmp); RNA_enum_item_add_separator(&item, &totitem); } /* add collections */ - collection = NULL; + collection = nullptr; while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) { item_tmp.identifier = item_tmp.name = collection->id.name + 2; item_tmp.icon = UI_icon_color_from_collection(collection); @@ -102,7 +102,7 @@ static Collection *collection_object_active_find_index(Main *bmain, Object *ob, const int collection_object_index) { - Collection *collection = NULL; + Collection *collection = nullptr; int i = 0; while ((collection = BKE_collection_object_find(bmain, scene, collection, ob))) { if (i == collection_object_index) { @@ -125,7 +125,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) bool is_cycle = false; bool updated = false; - if (ob == NULL) { + if (ob == nullptr) { return OPERATOR_CANCELLED; } @@ -165,7 +165,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) } DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -211,7 +211,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) bmain, scene, ob, single_collection_index); bool ok = false; - if (ob == NULL) { + if (ob == nullptr) { return OPERATOR_CANCELLED; } @@ -239,7 +239,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) } DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -273,7 +273,7 @@ void COLLECTION_OT_objects_remove_active(wmOperatorType *ot) ot->prop = prop; } -static int collection_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) +static int collection_objects_remove_all_exec(bContext *C, wmOperator * /*op*/) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -284,7 +284,7 @@ static int collection_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op CTX_DATA_END; DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -314,7 +314,7 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op) bmain, scene, ob, single_collection_index); bool updated = false; - if (ob == NULL) { + if (ob == nullptr) { return OPERATOR_CANCELLED; } @@ -341,7 +341,7 @@ static int collection_objects_remove_exec(bContext *C, wmOperator *op) } DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -382,7 +382,7 @@ static int collection_create_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", name); - Collection *collection = BKE_collection_add(bmain, NULL, name); + Collection *collection = BKE_collection_add(bmain, nullptr, name); id_fake_user_set(&collection->id); CTX_DATA_BEGIN (C, Base *, base, selected_bases) { @@ -392,7 +392,7 @@ static int collection_create_exec(bContext *C, wmOperator *op) CTX_DATA_END; DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GROUP | NA_EDITED, nullptr); return OPERATOR_FINISHED; } @@ -417,16 +417,16 @@ void COLLECTION_OT_create(wmOperatorType *ot) /****************** properties window operators *********************/ -static int collection_add_exec(bContext *C, wmOperator *UNUSED(op)) +static int collection_add_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_object_context(C); Main *bmain = CTX_data_main(C); - if (ob == NULL) { + if (ob == nullptr) { return OPERATOR_CANCELLED; } - Collection *collection = BKE_collection_add(bmain, NULL, "Collection"); + Collection *collection = BKE_collection_add(bmain, nullptr, "Collection"); id_fake_user_set(&collection->id); BKE_collection_object_add(bmain, collection, ob); @@ -457,9 +457,10 @@ static int collection_link_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Object *ob = ED_object_context(C); - Collection *collection = BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection")); + Collection *collection = static_cast( + BLI_findlink(&bmain->collections, RNA_enum_get(op->ptr, "collection"))); - if (ELEM(NULL, ob, collection)) { + if (ELEM(nullptr, ob, collection)) { return OPERATOR_CANCELLED; } @@ -533,7 +534,8 @@ static int collection_remove_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Object *ob = ED_object_context(C); - Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data; + Collection *collection = static_cast( + CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data); if (!ob || !collection) { return OPERATOR_CANCELLED; @@ -573,7 +575,8 @@ void OBJECT_OT_collection_remove(wmOperatorType *ot) static int collection_unlink_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data; + Collection *collection = static_cast( + CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data); if (!collection) { return OPERATOR_CANCELLED; @@ -592,7 +595,7 @@ static int collection_unlink_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, nullptr); return OPERATOR_FINISHED; } @@ -613,10 +616,11 @@ void OBJECT_OT_collection_unlink(wmOperatorType *ot) } /* Select objects in the same collection as the active */ -static int select_grouped_exec(bContext *C, wmOperator *UNUSED(op)) +static int select_grouped_exec(bContext *C, wmOperator * /*op*/) { Scene *scene = CTX_data_scene(C); - Collection *collection = CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data; + Collection *collection = static_cast( + CTX_data_pointer_get_type(C, "collection", &RNA_Collection).data); if (!collection) { return OPERATOR_CANCELLED; @@ -650,4 +654,4 @@ void OBJECT_OT_collection_objects_select(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} +} \ No newline at end of file diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.cc similarity index 91% rename from source/blender/editors/object/object_constraint.c rename to source/blender/editors/object/object_constraint.cc index c54ade60608..61ffe5480d9 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.cc @@ -70,8 +70,8 @@ ListBase *ED_object_constraint_active_list(Object *ob) { - if (ob == NULL) { - return NULL; + if (ob == nullptr) { + return nullptr; } if (ob->mode & OB_MODE_POSE) { @@ -86,16 +86,16 @@ ListBase *ED_object_constraint_active_list(Object *ob) return &ob->constraints; } - return NULL; + return nullptr; } ListBase *ED_object_pose_constraint_list(const bContext *C) { - bPoseChannel *pose_bone = CTX_data_pointer_get(C, "pose_bone").data; - if (pose_bone == NULL) { - pose_bone = CTX_data_pointer_get(C, "active_pose_bone").data; - if (pose_bone == NULL) { - return NULL; + bPoseChannel *pose_bone = static_cast(CTX_data_pointer_get(C, "pose_bone").data); + if (pose_bone == nullptr) { + pose_bone = static_cast(CTX_data_pointer_get(C, "active_pose_bone").data); + if (pose_bone == nullptr) { + return nullptr; } } @@ -107,11 +107,11 @@ ListBase *ED_object_constraint_list_from_constraint(Object *ob, bPoseChannel **r_pchan) { if (r_pchan) { - *r_pchan = NULL; + *r_pchan = nullptr; } - if (ELEM(NULL, ob, con)) { - return NULL; + if (ELEM(nullptr, ob, con)) { + return nullptr; } /* try object constraints first */ @@ -126,7 +126,8 @@ ListBase *ED_object_constraint_list_from_constraint(Object *ob, /* try each bone in order * NOTE: it's not possible to directly look up the active bone yet, so this will have to do */ - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { if (BLI_findindex(&pchan->constraints, con) != -1) { if (r_pchan) { @@ -139,7 +140,7 @@ ListBase *ED_object_constraint_list_from_constraint(Object *ob, } /* done */ - return NULL; + return nullptr; } bConstraint *ED_object_constraint_active_get(Object *ob) @@ -158,15 +159,17 @@ bConstraint *ED_object_constraint_active_get(Object *ob) /* this callback sets the text-file to be used for selected menu item */ static void validate_pyconstraint_cb(Main *bmain, void *arg1, void *arg2) { - bPythonConstraint *data = arg1; - Text *text = NULL; + bPythonConstraint *data = static_cast(arg1); + Text *text = nullptr; int index = *((int *)arg2); int i; /* exception for no script */ if (index) { /* innovative use of a for...loop to search */ - for (text = bmain->texts.first, i = 1; text && index != i; i++, text = text->id.next) { + for (text = static_cast(bmain->texts.first), i = 1; text && index != i; + i++, text = static_cast(text->id.next)) + { /* pass */ } } @@ -187,12 +190,14 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde BLI_dynstr_append(pupds, buf); /* init active-index first */ - if (con_text == NULL) { + if (con_text == nullptr) { *pyconindex = 0; } /* loop through markers, adding them */ - for (text = bmain->texts.first, i = 1; text; i++, text = text->id.next) { + for (text = static_cast(bmain->texts.first), i = 1; text; + i++, text = static_cast(text->id.next)) + { /* this is important to ensure that right script is shown as active */ if (text == con_text) { *pyconindex = i; @@ -248,7 +253,7 @@ static void set_constraint_nth_target(bConstraint *con, const char subtarget[], int index) { - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; int num_targets, i; @@ -267,7 +272,7 @@ static void set_constraint_nth_target(bConstraint *con, index = num_targets - 1; } - for (ct = targets.first, i = 0; ct; ct = ct->next, i++) { + for (ct = static_cast(targets.first), i = 0; ct; ct = ct->next, i++) { if (i == index) { ct->tar = target; STRNCPY(ct->subtarget, subtarget); @@ -288,7 +293,7 @@ static void set_constraint_nth_target(bConstraint *con, static void test_constraint( Main *bmain, Object *owner, bPoseChannel *pchan, bConstraint *con, int type) { - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; bConstraintTarget *ct; bool check_targets = true; @@ -296,14 +301,14 @@ static void test_constraint( con->flag &= ~CONSTRAINT_DISABLE; if (con->type == CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data = con->data; + bKinematicConstraint *data = static_cast(con->data); /* Bad: we need a separate set of checks here as pole-target is optional... * otherwise pole-target must exist too or else the constraint is deemed invalid. */ /* default IK check ... */ if (BKE_object_exists_check(bmain, data->tar) == 0) { - data->tar = NULL; + data->tar = nullptr; con->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { @@ -314,7 +319,7 @@ static void test_constraint( if (data->poletar) { if (BKE_object_exists_check(bmain, data->poletar) == 0) { - data->poletar = NULL; + data->poletar = nullptr; con->flag |= CONSTRAINT_DISABLE; } else if (data->poletar == owner) { @@ -329,11 +334,11 @@ static void test_constraint( check_targets = false; } else if (con->type == CONSTRAINT_TYPE_PIVOT) { - bPivotConstraint *data = con->data; + bPivotConstraint *data = static_cast(con->data); /* target doesn't have to exist, but if it is non-null, it must exist! */ if (data->tar && BKE_object_exists_check(bmain, data->tar) == 0) { - data->tar = NULL; + data->tar = nullptr; con->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { @@ -346,16 +351,16 @@ static void test_constraint( check_targets = false; } else if (con->type == CONSTRAINT_TYPE_ACTION) { - bActionConstraint *data = con->data; + bActionConstraint *data = static_cast(con->data); /* validate action */ - if (data->act == NULL) { + if (data->act == nullptr) { /* must have action */ con->flag |= CONSTRAINT_DISABLE; } else if (data->act->idroot != ID_OB) { /* only object-rooted actions can be used */ - data->act = NULL; + data->act = nullptr; con->flag |= CONSTRAINT_DISABLE; } @@ -365,7 +370,7 @@ static void test_constraint( } } else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { - bFollowPathConstraint *data = con->data; + bFollowPathConstraint *data = static_cast(con->data); /* don't allow track/up axes to be the same */ if (data->upflag == data->trackflag) { @@ -376,7 +381,7 @@ static void test_constraint( } } else if (con->type == CONSTRAINT_TYPE_TRACKTO) { - bTrackToConstraint *data = con->data; + bTrackToConstraint *data = static_cast(con->data); /* don't allow track/up axes to be the same */ if (data->reserved2 == data->reserved1) { @@ -387,7 +392,7 @@ static void test_constraint( } } else if (con->type == CONSTRAINT_TYPE_LOCKTRACK) { - bLockTrackConstraint *data = con->data; + bLockTrackConstraint *data = static_cast(con->data); if (data->lockflag == data->trackflag) { con->flag |= CONSTRAINT_DISABLE; @@ -397,12 +402,12 @@ static void test_constraint( } } else if (con->type == CONSTRAINT_TYPE_SPLINEIK) { - bSplineIKConstraint *data = con->data; + bSplineIKConstraint *data = static_cast(con->data); /* if the number of points does not match the amount required by the chain length, * free the points array and request a rebind... */ - if ((data->points == NULL) || (data->numpoints != data->chainlen + 1)) { + if ((data->points == nullptr) || (data->numpoints != data->chainlen + 1)) { MEM_SAFE_FREE(data->points); data->numpoints = 0; @@ -411,10 +416,10 @@ static void test_constraint( } } else if (con->type == CONSTRAINT_TYPE_FOLLOWTRACK) { - bFollowTrackConstraint *data = con->data; + bFollowTrackConstraint *data = static_cast(con->data); if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0) { - if (data->clip != NULL && data->track[0]) { + if (data->clip != nullptr && data->track[0]) { MovieTracking *tracking = &data->clip->tracking; MovieTrackingObject *tracking_object; @@ -440,23 +445,23 @@ static void test_constraint( } } else if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) { - bCameraSolverConstraint *data = con->data; + bCameraSolverConstraint *data = static_cast(con->data); - if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL)) { + if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == nullptr)) { con->flag |= CONSTRAINT_DISABLE; } } else if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) { - bObjectSolverConstraint *data = con->data; + bObjectSolverConstraint *data = static_cast(con->data); - if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == NULL)) { + if ((data->flag & CAMERASOLVER_ACTIVECLIP) == 0 && (data->clip == nullptr)) { con->flag |= CONSTRAINT_DISABLE; } } else if (con->type == CONSTRAINT_TYPE_TRANSFORM_CACHE) { - bTransformCacheConstraint *data = con->data; + bTransformCacheConstraint *data = static_cast(con->data); - if ((data->cache_file == NULL) || (data->object_path[0] == '\0')) { + if ((data->cache_file == nullptr) || (data->object_path[0] == '\0')) { con->flag |= CONSTRAINT_DISABLE; } } @@ -464,11 +469,11 @@ static void test_constraint( /* Check targets for constraints */ if (check_targets && BKE_constraint_targets_get(con, &targets)) { /* disable and clear constraints targets that are incorrect */ - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { /* general validity checks (for those constraints that need this) */ if (BKE_object_exists_check(bmain, ct->tar) == 0) { /* object doesn't exist, but constraint requires target */ - ct->tar = NULL; + ct->tar = nullptr; con->flag |= CONSTRAINT_DISABLE; } else if (ct->tar == owner) { @@ -486,7 +491,7 @@ static void test_constraint( } else { /* cannot use self as target */ - ct->tar = NULL; + ct->tar = nullptr; con->flag |= CONSTRAINT_DISABLE; } } @@ -506,7 +511,7 @@ static void test_constraint( con->flag |= CONSTRAINT_DISABLE; } else { - Curve *cu = ct->tar->data; + Curve *cu = static_cast(ct->tar->data); /* auto-set 'Path' setting on curve so this works. */ cu->flag |= CU_PATH; @@ -569,10 +574,10 @@ static int constraint_type_get(Object *owner, bPoseChannel *pchan) static void test_constraints(Main *bmain, Object *ob, bPoseChannel *pchan) { bConstraint *curcon; - ListBase *conlist = NULL; + ListBase *conlist = nullptr; int type; - if (ob == NULL) { + if (ob == nullptr) { return; } @@ -590,7 +595,7 @@ static void test_constraints(Main *bmain, Object *ob, bPoseChannel *pchan) /* Check all constraints - is constraint valid? */ if (conlist) { - for (curcon = conlist->first; curcon; curcon = curcon->next) { + for (curcon = static_cast(conlist->first); curcon; curcon = curcon->next) { test_constraint(bmain, ob, pchan, curcon, type); } } @@ -599,13 +604,14 @@ static void test_constraints(Main *bmain, Object *ob, bPoseChannel *pchan) void object_test_constraints(Main *bmain, Object *ob) { if (ob->constraints.first) { - test_constraints(bmain, ob, NULL); + test_constraints(bmain, ob, nullptr); } if (ob->type == OB_ARMATURE && ob->pose) { bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; pchan = pchan->next) + { if (pchan->constraints.first) { test_constraints(bmain, ob, pchan); } @@ -617,11 +623,12 @@ static void object_test_constraint(Main *bmain, Object *ob, bConstraint *con) { if (ob->type == OB_ARMATURE && ob->pose) { if (BLI_findindex(&ob->constraints, con) != -1) { - test_constraint(bmain, ob, NULL, con, CONSTRAINT_OBTYPE_OBJECT); + test_constraint(bmain, ob, nullptr, con, CONSTRAINT_OBTYPE_OBJECT); } else { bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; + pchan = pchan->next) { if (BLI_findindex(&pchan->constraints, con) != -1) { test_constraint(bmain, ob, pchan, con, CONSTRAINT_OBTYPE_BONE); break; @@ -630,7 +637,7 @@ static void object_test_constraint(Main *bmain, Object *ob, bConstraint *con) } } else { - test_constraint(bmain, ob, NULL, con, CONSTRAINT_OBTYPE_OBJECT); + test_constraint(bmain, ob, nullptr, con, CONSTRAINT_OBTYPE_OBJECT); } } @@ -650,7 +657,7 @@ static const EnumPropertyItem constraint_owner_items[] = { "Object", "Edit a constraint on the active object"}, {EDIT_CONSTRAINT_OWNER_BONE, "BONE", 0, "Bone", "Edit a constraint on the active bone"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static bool edit_constraint_poll_generic(bContext *C, @@ -659,13 +666,13 @@ static bool edit_constraint_poll_generic(bContext *C, { PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", rna_type); Object *ob = (ptr.owner_id) ? (Object *)ptr.owner_id : ED_object_active_context(C); - bConstraint *con = ptr.data; + bConstraint *con = static_cast(ptr.data); if (!ED_operator_object_active_editable_ex(C, ob)) { return false; } - if (ptr.owner_id != NULL && ID_IS_LINKED(ptr.owner_id)) { + if (ptr.owner_id != nullptr && ID_IS_LINKED(ptr.owner_id)) { CTX_wm_operator_poll_msg_set(C, "Cannot edit library data"); return false; } @@ -695,7 +702,7 @@ static void edit_constraint_properties(wmOperatorType *ot) { PropertyRNA *prop; prop = RNA_def_string( - ot->srna, "constraint", NULL, MAX_NAME, "Constraint", "Name of the constraint to edit"); + ot->srna, "constraint", nullptr, MAX_NAME, "Constraint", "Name of the constraint to edit"); RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_enum( ot->srna, "owner", constraint_owner_items, 0, "Owner", "The owner of this constraint"); @@ -726,10 +733,10 @@ static bool edit_constraint_invoke_properties(bContext *C, } if (ptr.data) { - con = ptr.data; + con = static_cast(ptr.data); RNA_string_set(op->ptr, "constraint", con->name); - list = ED_object_constraint_list_from_constraint(ob, con, NULL); + list = ED_object_constraint_list_from_constraint(ob, con, nullptr); if (&ob->constraints == list) { RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT); @@ -742,14 +749,14 @@ static bool edit_constraint_invoke_properties(bContext *C, } /* Check the custom data of panels under the mouse for a modifier. */ - if (event != NULL) { + if (event != nullptr) { PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); - if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { + if (!(panel_ptr == nullptr || RNA_pointer_is_null(panel_ptr))) { if (RNA_struct_is_a(panel_ptr->type, &RNA_Constraint)) { - con = panel_ptr->data; + con = static_cast(panel_ptr->data); RNA_string_set(op->ptr, "constraint", con->name); - list = ED_object_constraint_list_from_constraint(ob, con, NULL); + list = ED_object_constraint_list_from_constraint(ob, con, nullptr); RNA_enum_set(op->ptr, "owner", (&ob->constraints == list) ? EDIT_CONSTRAINT_OWNER_OBJECT : @@ -758,8 +765,8 @@ static bool edit_constraint_invoke_properties(bContext *C, return true; } - BLI_assert(r_retval != NULL); /* We need the return value in this case. */ - if (r_retval != NULL) { + BLI_assert(r_retval != nullptr); /* We need the return value in this case. */ + if (r_retval != nullptr) { *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); } return false; @@ -774,14 +781,14 @@ static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Ob char constraint_name[MAX_NAME]; int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; - ListBase *list = NULL; + ListBase *list = nullptr; RNA_string_get(op->ptr, "constraint", constraint_name); if (owner == EDIT_CONSTRAINT_OWNER_BONE) { list = ED_object_pose_constraint_list(C); if (!list) { - return NULL; + return nullptr; } } else { @@ -796,7 +803,7 @@ static bConstraint *edit_constraint_property_get(bContext *C, wmOperator *op, Ob #endif if (con && (type != 0) && (con->type != type)) { - con = NULL; + con = nullptr; } return con; @@ -815,10 +822,10 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_STRETCHTO); - bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL; + bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : nullptr; /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) { + if (data == nullptr) { return OPERATOR_CANCELLED; } @@ -826,13 +833,13 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op) data->orglength = 0.0f; ED_object_constraint_update(bmain, ob); - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, nullptr); return OPERATOR_FINISHED; } -static int stretchto_reset_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int stretchto_reset_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return stretchto_reset_exec(C, op); } return OPERATOR_CANCELLED; @@ -870,10 +877,10 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_DISTLIMIT); - bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL; + bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : nullptr; /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) { + if (data == nullptr) { return OPERATOR_CANCELLED; } @@ -881,13 +888,13 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op) data->dist = 0.0f; ED_object_constraint_update(bmain, ob); - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, nullptr); return OPERATOR_FINISHED; } -static int limitdistance_reset_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int limitdistance_reset_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return limitdistance_reset_exec(C, op); } return OPERATOR_CANCELLED; @@ -942,10 +949,10 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_CHILDOF); - bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; + bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : nullptr; /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) { + if (data == nullptr) { printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : ""); BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; @@ -963,9 +970,9 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int childof_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int childof_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return childof_set_inverse_exec(C, op); } return OPERATOR_CANCELLED; @@ -996,9 +1003,9 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_CHILDOF); - bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; + bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : nullptr; - if (data == NULL) { + if (data == nullptr) { BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found"); return OPERATOR_CANCELLED; } @@ -1012,9 +1019,9 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int childof_clear_inverse_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return childof_clear_inverse_exec(C, op); } return OPERATOR_CANCELLED; @@ -1050,16 +1057,16 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_FOLLOWPATH); - bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL; + bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : nullptr; - bAction *act = NULL; - FCurve *fcu = NULL; + bAction *act = nullptr; + FCurve *fcu = nullptr; int sfra = RNA_int_get(op->ptr, "frame_start"); int len = RNA_int_get(op->ptr, "length"); float standardRange = 1.0; /* nearly impossible sanity check */ - if (data == NULL) { + if (data == nullptr) { BKE_report(op->reports, RPT_ERROR, "Follow Path constraint not found"); return OPERATOR_CANCELLED; } @@ -1068,12 +1075,12 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) if (data->tar) { Curve *cu = (Curve *)data->tar->data; - if (ELEM(NULL, cu->adt, cu->adt->action) || - (BKE_fcurve_find(&cu->adt->action->curves, "eval_time", 0) == NULL)) + if (ELEM(nullptr, cu->adt, cu->adt->action) || + (BKE_fcurve_find(&cu->adt->action->curves, "eval_time", 0) == nullptr)) { /* create F-Curve for path animation */ act = ED_id_action_ensure(bmain, &cu->id); - fcu = ED_action_fcurve_ensure(bmain, act, NULL, NULL, "eval_time", 0); + fcu = ED_action_fcurve_ensure(bmain, act, nullptr, nullptr, "eval_time", 0); /* standard vertical range - 1:1 = 100 frames */ standardRange = 100.0f; @@ -1098,7 +1105,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) /* create F-Curve for constraint */ act = ED_id_action_ensure(bmain, &ob->id); - fcu = ED_action_fcurve_ensure(bmain, act, NULL, NULL, path, 0); + fcu = ED_action_fcurve_ensure(bmain, act, nullptr, nullptr, path, 0); /* standard vertical range - 0.0 to 1.0 */ standardRange = 1.0f; @@ -1117,7 +1124,7 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); - FMod_Generator *gen = fcm->data; + FMod_Generator *gen = static_cast(fcm->data); /* Assume that we have the following equation: * y = Ax + B @@ -1135,12 +1142,10 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int followpath_path_animate_invoke(bContext *C, - wmOperator *op, - const wmEvent *UNUSED(event)) +static int followpath_path_animate_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { /* hook up invoke properties for figuring out which constraint we're dealing with */ - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return followpath_path_animate_exec(C, op); } return OPERATOR_CANCELLED; @@ -1195,10 +1200,10 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); - bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; + bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : nullptr; /* despite 3 layers of checks, we may still not be able to find a constraint */ - if (data == NULL) { + if (data == nullptr) { printf("DEBUG: ObjectSolver Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : ""); BKE_report( op->reports, RPT_ERROR, "Could not find constraint data for ObjectSolver Set Inverse"); @@ -1217,11 +1222,9 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int objectsolver_set_inverse_invoke(bContext *C, - wmOperator *op, - const wmEvent *UNUSED(event)) +static int objectsolver_set_inverse_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return objectsolver_set_inverse_exec(C, op); } return OPERATOR_CANCELLED; @@ -1257,9 +1260,9 @@ static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); - bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : NULL; + bObjectSolverConstraint *data = (con) ? (bObjectSolverConstraint *)con->data : nullptr; - if (data == NULL) { + if (data == nullptr) { BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found"); return OPERATOR_CANCELLED; } @@ -1275,9 +1278,9 @@ static int objectsolver_clear_inverse_exec(bContext *C, wmOperator *op) static int objectsolver_clear_inverse_invoke(bContext *C, wmOperator *op, - const wmEvent *UNUSED(event)) + const wmEvent * /*event*/) { - if (edit_constraint_invoke_properties(C, op, NULL, NULL)) { + if (edit_constraint_invoke_properties(C, op, nullptr, nullptr)) { return objectsolver_clear_inverse_exec(C, op); } return OPERATOR_CANCELLED; @@ -1310,7 +1313,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) void ED_object_constraint_active_set(Object *ob, bConstraint *con) { - ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL); + ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, nullptr); /* lets be nice and escape if its active already */ /* NOTE: this assumes that the stack doesn't have other active ones set... */ @@ -1387,10 +1390,10 @@ void ED_object_constraint_dependency_tag_update(Main *bmain, Object *ob, bConstr bool ED_object_constraint_move_to_index(Object *ob, bConstraint *con, const int index) { - BLI_assert(con != NULL); + BLI_assert(con != nullptr); BLI_assert(index >= 0); - ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); + ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, nullptr); int current_index = BLI_findindex(conlist, con); BLI_assert(current_index >= 0); @@ -1408,7 +1411,7 @@ void ED_object_constraint_link(Main *bmain, Object *ob_dst, ListBase *dst, ListB LISTBASE_FOREACH (bConstraint *, con, dst) { ED_object_constraint_dependency_tag_update(bmain, ob_dst, con); } - WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); + WM_main_add_notifier(NC_OBJECT | ND_CONSTRAINT | NA_ADDED, nullptr); } void ED_object_constraint_copy_for_object(Main *bmain, Object *ob_dst, bConstraint *con) @@ -1444,11 +1447,11 @@ static int constraint_delete_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, 0); - if (con == NULL) { + if (con == nullptr) { return OPERATOR_CANCELLED; } - ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, NULL); + ListBase *lb = ED_object_constraint_list_from_constraint(ob, con, nullptr); /* Store name temporarily for report. */ char name[MAX_NAME]; @@ -1516,7 +1519,7 @@ static int constraint_apply_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, 0); - if (con == NULL) { + if (con == nullptr) { return OPERATOR_CANCELLED; } @@ -1613,7 +1616,7 @@ static int constraint_copy_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, ob, 0); - if (con == NULL) { + if (con == nullptr) { return OPERATOR_CANCELLED; } @@ -1698,7 +1701,7 @@ static int constraint_copy_to_selected_exec(bContext *C, wmOperator *op) Object *obact = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(C, op, obact, 0); - if (con == NULL) { + if (con == nullptr) { return OPERATOR_CANCELLED; } @@ -1707,12 +1710,12 @@ static int constraint_copy_to_selected_exec(bContext *C, wmOperator *op) if (pchan) { /* Don't do anything if bone doesn't exist or doesn't have any constraints. */ - if (pchan->constraints.first == NULL) { + if (pchan->constraints.first == nullptr) { BKE_report(op->reports, RPT_ERROR, "No constraints for copying"); return OPERATOR_CANCELLED; } - Object *prev_ob = NULL; + Object *prev_ob = nullptr; /* Copy all constraints from active pose-bone to all selected pose-bones. */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, chan, selected_pose_bones, Object *, ob) { @@ -1756,7 +1759,7 @@ static int constraint_copy_to_selected_exec(bContext *C, wmOperator *op) /* Force depsgraph to get recalculated since new relationships added. */ DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, nullptr); return OPERATOR_FINISHED; } @@ -1774,7 +1777,7 @@ static bool constraint_copy_to_selected_poll(bContext *C) { PointerRNA ptr = CTX_data_pointer_get_type(C, "constraint", &RNA_Constraint); Object *obact = (ptr.owner_id) ? (Object *)ptr.owner_id : ED_object_active_context(C); - bConstraint *con = ptr.data; + bConstraint *con = static_cast(ptr.data); bPoseChannel *pchan; ED_object_constraint_list_from_constraint(obact, con, &pchan); @@ -1850,7 +1853,7 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(C, op, ob, 0); if (con && con->next) { - ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); + ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, nullptr); bConstraint *nextCon = con->next; /* insert the nominated constraint after the one that used to be after it */ @@ -1906,7 +1909,7 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(C, op, ob, 0); if (con && con->prev) { - ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, NULL); + ListBase *conlist = ED_object_constraint_list_from_constraint(ob, con, nullptr); bConstraint *prevCon = con->prev; /* insert the nominated constraint before the one that used to be before it */ @@ -2018,10 +2021,10 @@ void CONSTRAINT_OT_move_to_index(wmOperatorType *ot) /** \name Clear Pose Constraints Operator * \{ */ -static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_constraints_clear_exec(bContext *C, wmOperator * /*op*/) { Main *bmain = CTX_data_main(C); - Object *prev_ob = NULL; + Object *prev_ob = nullptr; /* free constraints for all selected bones */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { @@ -2057,7 +2060,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) ot->poll = ED_operator_object_active_local_editable_posemode_exclusive; } -static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) +static int object_constraints_clear_exec(bContext *C, wmOperator * /*op*/) { Main *bmain = CTX_data_main(C); @@ -2072,7 +2075,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) DEG_relations_tag_update(bmain); /* do updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, nullptr); return OPERATOR_FINISHED; } @@ -2107,12 +2110,12 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) bPoseChannel *pchan = CTX_data_active_pose_bone(C); /* don't do anything if bone doesn't exist or doesn't have any constraints */ - if (ELEM(NULL, pchan, pchan->constraints.first)) { + if (ELEM(nullptr, pchan, pchan->constraints.first)) { BKE_report(op->reports, RPT_ERROR, "No active bone with constraints for copying"); return OPERATOR_CANCELLED; } - Object *prev_ob = NULL; + Object *prev_ob = nullptr; /* Copy all constraints from active pose-bone to all selected pose-bones. */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, chan, selected_pose_bones, Object *, ob) { @@ -2134,7 +2137,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) /* force depsgraph to get recalculated since new relationships added */ DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, nullptr); return OPERATOR_FINISHED; } @@ -2160,7 +2163,7 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) /** \name Copy Object Constraints Operator * \{ */ -static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) +static int object_constraint_copy_exec(bContext *C, wmOperator * /*op*/) { Main *bmain = CTX_data_main(C); Object *obact = ED_object_active_context(C); @@ -2179,7 +2182,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) DEG_relations_tag_update(bmain); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, nullptr); return OPERATOR_FINISHED; } @@ -2217,8 +2220,8 @@ static bool get_new_constraint_target( /* clear tar_ob and tar_pchan fields before use * - assume for now that both always exist... */ - *tar_ob = NULL; - *tar_pchan = NULL; + *tar_ob = nullptr; + *tar_pchan = nullptr; /* check if constraint type doesn't requires a target * - if so, no need to get any targets @@ -2287,7 +2290,7 @@ static bool get_new_constraint_target( /* Only use the object & bone if the bone is visible & selected * since we may have multiple objects in pose mode at once. */ bPoseChannel *pchan = BKE_pose_channel_active_or_first_selected(ob); - if (pchan != NULL) { + if (pchan != nullptr) { *tar_pchan = pchan; *tar_ob = ob; found = true; @@ -2326,7 +2329,7 @@ static bool get_new_constraint_target( Object *obt; /* add new target object */ - obt = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL); + obt = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, nullptr); /* transform cent to global coords for loc */ if (pchanact) { @@ -2365,13 +2368,13 @@ static int constraint_add_exec( bConstraint *con; if (list == &ob->constraints) { - pchan = NULL; + pchan = nullptr; } else { pchan = BKE_pose_channel_active_if_layer_visible(ob); /* ensure not to confuse object/pose adding */ - if (pchan == NULL) { + if (pchan == nullptr) { BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to"); return OPERATOR_CANCELLED; } @@ -2384,18 +2387,18 @@ static int constraint_add_exec( /* Create a new constraint of the type required, * and add it to the active/given constraints list. */ if (pchan) { - con = BKE_constraint_add_for_pose(ob, pchan, NULL, type); + con = BKE_constraint_add_for_pose(ob, pchan, nullptr, type); } else { - con = BKE_constraint_add_for_object(ob, NULL, type); + con = BKE_constraint_add_for_object(ob, nullptr, type); } /* get the first selected object/bone, and make that the target * - apart from the buttons-window add buttons, we shouldn't add in this way */ if (setTarget) { - Object *tar_ob = NULL; - bPoseChannel *tar_pchan = NULL; + Object *tar_ob = nullptr; + bPoseChannel *tar_pchan = nullptr; /* get the target objects, adding them as need be */ if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) { @@ -2419,7 +2422,7 @@ static int constraint_add_exec( char *menustr; int scriptint = 0; /* popup a list of usable scripts */ - menustr = buildmenu_pyconstraints(bmain, NULL, &scriptint); + menustr = buildmenu_pyconstraints(bmain, nullptr, &scriptint); /* XXX scriptint = pupmenu(menustr); */ MEM_freeN(menustr); @@ -2512,13 +2515,13 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op) /* ------------------ */ /* Filters constraints that are only compatible with bones */ -static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C), - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), +static const EnumPropertyItem *object_constraint_add_itemf(bContext * /*C*/, + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { const EnumPropertyItem *item = rna_enum_constraint_type_items; - EnumPropertyItem *object_constraint_items = NULL; + EnumPropertyItem *object_constraint_items = nullptr; int totitem = 0; while (item->identifier) { @@ -2639,25 +2642,25 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) /* TODO: should these be here, or back in `editors/armature/poseobject.c` again? */ /* present menu with options + validation for targets to use */ -static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob); - bConstraint *con = NULL; + bConstraint *con = nullptr; uiPopupMenu *pup; uiLayout *layout; - Object *tar_ob = NULL; - bPoseChannel *tar_pchan = NULL; + Object *tar_ob = nullptr; + bPoseChannel *tar_pchan = nullptr; /* must have active bone */ - if (ELEM(NULL, ob, pchan)) { + if (ELEM(nullptr, ob, pchan)) { BKE_report(op->reports, RPT_ERROR, "Must have an active bone to add IK constraint to"); return OPERATOR_CANCELLED; } /* bone must not have any constraints already */ - for (con = pchan->constraints.first; con; con = con->next) { + for (con = static_cast(pchan->constraints.first); con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) { break; } @@ -2742,9 +2745,9 @@ void POSE_OT_ik_add(wmOperatorType *ot) * Remove IK constraints from selected bones. * \{ */ -static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) +static int pose_ik_clear_exec(bContext *C, wmOperator * /*op*/) { - Object *prev_ob = NULL; + Object *prev_ob = nullptr; /* only remove IK Constraints */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { @@ -2752,7 +2755,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* TODO: should we be checking if these constraints were local * before we try and remove them? */ - for (con = pchan->constraints.first; con; con = next) { + for (con = static_cast(pchan->constraints.first); con; con = next) { next = con->next; if (con->type == CONSTRAINT_TYPE_KINEMATIC) { BKE_constraint_remove(&pchan->constraints, con); @@ -2790,4 +2793,4 @@ void POSE_OT_ik_clear(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -/** \} */ +/** \} */ \ No newline at end of file diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.cc similarity index 92% rename from source/blender/editors/object/object_data_transfer.c rename to source/blender/editors/object/object_data_transfer.cc index 9b3468b9407..e195a32b992 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.cc @@ -46,7 +46,7 @@ * Note some are 'fake' ones, i.e. they are not hold by real CDLayers. */ /* Not shared with modifier, since we use a usual enum here, not a multi-choice one. */ static const EnumPropertyItem DT_layer_items[] = { - RNA_ENUM_ITEM_HEADING(N_("Vertex Data"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Vertex Data"), nullptr), {DT_TYPE_MDEFORMVERT, "VGROUP_WEIGHTS", 0, @@ -67,7 +67,7 @@ static const EnumPropertyItem DT_layer_items[] = { "Colors", "Color Attributes"}, - RNA_ENUM_ITEM_HEADING(N_("Edge Data"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Edge Data"), nullptr), {DT_TYPE_SHARP_EDGE, "SHARP_EDGE", 0, "Sharp", "Transfer sharp mark"}, {DT_TYPE_SEAM, "SEAM", 0, "UV Seam", "Transfer UV seam mark"}, {DT_TYPE_CREASE, "CREASE", 0, "Subdivision Crease", "Transfer crease values"}, @@ -78,7 +78,7 @@ static const EnumPropertyItem DT_layer_items[] = { "Freestyle Mark", "Transfer Freestyle edge mark"}, - RNA_ENUM_ITEM_HEADING(N_("Face Corner Data"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Face Corner Data"), nullptr), {DT_TYPE_LNOR, "CUSTOM_NORMAL", 0, "Custom Normals", "Transfer custom normals"}, {DT_TYPE_MPROPCOL_LOOP | DT_TYPE_MLOOPCOL_LOOP, "COLOR_CORNER", @@ -87,14 +87,14 @@ static const EnumPropertyItem DT_layer_items[] = { "Color Attributes"}, {DT_TYPE_UV, "UV", 0, "UVs", "Transfer UV layers"}, - RNA_ENUM_ITEM_HEADING(N_("Face Data"), NULL), + RNA_ENUM_ITEM_HEADING(N_("Face Data"), nullptr), {DT_TYPE_SHARP_FACE, "SMOOTH", 0, "Smooth", "Transfer flat/smooth mark"}, {DT_TYPE_FREESTYLE_FACE, "FREESTYLE_FACE", 0, "Freestyle Mark", "Transfer Freestyle face mark"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static void dt_add_vcol_layers(const CustomData *cdata, @@ -105,7 +105,7 @@ static void dt_add_vcol_layers(const CustomData *cdata, int types[2] = {CD_PROP_COLOR, CD_PROP_BYTE_COLOR}; int idx = 0; for (int i = 0; i < 2; i++) { - eCustomDataType type = types[i]; + eCustomDataType type = eCustomDataType(types[i]); if (!(mask & CD_TYPE_AS_MASK(type))) { continue; @@ -126,19 +126,19 @@ static void dt_add_vcol_layers(const CustomData *cdata, /* NOTE: #rna_enum_dt_layers_select_src_items enum is from rna_modifier.cc. */ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, PointerRNA *ptr, - PropertyRNA *UNUSED(prop), + PropertyRNA * /*prop*/, bool *r_free) { if (!C) { /* needed for docs and i18n tools */ return rna_enum_dt_layers_select_src_items; } - EnumPropertyItem *item = NULL, tmp_item = {0}; + EnumPropertyItem *item = nullptr, tmp_item = {0}; int totitem = 0; const int data_type = RNA_enum_get(ptr, "data_type"); PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer"); - const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop); + const bool reverse_transfer = prop != nullptr && RNA_property_boolean_get(ptr, prop); const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") : RNA_enum_get(ptr, "layers_select_dst"); @@ -150,7 +150,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC); Object *ob_src = ED_object_active_context(C); - if (ob_src == NULL) { + if (ob_src == nullptr) { RNA_enum_item_end(&item, &totitem); *r_free = true; return item; @@ -170,7 +170,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, RNA_enum_item_add_separator(&item, &totitem); const ListBase *defbase = BKE_object_defgroup_list(ob_src); - for (i = 0, dg = defbase->first; dg; i++, dg = dg->next) { + for (i = 0, dg = static_cast(defbase->first); dg; i++, dg = dg->next) { tmp_item.value = i; tmp_item.identifier = tmp_item.name = dg->name; RNA_enum_item_add(&item, &totitem, &tmp_item); @@ -241,18 +241,18 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, /* NOTE: #rna_enum_dt_layers_select_dst_items enum is from `rna_modifier.cc`. */ static const EnumPropertyItem *dt_layers_select_dst_itemf(bContext *C, PointerRNA *ptr, - PropertyRNA *UNUSED(prop), + PropertyRNA * /*prop*/, bool *r_free) { if (!C) { /* needed for docs and i18n tools */ return rna_enum_dt_layers_select_dst_items; } - EnumPropertyItem *item = NULL; + EnumPropertyItem *item = nullptr; int totitem = 0; PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer"); - const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop); + const bool reverse_transfer = prop != nullptr && RNA_property_boolean_get(ptr, prop); const int layers_select_src = reverse_transfer ? RNA_enum_get(ptr, "layers_select_dst") : RNA_enum_get(ptr, "layers_select_src"); @@ -295,10 +295,10 @@ static const EnumPropertyItem *dt_layers_select_itemf(bContext *C, /* NOTE: rna_enum_dt_mix_mode_items enum is from `rna_modifier.cc`. */ static const EnumPropertyItem *dt_mix_mode_itemf(bContext *C, PointerRNA *ptr, - PropertyRNA *UNUSED(prop), + PropertyRNA * /*prop*/, bool *r_free) { - EnumPropertyItem *item = NULL; + EnumPropertyItem *item = nullptr; int totitem = 0; const int dtdata_type = RNA_enum_get(ptr, "data_type"); @@ -334,7 +334,7 @@ static const EnumPropertyItem *dt_mix_mode_itemf(bContext *C, return item; } -static bool data_transfer_check(bContext *UNUSED(C), wmOperator *op) +static bool data_transfer_check(bContext * /*C*/, wmOperator *op) { const int layers_select_src = RNA_enum_get(op->ptr, "layers_select_src"); PropertyRNA *prop = RNA_struct_find_property(op->ptr, "layers_select_dst"); @@ -364,14 +364,16 @@ static void data_transfer_exec_preprocess_objects(bContext *C, return; /* Nothing else to do in this case... */ } - for (ctx_ob = ctx_objects->first; ctx_ob; ctx_ob = ctx_ob->next) { - Object *ob = ctx_ob->ptr.data; + for (ctx_ob = static_cast(ctx_objects->first); ctx_ob; + ctx_ob = ctx_ob->next) + { + Object *ob = static_cast(ctx_ob->ptr.data); Mesh *me; if ((ob == ob_src) || (ob->type != OB_MESH)) { continue; } - me = ob->data; + me = static_cast(ob->data); if (ID_IS_LINKED(me) || ID_IS_OVERRIDE_LIBRARY(me)) { /* Do not transfer to linked/override data, not supported. */ BKE_reportf(op->reports, @@ -402,7 +404,7 @@ static bool data_transfer_exec_is_object_valid(wmOperator *op, return true; } - me = ob_dst->data; + me = static_cast(ob_dst->data); if (me->id.tag & LIB_TAG_DOIT) { me->id.tag &= ~LIB_TAG_DOIT; return true; @@ -461,7 +463,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op) SpaceTransform space_transform_data; SpaceTransform *space_transform = (use_object_transform && !use_auto_transform) ? &space_transform_data : - NULL; + nullptr; if (is_frozen) { BKE_report( @@ -487,8 +489,10 @@ static int data_transfer_exec(bContext *C, wmOperator *op) data_transfer_exec_preprocess_objects(C, op, ob_src, &ctx_objects, reverse_transfer); - for (ctx_ob_dst = ctx_objects.first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->next) { - Object *ob_dst = ctx_ob_dst->ptr.data; + for (ctx_ob_dst = static_cast(ctx_objects.first); ctx_ob_dst; + ctx_ob_dst = ctx_ob_dst->next) + { + Object *ob_dst = static_cast(ctx_ob_dst->ptr.data); if (reverse_transfer) { SWAP(Object *, ob_src, ob_dst); @@ -520,7 +524,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op) layers_select_dst, mix_mode, mix_factor, - NULL, + nullptr, false, op->reports)) { @@ -543,7 +547,7 @@ static int data_transfer_exec(bContext *C, wmOperator *op) if (changed) { DEG_relations_tag_update(CTX_data_main(C)); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, nullptr); } #if 0 /* TODO */ @@ -560,12 +564,12 @@ static int data_transfer_exec(bContext *C, wmOperator *op) static bool data_transfer_poll(bContext *C) { Object *ob = ED_object_active_context(C); - ID *data = (ob) ? ob->data : NULL; - return (ob != NULL && ob->type == OB_MESH && data != NULL); + ID *data = static_cast((ob) ? ob->data : nullptr); + return (ob != nullptr && ob->type == OB_MESH && data != nullptr); } /* Used by both OBJECT_OT_data_transfer and OBJECT_OT_datalayout_transfer */ -static bool data_transfer_poll_property(const bContext *UNUSED(C), +static bool data_transfer_poll_property(const bContext * /*C*/, wmOperator *op, const PropertyRNA *prop) { @@ -642,8 +646,8 @@ static bool data_transfer_poll_property(const bContext *UNUSED(C), return true; } -static char *data_transfer_get_description(bContext *UNUSED(C), - wmOperatorType *UNUSED(ot), +static char *data_transfer_get_description(bContext * /*C*/, + wmOperatorType * /*ot*/, PointerRNA *ptr) { const bool reverse_transfer = RNA_boolean_get(ptr, "use_reverse_transfer"); @@ -653,7 +657,7 @@ static char *data_transfer_get_description(bContext *UNUSED(C), "Transfer data layer(s) (weights, edge sharp, etc.) from selected meshes to active one")); } - return NULL; + return nullptr; } void OBJECT_OT_data_transfer(wmOperatorType *ot) @@ -787,7 +791,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot) DT_LAYERS_ACTIVE_SRC, "Source Layers Selection", "Which layers to transfer, in case of multi-layers types"); - RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_itemf); + RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_itemf); prop = RNA_def_enum(ot->srna, "layers_select_dst", @@ -795,7 +799,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot) DT_LAYERS_ACTIVE_DST, "Destination Layers Matching", "How to match source and destination layers"); - RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_itemf); + RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_itemf); prop = RNA_def_enum(ot->srna, "mix_mode", @@ -803,7 +807,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot) CDT_MIX_TRANSFER, "Mix Mode", "How to affect destination elements with source values"); - RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_mix_mode_itemf); + RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_mix_mode_itemf); RNA_def_float( ot->srna, "mix_factor", @@ -884,8 +888,10 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op) data_transfer_exec_preprocess_objects(C, op, ob_src, &ctx_objects, false); - for (ctx_ob_dst = ctx_objects.first; ctx_ob_dst; ctx_ob_dst = ctx_ob_dst->next) { - Object *ob_dst = ctx_ob_dst->ptr.data; + for (ctx_ob_dst = static_cast(ctx_objects.first); ctx_ob_dst; + ctx_ob_dst = ctx_ob_dst->next) + { + Object *ob_dst = static_cast(ctx_ob_dst->ptr.data); if (data_transfer_exec_is_object_valid(op, ob_src, ob_dst, false)) { BKE_object_data_transfer_layout(depsgraph, ob_src_eval, @@ -903,7 +909,7 @@ static int datalayout_transfer_exec(bContext *C, wmOperator *op) } DEG_relations_tag_update(CTX_data_main(C)); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, nullptr); return OPERATOR_FINISHED; } @@ -953,7 +959,7 @@ void OBJECT_OT_datalayout_transfer(wmOperatorType *ot) DT_LAYERS_ACTIVE_SRC, "Source Layers Selection", "Which layers to transfer, in case of multi-layers types"); - RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_src_itemf); + RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_src_itemf); prop = RNA_def_enum(ot->srna, "layers_select_dst", @@ -961,5 +967,5 @@ void OBJECT_OT_datalayout_transfer(wmOperatorType *ot) DT_LAYERS_ACTIVE_DST, "Destination Layers Matching", "How to match source and destination layers"); - RNA_def_property_enum_funcs_runtime(prop, NULL, NULL, dt_layers_select_dst_itemf); + RNA_def_property_enum_funcs_runtime(prop, nullptr, nullptr, dt_layers_select_dst_itemf); } diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.cc similarity index 91% rename from source/blender/editors/object/object_gpencil_modifier.c rename to source/blender/editors/object/object_gpencil_modifier.cc index 1f68c3f5349..f79ea5ce2ce 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.cc @@ -57,20 +57,20 @@ /******************************** API ****************************/ GpencilModifierData *ED_object_gpencil_modifier_add( - ReportList *reports, Main *bmain, Scene *UNUSED(scene), Object *ob, const char *name, int type) + ReportList *reports, Main *bmain, Scene * /*scene*/, Object *ob, const char *name, int type) { - GpencilModifierData *new_md = NULL; - const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(type); + GpencilModifierData *new_md = nullptr; + const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(GpencilModifierType(type)); if (ob->type != OB_GPENCIL_LEGACY) { BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2); - return NULL; + return nullptr; } if (mti->flags & eGpencilModifierTypeFlag_Single) { - if (BKE_gpencil_modifiers_findby_type(ob, type)) { + if (BKE_gpencil_modifiers_findby_type(ob, GpencilModifierType(type))) { BKE_report(reports, RPT_WARNING, "Only one modifier of this type is allowed"); - return NULL; + return nullptr; } } @@ -91,7 +91,7 @@ GpencilModifierData *ED_object_gpencil_modifier_add( new_md->mode |= eGpencilModifierMode_Editmode; } - bGPdata *gpd = ob->data; + bGPdata *gpd = static_cast(ob->data); DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -103,7 +103,7 @@ GpencilModifierData *ED_object_gpencil_modifier_add( static bool gpencil_object_modifier_remove(Main *bmain, Object *ob, GpencilModifierData *md, - bool *UNUSED(r_sort_depsgraph)) + bool * /*r_sort_depsgraph*/) { /* It seems on rapid delete it is possible to * get called twice on same modifier, so make @@ -144,7 +144,7 @@ bool ED_object_gpencil_modifier_remove(ReportList *reports, void ED_object_gpencil_modifier_clear(Main *bmain, Object *ob) { - GpencilModifierData *md = ob->greasepencil_modifiers.first; + GpencilModifierData *md = static_cast(ob->greasepencil_modifiers.first); bool sort_depsgraph = false; if (!md) { @@ -165,7 +165,7 @@ void ED_object_gpencil_modifier_clear(Main *bmain, Object *ob) DEG_relations_tag_update(bmain); } -bool ED_object_gpencil_modifier_move_up(ReportList *UNUSED(reports), +bool ED_object_gpencil_modifier_move_up(ReportList * /*reports*/, Object *ob, GpencilModifierData *md) { @@ -177,7 +177,7 @@ bool ED_object_gpencil_modifier_move_up(ReportList *UNUSED(reports), return true; } -bool ED_object_gpencil_modifier_move_down(ReportList *UNUSED(reports), +bool ED_object_gpencil_modifier_move_down(ReportList * /*reports*/, Object *ob, GpencilModifierData *md) { @@ -194,7 +194,7 @@ bool ED_object_gpencil_modifier_move_to_index(ReportList *reports, GpencilModifierData *md, const int index) { - BLI_assert(md != NULL); + BLI_assert(md != nullptr); BLI_assert(index >= 0); if (index >= BLI_listbase_count(&ob->greasepencil_modifiers)) { BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the stack"); @@ -229,7 +229,8 @@ bool ED_object_gpencil_modifier_move_to_index(ReportList *reports, static bool gpencil_modifier_apply_obdata( ReportList *reports, Main *bmain, Depsgraph *depsgraph, Object *ob, GpencilModifierData *md) { - const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); + const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( + GpencilModifierType(md->type)); if (mti->isDisabled && mti->isDisabled(md, 0)) { BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply"); @@ -237,10 +238,10 @@ static bool gpencil_modifier_apply_obdata( } if (ob->type == OB_GPENCIL_LEGACY) { - if (ELEM(NULL, ob, ob->data)) { + if (ELEM(nullptr, ob, ob->data)) { return false; } - if (mti->bakeModifier == NULL) { + if (mti->bakeModifier == nullptr) { BKE_report(reports, RPT_ERROR, "Not implemented"); return false; } @@ -260,7 +261,7 @@ bool ED_object_gpencil_modifier_apply(Main *bmain, Depsgraph *depsgraph, Object *ob, GpencilModifierData *md, - int UNUSED(mode)) + int /*mode*/) { if (ob->type == OB_GPENCIL_LEGACY) { @@ -296,8 +297,9 @@ bool ED_object_gpencil_modifier_apply(Main *bmain, bool ED_object_gpencil_modifier_copy(ReportList *reports, Object *ob, GpencilModifierData *md) { GpencilModifierData *nmd; - const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(md->type); - GpencilModifierType type = md->type; + const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( + GpencilModifierType(md->type)); + GpencilModifierType type = GpencilModifierType(md->type); if (mti->flags & eGpencilModifierTypeFlag_Single) { if (BKE_gpencil_modifiers_findby_type(ob, type)) { @@ -332,7 +334,7 @@ static int gpencil_modifier_add_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); - if (!ED_object_gpencil_modifier_add(op->reports, bmain, scene, ob, NULL, type)) { + if (!ED_object_gpencil_modifier_add(op->reports, bmain, scene, ob, nullptr, type)) { return OPERATOR_CANCELLED; } @@ -342,13 +344,13 @@ static int gpencil_modifier_add_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *gpencil_modifier_add_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { Object *ob = ED_object_active_context(C); - EnumPropertyItem *item = NULL; - const EnumPropertyItem *md_item, *group_item = NULL; + EnumPropertyItem *item = nullptr; + const EnumPropertyItem *md_item, *group_item = nullptr; const GpencilModifierTypeInfo *mti; int totitem = 0, a; @@ -359,7 +361,7 @@ static const EnumPropertyItem *gpencil_modifier_add_itemf(bContext *C, for (a = 0; rna_enum_object_greasepencil_modifier_type_items[a].identifier; a++) { md_item = &rna_enum_object_greasepencil_modifier_type_items[a]; if (md_item->identifier[0]) { - mti = BKE_gpencil_modifier_get_info(md_item->value); + mti = BKE_gpencil_modifier_get_info(GpencilModifierType(md_item->value)); if (mti->flags & eGpencilModifierTypeFlag_NoUserAdd) { continue; @@ -367,14 +369,14 @@ static const EnumPropertyItem *gpencil_modifier_add_itemf(bContext *C, } else { group_item = md_item; - md_item = NULL; + md_item = nullptr; continue; } if (group_item) { RNA_enum_item_add(&item, &totitem, group_item); - group_item = NULL; + group_item = nullptr; } RNA_enum_item_add(&item, &totitem, md_item); @@ -424,7 +426,7 @@ static bool gpencil_edit_modifier_poll_generic(bContext *C, Main *bmain = CTX_data_main(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.owner_id) ? (Object *)ptr.owner_id : ED_object_active_context(C); - GpencilModifierData *mod = ptr.data; /* May be NULL. */ + GpencilModifierData *mod = static_cast(ptr.data); /* May be nullptr. */ if (!ob || !BKE_id_is_editable(bmain, &ob->id)) { return false; @@ -460,7 +462,7 @@ static bool gpencil_edit_modifier_liboverride_allowed_poll(bContext *C) static void gpencil_edit_modifier_properties(wmOperatorType *ot) { PropertyRNA *prop = RNA_def_string( - ot->srna, "modifier", NULL, MAX_NAME, "Modifier", "Name of the modifier to edit"); + ot->srna, "modifier", nullptr, MAX_NAME, "Modifier", "Name of the modifier to edit"); RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -472,7 +474,7 @@ static void gpencil_edit_modifier_report_property(wmOperatorType *ot) } /** - * \param event: If this isn't NULL, the operator will also look for panels underneath + * \param event: If this isn't nullptr, the operator will also look for panels underneath * the cursor with custom-data set to a modifier. * \param r_retval: This should be used if #event is used in order to return * #OPERATOR_PASS_THROUGH to check other operators with the same key set. @@ -487,32 +489,32 @@ static bool gpencil_edit_modifier_invoke_properties(bContext *C, } PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_GpencilModifier); - if (ctx_ptr.data != NULL) { - GpencilModifierData *md = ctx_ptr.data; + if (ctx_ptr.data != nullptr) { + GpencilModifierData *md = static_cast(ctx_ptr.data); RNA_string_set(op->ptr, "modifier", md->name); return true; } /* Check the custom data of panels under the mouse for a modifier. */ - if (event != NULL) { + if (event != nullptr) { PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); - if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { + if (!(panel_ptr == nullptr || RNA_pointer_is_null(panel_ptr))) { if (RNA_struct_is_a(panel_ptr->type, &RNA_GpencilModifier)) { - GpencilModifierData *md = panel_ptr->data; + GpencilModifierData *md = static_cast(panel_ptr->data); RNA_string_set(op->ptr, "modifier", md->name); return true; } - BLI_assert(r_retval != NULL); /* We need the return value in this case. */ - if (r_retval != NULL) { + BLI_assert(r_retval != nullptr); /* We need the return value in this case. */ + if (r_retval != nullptr) { *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); } return false; } } - if (r_retval != NULL) { + if (r_retval != nullptr) { *r_retval = OPERATOR_CANCELLED; } return false; @@ -522,8 +524,8 @@ static GpencilModifierData *gpencil_edit_modifier_property_get(wmOperator *op, Object *ob, int type) { - if (ob == NULL) { - return NULL; + if (ob == nullptr) { + return nullptr; } char modifier_name[MAX_NAME]; @@ -533,7 +535,7 @@ static GpencilModifierData *gpencil_edit_modifier_property_get(wmOperator *op, md = BKE_gpencil_modifiers_findby_name(ob, modifier_name); if (md && type != 0 && md->type != type) { - md = NULL; + md = nullptr; } return md; @@ -547,7 +549,7 @@ static int gpencil_modifier_remove_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0); - if (md == NULL) { + if (md == nullptr) { return OPERATOR_CANCELLED; } @@ -728,7 +730,7 @@ static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op) int apply_as = RNA_enum_get(op->ptr, "apply_as"); const bool do_report = RNA_boolean_get(op->ptr, "report"); - if (md == NULL) { + if (md == nullptr) { return OPERATOR_CANCELLED; } @@ -773,7 +775,7 @@ static const EnumPropertyItem gpencil_modifier_apply_as_items[] = { 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; void OBJECT_OT_gpencil_modifier_apply(wmOperatorType *ot) @@ -959,12 +961,12 @@ static int time_segment_add_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)gpencil_edit_modifier_property_get( op, ob, eGpencilModifierType_Time); - if (gpmd == NULL) { + if (gpmd == nullptr) { return OPERATOR_CANCELLED; } const int new_active_index = gpmd->segment_active_index + 1; - TimeGpencilModifierSegment *new_segments = MEM_malloc_arrayN( - gpmd->segments_len + 1, sizeof(TimeGpencilModifierSegment), __func__); + TimeGpencilModifierSegment *new_segments = static_cast( + MEM_malloc_arrayN(gpmd->segments_len + 1, sizeof(TimeGpencilModifierSegment), __func__)); if (gpmd->segments_len != 0) { /* Copy the segments before the new segment. */ @@ -994,9 +996,9 @@ static int time_segment_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int time_segment_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int time_segment_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (gpencil_edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (gpencil_edit_modifier_invoke_properties(C, op, nullptr, nullptr)) { return time_segment_add_exec(C, op); } return OPERATOR_CANCELLED; @@ -1026,7 +1028,7 @@ static int time_segment_remove_exec(bContext *C, wmOperator *op) TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)gpencil_edit_modifier_property_get( op, ob, eGpencilModifierType_Time); - if (gpmd == NULL) { + if (gpmd == nullptr) { return OPERATOR_CANCELLED; } if (gpmd->segment_active_index < 0 || gpmd->segment_active_index >= gpmd->segments_len) { @@ -1038,8 +1040,8 @@ static int time_segment_remove_exec(bContext *C, wmOperator *op) gpmd->segment_active_index = -1; } else { - TimeGpencilModifierSegment *new_segments = MEM_malloc_arrayN( - gpmd->segments_len, sizeof(TimeGpencilModifierSegment), __func__); + TimeGpencilModifierSegment *new_segments = static_cast( + MEM_malloc_arrayN(gpmd->segments_len, sizeof(TimeGpencilModifierSegment), __func__)); /* Copy the segments before the deleted segment. */ memcpy(new_segments, @@ -1065,9 +1067,9 @@ static int time_segment_remove_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int time_segment_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int time_segment_remove_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (gpencil_edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (gpencil_edit_modifier_invoke_properties(C, op, nullptr, nullptr)) { return time_segment_remove_exec(C, op); } return OPERATOR_CANCELLED; @@ -1105,7 +1107,7 @@ static int time_segment_move_exec(bContext *C, wmOperator *op) TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)gpencil_edit_modifier_property_get( op, ob, eGpencilModifierType_Time); - if (gpmd == NULL) { + if (gpmd == nullptr) { return OPERATOR_CANCELLED; } if (gpmd->segments_len < 2) { @@ -1145,9 +1147,9 @@ static int time_segment_move_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int time_segment_move_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int time_segment_move_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (gpencil_edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (gpencil_edit_modifier_invoke_properties(C, op, nullptr, nullptr)) { return time_segment_move_exec(C, op); } return OPERATOR_CANCELLED; @@ -1158,7 +1160,7 @@ void GPENCIL_OT_time_segment_move(wmOperatorType *ot) static const EnumPropertyItem segment_move[] = { {GP_TIME_SEGEMENT_MOVE_UP, "UP", 0, "Up", ""}, {GP_TIME_SEGEMENT_MOVE_DOWN, "DOWN", 0, "Down", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -1202,12 +1204,12 @@ static int dash_segment_add_exec(bContext *C, wmOperator *op) DashGpencilModifierData *dmd = (DashGpencilModifierData *)gpencil_edit_modifier_property_get( op, ob, eGpencilModifierType_Dash); - if (dmd == NULL) { + if (dmd == nullptr) { return OPERATOR_CANCELLED; } const int new_active_index = dmd->segment_active_index + 1; - DashGpencilModifierSegment *new_segments = MEM_malloc_arrayN( - dmd->segments_len + 1, sizeof(DashGpencilModifierSegment), __func__); + DashGpencilModifierSegment *new_segments = static_cast( + MEM_malloc_arrayN(dmd->segments_len + 1, sizeof(DashGpencilModifierSegment), __func__)); if (dmd->segments_len != 0) { /* Copy the segments before the new segment. */ @@ -1237,9 +1239,9 @@ static int dash_segment_add_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int dash_segment_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int dash_segment_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (gpencil_edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (gpencil_edit_modifier_invoke_properties(C, op, nullptr, nullptr)) { return dash_segment_add_exec(C, op); } return OPERATOR_CANCELLED; @@ -1269,7 +1271,7 @@ static int dash_segment_remove_exec(bContext *C, wmOperator *op) DashGpencilModifierData *dmd = (DashGpencilModifierData *)gpencil_edit_modifier_property_get( op, ob, eGpencilModifierType_Dash); - if (dmd == NULL) { + if (dmd == nullptr) { return OPERATOR_CANCELLED; } @@ -1282,8 +1284,8 @@ static int dash_segment_remove_exec(bContext *C, wmOperator *op) dmd->segment_active_index = -1; } else { - DashGpencilModifierSegment *new_segments = MEM_malloc_arrayN( - dmd->segments_len, sizeof(DashGpencilModifierSegment), __func__); + DashGpencilModifierSegment *new_segments = static_cast( + MEM_malloc_arrayN(dmd->segments_len, sizeof(DashGpencilModifierSegment), __func__)); /* Copy the segments before the deleted segment. */ memcpy(new_segments, @@ -1309,9 +1311,9 @@ static int dash_segment_remove_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int dash_segment_remove_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int dash_segment_remove_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (gpencil_edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (gpencil_edit_modifier_invoke_properties(C, op, nullptr, nullptr)) { return dash_segment_remove_exec(C, op); } return OPERATOR_CANCELLED; @@ -1349,7 +1351,7 @@ static int dash_segment_move_exec(bContext *C, wmOperator *op) DashGpencilModifierData *dmd = (DashGpencilModifierData *)gpencil_edit_modifier_property_get( op, ob, eGpencilModifierType_Dash); - if (dmd == NULL) { + if (dmd == nullptr) { return OPERATOR_CANCELLED; } @@ -1390,9 +1392,9 @@ static int dash_segment_move_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int dash_segment_move_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int dash_segment_move_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { - if (gpencil_edit_modifier_invoke_properties(C, op, NULL, NULL)) { + if (gpencil_edit_modifier_invoke_properties(C, op, nullptr, nullptr)) { return dash_segment_move_exec(C, op); } return OPERATOR_CANCELLED; @@ -1403,7 +1405,7 @@ void GPENCIL_OT_segment_move(wmOperatorType *ot) static const EnumPropertyItem segment_move[] = { {GP_SEGEMENT_MOVE_UP, "UP", 0, "Up", ""}, {GP_SEGEMENT_MOVE_DOWN, "DOWN", 0, "Down", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.cc similarity index 90% rename from source/blender/editors/object/object_hook.c rename to source/blender/editors/object/object_hook.cc index 66d2abeefb0..17a17be95ae 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.cc @@ -73,7 +73,7 @@ static int return_editmesh_indexar(BMEditMesh *em, return 0; } - *r_indexar = index = MEM_mallocN(4 * indexar_num, "hook indexar"); + *r_indexar = index = static_cast(MEM_mallocN(4 * indexar_num, "hook indexar")); *r_indexar_num = indexar_num; nr = 0; zero_v3(r_cent); @@ -109,7 +109,7 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, /* find the vertices */ BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { - dvert = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); + dvert = static_cast(BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset)); if (BKE_defvert_find_weight(dvert, defgrp_index) > 0.0f) { add_v3_v3(r_cent, eve->co); @@ -118,7 +118,7 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, } if (indexar_num) { const ListBase *defbase = BKE_object_defgroup_list(obedit); - bDeformGroup *dg = BLI_findlink(defbase, defgrp_index); + bDeformGroup *dg = static_cast(BLI_findlink(defbase, defgrp_index)); BLI_strncpy(r_name, dg->name, sizeof(dg->name)); mul_v3_fl(r_cent, 1.0f / (float)indexar_num); return true; @@ -130,13 +130,13 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) { - Mesh *me = ob->data; + Mesh *me = static_cast(ob->data); BMEditMesh *em = me->edit_mesh; BMVert *eve; BMIter iter; int index = 0, nr = 0; - if (hmd->indexar == NULL) { + if (hmd->indexar == nullptr) { return; } @@ -178,7 +178,7 @@ static int return_editlattice_indexar(Lattice *editlatt, return 0; } - *r_indexar = index = MEM_mallocN(4 * indexar_num, "hook indexar"); + *r_indexar = index = static_cast(MEM_mallocN(4 * indexar_num, "hook indexar")); *r_indexar_num = indexar_num; nr = 0; zero_v3(r_cent); @@ -204,7 +204,7 @@ static int return_editlattice_indexar(Lattice *editlatt, static void select_editlattice_hook(Object *obedit, HookModifierData *hmd) { - Lattice *lt = obedit->data, *editlt; + Lattice *lt = static_cast(obedit->data), *editlt; BPoint *bp; int index = 0, nr = 0, a; @@ -266,7 +266,8 @@ static int return_editcurve_indexar(Object *obedit, return 0; } - *r_indexar = index = MEM_mallocN(sizeof(*index) * indexar_num, "hook indexar"); + *r_indexar = index = static_cast( + MEM_mallocN(sizeof(*index) * indexar_num, "hook indexar")); *r_indexar_num = indexar_num; nr = 0; zero_v3(r_cent); @@ -325,20 +326,20 @@ static bool object_hook_index_array(Main *bmain, char *r_name, float r_cent[3]) { - *r_indexar = NULL; + *r_indexar = nullptr; *r_indexar_num = 0; r_name[0] = 0; switch (obedit->type) { case OB_MESH: { - Mesh *me = obedit->data; + Mesh *me = static_cast(obedit->data); BMEditMesh *em; EDBM_mesh_load(bmain, obedit); EDBM_mesh_make(obedit, scene->toolsettings->selectmode, true); - DEG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(static_cast(obedit->data), 0); em = me->edit_mesh; @@ -356,7 +357,7 @@ static bool object_hook_index_array(Main *bmain, ED_curve_editnurb_make(obedit); return return_editcurve_indexar(obedit, r_indexar, r_indexar_num, r_cent); case OB_LATTICE: { - Lattice *lt = obedit->data; + Lattice *lt = static_cast(obedit->data); return return_editlattice_indexar(lt->editlatt->latt, r_indexar, r_indexar_num, r_cent); } default: @@ -426,7 +427,7 @@ static void object_hook_from_context( if (ptr->data) { /* if modifier context is available, use that */ ob = (Object *)ptr->owner_id; - hmd = ptr->data; + hmd = static_cast(ptr->data); } else { /* use the provided property */ ob = CTX_data_edit_object(C); @@ -438,14 +439,14 @@ static void object_hook_from_context( *r_hmd = hmd; } else { - *r_ob = NULL; - *r_hmd = NULL; + *r_ob = nullptr; + *r_hmd = nullptr; } } static void object_hook_select(Object *ob, HookModifierData *hmd) { - if (hmd->indexar == NULL) { + if (hmd->indexar == nullptr) { return; } @@ -490,7 +491,7 @@ static Object *add_hook_object_new( { Base *basedit; Object *ob; - ob = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, NULL); + ob = BKE_object_add(bmain, scene, view_layer, OB_EMPTY, nullptr); BKE_view_layer_synced_ensure(scene, view_layer); Base *basact = BKE_view_layer_active_base_get(view_layer); BLI_assert(basact->object == ob); @@ -517,8 +518,8 @@ static int add_hook_object(const bContext *C, ReportList *reports) { Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - ModifierData *md = NULL; - HookModifierData *hmd = NULL; + ModifierData *md = nullptr; + HookModifierData *hmd = nullptr; float cent[3]; float pose_mat[4][4]; int indexar_num, ok, *indexar; @@ -539,8 +540,9 @@ static int add_hook_object(const bContext *C, mul_v3_m4v3(ob->loc, obedit->object_to_world, cent); } - md = obedit->modifiers.first; - while (md && BKE_modifier_get_info(md->type)->type == eModifierTypeType_OnlyDeform) { + md = static_cast(obedit->modifiers.first); + while (md && BKE_modifier_get_info(ModifierType(md->type))->type == eModifierTypeType_OnlyDeform) + { md = md->next; } @@ -567,7 +569,7 @@ static int add_hook_object(const bContext *C, } if (mode == OBJECT_ADDHOOK_SELOB_BONE) { - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); BLI_assert(ob->type == OB_ARMATURE); if (arm->act_bone) { bPoseChannel *pchan_act; @@ -611,7 +613,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); - Object *obsel = NULL; + Object *obsel = nullptr; const bool use_bone = RNA_boolean_get(op->ptr, "use_bone"); const int mode = use_bone ? OBJECT_ADDHOOK_SELOB_BONE : OBJECT_ADDHOOK_SELOB; @@ -633,7 +635,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (add_hook_object(C, bmain, scene, view_layer, NULL, obedit, obsel, mode, op->reports)) { + if (add_hook_object(C, bmain, scene, view_layer, nullptr, obedit, obsel, mode, op->reports)) { WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); return OPERATOR_FINISHED; } @@ -670,7 +672,7 @@ static int object_add_hook_newob_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); if (add_hook_object( - C, bmain, scene, view_layer, v3d, obedit, NULL, OBJECT_ADDHOOK_NEWOB, op->reports)) + C, bmain, scene, view_layer, v3d, obedit, nullptr, OBJECT_ADDHOOK_NEWOB, op->reports)) { DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -699,7 +701,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) { int num = RNA_enum_get(op->ptr, "modifier"); Object *ob = CTX_data_edit_object(C); - HookModifierData *hmd = NULL; + HookModifierData *hmd = nullptr; hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); if (!hmd) { @@ -719,21 +721,21 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *hook_mod_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; - EnumPropertyItem *item = NULL; - ModifierData *md = NULL; + EnumPropertyItem *item = nullptr; + ModifierData *md = nullptr; int a, totitem = 0; if (!ob) { return DummyRNA_NULL_items; } - for (a = 0, md = ob->modifiers.first; md; md = md->next, a++) { + for (a = 0, md = static_cast(ob->modifiers.first); md; md = md->next, a++) { if (md->type == eModifierType_Hook) { tmp.value = a; tmp.icon = ICON_HOOK; @@ -764,8 +766,8 @@ void OBJECT_OT_hook_remove(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - /* this operator removes modifier which isn't stored in local undo stack, - * so redoing it from redo panel gives totally weird results. */ + /* this operator removes modifier which isn't stored in local undo stack, * so redoing it from + * redo panel gives totally weird results. */ ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ @@ -780,11 +782,11 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; - HookModifierData *hmd = NULL; + Object *ob = nullptr; + HookModifierData *hmd = nullptr; object_hook_from_context(C, &ptr, num, &ob, &hmd); - if (hmd == NULL) { + if (hmd == nullptr) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -824,13 +826,13 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; - HookModifierData *hmd = NULL; + Object *ob = nullptr; + HookModifierData *hmd = nullptr; Scene *scene = CTX_data_scene(C); float bmat[3][3], imat[3][3]; object_hook_from_context(C, &ptr, num, &ob, &hmd); - if (hmd == NULL) { + if (hmd == nullptr) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -877,14 +879,14 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; - HookModifierData *hmd = NULL; + Object *ob = nullptr; + HookModifierData *hmd = nullptr; float cent[3]; char name[MAX_NAME]; int *indexar, indexar_num; object_hook_from_context(C, &ptr, num, &ob, &hmd); - if (hmd == NULL) { + if (hmd == nullptr) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -923,8 +925,8 @@ void OBJECT_OT_hook_assign(wmOperatorType *ot) ot->poll = hook_op_edit_poll; /* flags */ - /* this operator changes data stored in modifier which doesn't get pushed to undo stack, - * so redoing it from redo panel gives totally weird results. */ + /* this operator changes data stored in modifier which doesn't get pushed to undo stack, * so + * redoing it from redo panel gives totally weird results. */ ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; /* properties */ @@ -938,11 +940,11 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_HookModifier); int num = RNA_enum_get(op->ptr, "modifier"); - Object *ob = NULL; - HookModifierData *hmd = NULL; + Object *ob = nullptr; + HookModifierData *hmd = nullptr; object_hook_from_context(C, &ptr, num, &ob, &hmd); - if (hmd == NULL) { + if (hmd == nullptr) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -950,7 +952,7 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) /* select functionality */ object_hook_select(ob, hmd); - DEG_id_tag_update(ob->data, ID_RECALC_SELECT); + DEG_id_tag_update(static_cast(ob->data), ID_RECALC_SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.cc similarity index 100% rename from source/blender/editors/object/object_ops.c rename to source/blender/editors/object/object_ops.cc diff --git a/source/blender/editors/object/object_random.c b/source/blender/editors/object/object_random.cc similarity index 97% rename from source/blender/editors/object/object_random.c rename to source/blender/editors/object/object_random.cc index 2d7a136982a..e638466cbb0 100644 --- a/source/blender/editors/object/object_random.c +++ b/source/blender/editors/object/object_random.cc @@ -92,11 +92,11 @@ static int object_rand_verts_exec(bContext *C, wmOperator *op) bool changed_multi = false; uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data( - scene, view_layer, CTX_wm_view3d(C), &objects_len, ob_mode); + scene, view_layer, CTX_wm_view3d(C), &objects_len, eObjectMode(ob_mode)); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *ob_iter = objects[ob_index]; - TransVertStore tvs = {NULL}; + TransVertStore tvs = {nullptr}; if (ob_iter) { int mode = TM_ALL_JOINTS; diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.cc similarity index 84% rename from source/blender/editors/object/object_relations.c rename to source/blender/editors/object/object_relations.cc index 0a476e1d4a4..c79f060d482 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.cc @@ -130,13 +130,13 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) /* we need 1 to 3 selected vertices */ if (obedit->type == OB_MESH) { - Mesh *me = obedit->data; + Mesh *me = static_cast(obedit->data); BMEditMesh *em; EDBM_mesh_load(bmain, obedit); EDBM_mesh_make(obedit, scene->toolsettings->selectmode, true); - DEG_id_tag_update(obedit->data, 0); + DEG_id_tag_update(static_cast(obedit->data), 0); em = me->edit_mesh; @@ -175,7 +175,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) else if (ELEM(obedit->type, OB_SURF, OB_CURVES_LEGACY)) { ListBase *editnurb = object_editcurve_get(obedit); - for (Nurb *nu = editnurb->first; nu != NULL; nu = nu->next) { + for (Nurb *nu = static_cast(editnurb->first); nu != nullptr; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; for (int curr_index = 0; curr_index < nu->pntsu; curr_index++, bezt++) { @@ -224,7 +224,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } else if (obedit->type == OB_LATTICE) { - Lattice *lt = obedit->data; + Lattice *lt = static_cast(obedit->data); const int num_points = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; @@ -292,7 +292,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT, NULL); + WM_event_add_notifier(C, NC_OBJECT, nullptr); return OPERATOR_FINISHED; @@ -339,7 +339,7 @@ EnumPropertyItem prop_clear_parent_types[] = { "Clear Parent Inverse", "Reset the transform corrections applied to the parenting relationship, does not remove " "parenting itself"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* Helper for ED_object_parent_clear() - Remove deform-modifiers associated with parent */ @@ -349,7 +349,7 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) ModifierData *md, *mdn; /* assume that we only need to remove the first instance of matching deform modifier here */ - for (md = ob->modifiers.first; md; md = mdn) { + for (md = static_cast(ob->modifiers.first); md; md = mdn) { bool free = false; mdn = md->next; @@ -385,7 +385,7 @@ static void object_remove_parent_deform_modifiers(Object *ob, const Object *par) void ED_object_parent_clear(Object *ob, const int type) { - if (ob->parent == NULL) { + if (ob->parent == nullptr) { return; } @@ -396,7 +396,7 @@ void ED_object_parent_clear(Object *ob, const int type) object_remove_parent_deform_modifiers(ob, ob->parent); /* clear parenting relationship completely */ - ob->parent = NULL; + ob->parent = nullptr; ob->partype = PAROBJECT; ob->parsubstr[0] = 0; break; @@ -404,7 +404,7 @@ void ED_object_parent_clear(Object *ob, const int type) case CLEAR_PARENT_KEEP_TRANSFORM: { /* remove parent, and apply the parented transform * result as object's local transforms */ - ob->parent = NULL; + ob->parent = nullptr; BKE_object_apply_mat4(ob, ob->object_to_world, true, false); break; } @@ -434,8 +434,8 @@ static int parent_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, nullptr); return OPERATOR_FINISHED; } @@ -468,7 +468,7 @@ void ED_object_parent(Object *ob, Object *par, const int type, const char *subst unit_m4(ob->parentinv); if (!par || BKE_object_parent_loop_check(par, ob)) { - ob->parent = NULL; + ob->parent = nullptr; ob->partype = PAROBJECT; ob->parsubstr[0] = 0; return; @@ -499,7 +499,7 @@ EnumPropertyItem prop_make_parent_types[] = { {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, {PAR_VERTEX_TRI, "VERTEX_TRI", 0, "Vertex (Triangle)", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; bool ED_object_parent_set(ReportList *reports, @@ -514,8 +514,8 @@ bool ED_object_parent_set(ReportList *reports, { Main *bmain = CTX_data_main(C); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); - bPoseChannel *pchan = NULL; - bPoseChannel *pchan_eval = NULL; + bPoseChannel *pchan = nullptr; + bPoseChannel *pchan_eval = nullptr; Object *parent_eval = DEG_get_evaluated_object(depsgraph, par); DEG_id_tag_update(&par->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); @@ -537,8 +537,8 @@ bool ED_object_parent_set(ReportList *reports, if (par->type != OB_CURVES_LEGACY) { return false; } - Curve *cu = par->data; - Curve *cu_eval = parent_eval->data; + Curve *cu = static_cast(par->data); + Curve *cu_eval = static_cast(parent_eval->data); if ((cu->flag & CU_PATH) == 0) { cu->flag |= CU_PATH | CU_FOLLOW; cu_eval->flag |= CU_PATH | CU_FOLLOW; @@ -554,7 +554,7 @@ bool ED_object_parent_set(ReportList *reports, if (partype == PAR_FOLLOW) { /* get or create F-Curve */ bAction *act = ED_id_action_ensure(bmain, &cu->id); - FCurve *fcu = ED_action_fcurve_ensure(bmain, act, NULL, NULL, "eval_time", 0); + FCurve *fcu = ED_action_fcurve_ensure(bmain, act, nullptr, nullptr, "eval_time", 0); /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { @@ -573,9 +573,9 @@ bool ED_object_parent_set(ReportList *reports, pchan = BKE_pose_channel_active_if_layer_visible(par); pchan_eval = BKE_pose_channel_active_if_layer_visible(parent_eval); - if (pchan == NULL || pchan_eval == NULL) { - /* If pchan_eval is NULL, pchan should also be NULL. */ - BLI_assert_msg(pchan == NULL, "Missing evaluated bone data"); + if (pchan == nullptr || pchan_eval == nullptr) { + /* If pchan_eval is nullptr, pchan should also be nullptr. */ + BLI_assert_msg(pchan == nullptr, "Missing evaluated bone data"); BKE_report(reports, RPT_ERROR, "No active bone"); return false; } @@ -585,8 +585,8 @@ bool ED_object_parent_set(ReportList *reports, /* Apply transformation of previous parenting. */ if (keep_transform) { - /* Was removed because of bug #23577, - * but this can be handy in some cases too #32616, so make optional. */ + /* Was removed because of bug #23577, * but this can be handy in some cases too #32616, so + * make optional. */ BKE_object_apply_mat4(ob, ob->object_to_world, false, false); } @@ -618,38 +618,39 @@ bool ED_object_parent_set(ReportList *reports, case PAR_ARMATURE_AUTO: /* partype is now set to PAROBJECT so that invisible 'virtual' * modifiers don't need to be created. - * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, - * creating the virtual modifiers. + * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, * creating the + * virtual modifiers. */ ob->partype = PAROBJECT; /* NOTE: DNA define, not operator property. */ /* ob->partype = PARSKEL; */ /* NOTE: DNA define, not operator property. */ - /* BUT, to keep the deforms, we need a modifier, - * and then we need to set the object that it uses - * - We need to ensure that the modifier we're adding doesn't already exist, - * so we check this by assuming that the parent is selected too. + /* BUT, to keep the deforms, we need a modifier, * and then we need to set the object + * that it uses + * - We need to ensure that the modifier we're adding doesn't already exist, * so we + * check this by assuming that the parent is selected too. */ - /* XXX currently this should only happen for meshes, curves, surfaces, - * and lattices - this stuff isn't available for meta-balls yet. */ + /* XXX currently this should only happen for meshes, curves, surfaces, * and lattices + * - this stuff isn't available for meta-balls yet. */ if (ELEM(ob->type, OB_MESH, OB_CURVES_LEGACY, OB_SURF, OB_FONT, OB_LATTICE)) { ModifierData *md; switch (partype) { case PAR_CURVE: /* curve deform */ if (BKE_modifiers_is_deformed_by_curve(ob) != par) { - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); + md = ED_object_modifier_add(reports, bmain, scene, ob, nullptr, eModifierType_Curve); if (md) { ((CurveModifierData *)md)->object = par; } if (par->runtime.curve_cache && - par->runtime.curve_cache->anim_path_accum_length == NULL) { + par->runtime.curve_cache->anim_path_accum_length == nullptr) { DEG_id_tag_update(&par->id, ID_RECALC_GEOMETRY); } } break; case PAR_LATTICE: /* lattice deform */ if (BKE_modifiers_is_deformed_by_lattice(ob) != par) { - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice); + md = ED_object_modifier_add( + reports, bmain, scene, ob, nullptr, eModifierType_Lattice); if (md) { ((LatticeModifierData *)md)->object = par; } @@ -657,7 +658,8 @@ bool ED_object_parent_set(ReportList *reports, break; default: /* armature deform */ if (BKE_modifiers_is_deformed_by_armature(ob) != par) { - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature); + md = ED_object_modifier_add( + reports, bmain, scene, ob, nullptr, eModifierType_Armature); if (md) { ((ArmatureModifierData *)md)->object = par; } @@ -704,11 +706,11 @@ bool ED_object_parent_set(ReportList *reports, con = BKE_constraint_add_for_object(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH); - data = con->data; + data = static_cast(con->data); data->tar = par; BKE_constraint_target_matrix_get( - depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra); + depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, nullptr, cmat, scene->r.cfra); sub_v3_v3v3(vec, ob->object_to_world[3], cmat[3]); copy_v3_v3(ob->loc, vec); @@ -791,7 +793,7 @@ static void parent_set_vert_find(KDTree_3d *tree, Object *child, int vert_par[3] BLI_assert(min_iii(UNPACK3(vert_par)) >= 0); } else { - vert_par[0] = BLI_kdtree_3d_find_nearest(tree, co_find, NULL); + vert_par[0] = BLI_kdtree_3d_find_nearest(tree, co_find, nullptr); BLI_assert(vert_par[0] >= 0); vert_par[1] = 0; vert_par[2] = 0; @@ -825,7 +827,7 @@ static bool parent_set_nonvertex_parent(bContext *C, struct ParentingContext *pa parenting_context->partype, parenting_context->xmirror, parenting_context->keep_transform, - NULL)) + nullptr)) { return false; } @@ -868,11 +870,11 @@ static bool parent_set_vertex_parent_with_kdtree(bContext *C, static bool parent_set_vertex_parent(bContext *C, struct ParentingContext *parenting_context) { - KDTree_3d *tree = NULL; + KDTree_3d *tree = nullptr; int tree_tot; tree = BKE_object_as_kdtree(parenting_context->par, &tree_tot); - BLI_assert(tree != NULL); + BLI_assert(tree != nullptr); if (tree_tot < (parenting_context->is_vertex_tri ? 3 : 1)) { BKE_report(parenting_context->reports, RPT_ERROR, "Not enough vertices for vertex-parent"); @@ -888,15 +890,14 @@ static bool parent_set_vertex_parent(bContext *C, struct ParentingContext *paren static int parent_set_exec(bContext *C, wmOperator *op) { const int partype = RNA_enum_get(op->ptr, "type"); - struct ParentingContext parenting_context = { - .reports = op->reports, - .scene = CTX_data_scene(C), - .par = ED_object_active_context(C), - .partype = partype, - .is_vertex_tri = partype == PAR_VERTEX_TRI, - .xmirror = RNA_boolean_get(op->ptr, "xmirror"), - .keep_transform = RNA_boolean_get(op->ptr, "keep_transform"), - }; + ParentingContext parenting_context{}; + parenting_context.reports = op->reports; + parenting_context.scene = CTX_data_scene(C); + parenting_context.par = ED_object_active_context(C); + parenting_context.partype = partype; + parenting_context.is_vertex_tri = partype == PAR_VERTEX_TRI; + parenting_context.xmirror = RNA_boolean_get(op->ptr, "xmirror"); + parenting_context.keep_transform = RNA_boolean_get(op->ptr, "keep_transform"); bool ok; if (ELEM(parenting_context.partype, PAR_VERTEX, PAR_VERTEX_TRI)) { @@ -911,8 +912,8 @@ static int parent_set_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, nullptr); return OPERATOR_FINISHED; } @@ -925,9 +926,9 @@ static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot) PointerRNA opptr; #if 0 - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_OBJECT); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_OBJECT); #else - uiItemFullO_ptr(layout, ot, IFACE_("Object"), ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); + uiItemFullO_ptr(layout, ot, IFACE_("Object"), ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", false); @@ -935,7 +936,7 @@ static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot) ot, IFACE_("Object (Keep Transform)"), ICON_NONE, - NULL, + nullptr, WM_OP_EXEC_DEFAULT, 0, &opptr); @@ -978,24 +979,24 @@ static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot) CTX_DATA_END; if (parent->type == OB_ARMATURE) { - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_NAME); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_ARMATURE); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_ARMATURE_NAME); if (!has_children_of_type.gpencil) { - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_ENVELOPE); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_ARMATURE_ENVELOPE); } if (has_children_of_type.mesh || has_children_of_type.gpencil) { - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_ARMATURE_AUTO); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_ARMATURE_AUTO); } - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_BONE_RELATIVE); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_BONE); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_BONE_RELATIVE); } else if (parent->type == OB_CURVES_LEGACY) { - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_CURVE); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_FOLLOW); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_PATH_CONST); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_CURVE); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_FOLLOW); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_PATH_CONST); } else if (parent->type == OB_LATTICE) { - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_LATTICE); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_LATTICE); } else if (parent->type == OB_MESH) { if (has_children_of_type.curves) { @@ -1005,8 +1006,8 @@ static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot) /* vertex parenting */ if (OB_TYPE_SUPPORT_PARVERT(parent->type)) { - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX); - uiItemEnumO_ptr(layout, ot, NULL, 0, "type", PAR_VERTEX_TRI); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_VERTEX); + uiItemEnumO_ptr(layout, ot, nullptr, 0, "type", PAR_VERTEX_TRI); } UI_popup_menu_end(C, pup); @@ -1014,7 +1015,7 @@ static int parent_set_invoke_menu(bContext *C, wmOperatorType *ot) return OPERATOR_INTERFACE; } -static int parent_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int parent_set_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { if (RNA_property_is_set(op->ptr, op->type->prop)) { return parent_set_exec(C, op); @@ -1022,7 +1023,7 @@ static int parent_set_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( return parent_set_invoke_menu(C, op->type); } -static bool parent_set_poll_property(const bContext *UNUSED(C), +static bool parent_set_poll_property(const bContext * /*C*/, wmOperator *op, const PropertyRNA *prop) { @@ -1113,8 +1114,8 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, nullptr); return OPERATOR_FINISHED; } @@ -1160,7 +1161,7 @@ static const EnumPropertyItem prop_clear_track_types[] = { 0, "Clear and Keep Transformation (Clear Track)", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* NOTE: poll should check for editable scene. */ @@ -1177,11 +1178,11 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) bConstraint *con, *pcon; /* remove track-object for old track */ - ob->track = NULL; + ob->track = nullptr; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); /* also remove all tracking constraints */ - for (con = ob->constraints.last; con; con = pcon) { + for (con = static_cast(ob->constraints.last); con; con = pcon) { pcon = con->prev; if (ELEM(con->type, CONSTRAINT_TYPE_TRACKTO, @@ -1198,7 +1199,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) CTX_DATA_END; DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr); return OPERATOR_FINISHED; } @@ -1238,7 +1239,7 @@ static const EnumPropertyItem prop_make_track_types[] = { {CREATE_TRACK_DAMPTRACK, "DAMPTRACK", 0, "Damped Track Constraint", ""}, {CREATE_TRACK_TRACKTO, "TRACKTO", 0, "Track to Constraint", ""}, {CREATE_TRACK_LOCKTRACK, "LOCKTRACK", 0, "Lock Track Constraint", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static int track_set_exec(bContext *C, wmOperator *op) @@ -1257,7 +1258,7 @@ static int track_set_exec(bContext *C, wmOperator *op) if (ob != obact) { con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK); - data = con->data; + data = static_cast(con->data); data->tar = obact; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); @@ -1279,7 +1280,7 @@ static int track_set_exec(bContext *C, wmOperator *op) if (ob != obact) { con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); - data = con->data; + data = static_cast(con->data); data->tar = obact; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); @@ -1302,7 +1303,7 @@ static int track_set_exec(bContext *C, wmOperator *op) if (ob != obact) { con = BKE_constraint_add_for_object(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK); - data = con->data; + data = static_cast(con->data); data->tar = obact; DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); @@ -1320,7 +1321,7 @@ static int track_set_exec(bContext *C, wmOperator *op) } DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, nullptr); return OPERATOR_FINISHED; } @@ -1352,12 +1353,12 @@ void OBJECT_OT_track_set(wmOperatorType *ot) * \{ */ #if 0 -static void link_to_scene(Main *UNUSED(bmain), ushort UNUSED(nr)) +static void link_to_scene(Main * /*bmain*/, ushort /*nr*/) { Scene *sce = (Scene *)BLI_findlink(&bmain->scene, G.curscreen->scenenr - 1); Base *base, *nbase; - if (sce == NULL) { + if (sce == nullptr) { return; } if (sce->id.lib) { @@ -1378,9 +1379,10 @@ static void link_to_scene(Main *UNUSED(bmain), ushort UNUSED(nr)) static int make_links_scene_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene_to = BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene")); + Scene *scene_to = static_cast( + BLI_findlink(&bmain->scenes, RNA_enum_get(op->ptr, "scene"))); - if (scene_to == NULL) { + if (scene_to == nullptr) { BKE_report(op->reports, RPT_ERROR, "Could not find scene"); return OPERATOR_CANCELLED; } @@ -1404,7 +1406,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); /* redraw the 3D view because the object center points are colored differently */ - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, nullptr); /* one day multiple scenes will be visible, then we should have some update function for them */ @@ -1479,7 +1481,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) int a; /* collection */ - LinkNode *ob_collections = NULL; + LinkNode *ob_collections = nullptr; bool is_cycle = false; bool is_lib = false; @@ -1495,18 +1497,18 @@ static int make_links_data_exec(bContext *C, wmOperator *op) if (ob_src != ob_dst) { if (allow_make_links_data(type, ob_src, ob_dst)) { - obdata_id = ob_dst->data; + obdata_id = static_cast(ob_dst->data); switch (type) { case MAKE_LINKS_OBDATA: /* obdata */ id_us_min(obdata_id); - obdata_id = ob_src->data; + obdata_id = static_cast(ob_src->data); id_us_plus(obdata_id); ob_dst->data = obdata_id; /* if amount of material indices changed: */ - BKE_object_materials_test(bmain, ob_dst, ob_dst->data); + BKE_object_materials_test(bmain, ob_dst, static_cast(ob_dst->data)); DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); break; @@ -1514,7 +1516,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) /* new approach, using functions from kernel */ for (a = 0; a < ob_src->totcol; a++) { Material *ma = BKE_object_material_get(ob_src, a + 1); - /* also works with `ma == NULL` */ + /* also works with `ma == nullptr` */ BKE_object_material_assign(bmain, ob_dst, ma, a + 1, BKE_MAT_ASSIGN_USERPREF); } DEG_id_tag_update(&ob_dst->id, ID_RECALC_GEOMETRY); @@ -1541,7 +1543,8 @@ static int make_links_data_exec(bContext *C, wmOperator *op) for (collection_node = ob_collections; collection_node; collection_node = collection_node->next) { if (ob_dst->instance_collection != collection_node->link) { - BKE_collection_object_add(bmain, collection_node->link, ob_dst); + BKE_collection_object_add( + bmain, static_cast(collection_node->link), ob_dst); } else { is_cycle = true; @@ -1563,8 +1566,8 @@ static int make_links_data_exec(bContext *C, wmOperator *op) ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); break; case MAKE_LINKS_FONTS: { - Curve *cu_src = ob_src->data; - Curve *cu_dst = ob_dst->data; + Curve *cu_src = static_cast(ob_src->data); + Curve *cu_dst = static_cast(ob_dst->data); if (!BKE_id_is_editable(bmain, obdata_id)) { is_lib = true; @@ -1609,7 +1612,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) if (type == MAKE_LINKS_GROUP) { if (ob_collections) { - BLI_linklist_free(ob_collections, NULL); + BLI_linklist_free(ob_collections, nullptr); } if (is_cycle) { @@ -1622,9 +1625,9 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } DEG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, CTX_wm_view3d(C)); - WM_event_add_notifier(C, NC_OBJECT, NULL); + WM_event_add_notifier(C, NC_OBJECT, nullptr); return OPERATOR_FINISHED; } @@ -1677,7 +1680,7 @@ void OBJECT_OT_make_links_data(wmOperatorType *ot) 0, "Copy Grease Pencil Effects", "Replace Grease Pencil Effects"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -1707,7 +1710,7 @@ static bool single_data_needs_duplication(ID *id) /* NOTE: When dealing with linked data, we always make a local copy of it. * While in theory we could rather make it local when it only has one user, this is difficult * in practice with current code of this function. */ - return (id != NULL && (id->us > 1 || ID_IS_LINKED(id))); + return (id != nullptr && (id->us > 1 || ID_IS_LINKED(id))); } static void libblock_relink_collection(Main *bmain, @@ -1718,7 +1721,10 @@ static void libblock_relink_collection(Main *bmain, BKE_libblock_relink_to_newid(bmain, &collection->id, 0); } - for (CollectionObject *cob = collection->gobject.first; cob != NULL; cob = cob->next) { + for (CollectionObject *cob = static_cast(collection->gobject.first); + cob != nullptr; + cob = cob->next) + { BKE_libblock_relink_to_newid(bmain, &cob->ob->id, 0); } @@ -1734,35 +1740,35 @@ static Collection *single_object_users_collection(Main *bmain, const bool copy_collections, const bool is_master_collection) { - /* Generate new copies for objects in given collection and all its children, - * and optionally also copy collections themselves. */ + /* Generate new copies for objects in given collection and all its children, * and optionally + * also copy collections themselves. */ if (copy_collections && !is_master_collection) { Collection *collection_new = (Collection *)BKE_id_copy_ex( - bmain, &collection->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); + bmain, &collection->id, nullptr, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); id_us_min(&collection_new->id); - collection = ID_NEW_SET(collection, collection_new); + collection = static_cast(ID_NEW_SET(collection, collection_new)); } /* We do not remap to new objects here, this is done in separate step. */ LISTBASE_FOREACH (CollectionObject *, cob, &collection->gobject) { Object *ob = cob->ob; /* an object may be in more than one collection */ - if ((ob->id.newid == NULL) && ((ob->flag & flag) == flag)) { + if ((ob->id.newid == nullptr) && ((ob->flag & flag) == flag)) { if (!ID_IS_LINKED(ob) && BKE_object_scenes_users_get(bmain, ob) > 1) { ID_NEW_SET( - ob, BKE_id_copy_ex(bmain, &ob->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob, + BKE_id_copy_ex(bmain, &ob->id, nullptr, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); id_us_min(ob->id.newid); } } } - /* Since master collection has already be duplicated as part of scene copy, - * we do not duplicate it here. - * However, this means its children need to be re-added manually here, + /* Since master collection has already be duplicated as part of scene copy, * we do not + * duplicate it here. However, this means its children need to be re-added manually here, * * otherwise their parent lists are empty (which will lead to crashes, see #63101). */ - CollectionChild *child_next, *child = collection->children.first; - CollectionChild *orig_child_last = collection->children.last; - for (; child != NULL; child = child_next) { + CollectionChild *child_next, *child = static_cast(collection->children.first); + CollectionChild *orig_child_last = static_cast(collection->children.last); + for (; child != nullptr; child = child_next) { child_next = child->next; Collection *collection_child_new = single_object_users_collection( bmain, scene, child->collection, flag, copy_collections, false); @@ -1818,7 +1824,7 @@ void ED_object_single_user(Main *bmain, Scene *scene, Object *ob) /* tag only the one object */ ob->flag |= OB_DONE; - single_object_users(bmain, scene, NULL, OB_DONE, false); + single_object_users(bmain, scene, nullptr, OB_DONE, false); BKE_main_id_newptr_and_tag_clear(bmain); } @@ -1834,93 +1840,128 @@ static void single_obdata_users( FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { if (BKE_id_is_editable(bmain, &ob->id)) { - id = ob->data; + id = static_cast(ob->data); if (single_data_needs_duplication(id)) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); switch (ob->type) { case OB_EMPTY: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_LAMP: - ob->data = la = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = la = static_cast( + ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS))); break; case OB_CAMERA: - cam = ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = cam = static_cast( + ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS))); ID_NEW_REMAP(cam->dof.focus_object); break; case OB_MESH: /* Needed to remap texcomesh below. */ - me = ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = me = static_cast( + ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS))); break; case OB_MBALL: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_CURVES_LEGACY: case OB_SURF: case OB_FONT: - ob->data = cu = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = cu = static_cast( + ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS))); ID_NEW_REMAP(cu->bevobj); ID_NEW_REMAP(cu->taperobj); break; case OB_LATTICE: - ob->data = lat = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = lat = static_cast( + ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS))); break; case OB_ARMATURE: DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); - BKE_pose_rebuild(bmain, ob, ob->data, true); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + BKE_pose_rebuild(bmain, ob, static_cast(ob->data), true); break; case OB_SPEAKER: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_LIGHTPROBE: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_GPENCIL_LEGACY: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_CURVES: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_POINTCLOUD: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_VOLUME: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; case OB_GREASE_PENCIL: - ob->data = ID_NEW_SET( - ob->data, - BKE_id_copy_ex(bmain, ob->data, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); + ob->data = ID_NEW_SET(ob->data, + BKE_id_copy_ex(bmain, + static_cast(ob->data), + nullptr, + LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS)); break; default: printf("ERROR %s: can't copy %s\n", __func__, id->name); @@ -1937,10 +1978,10 @@ static void single_obdata_users( } FOREACH_OBJECT_FLAG_END; - me = bmain->meshes.first; + me = static_cast(bmain->meshes.first); while (me) { ID_NEW_REMAP(me->texcomesh); - me = me->id.next; + me = static_cast(me->id.next); } } @@ -1954,7 +1995,7 @@ void ED_object_single_obdata_user(Main *bmain, Scene *scene, Object *ob) /* Tag only the one object. */ ob->flag |= OB_DONE; - single_obdata_users(bmain, scene, NULL, NULL, OB_DONE); + single_obdata_users(bmain, scene, nullptr, nullptr, OB_DONE); } static void single_object_action_users( @@ -1963,7 +2004,7 @@ static void single_object_action_users( FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { if (BKE_id_is_editable(bmain, &ob->id)) { AnimData *adt = BKE_animdata_from_id(&ob->id); - if (adt == NULL) { + if (adt == nullptr) { continue; } @@ -1981,10 +2022,10 @@ static void single_objectdata_action_users( Main *bmain, Scene *scene, ViewLayer *view_layer, View3D *v3d, const int flag) { FOREACH_OBJECT_FLAG_BEGIN (scene, view_layer, v3d, flag, ob) { - if (BKE_id_is_editable(bmain, &ob->id) && ob->data != NULL) { + if (BKE_id_is_editable(bmain, &ob->id) && ob->data != nullptr) { ID *id_obdata = (ID *)ob->data; AnimData *adt = BKE_animdata_from_id(id_obdata); - if (adt == NULL) { + if (adt == nullptr) { continue; } @@ -2010,7 +2051,7 @@ static void single_mat_users( ma = BKE_object_material_get(ob, (short)a); if (single_data_needs_duplication(&ma->id)) { man = (Material *)BKE_id_copy_ex( - bmain, &ma->id, NULL, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); + bmain, &ma->id, nullptr, LIB_ID_COPY_DEFAULT | LIB_ID_COPY_ACTIONS); man->id.us = 0; BKE_object_material_assign(bmain, ob, man, (short)a, BKE_MAT_ASSIGN_USERPREF); } @@ -2066,15 +2107,18 @@ static void tag_localizable_objects(bContext *C, const int mode) /* Also forbid making objects local if other library objects are using * them for modifiers or constraints. */ - for (Object *object = bmain->objects.first; object; object = object->id.next) { + for (Object *object = static_cast(bmain->objects.first); object; + object = static_cast(object->id.next)) + { if ((object->id.tag & LIB_TAG_DOIT) == 0) { BKE_library_foreach_ID_link( - NULL, &object->id, tag_localizable_looper, NULL, IDWALK_READONLY); + nullptr, &object->id, tag_localizable_looper, nullptr, IDWALK_READONLY); } if (object->data) { ID *data_id = (ID *)object->data; if ((data_id->tag & LIB_TAG_DOIT) == 0) { - BKE_library_foreach_ID_link(NULL, data_id, tag_localizable_looper, NULL, IDWALK_READONLY); + BKE_library_foreach_ID_link( + nullptr, data_id, tag_localizable_looper, nullptr, IDWALK_READONLY); } } } @@ -2083,8 +2127,8 @@ static void tag_localizable_objects(bContext *C, const int mode) } /** - * Instance indirectly referenced zero user objects, - * otherwise they're lost on reload, see #40595. + * Instance indirectly referenced zero user objects, * otherwise they're lost on reload, see + * #40595. */ static bool make_local_all__instance_indirect_unused(Main *bmain, const Scene *scene, @@ -2094,7 +2138,8 @@ static bool make_local_all__instance_indirect_unused(Main *bmain, Object *ob; bool changed = false; - for (ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ob = static_cast(bmain->objects.first); ob; + ob = static_cast(ob->id.next)) { if (ID_IS_LINKED(ob) && (ob->id.us == 0)) { Base *base; @@ -2117,7 +2162,7 @@ static void make_local_animdata_tag_strips(ListBase *strips) { NlaStrip *strip; - for (strip = strips->first; strip; strip = strip->next) { + for (strip = static_cast(strips->first); strip; strip = strip->next) { if (strip->act) { strip->act->id.tag &= ~LIB_TAG_PRE_EXISTING; } @@ -2154,8 +2199,8 @@ static void make_local_material_tag(Material *ma) ma->id.tag &= ~LIB_TAG_PRE_EXISTING; make_local_animdata_tag(BKE_animdata_from_id(&ma->id)); - /* About nodetrees: root one is made local together with material, - * others we keep linked for now... */ + /* About nodetrees: root one is made local together with material, * others we keep linked + * for now... */ } } @@ -2195,7 +2240,8 @@ static int make_local_exec(bContext *C, wmOperator *op) ob->id.tag &= ~LIB_TAG_PRE_EXISTING; make_local_animdata_tag(BKE_animdata_from_id(&ob->id)); - for (psys = ob->particlesystem.first; psys; psys = psys->next) { + for (psys = static_cast(ob->particlesystem.first); psys; psys = psys->next) + { psys->part->id.tag &= ~LIB_TAG_PRE_EXISTING; } @@ -2219,8 +2265,8 @@ static int make_local_exec(bContext *C, wmOperator *op) } if (ELEM(mode, MAKE_LOCAL_SELECT_OBDATA, MAKE_LOCAL_SELECT_OBDATA_MATERIAL) && - ob->data != NULL) { - ID *ob_data = ob->data; + ob->data != nullptr) { + ID *ob_data = static_cast(ob->data); ob_data->tag &= ~LIB_TAG_PRE_EXISTING; make_local_animdata_tag(BKE_animdata_from_id(ob_data)); } @@ -2228,9 +2274,9 @@ static int make_local_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - BKE_library_make_local(bmain, NULL, NULL, true, false); /* NULL is all libraries. */ + BKE_library_make_local(bmain, nullptr, nullptr, true, false); /* nullptr is all libraries. */ - WM_event_add_notifier(C, NC_WINDOW, NULL); + WM_event_add_notifier(C, NC_WINDOW, nullptr); return OPERATOR_FINISHED; } @@ -2245,7 +2291,7 @@ void OBJECT_OT_make_local(wmOperatorType *ot) "Selected Objects, Data and Materials", ""}, {MAKE_LOCAL_ALL, "ALL", 0, "All", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -2294,12 +2340,12 @@ static int make_override_library_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obact = CTX_data_active_object(C); - ID *id_root = NULL; + ID *id_root = nullptr; bool is_override_instancing_object = false; bool user_overrides_from_selected_objects = false; - if (!ID_IS_LINKED(obact) && obact->instance_collection != NULL && + if (!ID_IS_LINKED(obact) && obact->instance_collection != nullptr && ID_IS_LINKED(obact->instance_collection)) { if (!ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) { @@ -2324,10 +2370,11 @@ static int make_override_library_exec(bContext *C, wmOperator *op) obact->id.name + 2); return OPERATOR_CANCELLED; } - Collection *collection = BLI_listbase_bytes_find(&bmain->collections, - &collection_session_uuid, - sizeof(collection_session_uuid), - offsetof(ID, session_uuid)); + Collection *collection = static_cast( + BLI_listbase_bytes_find(&bmain->collections, + &collection_session_uuid, + sizeof(collection_session_uuid), + offsetof(ID, session_uuid))); id_root = &collection->id; user_overrides_from_selected_objects = true; } @@ -2360,7 +2407,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op) const bool do_fully_editable = !user_overrides_from_selected_objects; - GSet *user_overrides_objects_uids = do_fully_editable ? NULL : + GSet *user_overrides_objects_uids = do_fully_editable ? nullptr : BLI_gset_new(BLI_ghashutil_inthash_p, BLI_ghashutil_intcmp, __func__); @@ -2390,7 +2437,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op) /* For the time being, replace selected linked objects by their overrides in all collections. * While this may not be the absolute best behavior in all cases, in most common one this should * match the expected result. */ - if (user_overrides_objects_uids != NULL) { + if (user_overrides_objects_uids != nullptr) { LISTBASE_FOREACH (Collection *, coll_iter, &bmain->collections) { if (ID_IS_LINKED(coll_iter)) { continue; @@ -2411,7 +2458,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op) const bool success = BKE_lib_override_library_create(bmain, scene, view_layer, - NULL, + nullptr, id_root, id_root, &obact->id, @@ -2436,7 +2483,7 @@ static int make_override_library_exec(bContext *C, wmOperator *op) } FOREACH_MAIN_ID_END; - BLI_gset_free(user_overrides_objects_uids, NULL); + BLI_gset_free(user_overrides_objects_uids, nullptr); } if (success) { @@ -2473,15 +2520,15 @@ static int make_override_library_exec(bContext *C, wmOperator *op) } DEG_id_tag_update(&CTX_data_scene(C)->id, ID_RECALC_BASE_FLAGS | ID_RECALC_COPY_ON_WRITE); - WM_event_add_notifier(C, NC_WINDOW, NULL); - WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_WINDOW, nullptr); + WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, nullptr); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr); return success ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } /* Set the object to override. */ -static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -2493,7 +2540,7 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve return OPERATOR_CANCELLED; } - if ((!ID_IS_LINKED(obact) && obact->instance_collection != NULL && + if ((!ID_IS_LINKED(obact) && obact->instance_collection != nullptr && ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection)) || make_override_library_object_overridable_check(bmain, obact)) { @@ -2544,9 +2591,9 @@ static bool make_override_library_poll(bContext *C) /* Object must be directly linked to be overridable. */ return ( - ED_operator_objectmode(C) && obact != NULL && + ED_operator_objectmode(C) && obact != nullptr && (ID_IS_LINKED(obact) || ID_IS_OVERRIDE_LIBRARY(obact) || - (obact->instance_collection != NULL && + (obact->instance_collection != nullptr && ID_IS_OVERRIDABLE_LIBRARY(obact->instance_collection) && !ID_IS_OVERRIDE_LIBRARY(obact)))); } @@ -2594,11 +2641,11 @@ static bool reset_clear_override_library_poll(bContext *C) Object *obact = CTX_data_active_object(C); /* Object must be local and an override. */ - return (ED_operator_objectmode(C) && obact != NULL && !ID_IS_LINKED(obact) && + return (ED_operator_objectmode(C) && obact != nullptr && !ID_IS_LINKED(obact) && ID_IS_OVERRIDE_LIBRARY(obact)); } -static int reset_override_library_exec(bContext *C, wmOperator *UNUSED(op)) +static int reset_override_library_exec(bContext *C, wmOperator * /*op*/) { Main *bmain = CTX_data_main(C); @@ -2610,9 +2657,9 @@ static int reset_override_library_exec(bContext *C, wmOperator *UNUSED(op)) } FOREACH_SELECTED_OBJECT_END; - WM_event_add_notifier(C, NC_WINDOW, NULL); - WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_WINDOW, nullptr); + WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, nullptr); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr); return OPERATOR_FINISHED; } @@ -2638,12 +2685,12 @@ void OBJECT_OT_reset_override_library(wmOperatorType *ot) /** \name Clear Library Override Operator * \{ */ -static int clear_override_library_exec(bContext *C, wmOperator *UNUSED(op)) +static int clear_override_library_exec(bContext *C, wmOperator * /*op*/) { Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); Scene *scene = CTX_data_scene(C); - LinkNode *todo_objects = NULL, *todo_object_iter; + LinkNode *todo_objects = nullptr, *todo_object_iter; /* Make already existing selected liboverrides editable. */ FOREACH_SELECTED_OBJECT_BEGIN (view_layer, CTX_wm_view3d(C), ob_iter) { @@ -2654,10 +2701,10 @@ static int clear_override_library_exec(bContext *C, wmOperator *UNUSED(op)) } FOREACH_SELECTED_OBJECT_END; - for (todo_object_iter = todo_objects; todo_object_iter != NULL; + for (todo_object_iter = todo_objects; todo_object_iter != nullptr; todo_object_iter = todo_object_iter->next) { - Object *ob_iter = todo_object_iter->link; + Object *ob_iter = static_cast(todo_object_iter->link); if (BKE_lib_override_library_is_hierarchy_leaf(bmain, &ob_iter->id)) { bool do_remap_active = false; BKE_view_layer_synced_ensure(scene, view_layer); @@ -2671,7 +2718,7 @@ static int clear_override_library_exec(bContext *C, wmOperator *UNUSED(op)) if (do_remap_active) { Object *ref_object = (Object *)ob_iter->id.override_library->reference; Base *basact = BKE_view_layer_base_find(view_layer, ref_object); - if (basact != NULL) { + if (basact != nullptr) { view_layer->basact = basact; } DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); @@ -2684,9 +2731,9 @@ static int clear_override_library_exec(bContext *C, wmOperator *UNUSED(op)) } DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS | ID_RECALC_COPY_ON_WRITE); - WM_event_add_notifier(C, NC_WINDOW, NULL); - WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, NULL); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_WINDOW, nullptr); + WM_event_add_notifier(C, NC_WM | ND_LIB_OVERRIDE_CHANGED, nullptr); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr); return OPERATOR_FINISHED; } @@ -2724,7 +2771,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - View3D *v3d = CTX_wm_view3d(C); /* ok if this is NULL */ + View3D *v3d = CTX_wm_view3d(C); /* ok if this is nullptr */ const int flag = (RNA_enum_get(op->ptr, "type") == MAKE_SINGLE_USER_SELECTED) ? SELECT : 0; const bool copy_collections = false; bool update_deps = false; @@ -2763,7 +2810,7 @@ static int make_single_user_exec(bContext *C, wmOperator *op) BKE_main_id_newptr_and_tag_clear(bmain); - WM_event_add_notifier(C, NC_WINDOW, NULL); + WM_event_add_notifier(C, NC_WINDOW, nullptr); if (update_deps) { DEG_relations_tag_update(bmain); @@ -2777,7 +2824,7 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static const EnumPropertyItem type_items[] = { {MAKE_SINGLE_USER_SELECTED, "SELECTED_OBJECTS", 0, "Selected Objects", ""}, {MAKE_SINGLE_USER_ALL, "ALL", 0, "All", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; /* identifiers */ @@ -2785,8 +2832,8 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) ot->description = "Make linked data local to each object"; ot->idname = "OBJECT_OT_make_single_user"; - /* Note that the invoke callback is only used from operator search, - * otherwise this does nothing by default. */ + /* Note that the invoke callback is only used from operator search, * otherwise this does + * nothing by default. */ /* api callbacks */ ot->invoke = WM_operator_props_popup_confirm; @@ -2824,7 +2871,7 @@ char *ED_object_ot_drop_named_material_tooltip(bContext *C, const char *name, co { int mat_slot = 0; Object *ob = ED_view3d_give_material_slot_under_cursor(C, mval, &mat_slot); - if (ob == NULL) { + if (ob == nullptr) { return BLI_strdup(""); } mat_slot = max_ii(mat_slot, 1); @@ -2853,7 +2900,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent Material *ma = (Material *)WM_operator_properties_id_lookup_from_name_or_session_uuid( bmain, op->ptr, ID_MA); - if (ob == NULL || ma == NULL) { + if (ob == nullptr || ma == nullptr) { return OPERATOR_CANCELLED; } @@ -2862,7 +2909,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, nullptr); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma); return OPERATOR_FINISHED; @@ -2896,7 +2943,7 @@ char *ED_object_ot_drop_geometry_nodes_tooltip(bContext *C, const int mval[2]) { const Object *ob = ED_view3d_give_object_under_cursor(C, mval); - if (ob == NULL) { + if (ob == nullptr) { return BLI_strdup(""); } @@ -2969,7 +3016,7 @@ static int drop_geometry_nodes_invoke(bContext *C, wmOperator *op, const wmEvent MOD_nodes_update_interface(ob, nmd); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); - WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, nullptr); return OPERATOR_FINISHED; } @@ -3009,7 +3056,7 @@ static int object_unlink_data_exec(bContext *C, wmOperator *op) UI_context_active_but_prop_get_templateID(C, &pprop.ptr, &pprop.prop); - if (pprop.prop == NULL) { + if (pprop.prop == nullptr) { BKE_report(op->reports, RPT_ERROR, "Incorrect context for running object data unlink"); return OPERATOR_CANCELLED; } @@ -3019,11 +3066,11 @@ static int object_unlink_data_exec(bContext *C, wmOperator *op) if (GS(id->name) == ID_OB) { Object *ob = (Object *)id; if (ob->data) { - ID *id_data = ob->data; + ID *id_data = static_cast(ob->data); if (GS(id_data->name) == ID_IM) { id_us_min(id_data); - ob->data = NULL; + ob->data = nullptr; } else { BKE_report(op->reports, RPT_ERROR, "Can't unlink this object data"); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.cc similarity index 93% rename from source/blender/editors/object/object_select.c rename to source/blender/editors/object/object_select.cc index a442b1143aa..4f8369add68 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.cc @@ -103,7 +103,7 @@ void ED_object_base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_la WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); DEG_id_tag_update(&scene->id, ID_RECALC_SELECT); struct wmMsgBus *mbus = ((wmWindowManager *)bmain->wm.first)->message_bus; - if (mbus != NULL) { + if (mbus != nullptr) { WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active); } } @@ -195,7 +195,7 @@ bool ED_object_base_deselect_all(const Scene *scene, View3D *v3d, int action) { - return ED_object_base_deselect_all_ex(scene, view_layer, v3d, action, NULL); + return ED_object_base_deselect_all_ex(scene, view_layer, v3d, action, nullptr); } /** \} */ @@ -228,7 +228,7 @@ Base *ED_object_find_first_by_data_id(const Scene *scene, ViewLayer *view_layer, } /* Try all objects. */ - Base *base_best = NULL; + Base *base_best = nullptr; int priority_best = 0; LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) { @@ -249,7 +249,7 @@ Base *ED_object_find_first_by_data_id(const Scene *scene, ViewLayer *view_layer, return base_best; } -bool ED_object_jump_to_object(bContext *C, Object *ob, const bool UNUSED(reveal_hidden)) +bool ED_object_jump_to_object(bContext *C, Object *ob, const bool /*reveal_hidden*/) { const Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); @@ -257,7 +257,7 @@ bool ED_object_jump_to_object(bContext *C, Object *ob, const bool UNUSED(reveal_ BKE_view_layer_synced_ensure(scene, view_layer); Base *base = BKE_view_layer_base_find(view_layer, ob); - if (base == NULL) { + if (base == nullptr) { return false; } @@ -288,11 +288,11 @@ bool ED_object_jump_to_bone(bContext *C, const bool reveal_hidden) { /* Verify it's a valid armature object. */ - if (ob == NULL || ob->type != OB_ARMATURE) { + if (ob == nullptr || ob->type != OB_ARMATURE) { return false; } - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); /* Activate the armature object. */ if (!ED_object_jump_to_object(C, ob, reveal_hidden)) { @@ -304,10 +304,10 @@ bool ED_object_jump_to_bone(bContext *C, ED_object_mode_set(C, OB_MODE_POSE); } - if (ob->mode == OB_MODE_EDIT && arm->edbo != NULL) { + if (ob->mode == OB_MODE_EDIT && arm->edbo != nullptr) { /* In Edit mode select and activate the target Edit-Bone. */ EditBone *ebone = ED_armature_ebone_find_name(arm->edbo, bone_name); - if (ebone != NULL) { + if (ebone != nullptr) { if (reveal_hidden) { /* Unhide the bone. */ ebone->flag &= ~BONE_HIDDEN_A; @@ -331,10 +331,10 @@ bool ED_object_jump_to_bone(bContext *C, return true; } } - else if (ob->mode == OB_MODE_POSE && ob->pose != NULL) { + else if (ob->mode == OB_MODE_POSE && ob->pose != nullptr) { /* In Pose mode select and activate the target Bone/Pose-Channel. */ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, bone_name); - if (pchan != NULL) { + if (pchan != nullptr) { if (reveal_hidden) { /* Unhide the bone. */ pchan->bone->flag &= ~BONE_HIDDEN_P; @@ -465,7 +465,7 @@ static const EnumPropertyItem prop_select_linked_types[] = { {OBJECT_SELECT_LINKED_PARTICLE, "PARTICLE", 0, "Particle System", ""}, {OBJECT_SELECT_LINKED_LIBRARY, "LIBRARY", 0, "Library", ""}, {OBJECT_SELECT_LINKED_LIBRARY_OBDATA, "LIBRARY_OBDATA", 0, "Library (Object Data)", ""}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static bool object_select_all_by_obdata(bContext *C, void *obdata) @@ -515,13 +515,13 @@ static bool object_select_all_by_instance_collection(bContext *C, Object *ob) bool changed = false; Collection *instance_collection = (ob->transflag & OB_DUPLICOLLECTION) ? ob->instance_collection : - NULL; + nullptr; CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (((base->flag & BASE_SELECTED) == 0) && ((base->flag & BASE_SELECTABLE) != 0)) { Collection *instance_collection_other = (base->object->transflag & OB_DUPLICOLLECTION) ? base->object->instance_collection : - NULL; + nullptr; if (instance_collection == instance_collection_other) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -543,7 +543,9 @@ static bool object_select_all_by_particle(bContext *C, Object *ob) /* Loop through other particles. */ ParticleSystem *psys; - for (psys = base->object->particlesystem.first; psys; psys = psys->next) { + for (psys = static_cast(base->object->particlesystem.first); psys; + psys = psys->next) + { if (psys->part == psys_act->part) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -634,7 +636,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) BKE_view_layer_synced_ensure(scene, view_layer); ob = BKE_view_layer_active_object_get(view_layer); - if (ob == NULL) { + if (ob == nullptr) { BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } @@ -646,24 +648,24 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (nr == OBJECT_SELECT_LINKED_OBDATA) { - if (ob->data == NULL) { + if (ob->data == nullptr) { return OPERATOR_CANCELLED; } changed = object_select_all_by_obdata(C, ob->data); } else if (nr == OBJECT_SELECT_LINKED_MATERIAL) { - Material *mat = NULL; + Material *mat = nullptr; mat = BKE_object_material_get(ob, ob->actcol); - if (mat == NULL) { + if (mat == nullptr) { return OPERATOR_CANCELLED; } changed = object_select_all_by_material(C, mat); } else if (nr == OBJECT_SELECT_LINKED_DUPGROUP) { - if (ob->instance_collection == NULL) { + if (ob->instance_collection == nullptr) { return OPERATOR_CANCELLED; } @@ -681,7 +683,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) changed = object_select_all_by_library(C, ob->id.lib); } else if (nr == OBJECT_SELECT_LINKED_LIBRARY_OBDATA) { - if (ob->data == NULL) { + if (ob->data == nullptr) { return OPERATOR_CANCELLED; } @@ -761,7 +763,7 @@ static const EnumPropertyItem prop_select_grouped_types[] = { "Keying Set", "Objects included in active Keying Set"}, {OBJECT_GRPSEL_LIGHT_TYPE, "LIGHT_TYPE", 0, "Light Type", "Matching light types"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static bool select_grouped_children(bContext *C, Object *ob, const bool recursive) @@ -801,7 +803,7 @@ static bool select_grouped_parent(bContext *C) BKE_view_layer_synced_ensure(scene, view_layer); baspar = BKE_view_layer_base_find(view_layer, basact->object->parent); - /* can be NULL if parent in other scene */ + /* can be nullptr if parent in other scene */ if (baspar && BASE_SELECTABLE(v3d, baspar)) { ED_object_base_select(baspar, BA_SELECT); ED_object_base_activate(C, baspar); @@ -821,9 +823,9 @@ static bool select_grouped_collection(bContext *C, Object *ob) uiPopupMenu *pup; uiLayout *layout; - for (collection = bmain->collections.first; + for (collection = static_cast(bmain->collections.first); collection && (collection_count < COLLECTION_MENU_MAX); - collection = collection->id.next) + collection = static_cast(collection->id.next)) { if (BKE_collection_has_object(collection, ob)) { ob_collections[collection_count] = collection; @@ -877,7 +879,7 @@ static bool select_grouped_object_hooks(bContext *C, Object *ob) ModifierData *md; HookModifierData *hmd; - for (md = ob->modifiers.first; md; md = md->next) { + for (md = static_cast(ob->modifiers.first); md; md = md->next) { if (md->type == eModifierType_Hook) { hmd = (HookModifierData *)md; if (hmd->object) { @@ -894,7 +896,7 @@ static bool select_grouped_object_hooks(bContext *C, Object *ob) } /* Select objects with the same parent as the active (siblings), - * parent can be NULL also */ + * parent can be nullptr also */ static bool select_grouped_siblings(bContext *C, Object *ob) { bool changed = false; @@ -910,13 +912,13 @@ static bool select_grouped_siblings(bContext *C, Object *ob) } static bool select_grouped_lighttype(bContext *C, Object *ob) { - Light *la = ob->data; + Light *la = static_cast(ob->data); bool changed = false; CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { if (base->object->type == OB_LAMP) { - Light *la_test = base->object->data; + Light *la_test = static_cast(base->object->data); if ((la->type == la_test->type) && ((base->flag & BASE_SELECTED) == 0)) { ED_object_base_select(base, BA_SELECT); changed = true; @@ -969,18 +971,18 @@ static bool select_grouped_color(bContext *C, Object *ob) return changed; } -static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList *reports) +static bool select_grouped_keyingset(bContext *C, Object * /*ob*/, ReportList *reports) { KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); bool changed = false; /* firstly, validate KeyingSet */ - if (ks == NULL) { + if (ks == nullptr) { BKE_report(reports, RPT_ERROR, "No active Keying Set to use"); return false; } - if (ANIM_validate_keyingset(C, NULL, ks) != 0) { - if (ks->paths.first == NULL) { + if (ANIM_validate_keyingset(C, nullptr, ks) != 0) { + if (ks->paths.first == nullptr) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { BKE_report(reports, RPT_ERROR, @@ -1005,7 +1007,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList /* this is the slow way... we could end up with > 500 items here, * with none matching, but end up doing this on 1000 objects... */ - for (ksp = ks->paths.first; ksp; ksp = ksp->next) { + for (ksp = static_cast(ks->paths.first); ksp; ksp = ksp->next) { /* if id matches, select then stop looping (match found) */ if (ksp->id == (ID *)base->object) { ED_object_base_select(base, BA_SELECT); @@ -1037,7 +1039,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) BKE_view_layer_synced_ensure(scene, view_layer); ob = BKE_view_layer_active_object_get(view_layer); - if (ob == NULL) { + if (ob == nullptr) { BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } @@ -1226,8 +1228,12 @@ void OBJECT_OT_select_same_collection(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - RNA_def_string( - ot->srna, "collection", NULL, MAX_ID_NAME, "Collection", "Name of the collection to select"); + RNA_def_string(ot->srna, + "collection", + nullptr, + MAX_ID_NAME, + "Collection", + "Name of the collection to select"); } /** \} */ @@ -1329,7 +1335,9 @@ static bool object_select_more_less(bContext *C, const bool select) } CTX_DATA_END; - for (ctx_base = ctx_base_list.first; ctx_base; ctx_base = ctx_base->next) { + for (ctx_base = static_cast(ctx_base_list.first); ctx_base; + ctx_base = ctx_base->next) + { Object *ob = ((Base *)ctx_base->ptr.data)->object; if (ob->parent) { if ((ob->flag & OB_DONE) != (ob->parent->flag & OB_DONE)) { @@ -1343,11 +1351,13 @@ static bool object_select_more_less(bContext *C, const bool select) const short select_mode = select ? BA_SELECT : BA_DESELECT; const short select_flag = select ? BASE_SELECTED : 0; - for (ctx_base = ctx_base_list.first; ctx_base; ctx_base = ctx_base->next) { - Base *base = ctx_base->ptr.data; + for (ctx_base = static_cast(ctx_base_list.first); ctx_base; + ctx_base = ctx_base->next) + { + Base *base = static_cast(ctx_base->ptr.data); Object *ob = base->object; if ((ob->id.tag & LIB_TAG_DOIT) && ((base->flag & BASE_SELECTED) != select_flag)) { - ED_object_base_select(base, select_mode); + ED_object_base_select(base, eObjectSelect_Mode(select_mode)); changed = true; } } @@ -1357,7 +1367,7 @@ static bool object_select_more_less(bContext *C, const bool select) return changed; } -static int object_select_more_exec(bContext *C, wmOperator *UNUSED(op)) +static int object_select_more_exec(bContext *C, wmOperator * /*op*/) { bool changed = object_select_more_less(C, true); @@ -1388,7 +1398,7 @@ void OBJECT_OT_select_more(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int object_select_less_exec(bContext *C, wmOperator *UNUSED(op)) +static int object_select_less_exec(bContext *C, wmOperator * /*op*/) { bool changed = object_select_more_less(C, false); @@ -1435,18 +1445,20 @@ static int object_select_random_exec(bContext *C, wmOperator *op) CTX_data_selectable_bases(C, &ctx_data_list); const int tot = BLI_listbase_count(&ctx_data_list); int elem_map_len = 0; - Base **elem_map = MEM_mallocN(sizeof(*elem_map) * tot, __func__); + Base **elem_map = static_cast(MEM_mallocN(sizeof(*elem_map) * tot, __func__)); CollectionPointerLink *ctx_link; - for (ctx_link = ctx_data_list.first; ctx_link; ctx_link = ctx_link->next) { - elem_map[elem_map_len++] = ctx_link->ptr.data; + for (ctx_link = static_cast(ctx_data_list.first); ctx_link; + ctx_link = ctx_link->next) + { + elem_map[elem_map_len++] = static_cast(ctx_link->ptr.data); } BLI_freelistN(&ctx_data_list); BLI_array_randomize(elem_map, sizeof(*elem_map), elem_map_len, seed); const int count_select = elem_map_len * randfac; for (int i = 0; i < count_select; i++) { - ED_object_base_select(elem_map[i], select); + ED_object_base_select(elem_map[i], eObjectSelect_Mode(select)); } MEM_freeN(elem_map); diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.cc similarity index 89% rename from source/blender/editors/object/object_shader_fx.c rename to source/blender/editors/object/object_shader_fx.cc index dd13021ff06..6ae87a78b7c 100644 --- a/source/blender/editors/object/object_shader_fx.c +++ b/source/blender/editors/object/object_shader_fx.cc @@ -56,20 +56,20 @@ * \{ */ ShaderFxData *ED_object_shaderfx_add( - ReportList *reports, Main *bmain, Scene *UNUSED(scene), Object *ob, const char *name, int type) + ReportList *reports, Main *bmain, Scene * /*scene*/, Object *ob, const char *name, int type) { - ShaderFxData *new_fx = NULL; - const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(type); + ShaderFxData *new_fx = nullptr; + const ShaderFxTypeInfo *fxi = BKE_shaderfx_get_info(ShaderFxType(type)); if (ob->type != OB_GPENCIL_LEGACY) { BKE_reportf(reports, RPT_WARNING, "Effect cannot be added to object '%s'", ob->id.name + 2); - return NULL; + return nullptr; } if (fxi->flags & eShaderFxTypeFlag_Single) { - if (BKE_shaderfx_findby_type(ob, type)) { + if (BKE_shaderfx_findby_type(ob, ShaderFxType(type))) { BKE_report(reports, RPT_WARNING, "Only one Effect of this type is allowed"); - return NULL; + return nullptr; } } @@ -85,7 +85,7 @@ ShaderFxData *ED_object_shaderfx_add( /* make sure effect data has unique name */ BKE_shaderfx_unique_name(&ob->shader_fx, new_fx); - bGPdata *gpd = ob->data; + bGPdata *gpd = static_cast(ob->data); DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -102,7 +102,7 @@ static bool UNUSED_FUNCTION(object_has_shaderfx)(const Object *ob, { ShaderFxData *fx; - for (fx = ob->shader_fx.first; fx; fx = fx->next) { + for (fx = static_cast(ob->shader_fx.first); fx; fx = fx->next) { if ((fx != exclude) && (fx->type == type)) { return true; } @@ -114,7 +114,7 @@ static bool UNUSED_FUNCTION(object_has_shaderfx)(const Object *ob, static bool object_shaderfx_remove(Main *bmain, Object *ob, ShaderFxData *fx, - bool *UNUSED(r_sort_depsgraph)) + bool * /*r_sort_depsgraph*/) { /* It seems on rapid delete it is possible to * get called twice on same effect, so make @@ -152,7 +152,7 @@ bool ED_object_shaderfx_remove(ReportList *reports, Main *bmain, Object *ob, Sha void ED_object_shaderfx_clear(Main *bmain, Object *ob) { - ShaderFxData *fx = ob->shader_fx.first; + ShaderFxData *fx = static_cast(ob->shader_fx.first); bool sort_depsgraph = false; if (!fx) { @@ -173,7 +173,7 @@ void ED_object_shaderfx_clear(Main *bmain, Object *ob) DEG_relations_tag_update(bmain); } -int ED_object_shaderfx_move_up(ReportList *UNUSED(reports), Object *ob, ShaderFxData *fx) +int ED_object_shaderfx_move_up(ReportList * /*reports*/, Object *ob, ShaderFxData *fx) { if (fx->prev) { BLI_remlink(&ob->shader_fx, fx); @@ -183,7 +183,7 @@ int ED_object_shaderfx_move_up(ReportList *UNUSED(reports), Object *ob, ShaderFx return 1; } -int ED_object_shaderfx_move_down(ReportList *UNUSED(reports), Object *ob, ShaderFxData *fx) +int ED_object_shaderfx_move_down(ReportList * /*reports*/, Object *ob, ShaderFxData *fx) { if (fx->next) { BLI_remlink(&ob->shader_fx, fx); @@ -198,7 +198,7 @@ bool ED_object_shaderfx_move_to_index(ReportList *reports, ShaderFxData *fx, const int index) { - BLI_assert(fx != NULL); + BLI_assert(fx != nullptr); BLI_assert(index >= 0); if (index >= BLI_listbase_count(&ob->shader_fx)) { BKE_report(reports, RPT_WARNING, "Cannot move effect beyond the end of the stack"); @@ -263,7 +263,7 @@ static bool edit_shaderfx_poll_generic(bContext *C, { PointerRNA ptr = CTX_data_pointer_get_type(C, "shaderfx", rna_type); Object *ob = (ptr.owner_id) ? (Object *)ptr.owner_id : ED_object_active_context(C); - ShaderFxData *fx = ptr.data; /* May be NULL. */ + ShaderFxData *fx = static_cast(ptr.data); /* May be nullptr. */ if (!ED_operator_object_active_editable_ex(C, ob)) { return false; @@ -280,7 +280,7 @@ static bool edit_shaderfx_poll_generic(bContext *C, CTX_wm_operator_poll_msg_set(C, "Object type is not supported"); return false; } - if (ptr.owner_id != NULL && !BKE_id_is_editable(CTX_data_main(C), ptr.owner_id)) { + if (ptr.owner_id != nullptr && !BKE_id_is_editable(CTX_data_main(C), ptr.owner_id)) { CTX_wm_operator_poll_msg_set(C, "Cannot edit library or override data"); return false; } @@ -311,7 +311,7 @@ static int shaderfx_add_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); - if (!ED_object_shaderfx_add(op->reports, bmain, scene, ob, NULL, type)) { + if (!ED_object_shaderfx_add(op->reports, bmain, scene, ob, nullptr, type)) { return OPERATOR_CANCELLED; } @@ -321,13 +321,13 @@ static int shaderfx_add_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *shaderfx_add_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { Object *ob = ED_object_active_context(C); - EnumPropertyItem *item = NULL; - const EnumPropertyItem *fx_item, *group_item = NULL; + EnumPropertyItem *item = nullptr; + const EnumPropertyItem *fx_item, *group_item = nullptr; const ShaderFxTypeInfo *mti; int totitem = 0, a; @@ -338,7 +338,7 @@ static const EnumPropertyItem *shaderfx_add_itemf(bContext *C, for (a = 0; rna_enum_object_shaderfx_type_items[a].identifier; a++) { fx_item = &rna_enum_object_shaderfx_type_items[a]; if (fx_item->identifier[0]) { - mti = BKE_shaderfx_get_info(fx_item->value); + mti = BKE_shaderfx_get_info(ShaderFxType(fx_item->value)); if (mti->flags & eShaderFxTypeFlag_NoUserAdd) { continue; @@ -346,14 +346,14 @@ static const EnumPropertyItem *shaderfx_add_itemf(bContext *C, } else { group_item = fx_item; - fx_item = NULL; + fx_item = nullptr; continue; } if (group_item) { RNA_enum_item_add(&item, &totitem, group_item); - group_item = NULL; + group_item = nullptr; } RNA_enum_item_add(&item, &totitem, fx_item); @@ -398,7 +398,7 @@ void OBJECT_OT_shaderfx_add(wmOperatorType *ot) static void edit_shaderfx_properties(wmOperatorType *ot) { PropertyRNA *prop = RNA_def_string( - ot->srna, "shaderfx", NULL, MAX_NAME, "Shader", "Name of the shaderfx to edit"); + ot->srna, "shaderfx", nullptr, MAX_NAME, "Shader", "Name of the shaderfx to edit"); RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -410,7 +410,7 @@ static void edit_shaderfx_report_property(wmOperatorType *ot) } /** - * \param event: If this isn't NULL, the operator will also look for panels underneath + * \param event: If this isn't nullptr, the operator will also look for panels underneath * the cursor with custom-data set to a modifier. * \param r_retval: This should be used if #event is used in order to return * #OPERATOR_PASS_THROUGH to check other operators with the same key set. @@ -425,32 +425,32 @@ static bool edit_shaderfx_invoke_properties(bContext *C, } PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "shaderfx", &RNA_ShaderFx); - if (ctx_ptr.data != NULL) { - ShaderFxData *fx = ctx_ptr.data; + if (ctx_ptr.data != nullptr) { + ShaderFxData *fx = static_cast(ctx_ptr.data); RNA_string_set(op->ptr, "shaderfx", fx->name); return true; } /* Check the custom data of panels under the mouse for an effect. */ - if (event != NULL) { + if (event != nullptr) { PointerRNA *panel_ptr = UI_region_panel_custom_data_under_cursor(C, event); - if (!(panel_ptr == NULL || RNA_pointer_is_null(panel_ptr))) { + if (!(panel_ptr == nullptr || RNA_pointer_is_null(panel_ptr))) { if (RNA_struct_is_a(panel_ptr->type, &RNA_ShaderFx)) { - ShaderFxData *fx = panel_ptr->data; + ShaderFxData *fx = static_cast(panel_ptr->data); RNA_string_set(op->ptr, "shaderfx", fx->name); return true; } - BLI_assert(r_retval != NULL); /* We need the return value in this case. */ - if (r_retval != NULL) { + BLI_assert(r_retval != nullptr); /* We need the return value in this case. */ + if (r_retval != nullptr) { *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED); } return false; } } - if (r_retval != NULL) { + if (r_retval != nullptr) { *r_retval = OPERATOR_CANCELLED; } return false; @@ -465,7 +465,7 @@ static ShaderFxData *edit_shaderfx_property_get(wmOperator *op, Object *ob, int fx = BKE_shaderfx_findby_name(ob, shaderfx_name); if (fx && type != 0 && fx->type != type) { - fx = NULL; + fx = nullptr; } return fx; diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.cc similarity index 89% rename from source/blender/editors/object/object_shapekey.c rename to source/blender/editors/object/object_shapekey.cc index 841f7eb263f..348e162e438 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.cc @@ -62,7 +62,7 @@ static void ED_object_shape_key_add(bContext *C, Object *ob, const bool from_mix { Main *bmain = CTX_data_main(C); KeyBlock *kb; - if ((kb = BKE_object_shapekey_insert(bmain, ob, NULL, from_mix))) { + if ((kb = BKE_object_shapekey_insert(bmain, ob, nullptr, from_mix))) { Key *key = BKE_key_from_object(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -82,11 +82,11 @@ static bool object_shapekey_remove(Main *bmain, Object *ob) KeyBlock *kb; Key *key = BKE_key_from_object(ob); - if (key == NULL) { + if (key == nullptr) { return false; } - kb = BLI_findlink(&key->block, ob->shapenr - 1); + kb = static_cast(BLI_findlink(&key->block, ob->shapenr - 1)); if (kb) { return BKE_object_shapekey_remove(bmain, ob, kb); } @@ -104,25 +104,26 @@ static bool object_shape_key_mirror( *r_totmirr = *r_totfail = 0; key = BKE_key_from_object(ob); - if (key == NULL) { + if (key == nullptr) { return 0; } - kb = BLI_findlink(&key->block, ob->shapenr - 1); + kb = static_cast(BLI_findlink(&key->block, ob->shapenr - 1)); if (kb) { - char *tag_elem = MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror"); + char *tag_elem = static_cast( + MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror")); if (ob->type == OB_MESH) { - Mesh *me = ob->data; + Mesh *me = static_cast(ob->data); int i1, i2; float *fp1, *fp2; float tvec[3]; - ED_mesh_mirror_spatial_table_begin(ob, NULL, NULL); + ED_mesh_mirror_spatial_table_begin(ob, nullptr, nullptr); for (i1 = 0; i1 < me->totvert; i1++) { - i2 = mesh_get_x_mirror_vert(ob, NULL, i1, use_topology); + i2 = mesh_get_x_mirror_vert(ob, nullptr, i1, use_topology); if (i2 == i1) { fp1 = ((float *)kb->data) + i1 * 3; fp1[0] = -fp1[0]; @@ -153,7 +154,7 @@ static bool object_shape_key_mirror( ED_mesh_mirror_spatial_table_end(ob); } else if (ob->type == OB_LATTICE) { - Lattice *lt = ob->data; + Lattice *lt = static_cast(ob->data); int i1, i2; float *fp1, *fp2; int u, v, w; @@ -216,9 +217,9 @@ static bool object_shape_key_mirror( static bool shape_key_poll(bContext *C) { Object *ob = ED_object_context(C); - ID *data = (ob) ? ob->data : NULL; + ID *data = static_cast((ob) ? ob->data : nullptr); - return (ob != NULL && !ID_IS_LINKED(ob) && !ID_IS_OVERRIDE_LIBRARY(ob) && data != NULL && + return (ob != nullptr && !ID_IS_LINKED(ob) && !ID_IS_OVERRIDE_LIBRARY(ob) && data != nullptr && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data)); } @@ -235,7 +236,7 @@ static bool shape_key_mode_exists_poll(bContext *C) return (shape_key_mode_poll(C) && /* check a keyblock exists */ - (BKE_keyblock_from_object(ob) != NULL)); + (BKE_keyblock_from_object(ob) != nullptr)); } static bool shape_key_move_poll(bContext *C) @@ -244,7 +245,7 @@ static bool shape_key_move_poll(bContext *C) Object *ob = ED_object_context(C); Key *key = BKE_key_from_object(ob); - return (shape_key_mode_poll(C) && key != NULL && key->totkey > 1); + return (shape_key_mode_poll(C) && key != nullptr && key->totkey > 1); } /** \} */ @@ -302,7 +303,8 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "all")) { if (RNA_boolean_get(op->ptr, "apply_mix")) { - float *arr = BKE_key_evaluate_object_ex(ob, NULL, NULL, 0, ob->data); + float *arr = BKE_key_evaluate_object_ex( + ob, nullptr, nullptr, 0, static_cast(ob->data)); MEM_freeN(arr); } changed = BKE_object_shapekey_free(bmain, ob); @@ -321,7 +323,7 @@ static int shape_key_remove_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -static bool shape_key_remove_poll_property(const bContext *UNUSED(C), +static bool shape_key_remove_poll_property(const bContext * /*C*/, wmOperator *op, const PropertyRNA *prop) { @@ -335,8 +337,8 @@ static bool shape_key_remove_poll_property(const bContext *UNUSED(C), return true; } -static char *shape_key_remove_get_description(bContext *UNUSED(C), - wmOperatorType *UNUSED(ot), +static char *shape_key_remove_get_description(bContext * /*C*/, + wmOperatorType * /*ot*/, PointerRNA *ptr) { const bool do_apply_mix = RNA_boolean_get(ptr, "apply_mix"); @@ -346,7 +348,7 @@ static char *shape_key_remove_get_description(bContext *UNUSED(C), TIP_("Apply current visible shape to the object data, and delete all shape keys")); } - return NULL; + return nullptr; } void OBJECT_OT_shape_key_remove(wmOperatorType *ot) @@ -380,7 +382,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) /** \name Shape Key Clear Operator * \{ */ -static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) +static int shape_key_clear_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_object_context(C); Key *key = BKE_key_from_object(ob); @@ -390,7 +392,7 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - for (kb = key->block.first; kb; kb = kb->next) { + for (kb = static_cast(key->block.first); kb; kb = kb->next) { kb->curval = 0.0f; } @@ -416,7 +418,7 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot) } /* starting point and step size could be optional */ -static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op)) +static int shape_key_retime_exec(bContext *C, wmOperator * /*op*/) { Object *ob = ED_object_context(C); Key *key = BKE_key_from_object(ob); @@ -427,7 +429,7 @@ static int shape_key_retime_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - for (kb = key->block.first; kb; kb = kb->next) { + for (kb = static_cast(key->block.first); kb; kb = kb->next) { kb->pos = cfra; cfra += 0.1f; } @@ -552,7 +554,7 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) {KB_MOVE_UP, "UP", 0, "Up", ""}, {KB_MOVE_DOWN, "DOWN", 0, "Down", ""}, {KB_MOVE_BOTTOM, "BOTTOM", 0, "Bottom", "Bottom of the list"}, - {0, NULL, 0, NULL, NULL}}; + {0, nullptr, 0, nullptr, nullptr}}; /* identifiers */ ot->name = "Move Shape Key"; diff --git a/source/blender/editors/object/object_utils.c b/source/blender/editors/object/object_utils.cc similarity index 86% rename from source/blender/editors/object/object_utils.c rename to source/blender/editors/object/object_utils.cc index d82c0fa396b..f43cab87e96 100644 --- a/source/blender/editors/object/object_utils.c +++ b/source/blender/editors/object/object_utils.cc @@ -57,7 +57,7 @@ bool ED_object_calc_active_center_for_editmode(Object *obedit, break; } case OB_ARMATURE: { - bArmature *arm = obedit->data; + bArmature *arm = static_cast(obedit->data); EditBone *ebo = arm->act_edbone; if (ebo && (!select_only || (ebo->flag & (BONE_SELECTED | BONE_ROOTSEL)))) { @@ -69,7 +69,7 @@ bool ED_object_calc_active_center_for_editmode(Object *obedit, } case OB_CURVES_LEGACY: case OB_SURF: { - Curve *cu = obedit->data; + Curve *cu = static_cast(obedit->data); if (ED_curve_active_center(cu, r_center)) { return true; @@ -77,7 +77,7 @@ bool ED_object_calc_active_center_for_editmode(Object *obedit, break; } case OB_MBALL: { - MetaBall *mb = obedit->data; + MetaBall *mb = static_cast(obedit->data); MetaElem *ml_act = mb->lastelem; if (ml_act && (!select_only || (ml_act->flag & SELECT))) { @@ -87,7 +87,7 @@ bool ED_object_calc_active_center_for_editmode(Object *obedit, break; } case OB_LATTICE: { - BPoint *actbp = BKE_lattice_active_point_get(obedit->data); + BPoint *actbp = BKE_lattice_active_point_get(static_cast(obedit->data)); if (actbp) { copy_v3_v3(r_center, actbp->vec); @@ -163,8 +163,9 @@ struct XFormObjectSkipChild { struct XFormObjectSkipChild_Container *ED_object_xform_skip_child_container_create(void) { - struct XFormObjectSkipChild_Container *xcs = MEM_callocN(sizeof(*xcs), __func__); - if (xcs->obchild_in_obmode_map == NULL) { + struct XFormObjectSkipChild_Container *xcs = static_cast( + MEM_callocN(sizeof(*xcs), __func__)); + if (xcs->obchild_in_obmode_map == nullptr) { xcs->obchild_in_obmode_map = BLI_ghash_ptr_new(__func__); } return xcs; @@ -186,18 +187,18 @@ void ED_object_xform_skip_child_container_item_ensure_from_array( ListBase *object_bases = BKE_view_layer_object_bases_get(view_layer); LISTBASE_FOREACH (Base *, base, object_bases) { Object *ob = base->object; - if (ob->parent != NULL) { + if (ob->parent != nullptr) { if (!BLI_gset_haskey(objects_in_transdata, ob)) { if (BLI_gset_haskey(objects_in_transdata, ob->parent)) { ED_object_xform_skip_child_container_item_ensure( - xcs, ob, NULL, XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM); + xcs, ob, nullptr, XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM); } } else { if (!BLI_gset_haskey(objects_in_transdata, ob->parent)) { Object *ob_parent_recurse = ob->parent; - if (ob_parent_recurse != NULL) { - while (ob_parent_recurse != NULL) { + if (ob_parent_recurse != nullptr) { + while (ob_parent_recurse != nullptr) { if (BLI_gset_haskey(objects_in_transdata, ob_parent_recurse)) { break; } @@ -220,21 +221,21 @@ void ED_object_xform_skip_child_container_item_ensure_from_array( if (BLI_gset_haskey(objects_in_transdata, ob)) { /* pass. */ } - else if (ob->parent != NULL) { + else if (ob->parent != nullptr) { if (BLI_gset_haskey(objects_in_transdata, ob->parent)) { if (!BLI_gset_haskey(objects_in_transdata, ob)) { ED_object_xform_skip_child_container_item_ensure( - xcs, ob, NULL, XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM); + xcs, ob, nullptr, XFORM_OB_SKIP_CHILD_PARENT_IS_XFORM); } } } } - BLI_gset_free(objects_in_transdata, NULL); + BLI_gset_free(objects_in_transdata, nullptr); } void ED_object_xform_skip_child_container_destroy(struct XFormObjectSkipChild_Container *xcs) { - BLI_ghash_free(xcs->obchild_in_obmode_map, NULL, MEM_freeN); + BLI_ghash_free(xcs->obchild_in_obmode_map, nullptr, MEM_freeN); MEM_freeN(xcs); } @@ -245,7 +246,8 @@ void ED_object_xform_skip_child_container_item_ensure(struct XFormObjectSkipChil { void **xf_p; if (!BLI_ghash_ensure_p(xcs->obchild_in_obmode_map, ob, &xf_p)) { - struct XFormObjectSkipChild *xf = MEM_mallocN(sizeof(*xf), __func__); + struct XFormObjectSkipChild *xf = static_cast( + MEM_mallocN(sizeof(*xf), __func__)); copy_m4_m4(xf->parentinv_orig, ob->parentinv); copy_m4_m4(xf->obmat_orig, ob->object_to_world); copy_m4_m4(xf->parent_obmat_orig, ob->parent->object_to_world); @@ -267,8 +269,9 @@ void ED_object_xform_skip_child_container_update_all(struct XFormObjectSkipChild GHashIterator gh_iter; GHASH_ITER (gh_iter, xcs->obchild_in_obmode_map) { - Object *ob = BLI_ghashIterator_getKey(&gh_iter); - struct XFormObjectSkipChild *xf = BLI_ghashIterator_getValue(&gh_iter); + Object *ob = static_cast(BLI_ghashIterator_getKey(&gh_iter)); + struct XFormObjectSkipChild *xf = static_cast( + BLI_ghashIterator_getValue(&gh_iter)); /* The following blocks below assign 'dmat'. */ float dmat[4][4]; @@ -345,17 +348,18 @@ struct XFormObjectData_Extra { void ED_object_data_xform_container_item_ensure(struct XFormObjectData_Container *xds, Object *ob) { - if (xds->obdata_in_obmode_map == NULL) { + if (xds->obdata_in_obmode_map == nullptr) { xds->obdata_in_obmode_map = BLI_ghash_ptr_new(__func__); } void **xf_p; if (!BLI_ghash_ensure_p(xds->obdata_in_obmode_map, ob->data, &xf_p)) { - struct XFormObjectData_Extra *xf = MEM_mallocN(sizeof(*xf), __func__); + struct XFormObjectData_Extra *xf = static_cast( + MEM_mallocN(sizeof(*xf), __func__)); copy_m4_m4(xf->obmat_orig, ob->object_to_world); xf->ob = ob; - /* Result may be NULL, that's OK. */ - xf->xod = ED_object_data_xform_create(ob->data); + /* Result may be nullptr, that's OK. */ + xf->xod = ED_object_data_xform_create(static_cast(ob->data)); *xf_p = xf; } } @@ -364,16 +368,17 @@ void ED_object_data_xform_container_update_all(struct XFormObjectData_Container struct Main *bmain, Depsgraph *depsgraph) { - if (xds->obdata_in_obmode_map == NULL) { + if (xds->obdata_in_obmode_map == nullptr) { return; } BKE_scene_graph_evaluated_ensure(depsgraph, bmain); GHashIterator gh_iter; GHASH_ITER (gh_iter, xds->obdata_in_obmode_map) { - ID *id = BLI_ghashIterator_getKey(&gh_iter); - struct XFormObjectData_Extra *xf = BLI_ghashIterator_getValue(&gh_iter); - if (xf->xod == NULL) { + ID *id = static_cast(BLI_ghashIterator_getKey(&gh_iter)); + struct XFormObjectData_Extra *xf = static_cast( + BLI_ghashIterator_getValue(&gh_iter)); + if (xf->xod == nullptr) { continue; } @@ -397,7 +402,7 @@ void ED_object_data_xform_container_update_all(struct XFormObjectData_Container /** Callback for #GHash free. */ static void trans_obdata_in_obmode_free_elem(void *xf_p) { - struct XFormObjectData_Extra *xf = xf_p; + struct XFormObjectData_Extra *xf = static_cast(xf_p); if (xf->xod) { ED_object_data_xform_destroy(xf->xod); } @@ -406,14 +411,15 @@ static void trans_obdata_in_obmode_free_elem(void *xf_p) struct XFormObjectData_Container *ED_object_data_xform_container_create(void) { - struct XFormObjectData_Container *xds = MEM_callocN(sizeof(*xds), __func__); + struct XFormObjectData_Container *xds = static_cast( + MEM_callocN(sizeof(*xds), __func__)); xds->obdata_in_obmode_map = BLI_ghash_ptr_new(__func__); return xds; } void ED_object_data_xform_container_destroy(struct XFormObjectData_Container *xds) { - BLI_ghash_free(xds->obdata_in_obmode_map, NULL, trans_obdata_in_obmode_free_elem); + BLI_ghash_free(xds->obdata_in_obmode_map, nullptr, trans_obdata_in_obmode_free_elem); MEM_freeN(xds); } @@ -452,7 +458,7 @@ void ED_object_xform_array_m4(Object **objects, uint objects_len, const float ma i++; } } - BLI_gset_free(objects_set, NULL); + BLI_gset_free(objects_set, nullptr); } /* Detect translation only matrix, prevent rotation/scale channels from being touched at all. */ diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.cc similarity index 94% rename from source/blender/editors/object/object_volume.c rename to source/blender/editors/object/object_volume.cc index 4b687d9d803..4152d6324b9 100644 --- a/source/blender/editors/object/object_volume.c +++ b/source/blender/editors/object/object_volume.cc @@ -41,15 +41,17 @@ static Object *object_volume_add(bContext *C, wmOperator *op, const char *name) ushort local_view_bits; float loc[3], rot[3]; - if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, NULL, NULL, &local_view_bits, NULL)) { - return NULL; + if (!ED_object_add_generic_get_opts( + C, op, 'Z', loc, rot, nullptr, nullptr, &local_view_bits, nullptr)) + { + return nullptr; } return ED_object_add_type(C, OB_VOLUME, name, loc, rot, false, local_view_bits); } static int object_volume_add_exec(bContext *C, wmOperator *op) { - return (object_volume_add(C, op, NULL) != NULL) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + return (object_volume_add(C, op, nullptr) != nullptr) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void OBJECT_OT_volume_add(wmOperatorType *ot) @@ -131,7 +133,7 @@ static int volume_import_exec(bContext *C, wmOperator *op) return (imported) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } -static int volume_import_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int volume_import_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) { if (RNA_struct_property_is_set(op->ptr, "filepath")) { return volume_import_exec(C, op); diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.cc similarity index 96% rename from source/blender/editors/object/object_warp.c rename to source/blender/editors/object/object_warp.cc index 0bc2005014e..e3e9afc1387 100644 --- a/source/blender/editors/object/object_warp.c +++ b/source/blender/editors/object/object_warp.cc @@ -79,7 +79,7 @@ static void object_warp_transverts(TransVertStore *tvs, { TransVert *tv; const float angle = -angle_; - /* cache vars for tiny speedup */ +/* cache vars for tiny speedup */ #if 1 const float range = max - min; const float range_inv = 1.0f / range; @@ -127,7 +127,7 @@ static void object_warp_transverts(TransVertStore *tvs, zero_v2(co_add); } - /* map from x axis to (-0.5 - 0.5) */ +/* map from x axis to (-0.5 - 0.5) */ #if 0 val = ((val - min) / (max - min)) - 0.5f; #else @@ -153,7 +153,7 @@ static int object_warp_verts_exec(bContext *C, wmOperator *op) const float warp_angle = RNA_float_get(op->ptr, "warp_angle"); const float offset_angle = RNA_float_get(op->ptr, "offset_angle"); - TransVertStore tvs = {NULL}; + TransVertStore tvs = {nullptr}; Object *obedit = CTX_data_edit_object(C); /* typically from 'rv3d' and 3d cursor */ @@ -167,7 +167,7 @@ static int object_warp_verts_exec(bContext *C, wmOperator *op) float min, max; ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS | TM_SKIP_HANDLES); - if (tvs.transverts == NULL) { + if (tvs.transverts == nullptr) { return OPERATOR_CANCELLED; } @@ -285,10 +285,10 @@ void TRANSFORM_OT_vertex_warp(wmOperatorType *ot) /* hidden props */ prop = RNA_def_float_matrix( - ot->srna, "viewmat", 4, 4, NULL, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); + ot->srna, "viewmat", 4, 4, nullptr, 0.0f, 0.0f, "Matrix", "", 0.0f, 0.0f); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); prop = RNA_def_float_vector_xyz( - ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "", -FLT_MAX, FLT_MAX); + ot->srna, "center", 3, nullptr, -FLT_MAX, FLT_MAX, "Center", "", -FLT_MAX, FLT_MAX); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } diff --git a/source/blender/editors/scene/CMakeLists.txt b/source/blender/editors/scene/CMakeLists.txt index 32c0507d268..45de4756556 100644 --- a/source/blender/editors/scene/CMakeLists.txt +++ b/source/blender/editors/scene/CMakeLists.txt @@ -12,6 +12,7 @@ set(INC ../../makesrna ../../sequencer ../../windowmanager + ../../../../intern/guardedalloc ) set(INC_SYS @@ -19,7 +20,7 @@ set(INC_SYS ) set(SRC - scene_edit.c + scene_edit.cc ) set(LIB diff --git a/source/blender/editors/scene/scene_edit.c b/source/blender/editors/scene/scene_edit.cc similarity index 91% rename from source/blender/editors/scene/scene_edit.c rename to source/blender/editors/scene/scene_edit.cc index 37665069840..8074a49b986 100644 --- a/source/blender/editors/scene/scene_edit.c +++ b/source/blender/editors/scene/scene_edit.cc @@ -51,7 +51,7 @@ static Scene *scene_add(Main *bmain, Scene *scene_old, eSceneCopyMethod method) { - Scene *scene_new = NULL; + Scene *scene_new = nullptr; if (method == SCE_COPY_NEW) { scene_new = BKE_scene_add(bmain, DATA_("Scene")); } @@ -73,9 +73,9 @@ Scene *ED_scene_sequencer_add(Main *bmain, eSceneCopyMethod method, const bool assign_strip) { - Sequence *seq = NULL; + Sequence *seq = nullptr; Scene *scene_active = CTX_data_scene(C); - Scene *scene_strip = NULL; + Scene *scene_strip = nullptr; /* Sequencer need to use as base the scene defined in the strip, not the main scene. */ Editing *ed = scene_active->ed; if (ed) { @@ -86,7 +86,7 @@ Scene *ED_scene_sequencer_add(Main *bmain, } /* If no scene assigned to the strip, only NEW scene mode is logic. */ - if (scene_strip == NULL) { + if (scene_strip == nullptr) { method = SCE_COPY_NEW; } @@ -131,21 +131,21 @@ bool ED_scene_delete(bContext *C, Main *bmain, Scene *scene) Scene *scene_new; /* kill running jobs */ - wmWindowManager *wm = bmain->wm.first; + wmWindowManager *wm = static_cast(bmain->wm.first); WM_jobs_kill_type(wm, scene, WM_JOB_TYPE_ANY); if (scene->id.prev) { - scene_new = scene->id.prev; + scene_new = static_cast(scene->id.prev); } else if (scene->id.next) { - scene_new = scene->id.next; + scene_new = static_cast(scene->id.next); } else { return false; } LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { - if (win->parent != NULL) { /* We only care about main windows here... */ + if (win->parent != nullptr) { /* We only care about main windows here... */ continue; } if (win->scene == scene) { @@ -190,7 +190,9 @@ static void view_layer_remove_unset_nodetrees(const Main *bmain, Scene *scene, V { int act_layer_index = BLI_findindex(&scene->view_layers, layer); - for (Scene *sce = bmain->scenes.first; sce; sce = sce->id.next) { + for (Scene *sce = static_cast(bmain->scenes.first); sce; + sce = static_cast(sce->id.next)) + { if (sce->nodetree) { BKE_nodetree_remove_layer_n(sce->nodetree, scene, act_layer_index); } @@ -218,7 +220,7 @@ bool ED_scene_view_layer_delete(Main *bmain, Scene *scene, ViewLayer *layer, Rep BLI_assert(BLI_listbase_is_empty(&scene->view_layers) == false); /* Remove from windows. */ - wmWindowManager *wm = bmain->wm.first; + wmWindowManager *wm = static_cast(bmain->wm.first); LISTBASE_FOREACH (wmWindow *, win, &wm->windows) { if (win->scene == scene && STREQ(win->view_layer_name, layer->name)) { ViewLayer *first_layer = BKE_view_layer_default_view(scene); @@ -249,7 +251,7 @@ static int scene_new_exec(bContext *C, wmOperator *op) wmWindow *win = CTX_wm_window(C); int type = RNA_enum_get(op->ptr, "type"); - ED_scene_add(bmain, C, win, type); + ED_scene_add(bmain, C, win, eSceneCopyMethod(type)); return OPERATOR_FINISHED; } @@ -267,7 +269,7 @@ static EnumPropertyItem scene_new_items[] = { "Linked Copy", "Link in the collections from the current scene (shallow copy)"}, {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"}, - {0, NULL, 0, NULL, NULL}, + {0, nullptr, 0, nullptr, nullptr}, }; static void SCENE_OT_new(wmOperatorType *ot) @@ -301,7 +303,7 @@ static int scene_new_sequencer_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); int type = RNA_enum_get(op->ptr, "type"); - if (ED_scene_sequencer_add(bmain, C, type, true) == NULL) { + if (ED_scene_sequencer_add(bmain, C, eSceneCopyMethod(type), true) == nullptr) { return OPERATOR_CANCELLED; } @@ -316,11 +318,11 @@ static bool scene_new_sequencer_poll(bContext *C) } static const EnumPropertyItem *scene_new_sequencer_enum_itemf(bContext *C, - PointerRNA *UNUSED(ptr), - PropertyRNA *UNUSED(prop), + PointerRNA * /*ptr*/, + PropertyRNA * /*prop*/, bool *r_free) { - EnumPropertyItem *item = NULL; + EnumPropertyItem *item = nullptr; int totitem = 0; uint item_index; @@ -328,14 +330,14 @@ static const EnumPropertyItem *scene_new_sequencer_enum_itemf(bContext *C, RNA_enum_item_add(&item, &totitem, &scene_new_items[item_index]); bool has_scene_or_no_context = false; - if (C == NULL) { + if (C == nullptr) { /* For documentation generation. */ has_scene_or_no_context = true; } else { Scene *scene = CTX_data_scene(C); Sequence *seq = SEQ_select_active_get(scene); - if (seq && (seq->type == SEQ_TYPE_SCENE) && (seq->scene != NULL)) { + if (seq && (seq->type == SEQ_TYPE_SCENE) && (seq->scene != nullptr)) { has_scene_or_no_context = true; } } @@ -388,7 +390,7 @@ static bool scene_delete_poll(bContext *C) return BKE_scene_can_be_removed(bmain, scene); } -static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) +static int scene_delete_exec(bContext *C, wmOperator * /*op*/) { Scene *scene = CTX_data_scene(C); diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 7d61006b6d1..dda24c1aa56 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -682,7 +682,7 @@ typedef struct PreviewImage { (void *)((ID *)(_id))->newid) #define ID_NEW_REMAP(a) \ if ((a) && (a)->id.newid) { \ - (a) = (void *)(a)->id.newid; \ + *(void **)&(a) = (a)->id.newid; \ } \ ((void)0) diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 8e0408e79bf..822bad38632 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -1024,6 +1024,7 @@ typedef enum eKS_Settings { /** Keyingset does not depend on context info (i.e. paths are absolute). */ KEYINGSET_ABSOLUTE = (1 << 1), } eKS_Settings; +ENUM_OPERATORS(eKS_Settings, KEYINGSET_ABSOLUTE) /* Flags for use by keyframe creation/deletion calls */ typedef enum eInsertKeyFlags {