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-10-07 14:52:52 +0300
committerCampbell Barton <campbell@blender.org>2022-10-07 14:55:03 +0300
commit11abeae99fdbfc8f047c4a3c1d2b9b8c47883516 (patch)
treebe27c71b34cba12adf64fa94204a3725cf9cfeee
parent9dec9eee0d38b32ba4254b624c7a27dc22fc4302 (diff)
Cleanup: use function style casts for C++
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc4
-rw-r--r--source/blender/blenkernel/intern/shrinkwrap.cc6
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.cc8
-rw-r--r--source/blender/modifiers/intern/MOD_weighted_normal.cc34
4 files changed, 26 insertions, 26 deletions
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 1b315d29923..a56176b7d9b 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -1840,7 +1840,7 @@ static bool find_rna_property_rgba(PointerRNA *id_ptr, const char *name, float r
value = RNA_property_float_get(&ptr, prop);
}
else if (type == PROP_INT) {
- value = static_cast<float>(RNA_property_int_get(&ptr, prop));
+ value = float(RNA_property_int_get(&ptr, prop));
}
else if (type == PROP_BOOLEAN) {
value = RNA_property_boolean_get(&ptr, prop) ? 1.0f : 0.0f;
@@ -1863,7 +1863,7 @@ static bool find_rna_property_rgba(PointerRNA *id_ptr, const char *name, float r
int tmp[4] = {0, 0, 0, 1};
RNA_property_int_get_array(&ptr, prop, tmp);
for (int i = 0; i < 4; i++) {
- r_data[i] = static_cast<float>(tmp[i]);
+ r_data[i] = float(tmp[i]);
}
return true;
}
diff --git a/source/blender/blenkernel/intern/shrinkwrap.cc b/source/blender/blenkernel/intern/shrinkwrap.cc
index 91683788422..703b012d170 100644
--- a/source/blender/blenkernel/intern/shrinkwrap.cc
+++ b/source/blender/blenkernel/intern/shrinkwrap.cc
@@ -199,7 +199,7 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(Mesh *mesh)
/* Count faces per edge (up to 2). */
char *edge_mode = static_cast<char *>(
- MEM_calloc_arrayN((size_t)mesh->totedge, sizeof(char), __func__));
+ MEM_calloc_arrayN(size_t(mesh->totedge), sizeof(char), __func__));
for (int i = 0; i < mesh->totloop; i++) {
uint eidx = mloop[i].e;
@@ -258,7 +258,7 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(Mesh *mesh)
/* Find boundary vertices and build a mapping table for compact storage of data. */
int *vert_boundary_id = static_cast<int *>(
- MEM_calloc_arrayN((size_t)mesh->totvert, sizeof(int), __func__));
+ MEM_calloc_arrayN(size_t(mesh->totvert), sizeof(int), __func__));
for (int i = 0; i < mesh->totedge; i++) {
if (edge_mode[i]) {
@@ -272,7 +272,7 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(Mesh *mesh)
uint num_boundary_verts = 0;
for (int i = 0; i < mesh->totvert; i++) {
- vert_boundary_id[i] = (vert_boundary_id[i] != 0) ? (int)num_boundary_verts++ : -1;
+ vert_boundary_id[i] = (vert_boundary_id[i] != 0) ? int(num_boundary_verts++) : -1;
}
data->vert_boundary_id = vert_boundary_id;
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.cc b/source/blender/blenkernel/intern/subdiv_ccg.cc
index 704e0690892..f84f15c749b 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.cc
+++ b/source/blender/blenkernel/intern/subdiv_ccg.cc
@@ -129,8 +129,8 @@ static void subdiv_ccg_alloc_elements(SubdivCCG *subdiv_ccg, Subdiv *subdiv)
subdiv_ccg->grids = static_cast<CCGElem **>(
MEM_calloc_arrayN(num_grids, sizeof(CCGElem *), "subdiv ccg grids"));
subdiv_ccg->grids_storage = static_cast<unsigned char *>(MEM_calloc_arrayN(
- num_grids, ((size_t)grid_area) * element_size, "subdiv ccg grids storage"));
- const size_t grid_size_in_bytes = (size_t)grid_area * element_size;
+ num_grids, (size_t(grid_area)) * element_size, "subdiv ccg grids storage"));
+ const size_t grid_size_in_bytes = size_t(grid_area) * element_size;
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
const size_t grid_offset = grid_size_in_bytes * grid_index;
subdiv_ccg->grids[grid_index] = (CCGElem *)&subdiv_ccg->grids_storage[grid_offset];
@@ -241,7 +241,7 @@ static void subdiv_ccg_eval_regular_grid(CCGEvalGridsData *data, const int face_
const float grid_u = x * grid_size_1_inv;
float u, v;
BKE_subdiv_rotate_grid_to_quad(corner, grid_u, grid_v, &u, &v);
- const size_t grid_element_index = (size_t)y * grid_size + x;
+ const size_t grid_element_index = size_t(y) * grid_size + x;
const size_t grid_element_offset = grid_element_index * element_size;
subdiv_ccg_eval_grid_element(data, ptex_face_index, u, v, &grid[grid_element_offset]);
}
@@ -271,7 +271,7 @@ static void subdiv_ccg_eval_special_grid(CCGEvalGridsData *data, const int face_
const float u = 1.0f - (y * grid_size_1_inv);
for (int x = 0; x < grid_size; x++) {
const float v = 1.0f - (x * grid_size_1_inv);
- const size_t grid_element_index = (size_t)y * grid_size + x;
+ const size_t grid_element_index = size_t(y) * grid_size + x;
const size_t grid_element_offset = grid_element_index * element_size;
subdiv_ccg_eval_grid_element(data, ptex_face_index, u, v, &grid[grid_element_offset]);
}
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.cc b/source/blender/modifiers/intern/MOD_weighted_normal.cc
index cb81781479a..e7b1cb45234 100644
--- a/source/blender/modifiers/intern/MOD_weighted_normal.cc
+++ b/source/blender/modifiers/intern/MOD_weighted_normal.cc
@@ -221,7 +221,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
/* This will give us loop normal spaces,
* we do not actually care about computed loop_normals for now... */
loop_normals = static_cast<float(*)[3]>(
- MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__));
+ MEM_calloc_arrayN(size_t(loops_num), sizeof(*loop_normals), __func__));
BKE_mesh_normals_loop_split(mvert,
wn_data->vert_normals,
verts_num,
@@ -241,7 +241,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
items_num = lnors_spacearr.spaces_num;
items_data = static_cast<WeightedNormalDataAggregateItem *>(
- MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__));
+ MEM_calloc_arrayN(size_t(items_num), sizeof(*items_data), __func__));
/* In this first loop, we assign each WeightedNormalDataAggregateItem
* to its smooth fan of loops (aka lnor space). */
@@ -284,7 +284,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
else {
items_num = verts_num;
items_data = static_cast<WeightedNormalDataAggregateItem *>(
- MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__));
+ MEM_calloc_arrayN(size_t(items_num), sizeof(*items_data), __func__));
if (use_face_influence) {
for (int item_index = 0; item_index < items_num; item_index++) {
items_data[item_index].curr_strength = FACE_STRENGTH_WEAK;
@@ -380,7 +380,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
* But think we can live with it for now,
* and it makes code simpler & cleaner. */
float(*vert_normals)[3] = static_cast<float(*)[3]>(
- MEM_calloc_arrayN((size_t)verts_num, sizeof(*loop_normals), __func__));
+ MEM_calloc_arrayN(size_t(verts_num), sizeof(*loop_normals), __func__));
for (int ml_index = 0; ml_index < loops_num; ml_index++) {
const int mv_index = mloop[ml_index].v;
@@ -404,7 +404,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
}
else {
loop_normals = static_cast<float(*)[3]>(
- MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__));
+ MEM_calloc_arrayN(size_t(loops_num), sizeof(*loop_normals), __func__));
BKE_mesh_normals_loop_split(mvert,
wn_data->vert_normals,
@@ -463,7 +463,7 @@ static void wn_face_area(WeightedNormalModifierData *wnmd, WeightedNormalData *w
int mp_index;
ModePair *face_area = static_cast<ModePair *>(
- MEM_malloc_arrayN((size_t)polys_num, sizeof(*face_area), __func__));
+ MEM_malloc_arrayN(size_t(polys_num), sizeof(*face_area), __func__));
ModePair *f_area = face_area;
for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++, f_area++) {
@@ -490,23 +490,23 @@ static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData
int mp_index;
int *loop_to_poly = static_cast<int *>(
- MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__));
+ MEM_malloc_arrayN(size_t(loops_num), sizeof(*loop_to_poly), __func__));
ModePair *corner_angle = static_cast<ModePair *>(
- MEM_malloc_arrayN((size_t)loops_num, sizeof(*corner_angle), __func__));
+ MEM_malloc_arrayN(size_t(loops_num), sizeof(*corner_angle), __func__));
for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++) {
const MLoop *ml_start = &mloop[mp->loopstart];
float *index_angle = static_cast<float *>(
- MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__));
+ MEM_malloc_arrayN(size_t(mp->totloop), sizeof(*index_angle), __func__));
BKE_mesh_calc_poly_angles(mp, ml_start, mvert, index_angle);
ModePair *c_angl = &corner_angle[mp->loopstart];
float *angl = index_angle;
for (int ml_index = mp->loopstart; ml_index < mp->loopstart + mp->totloop;
ml_index++, c_angl++, angl++) {
- c_angl->val = (float)M_PI - *angl;
+ c_angl->val = float(M_PI) - *angl;
c_angl->index = ml_index;
loop_to_poly[ml_index] = mp_index;
@@ -534,17 +534,17 @@ static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalD
int mp_index;
int *loop_to_poly = static_cast<int *>(
- MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__));
+ MEM_malloc_arrayN(size_t(loops_num), sizeof(*loop_to_poly), __func__));
ModePair *combined = static_cast<ModePair *>(
- MEM_malloc_arrayN((size_t)loops_num, sizeof(*combined), __func__));
+ MEM_malloc_arrayN(size_t(loops_num), sizeof(*combined), __func__));
for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++) {
const MLoop *ml_start = &mloop[mp->loopstart];
float face_area = BKE_mesh_calc_poly_area(mp, ml_start, mvert);
float *index_angle = static_cast<float *>(
- MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__));
+ MEM_malloc_arrayN(size_t(mp->totloop), sizeof(*index_angle), __func__));
BKE_mesh_calc_poly_angles(mp, ml_start, mvert, index_angle);
ModePair *cmbnd = &combined[mp->loopstart];
@@ -552,7 +552,7 @@ static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalD
for (int ml_index = mp->loopstart; ml_index < mp->loopstart + mp->totloop;
ml_index++, cmbnd++, angl++) {
/* In this case val is product of corner angle and face area. */
- cmbnd->val = ((float)M_PI - *angl) * face_area;
+ cmbnd->val = (float(M_PI) - *angl) * face_area;
cmbnd->index = ml_index;
loop_to_poly[ml_index] = mp_index;
@@ -606,12 +606,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
* If weight < 50 then more weight given to faces with lesser vals. However current calculation
* does not converge to min/max.
*/
- float weight = ((float)wnmd->weight) / 50.0f;
+ float weight = float(wnmd->weight) / 50.0f;
if (wnmd->weight == 100) {
- weight = (float)SHRT_MAX;
+ weight = float(SHRT_MAX);
}
else if (wnmd->weight == 1) {
- weight = 1 / (float)SHRT_MAX;
+ weight = 1 / float(SHRT_MAX);
}
else if ((weight - 1) * 25 > 1) {
weight = (weight - 1) * 25;