Cleanup: various non functional C++ changes

This commit is contained in:
Campbell Barton
2024-04-20 13:09:21 +10:00
parent c6a9b11ef6
commit fd589fdca4
28 changed files with 53 additions and 59 deletions

View File

@@ -3616,7 +3616,7 @@ static void cursor_surface_handle_leave(void *data, wl_surface *wl_surface, wl_o
}
static void cursor_surface_handle_preferred_buffer_scale(void * /*data*/,
struct wl_surface * /*wl_surface*/,
wl_surface * /*wl_surface*/,
int32_t factor)
{
/* Only available in interface version 6. */
@@ -3624,7 +3624,7 @@ static void cursor_surface_handle_preferred_buffer_scale(void * /*data*/,
}
static void cursor_surface_handle_preferred_buffer_transform(void * /*data*/,
struct wl_surface * /*wl_surface*/,
wl_surface * /*wl_surface*/,
uint32_t transform)
{
/* Only available in interface version 6. */
@@ -6143,13 +6143,13 @@ static void output_handle_scale(void *data, wl_output * /*wl_output*/, const int
output->system->output_scale_update(output);
}
static void output_handle_name(void * /*data*/, struct wl_output * /*wl_output*/, const char *name)
static void output_handle_name(void * /*data*/, wl_output * /*wl_output*/, const char *name)
{
/* Only available in interface version 4. */
CLOG_INFO(LOG, 2, "name (%s)", name);
}
static void output_handle_description(void * /*data*/,
struct wl_output * /*wl_output*/,
wl_output * /*wl_output*/,
const char *description)
{
/* Only available in interface version 4. */

View File

@@ -1197,7 +1197,7 @@ static void xdg_toplevel_handle_close(void *data, xdg_toplevel * /*xdg_toplevel*
}
static void xdg_toplevel_handle_configure_bounds(void *data,
struct xdg_toplevel * /*xdg_toplevel*/,
xdg_toplevel * /*xdg_toplevel*/,
int32_t width,
int32_t height)
{
@@ -1213,8 +1213,8 @@ static void xdg_toplevel_handle_configure_bounds(void *data,
}
}
static void xdg_toplevel_handle_wm_capabilities(void * /*data*/,
struct xdg_toplevel * /*xdg_toplevel*/,
struct wl_array * /*capabilities*/)
xdg_toplevel * /*xdg_toplevel*/,
wl_array * /*capabilities*/)
{
/* Only available in interface version 5. */
CLOG_INFO(LOG, 2, "wm_capabilities");
@@ -1595,7 +1595,7 @@ static void surface_handle_leave(void *data, wl_surface * /*wl_surface*/, wl_out
}
static void surface_handle_preferred_buffer_scale(void * /*data*/,
struct wl_surface * /*wl_surface*/,
wl_surface * /*wl_surface*/,
int32_t factor)
{
/* Only available in interface version 6. */
@@ -1603,7 +1603,7 @@ static void surface_handle_preferred_buffer_scale(void * /*data*/,
}
static void surface_handle_preferred_buffer_transform(void * /*data*/,
struct wl_surface * /*wl_surface*/,
wl_surface * /*wl_surface*/,
uint32_t transform)
{
/* Only available in interface version 6. */

View File

@@ -101,7 +101,7 @@ void aligned_free(void *ptr)
* Helps catching issues (in debug build) caused by an unintended allocator type change when there
* are allocation happened.
*/
static void assert_for_allocator_change(void)
static void assert_for_allocator_change()
{
/* NOTE: Assume that there is no "sticky" internal state which would make switching allocator
* type after all allocations are freed unsafe. In fact, it should be safe to change allocator
@@ -110,7 +110,7 @@ static void assert_for_allocator_change(void)
assert(MEM_get_memory_blocks_in_use() == 0);
}
void MEM_use_lockfree_allocator(void)
void MEM_use_lockfree_allocator()
{
/* NOTE: Keep in sync with static initialization of the variables. */
@@ -150,7 +150,7 @@ void MEM_use_lockfree_allocator(void)
#endif
}
void MEM_use_guarded_allocator(void)
void MEM_use_guarded_allocator()
{
assert_for_allocator_change();

View File

@@ -365,7 +365,7 @@ void BKE_curvemap_reset(CurveMap *cuma, const rctf *clipr, int preset, int slope
break;
case CURVE_PRESET_MID8: {
for (int i = 0; i < cuma->totpoint; i++) {
cuma->curve[i].x = i / (float(cuma->totpoint));
cuma->curve[i].x = i / float(cuma->totpoint);
cuma->curve[i].y = 0.5;
}
break;

View File

@@ -2982,7 +2982,7 @@ bool pbvh_has_mask(const PBVH *pbvh)
return pbvh->mesh->attributes().contains(".sculpt_mask");
case PBVH_BMESH:
return pbvh->header.bm &&
(CustomData_has_layer_named(&pbvh->header.bm->vdata, CD_PROP_FLOAT, ".sculpt_mask"));
CustomData_has_layer_named(&pbvh->header.bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
}
return false;

View File

@@ -2976,7 +2976,6 @@ static void curve_surf_to_softbody(Object *ob)
SoftBody *sb;
BodyPoint *bp;
BodySpring *bs;
Nurb *nu;
BezTriple *bezt;
BPoint *bpnt;
int a, curindex = 0;
@@ -3005,7 +3004,7 @@ static void curve_surf_to_softbody(Object *ob)
setgoal = 1;
}
for (nu = static_cast<Nurb *>(cu->nurb.first); nu; nu = nu->next) {
LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) {
if (nu->bezt) {
/* Bezier case; this is nicely said naive; who ever wrote this part,
* it was not me (JOW) :).

View File

@@ -472,7 +472,7 @@ static void bchunk_list_ensure_min_size_last(const BArrayInfo *info,
BArrayMemory *bs_mem,
BChunkList *chunk_list)
{
BChunkRef *cref = static_cast<BChunkRef *>((chunk_list->chunk_refs.last));
BChunkRef *cref = static_cast<BChunkRef *>(chunk_list->chunk_refs.last);
if (cref && cref->prev) {
/* Both are decrefed after use (end of this block). */
BChunk *chunk_curr = cref->link;

View File

@@ -1060,9 +1060,7 @@ static void versioning_replace_musgrave_texture_node(bNodeTree *ntree)
}
else {
if (*detail < 1.0f) {
if ((noise_type != SHD_NOISE_RIDGED_MULTIFRACTAL) &&
(noise_type != SHD_NOISE_HETERO_TERRAIN))
{
if (!ELEM(noise_type, SHD_NOISE_RIDGED_MULTIFRACTAL, SHD_NOISE_HETERO_TERRAIN)) {
/* Add Multiply Math node behind Fac output. */
bNode *mul_node = nodeAddStaticNode(nullptr, ntree, SH_NODE_MATH);

View File

@@ -621,9 +621,9 @@ static void mywrite_id_begin(WriteData *wd, ID *id)
MemFileChunk *prev_memchunk = curr_memchunk != nullptr ?
static_cast<MemFileChunk *>(curr_memchunk->prev) :
nullptr;
if ((curr_memchunk == nullptr || curr_memchunk->id_session_uid != id->session_uid ||
(prev_memchunk != nullptr &&
(prev_memchunk->id_session_uid == curr_memchunk->id_session_uid))))
if (curr_memchunk == nullptr || curr_memchunk->id_session_uid != id->session_uid ||
(prev_memchunk != nullptr &&
(prev_memchunk->id_session_uid == curr_memchunk->id_session_uid)))
{
if (MemFileChunk *ref = wd->mem.id_session_uid_mapping.lookup_default(id->session_uid,
nullptr))

View File

@@ -64,7 +64,7 @@ void SunBeamsOperation::update_memory_buffer_partial(MemoryBuffer *output,
/* Attenuate the contributions of pixels that are further away from the source using a
* quadratic falloff. Also weight by the alpha to give more significance to opaque pixels.
*/
const float weight = (math::square(1.0f - i / float(steps))) * sample_color.w;
const float weight = math::square(1.0f - i / float(steps)) * sample_color.w;
accumulated_weight += weight;
accumulated_color += sample_color * weight;

View File

@@ -131,7 +131,7 @@ void eevee_shader_material_create_info_amend(GPUMaterial *gpumat,
attr_load << "void attrib_load()\n";
attr_load << "{\n";
attr_load << ((!codegen.attr_load.empty()) ? codegen.attr_load : "");
attr_load << (!codegen.attr_load.empty() ? codegen.attr_load : "");
attr_load << "}\n\n";
std::stringstream vert_gen, frag_gen, geom_gen;
@@ -156,10 +156,10 @@ void eevee_shader_material_create_info_amend(GPUMaterial *gpumat,
frag_gen << "Closure nodetree_exec()\n";
frag_gen << "{\n";
if (is_volume) {
frag_gen << ((!codegen.volume.empty()) ? codegen.volume : "return CLOSURE_DEFAULT;\n");
frag_gen << (!codegen.volume.empty() ? codegen.volume : "return CLOSURE_DEFAULT;\n");
}
else {
frag_gen << ((!codegen.surface.empty()) ? codegen.surface : "return CLOSURE_DEFAULT;\n");
frag_gen << (!codegen.surface.empty() ? codegen.surface : "return CLOSURE_DEFAULT;\n");
}
frag_gen << "}\n\n";

View File

@@ -189,13 +189,13 @@ void EEVEE_shadows_draw_cubemap(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata,
for (int j = 0; j < 6; j++) {
/* Optimization: Only render the needed faces. */
/* Skip all but -Z face. */
if ((ELEM(evli->light_type, LA_SPOT, LAMPTYPE_SPOT_DISK)) && j != 5 &&
if (ELEM(evli->light_type, LA_SPOT, LAMPTYPE_SPOT_DISK) && j != 5 &&
spot_angle_fit_single_face(evli))
{
continue;
}
/* Skip +Z face. */
if (!(ELEM(evli->light_type, LA_LOCAL, LAMPTYPE_OMNI_DISK)) && j == 4) {
if (!ELEM(evli->light_type, LA_LOCAL, LAMPTYPE_OMNI_DISK) && j == 4) {
continue;
}
/* TODO(fclem): some cube sides can be invisible in the main views. Cull them. */

View File

@@ -589,7 +589,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
std::stringstream attr_load;
attr_load << "void attrib_load()\n";
attr_load << "{\n";
attr_load << ((!codegen.attr_load.empty()) ? codegen.attr_load : "");
attr_load << (!codegen.attr_load.empty() ? codegen.attr_load : "");
attr_load << "}\n\n";
std::stringstream vert_gen, frag_gen, comp_gen;
@@ -604,9 +604,9 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
}
{
const bool use_vertex_displacement = (!codegen.displacement.empty()) &&
const bool use_vertex_displacement = !codegen.displacement.empty() &&
(displacement_type != MAT_DISPLACEMENT_BUMP) &&
(!ELEM(geometry_type, MAT_GEOM_WORLD, MAT_GEOM_VOLUME));
!ELEM(geometry_type, MAT_GEOM_WORLD, MAT_GEOM_VOLUME);
vert_gen << "vec3 nodetree_displacement()\n";
vert_gen << "{\n";
@@ -617,7 +617,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
}
if (pipeline_type != MAT_PIPE_VOLUME_OCCUPANCY) {
frag_gen << ((!codegen.material_functions.empty()) ? codegen.material_functions : "\n");
frag_gen << (!codegen.material_functions.empty() ? codegen.material_functions : "\n");
if (!codegen.displacement.empty()) {
/* Bump displacement. Needed to recompute normals after displacement. */
@@ -632,7 +632,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
frag_gen << "Closure nodetree_surface(float closure_rand)\n";
frag_gen << "{\n";
frag_gen << " closure_weights_reset(closure_rand);\n";
frag_gen << ((!codegen.surface.empty()) ? codegen.surface : "return Closure(0);\n");
frag_gen << (!codegen.surface.empty() ? codegen.surface : "return Closure(0);\n");
frag_gen << "}\n\n";
frag_gen << "float nodetree_thickness()\n";
@@ -662,7 +662,7 @@ void ShaderModule::material_create_info_ammend(GPUMaterial *gpumat, GPUCodegenOu
frag_gen << "Closure nodetree_volume()\n";
frag_gen << "{\n";
frag_gen << " closure_weights_reset(0.0);\n";
frag_gen << ((!codegen.volume.empty()) ? codegen.volume : "return Closure(0);\n");
frag_gen << (!codegen.volume.empty() ? codegen.volume : "return Closure(0);\n");
frag_gen << "}\n\n";
info.fragment_source_generated = frag_gen.str();

View File

@@ -1217,7 +1217,7 @@ void GPENCIL_draw_scene(void *ved)
/* Fade 3D objects. */
if ((!pd->is_render) && (pd->fade_3d_object_opacity > -1.0f) && (pd->obact != nullptr) &&
(ELEM(pd->obact->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL)))
ELEM(pd->obact->type, OB_GPENCIL_LEGACY, OB_GREASE_PENCIL))
{
float background_color[3];
ED_view3d_background_color_get(pd->scene, pd->v3d, background_color);

View File

@@ -133,7 +133,7 @@ static void draw_current_frame(const Scene *scene,
uchar text_color[4];
UI_GetThemeColor4ubv(TH_HEADER_TEXT_HI, text_color);
const int y = BLI_rcti_cent_y(scrub_region_rect) - int((fstyle->points * UI_SCALE_FAC * 0.35f));
const int y = BLI_rcti_cent_y(scrub_region_rect) - int(fstyle->points * UI_SCALE_FAC * 0.35f);
UI_fontstyle_draw_simple(
+fstyle, frame_x - text_width / 2 + U.pixelsize / 2, y, frame_str, text_color);

View File

@@ -1259,7 +1259,7 @@ static uiBut *template_id_def_new_but(uiBlock *block,
int w = id ? UI_UNIT_X : id_open ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
if (!id) {
w = std::max(UI_fontstyle_string_width(fstyle, button_text) + int((UI_UNIT_X * 1.5f)), w);
w = std::max(UI_fontstyle_string_width(fstyle, button_text) + int(UI_UNIT_X * 1.5f), w);
}
if (newop) {
@@ -1544,7 +1544,7 @@ static void template_ID(const bContext *C,
int w = id ? UI_UNIT_X : (flag & UI_ID_ADD_NEW) ? UI_UNIT_X * 3 : UI_UNIT_X * 6;
if (!id) {
w = std::max(UI_fontstyle_string_width(fstyle, button_text) + int((UI_UNIT_X * 1.5f)), w);
w = std::max(UI_fontstyle_string_width(fstyle, button_text) + int(UI_UNIT_X * 1.5f), w);
}
if (openop) {
@@ -2827,7 +2827,7 @@ static eAutoPropButsReturn template_operator_property_buts_draw_single(
* - this is used for allowing operators with popups to rename stuff with fewer clicks
*/
if (is_popup) {
if ((but->rnaprop == op->type->prop) && (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM))) {
if ((but->rnaprop == op->type->prop) && ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_NUM)) {
UI_but_focus_on_enter_event(CTX_wm_window(C), but);
}
}

View File

@@ -1386,7 +1386,7 @@ static int console_modal_select_all_invoke(bContext *C,
int offset = strlen(sc->prompt);
for (ConsoleLine *cl = static_cast<ConsoleLine *>(sc->scrollback.first); cl; cl = cl->next) {
LISTBASE_FOREACH (ConsoleLine *, cl, &sc->scrollback) {
offset += cl->len + 1;
}

View File

@@ -895,7 +895,7 @@ static void sequencer_draw_scopes(Scene *scene, ARegion *region, SpaceSeq *sseq)
if (sseq->mainb == SEQ_DRAW_IMG_HISTOGRAM) {
draw_histogram(region, scopes->histogram, quads, preview);
}
if (sseq->mainb == SEQ_DRAW_IMG_WAVEFORM || sseq->mainb == SEQ_DRAW_IMG_RGBPARADE) {
if (ELEM(sseq->mainb, SEQ_DRAW_IMG_WAVEFORM, SEQ_DRAW_IMG_RGBPARADE)) {
use_blend = true;
draw_waveform_graticule(region, quads, preview);
}

View File

@@ -937,7 +937,7 @@ static bool drop_extension_url_poll(bContext * /*C*/, wmDrag *drag, const wmEven
/* Check the URL has a `.zip` suffix OR has a known repository as a prefix.
* This is needed to support redirects which don't contain an extension. */
if (!(cstr_ext && STRCASEEQ(cstr_ext, ".zip")) &&
!(BKE_preferences_extension_repo_find_by_remote_path_prefix(&U, cstr, true)))
!BKE_preferences_extension_repo_find_by_remote_path_prefix(&U, cstr, true))
{
return false;
}

View File

@@ -2426,7 +2426,7 @@ Array<TransDataEdgeSlideVert> transform_mesh_edge_slide_data_create(const TransD
* Find the best direction to slide among the ones already computed.
*
* \param curr_side_other: previous state of the #SlideTempDataMesh where the faces are
linked to the previous edge.
* linked to the previous edge.
* \param l_src: the source corner in the edge to slide.
* \param l_dst: the current destination corner.
*/

View File

@@ -945,7 +945,7 @@ Array<TransDataEdgeSlideVert> transform_mesh_uv_edge_slide_data_create(const Tra
* Find the best direction to slide among the ones already computed.
*
* \param curr_prev: prev state of the #SlideTempDataUV where the faces are linked to the
previous edge.
* previous edge.
* \param l_src: the source corner in the edge to slide.
* \param l_dst: the current destination corner.
*/

View File

@@ -257,10 +257,10 @@ bke::CurvesGeometry extend_curves(bke::CurvesGeometry &src_curves,
}
const int count_start = (use_start_lengths[curve] > 0) ?
(math::ceil(use_start_lengths[curve] * point_density)) :
math::ceil(use_start_lengths[curve] * point_density) :
0;
const int count_end = (use_end_lengths[curve] > 0) ?
(math::ceil(use_end_lengths[curve] * point_density)) :
math::ceil(use_end_lengths[curve] * point_density) :
0;
dst_points_by_curve[curve] += count_start;
dst_points_by_curve[curve] += count_end;

View File

@@ -748,7 +748,7 @@ template<typename StorageType> void convert(SignedNormalized<StorageType> &dst,
static constexpr int32_t scalar = SignedNormalized<StorageType>::scalar();
static constexpr int32_t delta = SignedNormalized<StorageType>::delta();
static constexpr int32_t max = SignedNormalized<StorageType>::max();
dst.value = (clamp_i((src.value * scalar + delta), 0, max));
dst.value = clamp_i((src.value * scalar + delta), 0, max);
}
template<typename StorageType> void convert(F32 &dst, const SignedNormalized<StorageType> &src)
@@ -762,7 +762,7 @@ template<typename StorageType> void convert(UnsignedNormalized<StorageType> &dst
{
static constexpr uint32_t scalar = UnsignedNormalized<StorageType>::scalar();
static constexpr uint32_t max = scalar;
dst.value = (clamp_f((src.value * float(scalar)), 0, float(max)));
dst.value = clamp_f((src.value * float(scalar)), 0, float(max));
}
template<typename StorageType> void convert(F32 &dst, const UnsignedNormalized<StorageType> &src)

View File

@@ -28,7 +28,7 @@ VkDescriptorSetLayout VKDescriptorSetLayouts::get_or_create(const VKDescriptorSe
bool &r_needed)
{
r_created = false;
r_needed = !(info.bindings.is_empty());
r_needed = !info.bindings.is_empty();
if (r_needed == false) {
return VK_NULL_HANDLE;
}

View File

@@ -300,7 +300,7 @@ std::string VKDevice::driver_version() const
/* When using Mesa driver we should use VK_VERSION_*. */
if (major > 30) {
return std::to_string((driver_version >> 14) & 0x3FFFF) + "." +
std::to_string((driver_version & 0x3FFF));
std::to_string(driver_version & 0x3FFF);
}
break;
}

View File

@@ -316,9 +316,9 @@ static void deform_drawing_as_envelope(const GreasePencilEnvelopeModifierData &e
const IndexRange points = points_by_curve[curve_i];
const bool cyclic = cyclic_flags[curve_i];
const int point_num = points.size();
const int spread = cyclic ? (math::abs(((emd.spread + point_num / 2) % point_num) -
point_num / 2)) :
std::min(emd.spread, point_num - 1);
const int spread = cyclic ?
math::abs(((emd.spread + point_num / 2) % point_num) - point_num / 2) :
std::min(emd.spread, point_num - 1);
for (const int64_t i : points.index_range()) {
const int64_t point_i = points[i];

View File

@@ -1569,7 +1569,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context,
is_frame_update = (orig_data.timeline_frame != scene->r.cfra) ||
(orig_data.subframe != scene->r.subframe);
if ((sequencer_view3d_fn && do_seq_gl && camera)) {
if (sequencer_view3d_fn && do_seq_gl && camera) {
char err_out[256] = "unknown";
int width, height;
BKE_render_resolution(&scene->r, false, &width, &height);

View File

@@ -116,10 +116,7 @@ void SEQ_transform_translate_sequence(Scene *evil_scene, Sequence *seq, int delt
* updated based on nested strips. This won't work for empty meta-strips,
* so they can be treated as normal strip. */
if (seq->type == SEQ_TYPE_META && !BLI_listbase_is_empty(&seq->seqbase)) {
Sequence *seq_child;
for (seq_child = static_cast<Sequence *>(seq->seqbase.first); seq_child;
seq_child = seq_child->next)
{
LISTBASE_FOREACH (Sequence *, seq_child, &seq->seqbase) {
SEQ_transform_translate_sequence(evil_scene, seq_child, delta);
}
/* Move meta start/end points. */