Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-25 13:27:46 +0300
committerCampbell Barton <campbell@blender.org>2022-09-25 15:31:31 +0300
commit21d77a417e17ac92bfc10dbd742c867d4019ce69 (patch)
treeec664b5c6ca7882bcc5a1e1ce09cad67b842af9d /source/blender/blenkernel
parentd35a10134cfdbd3e24a56218ef3f05aac2a2fc7e (diff)
Cleanup: replace C-style casts with functional casts for numeric types
Some changes missed from f68cfd6bb078482c4a779a6e26a56e2734edb5b8.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/curveprofile.cc14
-rw-r--r--source/blender/blenkernel/intern/customdata.cc22
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.cc26
-rw-r--r--source/blender/blenkernel/intern/mesh_normals.cc12
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc2
-rw-r--r--source/blender/blenkernel/intern/scene.cc4
6 files changed, 40 insertions, 40 deletions
diff --git a/source/blender/blenkernel/intern/curveprofile.cc b/source/blender/blenkernel/intern/curveprofile.cc
index 5cff804cb18..db0cf16d467 100644
--- a/source/blender/blenkernel/intern/curveprofile.cc
+++ b/source/blender/blenkernel/intern/curveprofile.cc
@@ -1048,13 +1048,13 @@ void BKE_curveprofile_evaluate_length_portion(const CurveProfile *profile,
#ifdef DEBUG_CURVEPROFILE_EVALUATE
printf("CURVEPROFILE EVALUATE\n");
- printf(" length portion input: %f\n", (double)length_portion);
- printf(" requested path length: %f\n", (double)requested_length);
- printf(" distance to next point: %f\n", (double)distance_to_next_point);
- printf(" length travelled: %f\n", (double)length_travelled);
- printf(" lerp-factor: %f\n", (double)lerp_factor);
- printf(" ith point (%f, %f)\n", (double)profile->path[i].x, (double)profile->path[i].y);
- printf(" next point(%f, %f)\n", (double)profile->path[i + 1].x, (double)profile->path[i + 1].y);
+ printf(" length portion input: %f\n", double(length_portion));
+ printf(" requested path length: %f\n", double(requested_length));
+ printf(" distance to next point: %f\n", double(distance_to_next_point));
+ printf(" length travelled: %f\n", double(length_travelled));
+ printf(" lerp-factor: %f\n", double(lerp_factor));
+ printf(" ith point (%f, %f)\n", double(profile->path[i].x), double(profile->path[i].y));
+ printf(" next point(%f, %f)\n", double(profile->path[i + 1].x), double(profile->path[i + 1].y));
#endif
*x_out = interpf(profile->table[i].x, profile->table[i + 1].x, lerp_factor);
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 0968f9a8a01..3acd7bb0c80 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4278,7 +4278,7 @@ void CustomData_bmesh_interp(CustomData *data,
float *default_weights = nullptr;
if (weights == nullptr) {
default_weights = (count > SOURCE_BUF_SIZE) ?
- (float *)MEM_mallocN(sizeof(*weights) * (size_t)count, __func__) :
+ (float *)MEM_mallocN(sizeof(*weights) * size_t(count), __func__) :
default_weights_buf;
copy_vn_fl(default_weights, count, 1.0f / count);
weights = default_weights;
@@ -4341,7 +4341,7 @@ void CustomData_to_bmesh_block(const CustomData *source,
void *dest_data = POINTER_OFFSET(*dest_block, offset);
const LayerTypeInfo *typeInfo = layerType_getInfo(dest->layers[dest_i].type);
- const size_t src_offset = (size_t)src_index * typeInfo->size;
+ const size_t src_offset = size_t(src_index) * typeInfo->size;
if (typeInfo->copy) {
typeInfo->copy(POINTER_OFFSET(src_data, src_offset), dest_data, 1);
@@ -4393,7 +4393,7 @@ void CustomData_from_bmesh_block(const CustomData *source,
int offset = source->layers[src_i].offset;
const void *src_data = POINTER_OFFSET(src_block, offset);
void *dst_data = POINTER_OFFSET(dest->layers[dest_i].data,
- (size_t)dest_index * typeInfo->size);
+ size_t(dest_index) * typeInfo->size);
if (typeInfo->copy) {
typeInfo->copy(src_data, dst_data, 1);
@@ -4998,13 +4998,13 @@ static bool check_bit_flag(const void *data, const size_t data_size, const uint6
{
switch (data_size) {
case 1:
- return ((*((uint8_t *)data) & ((uint8_t)flag)) != 0);
+ return ((*((uint8_t *)data) & uint8_t(flag)) != 0);
case 2:
- return ((*((uint16_t *)data) & ((uint16_t)flag)) != 0);
+ return ((*((uint16_t *)data) & uint16_t(flag)) != 0);
case 4:
- return ((*((uint32_t *)data) & ((uint32_t)flag)) != 0);
+ return ((*((uint32_t *)data) & uint32_t(flag)) != 0);
case 8:
- return ((*((uint64_t *)data) & ((uint64_t)flag)) != 0);
+ return ((*((uint64_t *)data) & uint64_t(flag)) != 0);
default:
// CLOG_ERROR(&LOG, "Unknown flags-container size (%zu)", datasize);
return false;
@@ -5047,7 +5047,7 @@ static void customdata_data_transfer_interp_generic(const CustomDataTransferLaye
else {
const LayerTypeInfo *type_info = layerType_getInfo(data_type);
- data_size = (size_t)type_info->size;
+ data_size = size_t(type_info->size);
interp_cd = type_info->interp;
copy_cd = type_info->copy;
}
@@ -5200,7 +5200,7 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap,
const LayerTypeInfo *type_info = layerType_getInfo(data_type);
/* NOTE: we can use 'fake' CDLayers for crease :/. */
- data_size = (size_t)type_info->size;
+ data_size = size_t(type_info->size);
data_step = laymap->elem_size ? laymap->elem_size : data_size;
data_offset = laymap->data_offset;
}
@@ -5219,13 +5219,13 @@ void CustomData_data_transfer(const MeshPairRemap *me_remap,
if (tmp_data_src) {
if (UNLIKELY(sources_num > tmp_buff_size)) {
- tmp_buff_size = (size_t)sources_num;
+ tmp_buff_size = size_t(sources_num);
tmp_data_src = (const void **)MEM_reallocN((void *)tmp_data_src,
sizeof(*tmp_data_src) * tmp_buff_size);
}
for (int j = 0; j < sources_num; j++) {
- const size_t src_idx = (size_t)mapit->indices_src[j];
+ const size_t src_idx = size_t(mapit->indices_src[j]);
tmp_data_src[j] = POINTER_OFFSET(data_src, (data_step * src_idx) + data_offset);
}
}
diff --git a/source/blender/blenkernel/intern/mesh_mapping.cc b/source/blender/blenkernel/intern/mesh_mapping.cc
index bd3902298b2..2db0adce033 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@ -623,8 +623,8 @@ static void poly_edge_loop_islands_calc(const MEdge *medge,
&edge_poly_map, &edge_poly_mem, medge, totedge, mpoly, totpoly, mloop, totloop);
}
- poly_groups = static_cast<int *>(MEM_callocN(sizeof(int) * (size_t)totpoly, __func__));
- poly_stack = static_cast<int *>(MEM_mallocN(sizeof(int) * (size_t)totpoly, __func__));
+ poly_groups = static_cast<int *>(MEM_callocN(sizeof(int) * size_t(totpoly), __func__));
+ poly_stack = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totpoly), __func__));
while (true) {
int poly;
@@ -838,7 +838,7 @@ void BKE_mesh_loop_islands_init(MeshIslandStore *island_store,
island_store->item_type = item_type;
island_store->items_to_islands_num = items_num;
island_store->items_to_islands = static_cast<int *>(
- BLI_memarena_alloc(mem, sizeof(*island_store->items_to_islands) * (size_t)items_num));
+ BLI_memarena_alloc(mem, sizeof(*island_store->items_to_islands) * size_t(items_num)));
island_store->island_type = island_type;
island_store->islands_num_alloc = MISLAND_DEFAULT_BUFSIZE;
@@ -890,7 +890,7 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
MeshElemMap *isld, *innrcut;
const int curr_island_idx = island_store->islands_num++;
- const size_t curr_num_islands = (size_t)island_store->islands_num;
+ const size_t curr_num_islands = size_t(island_store->islands_num);
int i = item_num;
while (i--) {
@@ -916,17 +916,17 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
BLI_memarena_alloc(mem, sizeof(*isld)));
isld->count = num_island_items;
isld->indices = static_cast<int *>(
- BLI_memarena_alloc(mem, sizeof(*isld->indices) * (size_t)num_island_items));
- memcpy(isld->indices, island_item_indices, sizeof(*isld->indices) * (size_t)num_island_items);
+ BLI_memarena_alloc(mem, sizeof(*isld->indices) * size_t(num_island_items)));
+ memcpy(isld->indices, island_item_indices, sizeof(*isld->indices) * size_t(num_island_items));
island_store->innercuts[curr_island_idx] = innrcut = static_cast<MeshElemMap *>(
BLI_memarena_alloc(mem, sizeof(*innrcut)));
innrcut->count = num_innercut_items;
innrcut->indices = static_cast<int *>(
- BLI_memarena_alloc(mem, sizeof(*innrcut->indices) * (size_t)num_innercut_items));
+ BLI_memarena_alloc(mem, sizeof(*innrcut->indices) * size_t(num_innercut_items)));
memcpy(innrcut->indices,
innercut_item_indices,
- sizeof(*innrcut->indices) * (size_t)num_innercut_items);
+ sizeof(*innrcut->indices) * size_t(num_innercut_items));
}
/* TODO: I'm not sure edge seam flag is enough to define UV islands?
@@ -1066,22 +1066,22 @@ static bool mesh_calc_islands_loop_poly_uv(const MVert *UNUSED(verts),
if (num_edge_borders) {
edge_border_count = static_cast<char *>(
- MEM_mallocN(sizeof(*edge_border_count) * (size_t)totedge, __func__));
+ MEM_mallocN(sizeof(*edge_border_count) * size_t(totedge), __func__));
edge_innercut_indices = static_cast<int *>(
- MEM_mallocN(sizeof(*edge_innercut_indices) * (size_t)num_edge_borders, __func__));
+ MEM_mallocN(sizeof(*edge_innercut_indices) * size_t(num_edge_borders), __func__));
}
poly_indices = static_cast<int *>(
- MEM_mallocN(sizeof(*poly_indices) * (size_t)totpoly, __func__));
+ MEM_mallocN(sizeof(*poly_indices) * size_t(totpoly), __func__));
loop_indices = static_cast<int *>(
- MEM_mallocN(sizeof(*loop_indices) * (size_t)totloop, __func__));
+ MEM_mallocN(sizeof(*loop_indices) * size_t(totloop), __func__));
/* NOTE: here we ignore '0' invalid group - this should *never* happen in this case anyway? */
for (grp_idx = 1; grp_idx <= num_poly_groups; grp_idx++) {
num_pidx = num_lidx = 0;
if (num_edge_borders) {
num_einnercuts = 0;
- memset(edge_border_count, 0, sizeof(*edge_border_count) * (size_t)totedge);
+ memset(edge_border_count, 0, sizeof(*edge_border_count) * size_t(totedge));
}
for (p_idx = 0; p_idx < totpoly; p_idx++) {
diff --git a/source/blender/blenkernel/intern/mesh_normals.cc b/source/blender/blenkernel/intern/mesh_normals.cc
index 3eeebc8485a..450c6f36568 100644
--- a/source/blender/blenkernel/intern/mesh_normals.cc
+++ b/source/blender/blenkernel/intern/mesh_normals.cc
@@ -1670,12 +1670,12 @@ void BKE_mesh_normals_loop_split(const MVert *mverts,
* to retrieve the real value later in code).
* Note also that loose edges always have both values set to 0! */
int(*edge_to_loops)[2] = (int(*)[2])MEM_calloc_arrayN(
- (size_t)numEdges, sizeof(*edge_to_loops), __func__);
+ size_t(numEdges), sizeof(*edge_to_loops), __func__);
/* Simple mapping from a loop to its polygon index. */
int *loop_to_poly = r_loop_to_poly ? r_loop_to_poly :
(int *)MEM_malloc_arrayN(
- (size_t)numLoops, sizeof(*loop_to_poly), __func__);
+ size_t(numLoops), sizeof(*loop_to_poly), __func__);
/* When using custom loop normals, disable the angle feature! */
const bool check_angle = (split_angle < (float)M_PI) && (clnors_data == nullptr);
@@ -1779,8 +1779,8 @@ static void mesh_normals_loop_custom_set(const MVert *mverts,
* So better to keep some simplicity here, and just call #BKE_mesh_normals_loop_split() twice! */
MLoopNorSpaceArray lnors_spacearr = {nullptr};
BitVector<> done_loops(numLoops, false);
- float(*lnors)[3] = (float(*)[3])MEM_calloc_arrayN((size_t)numLoops, sizeof(*lnors), __func__);
- int *loop_to_poly = (int *)MEM_malloc_arrayN((size_t)numLoops, sizeof(int), __func__);
+ float(*lnors)[3] = (float(*)[3])MEM_calloc_arrayN(size_t(numLoops), sizeof(*lnors), __func__);
+ int *loop_to_poly = (int *)MEM_malloc_arrayN(size_t(numLoops), sizeof(int), __func__);
/* In this case we always consider split nors as ON,
* and do not want to use angle to define smooth fans! */
const bool use_split_normals = true;
@@ -2056,7 +2056,7 @@ static void mesh_set_custom_normals(Mesh *mesh, float (*r_custom_nors)[3], const
clnors = (short(*)[2])CustomData_get_layer(&mesh->ldata, CD_CUSTOMLOOPNORMAL);
if (clnors != nullptr) {
- memset(clnors, 0, sizeof(*clnors) * (size_t)numloops);
+ memset(clnors, 0, sizeof(*clnors) * size_t(numloops));
}
else {
clnors = (short(*)[2])CustomData_add_layer(
@@ -2099,7 +2099,7 @@ void BKE_mesh_normals_loop_to_vertex(const int numVerts,
float (*r_vert_clnors)[3])
{
int *vert_loops_count = (int *)MEM_calloc_arrayN(
- (size_t)numVerts, sizeof(*vert_loops_count), __func__);
+ size_t(numVerts), sizeof(*vert_loops_count), __func__);
copy_vn_fl((float *)r_vert_clnors, 3 * numVerts, 0.0f);
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 4d9b4baaffc..e28aaabb4e1 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -1326,7 +1326,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END;
}
- oblist = (Object **)MEM_callocN((size_t)totcollection * sizeof(Object *),
+ oblist = (Object **)MEM_callocN(size_t(totcollection) * sizeof(Object *),
"dupcollection object list");
if (use_collection_count) {
diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc
index bc2235f9205..7959ab845e8 100644
--- a/source/blender/blenkernel/intern/scene.cc
+++ b/source/blender/blenkernel/intern/scene.cc
@@ -2425,7 +2425,7 @@ float BKE_scene_frame_get(const Scene *scene)
void BKE_scene_frame_set(Scene *scene, float frame)
{
double intpart;
- scene->r.subframe = modf((double)frame, &intpart);
+ scene->r.subframe = modf(double(frame), &intpart);
scene->r.cfra = int(intpart);
}
@@ -2997,7 +2997,7 @@ double BKE_scene_unit_scale(const UnitSettings *unit, const int unit_type, doubl
case B_UNIT_LENGTH:
case B_UNIT_VELOCITY:
case B_UNIT_ACCELERATION:
- return value * (double)unit->scale_length;
+ return value * double(unit->scale_length);
case B_UNIT_AREA:
case B_UNIT_POWER:
return value * pow(unit->scale_length, 2);