Cleanup: use function style casts in C++

This commit is contained in:
Campbell Barton 2023-02-06 12:35:51 +11:00
parent 731c3efd97
commit d6b6050e5b
5 changed files with 17 additions and 20 deletions

View File

@ -393,8 +393,8 @@ int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden,
/* grid hidden layer is present, so have to check each grid for
* visibility */
int depth1 = int(log2((double)gridsize - 1.0) + DBL_EPSILON);
int depth2 = int(log2((double)display_gridsize - 1.0) + DBL_EPSILON);
int depth1 = int(log2(double(gridsize) - 1.0) + DBL_EPSILON);
int depth2 = int(log2(double(display_gridsize) - 1.0) + DBL_EPSILON);
int skip = depth2 < depth1 ? 1 << (depth1 - depth2 - 1) : 1;
@ -3667,7 +3667,7 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
}
BMFace *f = (BMFace *)BLI_gsetIterator_getKey(&fd->bm_faces_iter_);
fd->face.i = (intptr_t)f;
fd->face.i = intptr_t(f);
fd->index = f->head.index;
if (fd->cd_face_set_ != -1) {
@ -3683,7 +3683,7 @@ static void pbvh_face_iter_step(PBVHFaceIter *fd, bool do_step)
BMLoop *l = f->l_first;
do {
fd->verts[vertex_i++].i = (intptr_t)l->v;
fd->verts[vertex_i++].i = intptr_t(l->v);
} while ((l = l->next) != f->l_first);
break;

View File

@ -1528,7 +1528,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
if (j == 0 || len_squared_v3v3(location, cos[j]) <
len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, cos[j]);
r_active_vertex->i = (intptr_t)node->bm_orvert[node->bm_ortri[i][j]];
r_active_vertex->i = intptr_t(node->bm_orvert[node->bm_ortri[i][j]]);
}
}
}
@ -1560,7 +1560,7 @@ bool pbvh_bmesh_node_raycast(PBVHNode *node,
if (j == 0 || len_squared_v3v3(location, v_tri[j]->co) <
len_squared_v3v3(location, nearest_vertex_co)) {
copy_v3_v3(nearest_vertex_co, v_tri[j]->co);
r_active_vertex->i = (intptr_t)v_tri[j];
r_active_vertex->i = intptr_t(v_tri[j]);
}
}
}

View File

@ -116,7 +116,7 @@ static void split_pixel_node(
const int axis = BB_widest_axis(&cb);
const float mid = (cb.bmax[axis] + cb.bmin[axis]) * 0.5f;
node->flag = (PBVHNodeFlags)((int)node->flag & (int)~PBVH_TexLeaf);
node->flag = (PBVHNodeFlags)(int(node->flag) & int(~PBVH_TexLeaf));
SplitNodePair *split1 = MEM_new<SplitNodePair>("split_pixel_node split1", split);
SplitNodePair *split2 = MEM_new<SplitNodePair>("split_pixel_node split1", split);
@ -188,7 +188,7 @@ static void split_pixel_node(
float2 delta = uv_prim.delta_barycentric_coord_u;
float2 uv1 = row.start_barycentric_coord;
float2 uv2 = row.start_barycentric_coord + delta * (float)row.num_pixels;
float2 uv2 = row.start_barycentric_coord + delta * float(row.num_pixels);
float co1[3];
float co2[3];
@ -210,7 +210,7 @@ static void split_pixel_node(
t = (mid - co1[axis]) / (co2[axis] - co1[axis]);
}
int num_pixels = (int)floorf((float)row.num_pixels * t);
int num_pixels = int(floorf(float(row.num_pixels) * t));
if (num_pixels) {
row1.num_pixels = num_pixels;
@ -223,7 +223,7 @@ static void split_pixel_node(
row2.num_pixels = row.num_pixels - num_pixels;
row2.start_barycentric_coord = row.start_barycentric_coord +
uv_prim.delta_barycentric_coord_u * (float)num_pixels;
uv_prim.delta_barycentric_coord_u * float(num_pixels);
row2.start_image_coordinate = row.start_image_coordinate;
row2.start_image_coordinate[0] += num_pixels;
@ -731,7 +731,7 @@ static bool update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image
PBVHNode &node = pbvh->nodes[i];
if (node.flag & PBVH_Leaf) {
node.flag = (PBVHNodeFlags)((int)node.flag | (int)PBVH_TexLeaf);
node.flag = (PBVHNodeFlags)(int(node.flag) | int(PBVH_TexLeaf));
}
}

View File

@ -76,8 +76,7 @@ void MeshPass::draw(ObjectRef &ref,
}
if (texture) {
auto add_cb = [&] {
PassMain::Sub *sub_pass =
passes_[static_cast<int>(geometry_type)][static_cast<int>(eShaderType::TEXTURE)];
PassMain::Sub *sub_pass = passes_[int(geometry_type)][int(eShaderType::TEXTURE)];
sub_pass = &sub_pass->sub(image->id.name);
if (tilemap) {
sub_pass->bind_texture(WB_TILE_ARRAY_SLOT, texture, sampler_state);
@ -100,8 +99,7 @@ void MeshPass::draw(ObjectRef &ref,
return;
}
}
passes_[static_cast<int>(geometry_type)][static_cast<int>(eShaderType::MATERIAL)]->draw(batch,
handle);
passes_[int(geometry_type)][int(eShaderType::MATERIAL)]->draw(batch, handle);
}
/** \} */

View File

@ -34,9 +34,8 @@ GPUShader *ShaderCache::prepass_shader_get(ePipelineType pipeline_type,
eLightingType lighting_type,
bool clip)
{
GPUShader *&shader_ptr = prepass_shader_cache_[static_cast<int>(pipeline_type)][static_cast<int>(
geometry_type)][static_cast<int>(shader_type)][static_cast<int>(lighting_type)]
[clip ? 1 : 0];
GPUShader *&shader_ptr = prepass_shader_cache_[int(pipeline_type)][int(geometry_type)][int(
shader_type)][int(lighting_type)][clip ? 1 : 0];
if (shader_ptr != nullptr) {
return shader_ptr;
@ -93,8 +92,8 @@ GPUShader *ShaderCache::resolve_shader_get(ePipelineType pipeline_type,
bool cavity,
bool curvature)
{
GPUShader *&shader_ptr = resolve_shader_cache_[static_cast<int>(pipeline_type)][static_cast<int>(
lighting_type)][cavity][curvature];
GPUShader *&shader_ptr =
resolve_shader_cache_[int(pipeline_type)][int(lighting_type)][cavity][curvature];
if (shader_ptr != nullptr) {
return shader_ptr;