Cleanup: various non-functional changes for C++

- Remove redundant parenthesis
- Use strings macros
- NULL -> nullptr
This commit is contained in:
Campbell Barton
2024-10-02 15:42:49 +10:00
parent 0b69e1d6f5
commit 0f3fdd25bc
24 changed files with 37 additions and 38 deletions

View File

@@ -1032,7 +1032,7 @@ void Slot::set_expanded(const bool expanded)
this->slot_flags |= uint8_t(Flags::Expanded);
}
else {
this->slot_flags &= ~(uint8_t(Flags::Expanded));
this->slot_flags &= ~uint8_t(Flags::Expanded);
}
}
@@ -1046,7 +1046,7 @@ void Slot::set_selected(const bool selected)
this->slot_flags |= uint8_t(Flags::Selected);
}
else {
this->slot_flags &= ~(uint8_t(Flags::Selected));
this->slot_flags &= ~uint8_t(Flags::Selected);
}
}
@@ -1060,7 +1060,7 @@ void Slot::set_active(const bool active)
this->slot_flags |= uint8_t(Flags::Active);
}
else {
this->slot_flags &= ~(uint8_t(Flags::Active));
this->slot_flags &= ~uint8_t(Flags::Active);
}
}

View File

@@ -135,7 +135,7 @@ static std::string asset_blendfile_path_for_save(const bUserAssetLibrary &user_l
for (int i = 1;; i++) {
const std::string filepath = root_path + SEP + base_name_filesafe + "_" + std::to_string(i++) +
BLENDER_ASSET_FILE_SUFFIX;
if (!BLI_is_file((filepath.c_str()))) {
if (!BLI_is_file(filepath.c_str())) {
return filepath;
}
}

View File

@@ -833,19 +833,19 @@ int *BKE_attributes_active_index_p(AttributeOwner &owner)
{
switch (owner.type()) {
case AttributeOwnerType::PointCloud: {
return &(owner.get_pointcloud())->attributes_active_index;
return &owner.get_pointcloud()->attributes_active_index;
}
case AttributeOwnerType::Mesh: {
return &(owner.get_mesh())->attributes_active_index;
return &owner.get_mesh()->attributes_active_index;
}
case AttributeOwnerType::Curves: {
return &owner.get_curves()->geometry.attributes_active_index;
}
case AttributeOwnerType::GreasePencil: {
return &(owner.get_grease_pencil())->attributes_active_index;
return &owner.get_grease_pencil()->attributes_active_index;
}
case AttributeOwnerType::GreasePencilDrawing: {
return &(owner.get_grease_pencil_drawing())->geometry.attributes_active_index;
return &owner.get_grease_pencil_drawing()->geometry.attributes_active_index;
}
}
return nullptr;

View File

@@ -481,7 +481,7 @@ static void reuse_editable_asset_bmain_data_for_blendfile(ReuseOldBMainData *reu
FOREACH_MAIN_LISTBASE_ID_BEGIN (old_lb, old_id_iter) {
/* Keep any datablocks from libraries marked as LIBRARY_ASSET_EDITABLE. */
if (!((ID_IS_LINKED(old_id_iter) && old_id_iter->lib->runtime.tag & LIBRARY_ASSET_EDITABLE))) {
if (!(ID_IS_LINKED(old_id_iter) && old_id_iter->lib->runtime.tag & LIBRARY_ASSET_EDITABLE)) {
continue;
}

View File

@@ -67,7 +67,7 @@ static bool is_vertex_in_id(BMVert *v, const int *elem_id, int elem)
static bool is_vertex_pole_three(BMVert *v)
{
return !BM_vert_is_boundary(v) && (BM_vert_edge_count_is_equal(v, 3));
return !BM_vert_is_boundary(v) && BM_vert_edge_count_is_equal(v, 3);
}
static bool is_vertex_pole(BMVert *v)

View File

@@ -794,7 +794,7 @@ static void bchunk_list_fill_from_array(const BArrayInfo *info,
BLI_INLINE hash_key hash_data_single(const uchar p)
{
return ((HASH_INIT << 5) + HASH_INIT) + (hash_key)(*((signed char *)&p));
return ((HASH_INIT << 5) + HASH_INIT) + (hash_key) * ((signed char *)&p);
}
/* Hash bytes, from #BLI_ghashutil_strhash_n. */

View File

@@ -22,8 +22,8 @@ RotateOperation::RotateOperation()
void RotateOperation::get_rotation_center(const rcti &area, float &r_x, float &r_y)
{
r_x = (BLI_rcti_size_x(&area)) / 2.0;
r_y = (BLI_rcti_size_y(&area)) / 2.0;
r_x = BLI_rcti_size_x(&area) / 2.0;
r_y = BLI_rcti_size_y(&area) / 2.0;
}
void RotateOperation::get_rotation_offset(const rcti &input_canvas,

View File

@@ -109,7 +109,7 @@ void SyncModule::sync_mesh(Object *ob,
return;
}
if ((ob->dt < OB_SOLID) && ((inst_.is_viewport() && inst_.v3d->shading.type != OB_RENDER))) {
if ((ob->dt < OB_SOLID) && (inst_.is_viewport() && inst_.v3d->shading.type != OB_RENDER)) {
/** Do not render objects with display type lower than solid when in material preview mode. */
return;
}

View File

@@ -213,7 +213,7 @@ static float grease_pencil_layer_final_opacity_get(const GPENCIL_PrivateData *pd
{
const bool is_obact = ((pd->obact) && (pd->obact == ob));
const bool is_fade = (pd->fade_layer_opacity > -1.0f) && (is_obact) &&
(!grease_pencil.is_layer_active(&layer));
!grease_pencil.is_layer_active(&layer);
/* Defines layer opacity. For active object depends of layer opacity factor, and
* for no active object, depends if the fade grease pencil objects option is enabled. */

View File

@@ -272,7 +272,7 @@ static void append_line_loop(
const int step = dashed ? 2 : 1;
for (const int i : IndexRange(verts.size() / step)) {
for (const int j : IndexRange(2)) {
const float2 &cv = verts[(i * step + j) % (verts.size())];
const float2 &cv = verts[(i * step + j) % verts.size()];
dest.append({{cv[0], cv[1], z}, flag});
}
}

View File

@@ -3236,7 +3236,7 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac,
}
/* grease pencil */
if ((ELEM(ob->type, OB_GREASE_PENCIL, OB_GPENCIL_LEGACY)) && (ob->data) &&
if (ELEM(ob->type, OB_GREASE_PENCIL, OB_GPENCIL_LEGACY) && (ob->data) &&
!(ads_filterflag & ADS_FILTER_NOGPENCIL))
{
if (ob->type == OB_GREASE_PENCIL) {

View File

@@ -339,7 +339,7 @@ static bool gpencil_paintmode_toggle_poll(bContext *C)
{
/* if using gpencil object, use this gpd */
Object *ob = CTX_data_active_object(C);
if ((ob) && (ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL))) {
if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) {
return ob->data != nullptr;
}
return false;
@@ -627,7 +627,7 @@ static bool gpencil_weightmode_toggle_poll(bContext *C)
{
/* if using gpencil object, use this gpd */
Object *ob = CTX_data_active_object(C);
if ((ob) && (ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL))) {
if ((ob) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)) {
return ob->data != nullptr;
}
return false;

View File

@@ -3838,7 +3838,7 @@ static void remap_vertex_groups(bke::greasepencil::Drawing &drawing,
const Map<StringRefNull, StringRefNull> &vertex_group_map)
{
LISTBASE_FOREACH (bDeformGroup *, dg, &drawing.strokes_for_write().vertex_group_names) {
BLI_strncpy(dg->name, vertex_group_map.lookup(dg->name).c_str(), sizeof(dg->name));
STRNCPY(dg->name, vertex_group_map.lookup(dg->name).c_str());
}
/* Indices in vertex weights remain valid, they are local to the drawing's vertex groups.

View File

@@ -581,7 +581,7 @@ static const EnumPropertyItem select_similar_mode_items[] = {
{int(SelectSimilarMode::VERTEX_COLOR), "VERTEX_COLOR", 0, "Vertex Color", ""},
{int(SelectSimilarMode::RADIUS), "RADIUS", 0, "Radius", ""},
{int(SelectSimilarMode::OPACITY), "OPACITY", 0, "Opacity", ""},
{0, NULL, 0, NULL, NULL},
{0, nullptr, 0, nullptr, nullptr},
};
template<typename T>

View File

@@ -3804,7 +3804,7 @@ void static area_docking_apply(bContext *C, wmOperator *op)
bool same_area = (jd->sa1 == jd->sa2);
if (!(jd->dock_target == AreaDockTarget::Center)) {
eScreenAxis dir = (ELEM(jd->dock_target, AreaDockTarget::Left, AreaDockTarget::Right)) ?
eScreenAxis dir = ELEM(jd->dock_target, AreaDockTarget::Left, AreaDockTarget::Right) ?
SCREEN_AXIS_V :
SCREEN_AXIS_H;
@@ -3992,7 +3992,7 @@ static AreaDockTarget area_docking_target(sAreaJoinData *jd, const wmEvent *even
if (fac_y > 0.4f && fac_y < 0.6f) {
return AreaDockTarget::Center;
}
if ((float(y) > float(jd->sa2->winy) / 2.0f)) {
if (float(y) > float(jd->sa2->winy) / 2.0f) {
jd->factor = area_docking_snap(1.0f - float(y) / float(jd->sa2->winy), event);
return AreaDockTarget::Top;
}
@@ -4005,7 +4005,7 @@ static AreaDockTarget area_docking_target(sAreaJoinData *jd, const wmEvent *even
if (fac_x > 0.4f && fac_x < 0.6f) {
return AreaDockTarget::Center;
}
if ((float(x) > float(jd->sa2->winx) / 2.0f)) {
if (float(x) > float(jd->sa2->winx) / 2.0f) {
jd->factor = area_docking_snap(1.0f - float(x) / float(jd->sa2->winx), event);
return AreaDockTarget::Right;
}
@@ -4365,8 +4365,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
if (dir != SCREEN_DIR_NONE) {
uiItemFullO(layout,
"SCREEN_OT_area_join",
(ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S)) ? IFACE_("Join Up") :
IFACE_("Join Right"),
ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S) ? IFACE_("Join Up") : IFACE_("Join Right"),
ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S) ? ICON_AREA_JOIN_UP : ICON_AREA_JOIN,
nullptr,
WM_OP_EXEC_DEFAULT,
@@ -4378,7 +4377,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
uiItemFullO(
layout,
"SCREEN_OT_area_join",
(ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S)) ? IFACE_("Join Down") : IFACE_("Join Left"),
ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S) ? IFACE_("Join Down") : IFACE_("Join Left"),
ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S) ? ICON_AREA_JOIN_DOWN : ICON_AREA_JOIN_LEFT,
nullptr,
WM_OP_EXEC_DEFAULT,

View File

@@ -1611,7 +1611,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
NlaStrip *mstrip = static_cast<NlaStrip *>(nlt->strips.first);
if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) &&
(BLI_listbase_count_is_equal_to(&mstrip->strips, 2)))
BLI_listbase_count_is_equal_to(&mstrip->strips, 2))
{
/* remove this temp meta, so that we can see the strips inside */
BKE_nlastrips_clear_metas(&nlt->strips, false, true);

View File

@@ -901,7 +901,7 @@ static void sequencer_add_movie_multiple_strips(bContext *C,
seq_load_apply_generic_options(C, op, seq_movie);
}
if ((U.sequencer_editor_flag & USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT)) {
if (U.sequencer_editor_flag & USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT) {
SEQ_connect(seq_movie, seq_sound);
}
@@ -972,7 +972,7 @@ static bool sequencer_add_movie_single_strip(bContext *C,
seq_load_apply_generic_options(C, op, seq_movie);
}
if ((U.sequencer_editor_flag & USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT)) {
if (U.sequencer_editor_flag & USER_SEQ_ED_CONNECT_STRIPS_BY_DEFAULT) {
SEQ_connect(seq_movie, seq_sound);
}

View File

@@ -931,7 +931,7 @@ void axis_set_view(bContext *C,
else if (rv3d->persp == RV3D_CAMOB) {
rv3d->persp = perspo;
}
if ((rv3d->persp != orig_persp)) {
if (rv3d->persp != orig_persp) {
ED_region_tag_redraw(region);
}

View File

@@ -2363,9 +2363,9 @@ bke::GeometrySet realize_instances(bke::GeometrySet geometry_set,
if (not_to_realize_set.has_instances()) {
gather_info.instances.instances_components_to_merge.append(
(not_to_realize_set.get_component_for_write<bke::InstancesComponent>()).copy());
not_to_realize_set.get_component_for_write<bke::InstancesComponent>().copy());
gather_info.instances.instances_components_transforms.append(float4x4::identity());
gather_info.instances.attribute_fallback.append((gather_info.instances_attriubutes.size()));
gather_info.instances.attribute_fallback.append(gather_info.instances_attriubutes.size());
}
const float4x4 transform = float4x4::identity();

View File

@@ -59,7 +59,7 @@ static bool is_selected_frame(const GreasePencil &grease_pencil, const int frame
for (const bke::greasepencil::Layer *layer : grease_pencil.layers()) {
if (layer->is_visible()) {
const GreasePencilFrame *frame = layer->frames().lookup_ptr(frame_number);
if ((frame != nullptr) && (frame->is_selected())) {
if ((frame != nullptr) && frame->is_selected()) {
return true;
}
}

View File

@@ -215,7 +215,7 @@ static void deform_drawing(const ModifierData &md,
float length = curves.evaluated_length_total_for_curve(curve, false);
if (mmd.mode & GP_LENGTH_ABSOLUTE) {
starts[curve] = -math::min(use_starts[curve], 0.0f);
ends[curve] = length - (-math::min(use_ends[curve], 0.0f));
ends[curve] = length - -math::min(use_ends[curve], 0.0f);
}
else {
starts[curve] = -math::min(use_starts[curve], 0.0f) * length;

View File

@@ -780,7 +780,7 @@ static void generate_strokes(ModifierData &md,
lmd.flags,
lmd.calculation_flags);
if ((!(lmd.flags & MOD_LINEART_USE_CACHE)) && (&first_lineart != &lmd)) {
if (!(lmd.flags & MOD_LINEART_USE_CACHE) && (&first_lineart != &lmd)) {
/* Clear local cache. */
if (local_lc != first_lineart.shared_cache) {
MOD_lineart_clear_cache(&local_lc);

View File

@@ -216,7 +216,7 @@ static bool shaderfx_ui_poll(const bContext *C, PanelType * /*pt*/)
{
Object *ob = blender::ed::object::context_active_object(C);
return (ob != nullptr) && (ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL));
return (ob != nullptr) && ELEM(ob->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL);
}
PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelDrawFn draw)

View File

@@ -194,7 +194,7 @@ void WM_gizmo_unlink(ListBase *gizmolist, wmGizmoMap *gzmap, wmGizmo *gz, bConte
wmGizmoOpElem *WM_gizmo_operator_get(wmGizmo *gz, int part_index)
{
if (((part_index >= 0) && (part_index < gz->op_data.size()))) {
if ((part_index >= 0) && (part_index < gz->op_data.size())) {
return &gz->op_data[part_index];
}
return nullptr;