Cleanup: remove redundant cast, use const casts

This commit is contained in:
2021-06-08 00:11:05 +10:00
parent dfac5a63bd
commit 72d2355af5
11 changed files with 20 additions and 21 deletions

View File

@@ -50,7 +50,7 @@ void BKE_volume_dense_float_grid_clear(DenseFloatVolumeGrid *dense_grid);
/* Wireframe */
typedef void (*BKE_volume_wireframe_cb)(
void *userdata, float (*verts)[3], int (*edges)[2], int totvert, int totedge);
void *userdata, const float (*verts)[3], const int (*edges)[2], int totvert, int totedge);
void BKE_volume_grid_wireframe(const struct Volume *volume,
const struct VolumeGrid *volume_grid,

View File

@@ -2351,7 +2351,7 @@ float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array)
}
/* finally calculate the area */
area = area_poly_v2((const float(*)[2])vertexcos, (unsigned int)mpoly->totloop);
area = area_poly_v2(vertexcos, (uint)mpoly->totloop);
return area;
}

View File

@@ -2399,8 +2399,7 @@ void BKE_mesh_remap_calc_polys_from_mesh(const int mode,
}
tot_rays *= tot_rays;
poly_area_2d_inv = area_poly_v2((const float(*)[2])poly_vcos_2d,
(unsigned int)mp->totloop);
poly_area_2d_inv = area_poly_v2(poly_vcos_2d, (uint)mp->totloop);
/* In case we have a null-area degenerated poly... */
poly_area_2d_inv = 1.0f / max_ff(poly_area_2d_inv, 1e-9f);

View File

@@ -534,7 +534,7 @@ void BM_mesh_normals_update(BMesh *bm)
bm_mesh_edges_calc_vectors(bm, edgevec, NULL);
/* Add weighted face normals to vertices, and normalize vert normals. */
bm_mesh_verts_calc_normals(bm, (const float(*)[3])edgevec, NULL, NULL, NULL);
bm_mesh_verts_calc_normals(bm, edgevec, NULL, NULL, NULL);
MEM_freeN(edgevec);
}
@@ -681,7 +681,7 @@ void BM_verts_calc_normal_vcos(BMesh *bm,
bm_mesh_edges_calc_vectors(bm, edgevec, vcos);
/* Add weighted face normals to vertices, and normalize vert normals. */
bm_mesh_verts_calc_normals(bm, (const float(*)[3])edgevec, fnos, vcos, vnos);
bm_mesh_verts_calc_normals(bm, edgevec, fnos, vcos, vnos);
MEM_freeN(edgevec);
}

View File

