Cleanup: various non functional changes for C++

This commit is contained in:
Campbell Barton
2025-05-15 10:25:32 +10:00
parent 3ec7748485
commit e97e9c2904
11 changed files with 22 additions and 21 deletions

View File

@@ -1128,7 +1128,7 @@ void BLI_rctf_rotate_expand(rctf *dst, const rctf *src, const float angle)
#undef ROTATE_SINCOS
bool BLI_rctf_clamp_segment(const struct rctf *rect, float s1[2], float s2[2])
bool BLI_rctf_clamp_segment(const rctf *rect, float s1[2], float s2[2])
{
using namespace blender;

View File

@@ -3488,7 +3488,7 @@ static void version_escape_curly_braces_in_compositor_file_output_nodes(bNodeTre
}
LISTBASE_FOREACH (bNode *, node, &nodetree.nodes) {
if (strcmp(node->idname, "CompositorNodeOutputFile") != 0) {
if (!STREQ(node->idname, "CompositorNodeOutputFile")) {
continue;
}

View File

@@ -605,7 +605,8 @@ static void ui_searchbox_draw_clip_tri_down(rcti *rect, const float zoom)
zoom * UI_ICON_SIZE;
const float aspect = U.inv_scale_factor / zoom;
GPU_blend(GPU_BLEND_ALPHA);
UI_icon_draw_ex(x, y, ICON_TRIA_DOWN, aspect, 1.0f, 0.0f, NULL, false, UI_NO_ICON_OVERLAY_TEXT);
UI_icon_draw_ex(
x, y, ICON_TRIA_DOWN, aspect, 1.0f, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT);
GPU_blend(GPU_BLEND_NONE);
}
@@ -620,7 +621,7 @@ static void ui_searchbox_draw_clip_tri_up(rcti *rect, const float zoom)
const float y = rect->ymax + (0.5f * zoom * (UI_SEARCHBOX_TRIA_H - UI_ICON_SIZE) - U.pixelsize);
const float aspect = U.inv_scale_factor / zoom;
GPU_blend(GPU_BLEND_ALPHA);
UI_icon_draw_ex(x, y, ICON_TRIA_UP, aspect, 1.0f, 0.0f, NULL, false, UI_NO_ICON_OVERLAY_TEXT);
UI_icon_draw_ex(x, y, ICON_TRIA_UP, aspect, 1.0f, 0.0f, nullptr, false, UI_NO_ICON_OVERLAY_TEXT);
GPU_blend(GPU_BLEND_NONE);
}

View File

@@ -443,7 +443,7 @@ static wmOperatorStatus sequencer_de_select_all_exec(bContext *C, wmOperator *op
}
}
}
if (action == SEL_INVERT || action == SEL_SELECT) {
if (ELEM(action, SEL_INVERT, SEL_SELECT)) {
if (action == SEL_INVERT) {
for (Strip *strip : strips) {
if (strip->flag & STRIP_ALLSEL) {

View File

@@ -132,7 +132,7 @@ static void dump_mesh(const Mesh *mesh, const std::string &name)
if (ELEM(iter.name, "position", ".edge_verts", ".corner_vert", ".corner_edge")) {
return;
}
const int di = static_cast<int8_t>(iter.domain);
const int di = int8_t(iter.domain);
const char *domain = (di >= 0 && di < ATTR_DOMAIN_NUM) ? domain_names[di] : "?";
std::string label = std::string(domain) + ": " + iter.name;
switch (iter.data_type) {
@@ -913,14 +913,14 @@ static bool is_legal_merge(const OutFace &f1, const OutFace &f2, int v1, int v2)
* TODO: if the faces are big, sort both together and look for repeats after sorting.
*/
for (const int v : f1.verts) {
if (v != v1 && v != v2) {
if (!ELEM(v, v1, v2)) {
if (f2.find_vert_index(v) != -1) {
return false;
}
}
}
for (const int v : f2.verts) {
if (v != v1 && v != v2) {
if (!ELEM(v, v1, v2)) {
if (f1.find_vert_index(v) != -1) {
return false;
}

View File

@@ -74,7 +74,7 @@ class DisplayCPUProcessor : public BaseDisplayCPUProcessor {
void apply_rgba_predivide(float rgba[4]) const override
{
if (rgba[3] == 1.0f || rgba[3] == 0.0f) {
if (ELEM(rgba[3], 1.0f, 0.0f)) {
process_rgb(rgba);
return;
}
@@ -184,7 +184,7 @@ std::shared_ptr<const CPUProcessor> create_fallback_display_cpu_processor(
if (display_parameters.view != "Standard") {
return NOOPDisplayCPUProcessor::get();
}
if (display_parameters.look != "" && display_parameters.look != "None") {
if (!ELEM(display_parameters.look, "", "None")) {
return NOOPDisplayCPUProcessor::get();
}

View File

@@ -38,7 +38,7 @@ static bool color_space_is_invertible(const OCIO_NAMESPACE::ConstColorSpaceRcPtr
{
const StringRefNull family = ocio_color_space->getFamily();
if (family == "rrt" || family == "display") {
if (ELEM(family, "rrt", "display")) {
/* assume display and rrt transformations are not invertible in fact some of them could be,
* but it doesn't make much sense to allow use them as invertible. */
return false;

View File

@@ -33,7 +33,7 @@ void LibOCIOCPUProcessor::apply_rgba(float rgba[4]) const
void LibOCIOCPUProcessor::apply_rgba_predivide(float rgba[4]) const
{
if (rgba[3] == 1.0f || rgba[3] == 0.0f) {
if (ELEM(rgba[3], 1.0f, 0.0f)) {
apply_rgba(rgba);
return;
}
@@ -80,7 +80,7 @@ void LibOCIOCPUProcessor::apply_predivide(const PackedImage &image) const
const size_t pixel_count = image.get_width() * image.get_height();
for (size_t i = 0; i < pixel_count; i++, pixel += 4) {
const float alpha = pixel[3];
if (alpha != 0.0f && alpha != 1.0f) {
if (!ELEM(alpha, 0.0f, 1.0f)) {
const float inv_alpha = 1.0f / alpha;
pixel[0] *= inv_alpha;
pixel[1] *= inv_alpha;
@@ -97,7 +97,7 @@ void LibOCIOCPUProcessor::apply_predivide(const PackedImage &image) const
const size_t pixel_count = image.get_width() * image.get_height();
for (size_t i = 0; i < pixel_count; i++, pixel += 4) {
const float alpha = pixel[3];
if (alpha != 0.0f && alpha != 1.0f) {
if (!ELEM(alpha, 0.0f, 1.0f)) {
pixel[0] *= alpha;
pixel[1] *= alpha;
pixel[2] *= alpha;

View File

@@ -59,8 +59,8 @@ static bool add_gpu_lut_1D2D(internal::GPUTextures &textures,
{
const char *texture_name = nullptr;
const char *sampler_name = nullptr;
unsigned int width = 0;
unsigned int height = 0;
uint width = 0;
uint height = 0;
GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL;
Interpolation interpolation = INTERP_LINEAR;
@@ -105,7 +105,7 @@ static bool add_gpu_lut_3D(internal::GPUTextures &textures,
{
const char *texture_name = nullptr;
const char *sampler_name = nullptr;
unsigned int edgelen = 0;
uint edgelen = 0;
Interpolation interpolation = INTERP_LINEAR;
shader_desc->get3DTexture(index, texture_name, sampler_name, edgelen, interpolation);

View File

@@ -882,7 +882,7 @@ class FileOutputOperation : public NodeOperation {
/* Do template expansion on the node's base path. */
char node_base_path[FILE_MAX] = "";
BLI_strncpy(node_base_path, get_base_path(), FILE_MAX);
STRNCPY(node_base_path, get_base_path());
{
blender::Vector<path_templates::Error> errors = BKE_path_apply_template(
node_base_path, FILE_MAX, template_variables);
@@ -895,7 +895,7 @@ class FileOutputOperation : public NodeOperation {
if (base_name[0]) {
/* Do template expansion on the socket's sub path ("base name"). */
char sub_path[FILE_MAX] = "";
BLI_strncpy(sub_path, base_name, FILE_MAX);
STRNCPY(sub_path, base_name);
{
blender::Vector<path_templates::Error> errors = BKE_path_apply_template(
sub_path, FILE_MAX, template_variables);

View File

@@ -58,8 +58,8 @@ static void node_declare(NodeDeclarationBuilder &b)
const auto operation = geometry::boolean::Operation(node->custom1);
const auto solver = geometry::boolean::Solver(node->custom2);
output_edges.available(solver == geometry::boolean::Solver::MeshArr ||
solver == geometry::boolean::Solver::Manifold);
output_edges.available(
ELEM(solver, geometry::boolean::Solver::MeshArr, geometry::boolean::Solver::Manifold));
self_intersect.available(solver == geometry::boolean::Solver::MeshArr);
hole_tolerant.available(solver == geometry::boolean::Solver::MeshArr);