Cleanup: Use std::swap instead of macro in C++ code

This commit is contained in:
Hans Goudey 2023-01-09 11:12:03 -05:00
parent 8d2f4ddb2f
commit 08b2d04021
43 changed files with 128 additions and 128 deletions

View File

@ -286,7 +286,7 @@ void DM_ensure_looptri_data(DerivedMesh *dm)
BLI_assert(dm->looptris.array_wip == nullptr);
SWAP(MLoopTri *, dm->looptris.array, dm->looptris.array_wip);
std::swap(dm->looptris.array, dm->looptris.array_wip);
if ((looptris_num > dm->looptris.num_alloc) || (looptris_num < dm->looptris.num_alloc * 2) ||
(totpoly == 0)) {

View File

@ -612,7 +612,7 @@ static void get_domains_types(eAttrDomain domains[ATTR_DOMAIN_NUM])
}
/* Swap corner and face. */
SWAP(eAttrDomain, domains[ATTR_DOMAIN_FACE], domains[ATTR_DOMAIN_CORNER]);
std::swap(domains[ATTR_DOMAIN_FACE], domains[ATTR_DOMAIN_CORNER]);
}
int BKE_id_attribute_to_index(const ID *id,

View File

@ -407,7 +407,7 @@ static void brush_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
/* NOTE: We do not swap IDProperties, as dealing with potential ID pointers in those would be
* fairly delicate. */
SWAP(IDProperty *, id_new->properties, id_old->properties);
std::swap(id_new->properties, id_old->properties);
}
IDTypeInfo IDType_ID_BR = {

View File

@ -704,7 +704,7 @@ Nurb *BKE_nurb_copy(Nurb *src, int pntsu, int pntsv)
*newnu = blender::dna::shallow_copy(*src);
if (pntsu == 1) {
SWAP(int, pntsu, pntsv);
std::swap(pntsu, pntsv);
}
newnu->pntsu = pntsu;
newnu->pntsv = pntsv;
@ -3048,7 +3048,7 @@ void BKE_curve_bevelList_make(Object *ob, const ListBase *nurbs, const bool for_
bevp2 = bevp1 + (bl->nr - 1);
nr = bl->nr / 2;
while (nr--) {
SWAP(BevPoint, *bevp1, *bevp2);
std::swap( *bevp1, *bevp2);
bevp1++;
bevp2--;
}
@ -4437,7 +4437,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
a /= 2;
while (a > 0) {
if (bezt1 != bezt2) {
SWAP(BezTriple, *bezt1, *bezt2);
std::swap(*bezt1, *bezt2);
}
swap_v3_v3(bezt1->vec[0], bezt1->vec[2]);
@ -4446,12 +4446,12 @@ void BKE_nurb_direction_switch(Nurb *nu)
swap_v3_v3(bezt2->vec[0], bezt2->vec[2]);
}
SWAP(uint8_t, bezt1->h1, bezt1->h2);
SWAP(uint8_t, bezt1->f1, bezt1->f3);
std::swap( bezt1->h1, bezt1->h2);
std::swap( bezt1->f1, bezt1->f3);
if (bezt1 != bezt2) {
SWAP(uint8_t, bezt2->h1, bezt2->h2);
SWAP(uint8_t, bezt2->f1, bezt2->f3);
std::swap( bezt2->h1, bezt2->h2);
std::swap( bezt2->f1, bezt2->f3);
bezt1->tilt = -bezt1->tilt;
bezt2->tilt = -bezt2->tilt;
}
@ -4469,7 +4469,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
bp2 = bp1 + (a - 1);
a /= 2;
while (bp1 != bp2 && a > 0) {
SWAP(BPoint, *bp1, *bp2);
std::swap( *bp1, *bp2);
a--;
bp1->tilt = -bp1->tilt;
bp2->tilt = -bp2->tilt;
@ -4491,7 +4491,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
fp2 = fp1 + (a - 1);
a /= 2;
while (fp1 != fp2 && a > 0) {
SWAP(float, *fp1, *fp2);
std::swap( *fp1, *fp2);
a--;
fp1++;
fp2--;
@ -4530,7 +4530,7 @@ void BKE_nurb_direction_switch(Nurb *nu)
a /= 2;
while (bp1 != bp2 && a > 0) {
SWAP(BPoint, *bp1, *bp2);
std::swap( *bp1, *bp2);
a--;
bp1++;
bp2--;

View File

@ -1090,7 +1090,7 @@ static void calc_bevfac_mapping(const Curve *cu,
}
if (end < *r_start || (end == *r_start && *r_lastblend < 1.0f - *r_firstblend)) {
SWAP(int, *r_start, end);
std::swap(*r_start, end);
tmpf = *r_lastblend;
*r_lastblend = 1.0f - *r_firstblend;
*r_firstblend = 1.0f - tmpf;

View File

@ -2547,7 +2547,7 @@ bool BKE_keyblock_move(Object *ob, int org_index, int new_index)
BLI_listbase_swaplinks(&key->block, kb, other_kb);
/* Swap absolute positions. */
SWAP(float, kb->pos, other_kb->pos);
std::swap(kb->pos, other_kb->pos);
kb = other_kb;
}

View File

@ -181,7 +181,7 @@ static uint partition_mainb(MetaElem **mainb, uint start, uint end, uint s, floa
break;
}
SWAP(MetaElem *, mainb[i], mainb[j]);
std::swap(mainb[i], mainb[j]);
i++;
j--;
}

View File

@ -1746,7 +1746,7 @@ void BKE_mesh_mselect_active_set(Mesh *me, int index, int type)
}
else if (msel_index != me->totselect - 1) {
/* move to the end */
SWAP(MSelect, me->mselect[msel_index], me->mselect[me->totselect - 1]);
std::swap(me->mselect[msel_index], me->mselect[me->totselect - 1]);
}
BLI_assert((me->mselect[me->totselect - 1].index == index) &&

View File

@ -542,8 +542,8 @@ void BKE_mesh_mdisp_flip(MDisps *md, const bool use_loop_mdisp_flip)
co_b = co[x * sides + y];
swap_v3_v3(co_a, co_b);
SWAP(float, co_a[0], co_a[1]);
SWAP(float, co_b[0], co_b[1]);
std::swap(co_a[0], co_a[1]);
std::swap(co_b[0], co_b[1]);
if (use_loop_mdisp_flip) {
co_a[2] *= -1.0f;
@ -553,7 +553,7 @@ void BKE_mesh_mdisp_flip(MDisps *md, const bool use_loop_mdisp_flip)
co_a = co[x * sides + x];
SWAP(float, co_a[0], co_a[1]);
std::swap(co_a[0], co_a[1]);
if (use_loop_mdisp_flip) {
co_a[2] *= -1.0f;
@ -588,10 +588,10 @@ void BKE_mesh_polygon_flip_ex(const MPoly *mpoly,
for (loopstart++; loopend > loopstart; loopstart++, loopend--) {
mloop[loopend].e = mloop[loopend - 1].e;
SWAP(uint, mloop[loopstart].e, prev_edge_index);
std::swap(mloop[loopstart].e, prev_edge_index);
if (!loops_in_ldata) {
SWAP(MLoop, mloop[loopstart], mloop[loopend]);
std::swap(mloop[loopstart], mloop[loopend]);
}
if (lnors) {
swap_v3_v3(lnors[loopstart], lnors[loopend]);

View File

@ -158,7 +158,7 @@ static void mesh_calc_edges_mdata(const MVert * /*allvert*/,
/* order is swapped so extruding this edge as a surface won't flip face normals
* with cyclic curves */
if (ed->v1 + 1 != ed->v2) {
SWAP(uint, med->v1, med->v2);
std::swap(med->v1, med->v2);
}
med++;
}
@ -912,8 +912,8 @@ int BKE_mesh_mface_index_validate(MFace *mface, CustomData *fdata, int mfindex,
if (mface->v3 == 0) {
static int corner_indices[4] = {1, 2, 0, 3};
SWAP(uint, mface->v1, mface->v2);
SWAP(uint, mface->v2, mface->v3);
std::swap(mface->v1, mface->v2);
std::swap(mface->v2, mface->v3);
if (fdata) {
CustomData_swap_corners(fdata, mfindex, corner_indices);
@ -924,8 +924,8 @@ int BKE_mesh_mface_index_validate(MFace *mface, CustomData *fdata, int mfindex,
if (mface->v3 == 0 || mface->v4 == 0) {
static int corner_indices[4] = {2, 3, 0, 1};
SWAP(uint, mface->v1, mface->v3);
SWAP(uint, mface->v2, mface->v4);
std::swap(mface->v1, mface->v3);
std::swap(mface->v2, mface->v4);
if (fdata) {
CustomData_swap_corners(fdata, mfindex, corner_indices);

View File

@ -128,7 +128,7 @@ static void palette_undo_preserve(BlendLibReader * /*reader*/, ID *id_new, ID *i
/* NOTE: We do not swap IDProperties, as dealing with potential ID pointers in those would be
* fairly delicate. */
BKE_lib_id_swap(nullptr, id_new, id_old);
SWAP(IDProperty *, id_new->properties, id_old->properties);
std::swap(id_new->properties, id_old->properties);
}
IDTypeInfo IDType_ID_PAL = {
@ -1080,7 +1080,7 @@ bool BKE_paint_ensure(ToolSettings *ts, Paint **r_paint)
Paint paint_test = **r_paint;
BKE_paint_runtime_init(ts, *r_paint);
/* Swap so debug doesn't hide errors when release fails. */
SWAP(Paint, **r_paint, paint_test);
std::swap(**r_paint, paint_test);
BLI_assert(paint_test.runtime.ob_mode == (*r_paint)->runtime.ob_mode);
BLI_assert(paint_test.runtime.tool_offset == (*r_paint)->runtime.tool_offset);
#endif

View File

@ -510,12 +510,12 @@ static void scene_foreach_toolsettings_id_pointer_process(
}
/* We failed to find a new valid pointer for the previous ID, just keep the current one as
* if we had been under SCENE_FOREACH_UNDO_NO_RESTORE case. */
SWAP(ID *, *id_p, *id_old_p);
std::swap(*id_p, *id_old_p);
break;
}
case SCENE_FOREACH_UNDO_NO_RESTORE:
/* Counteract the swap of the whole ToolSettings container struct. */
SWAP(ID *, *id_p, *id_old_p);
std::swap(*id_p, *id_old_p);
break;
}
}
@ -1686,14 +1686,14 @@ static void scene_undo_preserve(BlendLibReader *reader, ID *id_new, ID *id_old)
Scene *scene_new = (Scene *)id_new;
Scene *scene_old = (Scene *)id_old;
SWAP(View3DCursor, scene_old->cursor, scene_new->cursor);
std::swap( scene_old->cursor, scene_new->cursor);
if (scene_new->toolsettings != nullptr && scene_old->toolsettings != nullptr) {
/* First try to restore ID pointers that can be and should be preserved (like brushes or
* palettes), and counteract the swap of the whole ToolSettings structs below for the others
* (like object ones). */
scene_foreach_toolsettings(
nullptr, scene_new->toolsettings, true, reader, scene_old->toolsettings);
SWAP(ToolSettings, *scene_old->toolsettings, *scene_new->toolsettings);
std::swap( *scene_old->toolsettings, *scene_new->toolsettings);
}
}

View File

@ -140,7 +140,7 @@ void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb)
}
if (linkb->next == linka) {
SWAP(Link *, linka, linkb);
std::swap(linka, linkb);
}
if (linka->next == linkb) {
@ -150,8 +150,8 @@ void BLI_listbase_swaplinks(ListBase *listbase, void *vlinka, void *vlinkb)
linkb->next = linka;
}
else { /* Non-contiguous items, we can safely swap. */
SWAP(Link *, linka->prev, linkb->prev);
SWAP(Link *, linka->next, linkb->next);
std::swap(linka->prev, linkb->prev);
std::swap(linka->next, linkb->next);
}
/* Update neighbors of linka and linkb. */

View File

@ -221,7 +221,7 @@ static void test_sin_cos_from_fraction_symmetry(const int range)
sin_cos_fl[0] = fabsf(sin_cos_fl[0]);
sin_cos_fl[1] = fabsf(sin_cos_fl[1]);
if (sin_cos_fl[0] > sin_cos_fl[1]) {
SWAP(float, sin_cos_fl[0], sin_cos_fl[1]);
std::swap(sin_cos_fl[0], sin_cos_fl[1]);
}
break;
}

View File

@ -1249,7 +1249,7 @@ void BM_mesh_rebuild(BMesh *bm,
* (and not be needed). */
if (remap & BM_VERT) {
if (bm->vtable) {
SWAP(BMVert **, vtable_dst, bm->vtable);
std::swap(vtable_dst, bm->vtable);
bm->vtable_tot = bm->totvert;
bm->elem_table_dirty &= ~BM_VERT;
}
@ -1260,7 +1260,7 @@ void BM_mesh_rebuild(BMesh *bm,
if (remap & BM_EDGE) {
if (bm->etable) {
SWAP(BMEdge **, etable_dst, bm->etable);
std::swap(etable_dst, bm->etable);
bm->etable_tot = bm->totedge;
bm->elem_table_dirty &= ~BM_EDGE;
}
@ -1278,7 +1278,7 @@ void BM_mesh_rebuild(BMesh *bm,
if (remap & BM_FACE) {
if (bm->ftable) {
SWAP(BMFace **, ftable_dst, bm->ftable);
std::swap(ftable_dst, bm->ftable);
bm->ftable_tot = bm->totface;
bm->elem_table_dirty &= ~BM_FACE;
}

View File

@ -935,7 +935,7 @@ static void bm_mesh_loops_calc_normals_for_vert_with_clnors(BMesh *bm,
* The order doesn't matter, so swap the links as it's simpler than tracking
* reference to `link_best`. */
if (link_best != loops_of_vert) {
SWAP(void *, link_best->link, loops_of_vert->link);
std::swap(link_best->link, loops_of_vert->link);
}
}

View File

@ -130,7 +130,7 @@ static void FHT2D(fREAL *data, uint Mx, uint My, uint nzp, uint inverse)
for (j = 0; j < Ny; j++) {
for (i = j + 1; i < Nx; i++) {
uint op = i + (j << Mx), np = j + (i << My);
SWAP(fREAL, data[op], data[np]);
std::swap(data[op], data[np]);
}
}
}
@ -145,15 +145,15 @@ static void FHT2D(fREAL *data, uint Mx, uint My, uint nzp, uint inverse)
continue;
}
for (k = i, j = PRED(i); j != i; k = j, j = PRED(j), stm--) {
SWAP(fREAL, data[j], data[k]);
std::swap(data[j], data[k]);
}
#undef PRED
stm--;
}
}
SWAP(uint, Nx, Ny);
SWAP(uint, Mx, My);
std::swap(Nx, Ny);
std::swap(Mx, My);
/* Now columns == transposed rows. */
for (j = 0; j < Ny; j++) {

View File

@ -655,7 +655,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd,
}
}
}
SWAP(float *, minvecbufrect, vecbufrect);
std::swap(minvecbufrect, vecbufrect);
}
/* Make vertex buffer with averaged speed and Z-values. */

View File

@ -754,7 +754,7 @@ void DepthOfField::render(View &view,
DRW_stats_group_end();
/* Swap buffers so that next effect has the right input. */
SWAP(GPUTexture *, *input_tx, *output_tx);
std::swap(*input_tx, *output_tx);
}
/** \} */

View File

@ -595,7 +595,7 @@ void Film::update_sample_table()
}
/* Put the closest one in first position. */
if (closest_index != 0) {
SWAP(FilmSample, data_.samples[closest_index], data_.samples[0]);
std::swap(data_.samples[closest_index], data_.samples[0]);
}
}
else {

View File

@ -219,10 +219,10 @@ void VelocityModule::step_swap()
}
auto swap_steps = [&](eVelocityStep step_a, eVelocityStep step_b) {
SWAP(VelocityObjectBuf *, object_steps[step_a], object_steps[step_b]);
SWAP(VelocityGeometryBuf *, geometry_steps[step_a], geometry_steps[step_b]);
SWAP(CameraDataBuf *, camera_steps[step_a], camera_steps[step_b]);
SWAP(float, step_time[step_a], step_time[step_b]);
std::swap(object_steps[step_a], object_steps[step_b]);
std::swap(geometry_steps[step_a], geometry_steps[step_b]);
std::swap(camera_steps[step_a], camera_steps[step_b]);
std::swap(step_time[step_a], step_time[step_b]);
for (VelocityObjectData &vel : velocity_map.values()) {
vel.obj.ofs[step_a] = vel.obj.ofs[step_b];

View File

@ -95,7 +95,7 @@ static void motion_path_get_frame_range_to_draw(bAnimVizSettings *avs,
}
if (start > end) {
SWAP(int, start, end);
std::swap(start, end);
}
CLAMP(start, mpath->start_frame, mpath->end_frame);

View File

@ -148,7 +148,7 @@ static void extract_lines_adjacency_finish(const MeshRenderData * /*mr*/,
BLI_edgehashIterator_getKey(ehi, &v2, &v3);
l1 = uint(abs(v_data)) - 1;
if (v_data < 0) { /* `inv_opposite`. */
SWAP(uint, v2, v3);
std::swap(v2, v3);
}
l2 = data->vert_to_loop[v2];
l3 = data->vert_to_loop[v3];

View File

@ -863,26 +863,26 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
/* typically the same pointers, but not on undo/redo */
/* XXX some menu buttons store button itself in but->poin. Ugly */
if (oldbut->poin != (char *)oldbut) {
SWAP(char *, oldbut->poin, but->poin);
SWAP(void *, oldbut->func_argN, but->func_argN);
std::swap(oldbut->poin, but->poin);
std::swap(oldbut->func_argN, but->func_argN);
}
/* Move tooltip from new to old. */
SWAP(uiButToolTipFunc, oldbut->tip_func, but->tip_func);
SWAP(void *, oldbut->tip_arg, but->tip_arg);
SWAP(uiFreeArgFunc, oldbut->tip_arg_free, but->tip_arg_free);
std::swap(oldbut->tip_func, but->tip_func);
std::swap(oldbut->tip_arg, but->tip_arg);
std::swap(oldbut->tip_arg_free, but->tip_arg_free);
oldbut->flag = (oldbut->flag & ~flag_copy) | (but->flag & flag_copy);
oldbut->drawflag = (oldbut->drawflag & ~drawflag_copy) | (but->drawflag & drawflag_copy);
ui_but_extra_icons_update_from_old_but(but, oldbut);
SWAP(ListBase, but->extra_op_icons, oldbut->extra_op_icons);
std::swap(but->extra_op_icons, oldbut->extra_op_icons);
if (oldbut->type == UI_BTYPE_SEARCH_MENU) {
uiButSearch *search_oldbut = (uiButSearch *)oldbut, *search_but = (uiButSearch *)but;
SWAP(uiFreeArgFunc, search_oldbut->arg_free_fn, search_but->arg_free_fn);
SWAP(void *, search_oldbut->arg, search_but->arg);
std::swap(search_oldbut->arg_free_fn, search_but->arg_free_fn);
std::swap(search_oldbut->arg, search_but->arg);
}
/* copy hardmin for list rows to prevent 'sticking' highlight to mouse position
@ -901,7 +901,7 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
case UI_BTYPE_VIEW_ITEM: {
uiButViewItem *view_item_oldbut = (uiButViewItem *)oldbut;
uiButViewItem *view_item_newbut = (uiButViewItem *)but;
SWAP(uiViewItemHandle *, view_item_newbut->view_item, view_item_oldbut->view_item);
std::swap(view_item_newbut->view_item, view_item_oldbut->view_item);
break;
}
default:
@ -912,7 +912,7 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
/* needed for alt+mouse wheel over enums */
if (but->str != but->strdata) {
if (oldbut->str != oldbut->strdata) {
SWAP(char *, but->str, oldbut->str);
std::swap(but->str, oldbut->str);
}
else {
oldbut->str = but->str;
@ -928,10 +928,10 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but)
}
if (but->dragpoin) {
SWAP(void *, but->dragpoin, oldbut->dragpoin);
std::swap(but->dragpoin, oldbut->dragpoin);
}
if (but->imb) {
SWAP(ImBuf *, but->imb, oldbut->imb);
std::swap(but->imb, oldbut->imb);
}
/* NOTE: if layout hasn't been applied yet, it uses old button pointers... */
@ -5853,7 +5853,7 @@ void UI_block_order_flip(uiBlock *block)
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
but->rect.ymin = centy - (but->rect.ymin - centy);
but->rect.ymax = centy - (but->rect.ymax - centy);
SWAP(float, but->rect.ymin, but->rect.ymax);
std::swap(but->rect.ymin, but->rect.ymax);
}
block->flag ^= UI_BLOCK_IS_FLIP;

View File

@ -156,7 +156,7 @@ static void block_align_proximity_compute(ButAlign *butal, ButAlign *butal_other
delta_side_opp = max_ff(fabsf(*butal->borders[side_opp] - *butal_other->borders[side]),
FLT_MIN);
if (delta_side_opp < delta) {
SWAP(int, side, side_opp);
std::swap(side, side_opp);
delta = delta_side_opp;
}

View File

@ -326,7 +326,7 @@ void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void * /*arg_dummy*/)
}
/* FIXME(@campbellbarton): swapping active pointer is weak. */
SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->but.active);
std::swap(but_anim->active, but_decorate->but.active);
wm->op_undo_depth++;
if (but_anim->flag & UI_BUT_DRIVEN) {
@ -350,6 +350,6 @@ void ui_but_anim_decorate_cb(bContext *C, void *arg_but, void * /*arg_dummy*/)
WM_operator_properties_free(&props_ptr);
}
SWAP(struct uiHandleButtonData *, but_anim->active, but_decorate->but.active);
std::swap(but_anim->active, but_decorate->but.active);
wm->op_undo_depth--;
}

View File

@ -3087,7 +3087,7 @@ static void ui_textedit_set_cursor_select(uiBut *but, uiHandleButtonData *data,
but->selsta = but->pos;
but->selend = data->sel_pos_init;
if (but->selend < but->selsta) {
SWAP(short, but->selsta, but->selend);
std::swap(but->selsta, but->selend);
}
ui_but_update(but);
@ -3190,7 +3190,7 @@ static void ui_textedit_move(uiBut *but,
but->selend = data->sel_pos_init;
}
if (but->selend < but->selsta) {
SWAP(short, but->selsta, but->selend);
std::swap( but->selsta, but->selend);
}
}
}

View File

@ -2500,7 +2500,7 @@ static void widget_state(uiWidgetType *wt, const uiWidgetStateInfo *state, eUIEm
copy_v3_v3_uchar(wt->wcol.text, wt->wcol.text_sel);
if (state->but_flag & UI_SELECT) {
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
std::swap(wt->wcol.shadetop, wt->wcol.shadedown);
}
}
else {
@ -2534,7 +2534,7 @@ static void widget_state(uiWidgetType *wt, const uiWidgetStateInfo *state, eUIEm
if (state->but_flag & UI_BUT_DRAG_MULTI) {
/* the button isn't SELECT but we're editing this so draw with sel color */
copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel);
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
std::swap(wt->wcol.shadetop, wt->wcol.shadedown);
color_blend_v3_v3(wt->wcol.text, wt->wcol.text_sel, 0.85f);
}
@ -2592,7 +2592,7 @@ static void widget_state_numslider(uiWidgetType *wt,
}
if (state->but_flag & UI_SELECT) {
SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown);
std::swap(wt->wcol.shadetop, wt->wcol.shadedown);
}
}
@ -3306,7 +3306,7 @@ static void widget_numbut_draw(uiWidgetColors *wcol,
const int handle_width = min_ii(BLI_rcti_size_x(rect) / 3, BLI_rcti_size_y(rect) * 0.7f);
if (state->but_flag & UI_SELECT) {
SWAP(short, wcol->shadetop, wcol->shadedown);
std::swap(wcol->shadetop, wcol->shadedown);
}
uiWidgetBase wtb;
@ -3483,7 +3483,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
/* draw back part, colors swapped and shading inverted */
if (horizontal) {
SWAP(short, wcol->shadetop, wcol->shadedown);
std::swap(wcol->shadetop, wcol->shadedown);
}
round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
@ -3494,7 +3494,7 @@ void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *s
/* pass */
}
else {
SWAP(short, wcol->shadetop, wcol->shadedown);
std::swap(wcol->shadetop, wcol->shadedown);
copy_v4_v4_uchar(wcol->inner, wcol->item);
@ -3721,7 +3721,7 @@ static void widget_numslider(uiBut *but,
copy_v3_v3_uchar(wcol->inner, wcol->item);
if (!(state->but_flag & UI_SELECT)) {
SWAP(short, wcol->shadetop, wcol->shadedown);
std::swap(wcol->shadetop, wcol->shadedown);
}
rcti rect1 = *rect;
@ -3789,7 +3789,7 @@ static void widget_numslider(uiBut *but,
copy_v3_v3_uchar(wcol->outline, outline);
if (!(state->but_flag & UI_SELECT)) {
SWAP(short, wcol->shadetop, wcol->shadedown);
std::swap(wcol->shadetop, wcol->shadedown);
}
}
@ -3946,7 +3946,7 @@ static void widget_textbut(uiWidgetColors *wcol,
const float zoom)
{
if (state->but_flag & UI_SELECT) {
SWAP(short, wcol->shadetop, wcol->shadedown);
std::swap(wcol->shadetop, wcol->shadedown);
}
uiWidgetBase wtb;

View File

@ -3048,7 +3048,7 @@ bool EDBM_select_interior_faces(BMEditMesh *em)
/* Only for predictable results that don't depend on the order of radial loops,
* not essential. */
if (i_a > i_b) {
SWAP(int, i_a, i_b);
std::swap(i_a, i_b);
}
/* Merge the groups. */

View File

@ -1158,8 +1158,8 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, Mesh *me_eval)
/* make sure v4 is not 0 if a quad */
if (mf->v4 && mirrormf.v4 == 0) {
SWAP(uint, mirrormf.v1, mirrormf.v3);
SWAP(uint, mirrormf.v2, mirrormf.v4);
std::swap(mirrormf.v1, mirrormf.v3);
std::swap(mirrormf.v2, mirrormf.v4);
}
hashmf = static_cast<MFace *>(BLI_ghash_lookup(fhash, &mirrormf));

View File

@ -1465,10 +1465,10 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph,
}
/* switch with k */
if (bestIndex != k) {
SWAP(bool, upDown[k], upDown[bestIndex]);
SWAP(int, dwIndices[k], dwIndices[bestIndex]);
std::swap(upDown[k], upDown[bestIndex]);
std::swap(dwIndices[k], dwIndices[bestIndex]);
swap_v2_v2(changes[k], changes[bestIndex]);
SWAP(float, dists[k], dists[bestIndex]);
std::swap(dists[k], dists[bestIndex]);
}
}
bestIndex = -1;
@ -2092,7 +2092,7 @@ static void vgroup_smooth_subset(Object *ob,
}
}
SWAP(float *, weight_accum_curr, weight_accum_prev);
std::swap(weight_accum_curr, weight_accum_prev);
}
ED_vgroup_parray_from_weight_array(dvert_array, dvert_tot, weight_accum_prev, def_nr, true);
@ -2319,14 +2319,14 @@ static void dvert_mirror_op(MDeformVert *dvert,
/* swap */
if (mirror_weights) {
if (all_vgroups) {
SWAP(MDeformVert, *dvert, *dvert_mirr);
std::swap(*dvert, *dvert_mirr);
}
else {
MDeformWeight *dw = BKE_defvert_find_index(dvert, act_vgroup);
MDeformWeight *dw_mirr = BKE_defvert_find_index(dvert_mirr, act_vgroup);
if (dw && dw_mirr) {
SWAP(float, dw->weight, dw_mirr->weight);
std::swap(dw->weight, dw_mirr->weight);
}
else if (dw) {
dw_mirr = BKE_defvert_ensure_index(dvert_mirr, act_vgroup);
@ -2349,7 +2349,7 @@ static void dvert_mirror_op(MDeformVert *dvert,
else {
/* dvert should always be the target, only swaps pointer */
if (sel_mirr) {
SWAP(MDeformVert *, dvert, dvert_mirr);
std::swap(dvert, dvert_mirr);
}
if (mirror_weights) {

View File

@ -261,10 +261,10 @@ void *ED_image_paint_tile_push(PaintTileMap *paint_tile_map,
ED_IMAGE_UNDO_TILE_SIZE);
if (has_float) {
SWAP(float *, ptile->rect.fp, (*tmpibuf)->rect_float);
std::swap( ptile->rect.fp, (*tmpibuf)->rect_float);
}
else {
SWAP(uint32_t *, ptile->rect.uint, (*tmpibuf)->rect);
std::swap(ptile->rect.uint, (*tmpibuf)->rect);
}
PaintTileKey key = {};
@ -299,10 +299,10 @@ static void ptile_restore_runtime_map(PaintTileMap *paint_tile_map)
const bool has_float = (ibuf->rect_float != nullptr);
if (has_float) {
SWAP(float *, ptile->rect.fp, tmpibuf->rect_float);
std::swap( ptile->rect.fp, tmpibuf->rect_float);
}
else {
SWAP(uint32_t *, ptile->rect.uint, tmpibuf->rect);
std::swap(ptile->rect.uint, tmpibuf->rect);
}
IMB_rectcpy(ibuf,
@ -315,10 +315,10 @@ static void ptile_restore_runtime_map(PaintTileMap *paint_tile_map)
ED_IMAGE_UNDO_TILE_SIZE);
if (has_float) {
SWAP(float *, ptile->rect.fp, tmpibuf->rect_float);
std::swap( ptile->rect.fp, tmpibuf->rect_float);
}
else {
SWAP(uint32_t *, ptile->rect.uint, tmpibuf->rect);
std::swap(ptile->rect.uint, tmpibuf->rect);
}
/* Force OpenGL reload (maybe partial update will operate better?) */
@ -380,19 +380,19 @@ static void utile_init_from_imbuf(
const bool has_float = ibuf->rect_float;
if (has_float) {
SWAP(float *, utile->rect.fp, tmpibuf->rect_float);
std::swap( utile->rect.fp, tmpibuf->rect_float);
}
else {
SWAP(uint32_t *, utile->rect.uint_ptr, tmpibuf->rect);
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
}
IMB_rectcpy(tmpibuf, ibuf, 0, 0, x, y, ED_IMAGE_UNDO_TILE_SIZE, ED_IMAGE_UNDO_TILE_SIZE);
if (has_float) {
SWAP(float *, utile->rect.fp, tmpibuf->rect_float);
std::swap( utile->rect.fp, tmpibuf->rect_float);
}
else {
SWAP(uint32_t *, utile->rect.uint_ptr, tmpibuf->rect);
std::swap(utile->rect.uint_ptr, tmpibuf->rect);
}
}

View File

@ -434,10 +434,10 @@ static void node_update_basis(const bContext &C,
/* Make sure that maximums are bigger or equal to minimums. */
if (node.runtime->prvr.xmax < node.runtime->prvr.xmin) {
SWAP(float, node.runtime->prvr.xmax, node.runtime->prvr.xmin);
std::swap(node.runtime->prvr.xmax, node.runtime->prvr.xmin);
}
if (node.runtime->prvr.ymax < node.runtime->prvr.ymin) {
SWAP(float, node.runtime->prvr.ymax, node.runtime->prvr.ymin);
std::swap(node.runtime->prvr.ymax, node.runtime->prvr.ymin);
}
}

View File

@ -285,10 +285,10 @@ static void gizmo_node_crop_prop_matrix_set(const wmGizmo *gz,
rct_isect.ymax = 1;
BLI_rctf_isect(&rct_isect, &rct, &rct);
if (nx) {
SWAP(float, rct.xmin, rct.xmax);
std::swap( rct.xmin, rct.xmax);
}
if (ny) {
SWAP(float, rct.ymin, rct.ymax);
std::swap( rct.ymin, rct.ymax);
}
two_xy_from_rect(nxy, &rct, dims, is_relative);
gizmo_node_crop_update(crop_group);

View File

@ -355,7 +355,7 @@ static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const
bNode *node_to = sorted_nodes[i + 1];
/* Corner case: input/output node aligned the wrong way around (T47729). */
if (BLI_listbase_is_empty(&node_to->inputs) || BLI_listbase_is_empty(&node_fr->outputs)) {
SWAP(bNode *, node_fr, node_to);
std::swap(node_fr, node_to);
}
/* If there are selected sockets, connect those. */

View File

@ -493,7 +493,7 @@ static void drawviewborder_triangle(
ofs = h * (h / w);
}
if (dir == 'B') {
SWAP(float, y1, y2);
std::swap(y1, y2);
}
immVertex2f(shdr_pos, x1, y1);
@ -513,7 +513,7 @@ static void drawviewborder_triangle(
ofs = w * (w / h);
}
if (dir == 'B') {
SWAP(float, x1, x2);
std::swap(x1, x2);
}
immVertex2f(shdr_pos, x1, y1);

View File

@ -1654,7 +1654,7 @@ std::optional<Mesh *> mesh_merge_by_distance_connected(const Mesh &mesh,
continue;
}
if (v1 > v2) {
SWAP(int, v1, v2);
std::swap( v1, v2);
}
WeldVertexCluster *v1_cluster = &vert_clusters[v1];
WeldVertexCluster *v2_cluster = &vert_clusters[v2];

View File

@ -2168,7 +2168,7 @@ static void p_chart_simplify_compute(PChart *chart)
if (edge->vert->u.heaplink != link) {
edge->flag |= (PEDGE_COLLAPSE_EDGE | PEDGE_COLLAPSE_PAIR);
edge->next->vert->u.heaplink = nullptr;
SWAP(PEdge *, edge, pair);
std::swap( edge, pair);
}
else {
edge->flag |= PEDGE_COLLAPSE_EDGE;
@ -2237,7 +2237,7 @@ static void p_chart_complexify(PChart *chart)
pair = e->pair;
if (edge->flag & PEDGE_COLLAPSE_PAIR) {
SWAP(PEdge *, edge, pair);
std::swap( edge, pair);
}
p_split_vertex(edge, pair);
@ -3142,9 +3142,9 @@ static bool p_chart_lscm_solve(ParamHandle *handle, PChart *chart)
}
if (flip_faces) {
SWAP(float, a2, a3);
SWAP(PEdge *, e2, e3);
SWAP(PVert *, v2, v3);
std::swap(a2, a3);
std::swap(e2, e3);
std::swap(v2, v3);
}
float sina1 = sinf(a1);

View File

@ -1878,7 +1878,7 @@ static void lineart_edge_neighbor_init_task(void *__restrict userdata,
adj_e->v1 = mloop[looptri->tri[i % 3]].v;
adj_e->v2 = mloop[looptri->tri[(i + 1) % 3]].v;
if (adj_e->v1 > adj_e->v2) {
SWAP(uint32_t, adj_e->v1, adj_e->v2);
std::swap( adj_e->v1, adj_e->v2);
}
edge_nabr->e = -1;
@ -3267,7 +3267,7 @@ static void lineart_add_isec_thread(LineartIsecThread *th,
isec_single->tri1 = tri1;
isec_single->tri2 = tri2;
if (tri1->target_reference > tri2->target_reference) {
SWAP(LineartTriangle *, isec_single->tri1, isec_single->tri2);
std::swap( isec_single->tri1, isec_single->tri2);
}
th->current++;
}

View File

@ -464,7 +464,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
/* also order edges based on faces */
if (medge_new[ml_orig->e].v1 != ml_orig->v) {
SWAP(uint, medge_new[ml_orig->e].v1, medge_new[ml_orig->e].v2);
std::swap(medge_new[ml_orig->e].v1, medge_new[ml_orig->e].v2);
}
}
}
@ -716,7 +716,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
if (lt_iter.v == lt_iter.e->v1) {
if (ed_loop_flip == 0) {
// printf("\t\t\tFlipping 0\n");
SWAP(uint, lt_iter.e->v1, lt_iter.e->v2);
std::swap(lt_iter.e->v1, lt_iter.e->v2);
}
#if 0
else {
@ -727,7 +727,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
else if (lt_iter.v == lt_iter.e->v2) {
if (ed_loop_flip == 1) {
// printf("\t\t\tFlipping 1\n");
SWAP(uint, lt_iter.e->v1, lt_iter.e->v2);
std::swap(lt_iter.e->v1, lt_iter.e->v2);
}
#if 0
else {

View File

@ -259,7 +259,7 @@ static void rasterize_half(const MBakeRast *bake_rast,
float x_r = l_stable != 0 ? (s0_l + (((s1_l - s0_l) * (y - t0_l)) / (t1_l - t0_l))) : s0_l;
if (is_mid_right != 0) {
SWAP(float, x_l, x_r);
std::swap( x_l, x_r);
}
iXl = int(ceilf(x_l));
@ -298,17 +298,17 @@ static void bake_rasterize(const MBakeRast *bake_rast,
/* sort by T */
if (tlo > tmi && tlo > thi) {
SWAP(float, shi, slo);
SWAP(float, thi, tlo);
std::swap( shi, slo);
std::swap( thi, tlo);
}
else if (tmi > thi) {
SWAP(float, shi, smi);
SWAP(float, thi, tmi);
std::swap( shi, smi);
std::swap( thi, tmi);
}
if (tlo > tmi) {
SWAP(float, slo, smi);
SWAP(float, tlo, tmi);
std::swap( slo, smi);
std::swap( tlo, tmi);
}
/* check if mid point is to the left or to the right of the lo-hi edge */

View File

@ -340,7 +340,7 @@ void RE_SwapResult(Render *re, RenderResult **rr)
{
/* for keeping render buffers */
if (re) {
SWAP(RenderResult *, re->result, *rr);
std::swap(re->result, *rr);
}
}

View File

@ -4426,7 +4426,7 @@ static void wm_event_get_keymap_from_toolsystem_ex(wmWindowManager *wm,
if (is_gizmo_visible && !is_gizmo_highlight) {
if (keymap_id_list_len == 2) {
SWAP(const char *, keymap_id_list[0], keymap_id_list[1]);
std::swap(keymap_id_list[0], keymap_id_list[1]);
}
}