@@ -421,10 +421,10 @@ void BMO_slot_mat_set(BMOperator *op,
slot->data.p = BLI_memarena_alloc(op->arena, sizeof(float[4][4]));
if (size == 4) {
copy_m4_m4(slot->data.p, (float(*)[4])mat);
copy_m4_m4(slot->data.p, (const float(*)[4])mat);
}
else if (size == 3) {
copy_m4_m3(slot->data.p, (float(*)[3])mat);
copy_m4_m3(slot->data.p, (const float(*)[3])mat);
}
else {
fprintf(stderr, "%s: invalid size argument %d (bmesh internal error)\n", __func__, size);

View File

@@ -180,8 +180,8 @@ static void min_dist_dir_update(MinDistDir *dist, const float dist_dir[3])
static int state_isect_co_pair(const PathContext *pc, const float co_a[3], const float co_b[3])
{
const float diff_a = dot_m3_v3_row_x((float(*)[3])pc->matrix, co_a) - pc->axis_sep;
const float diff_b = dot_m3_v3_row_x((float(*)[3])pc->matrix, co_b) - pc->axis_sep;
const float diff_a = dot_m3_v3_row_x(pc->matrix, co_a) - pc->axis_sep;
const float diff_b = dot_m3_v3_row_x(pc->matrix, co_b) - pc->axis_sep;
const int test_a = (fabsf(diff_a) < CONNECT_EPS) ? 0 : (diff_a < 0.0f) ? -1 : 1;
const int test_b = (fabsf(diff_b) < CONNECT_EPS) ? 0 : (diff_b < 0.0f) ? -1 : 1;
@@ -194,7 +194,7 @@ static int state_isect_co_pair(const PathContext *pc, const float co_a[3], const
static int state_isect_co_exact(const PathContext *pc, const float co[3])
{
const float diff = dot_m3_v3_row_x((float(*)[3])pc->matrix, co) - pc->axis_sep;
const float diff = dot_m3_v3_row_x(pc->matrix, co) - pc->axis_sep;
return (fabsf(diff) <= CONNECT_EPS);
}
@@ -204,8 +204,8 @@ static float state_calc_co_pair_fac(const PathContext *pc,
{
float diff_a, diff_b, diff_tot;
diff_a = fabsf(dot_m3_v3_row_x((float(*)[3])pc->matrix, co_a) - pc->axis_sep);
diff_b = fabsf(dot_m3_v3_row_x((float(*)[3])pc->matrix, co_b) - pc->axis_sep);
diff_a = fabsf(dot_m3_v3_row_x(pc->matrix, co_a) - pc->axis_sep);
diff_b = fabsf(dot_m3_v3_row_x(pc->matrix, co_b) - pc->axis_sep);
diff_tot = (diff_a + diff_b);
return (diff_tot > FLT_EPSILON) ? (diff_a / diff_tot) : 0.5f;
}

View File

@@ -469,7 +469,7 @@ static void displist_surf_fnors_ensure(const DispList *dl, float (**fnors)[3])
{
int u_len = dl->nr - ((dl->flag & DL_CYCL_U) ? 0 : 1);
int v_len = dl->parts - ((dl->flag & DL_CYCL_V) ? 0 : 1);
const float(*verts)[3] = (float(*)[3])dl->verts;
const float(*verts)[3] = (const float(*)[3])dl->verts;
float(*nor_flat)[3] = MEM_mallocN(sizeof(float[3]) * u_len * v_len, __func__);
*fnors = nor_flat;
@@ -559,8 +559,8 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb,
LISTBASE_FOREACH (const DispList *, dl, lb) {
const bool is_smooth = (dl->rt & CU_SMOOTH) != 0;
if (ELEM(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
const float(*verts)[3] = (float(*)[3])dl->verts;
const float(*nors)[3] = (float(*)[3])dl->nors;
const float(*verts)[3] = (const float(*)[3])dl->verts;
const float(*nors)[3] = (const float(*)[3])dl->nors;
const int *idx = dl->index;
float uv[4][2];

View File

@@ -152,7 +152,7 @@ typedef struct VolumeWireframeUserData {
} VolumeWireframeUserData;
static void drw_volume_wireframe_cb(
void *userdata, float (*verts)[3], int (*edges)[2], int totvert, int totedge)
void *userdata, const float (*verts)[3], const int (*edges)[2], int totvert, int totedge)
{
VolumeWireframeUserData *data = userdata;
Scene *scene = data->scene;

View File

@@ -434,7 +434,7 @@ static void py_bvhtree_nearest_point_range_cb(void *userdata,
struct PyBVH_RangeData *data = userdata;
PyBVHTree *self = data->self;
const float(*coords)[3] = (const float(*)[3])self->coords;
const float(*coords)[3] = self->coords;
const uint *tri = self->tris[index];
const float *tri_co[3] = {coords[tri[0]], coords[tri[1]], coords[tri[2]]};
float nearest_tmp[3], dist_sq;

View File

@@ -349,7 +349,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args)
goto finally;
}
normal_poly_v3(n, (const float(*)[3])coords, coords_len);
normal_poly_v3(n, coords, coords_len);
ret = Vector_CreatePyObject(n, 3, NULL);
finally:

View File

@@ -385,7 +385,7 @@ static void draw_filled_lasso(wmGesture *gt)
mcoords[i][1] = lasso[1];
}
BLI_lasso_boundbox(&rect, (const int(*)[2])mcoords, mcoords_len);
BLI_lasso_boundbox(&rect, mcoords, mcoords_len);
BLI_rcti_translate(&rect, gt->winrct.xmin, gt->winrct.ymin);
BLI_rcti_isect(&gt->winrct, &rect, &rect);
@@ -402,7 +402,7 @@ static void draw_filled_lasso(wmGesture *gt)
rect.ymin,
rect.xmax,
rect.ymax,
(const int(*)[2])mcoords,
mcoords,
mcoords_len,
draw_filled_lasso_px_cb,
&lasso_fill_data);