Cleanup: Declare variables where initialized

This commit is contained in:
Hans Goudey 2020-12-27 21:46:57 -06:00
parent 57fe65b17e
commit e590d2d167
2 changed files with 12 additions and 26 deletions

View File

@ -845,9 +845,7 @@ static void mesh_tessface_clear_intern(Mesh *mesh, int free_customdata)
Mesh *BKE_mesh_add(Main *bmain, const char *name)
{
Mesh *me;
me = BKE_id_new(bmain, ID_ME, name);
Mesh *me = BKE_id_new(bmain, ID_ME, name);
return me;
}
@ -1007,10 +1005,9 @@ BMesh *BKE_mesh_to_bmesh_ex(const Mesh *me,
const struct BMeshCreateParams *create_params,
const struct BMeshFromMeshParams *convert_params)
{
BMesh *bm;
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me);
bm = BM_mesh_create(&allocsize, create_params);
BMesh *bm = BM_mesh_create(&allocsize, create_params);
BM_mesh_bm_from_me(bm, me, convert_params);
return bm;
@ -1162,17 +1159,14 @@ void BKE_mesh_texspace_copy_from_object(Mesh *me, Object *ob)
float (*BKE_mesh_orco_verts_get(Object *ob))[3]
{
Mesh *me = ob->data;
MVert *mvert = NULL;
Mesh *tme = me->texcomesh ? me->texcomesh : me;
int a, totvert;
float(*vcos)[3] = NULL;
/* Get appropriate vertex coordinates */
vcos = MEM_calloc_arrayN(me->totvert, sizeof(*vcos), "orco mesh");
mvert = tme->mvert;
totvert = min_ii(tme->totvert, me->totvert);
float(*vcos)[3] = MEM_calloc_arrayN(me->totvert, sizeof(*vcos), "orco mesh");
MVert *mvert = tme->mvert;
int totvert = min_ii(tme->totvert, me->totvert);
for (a = 0; a < totvert; a++, mvert++) {
for (int a = 0; a < totvert; a++, mvert++) {
copy_v3_v3(vcos[a], mvert->co);
}
@ -1182,18 +1176,17 @@ float (*BKE_mesh_orco_verts_get(Object *ob))[3]
void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert)
{
float loc[3], size[3];
int a;
BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, size);
if (invert) {
for (a = 0; a < totvert; a++) {
for (int a = 0; a < totvert; a++) {
float *co = orco[a];
madd_v3_v3v3v3(co, loc, co, size);
}
}
else {
for (a = 0; a < totvert; a++) {
for (int a = 0; a < totvert; a++) {
float *co = orco[a];
co[0] = (co[0] - loc[0]) / size[0];
co[1] = (co[1] - loc[1]) / size[1];
@ -1274,7 +1267,6 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr)
Mesh *BKE_mesh_from_object(Object *ob)
{
if (ob == NULL) {
return NULL;
}
@ -1414,8 +1406,7 @@ void BKE_mesh_smooth_flag_set(Mesh *me, const bool use_smooth)
*/
int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, uint vert)
{
int j;
for (j = 0; j < poly->totloop; j++, loopstart++) {
for (int j = 0; j < poly->totloop; j++, loopstart++) {
if (loopstart->v == vert) {
return j;
}
@ -1682,11 +1673,9 @@ void BKE_mesh_mselect_validate(Mesh *me)
*/
int BKE_mesh_mselect_find(Mesh *me, int index, int type)
{
int i;
BLI_assert(ELEM(type, ME_VSEL, ME_ESEL, ME_FSEL));
for (i = 0; i < me->totselect; i++) {
for (int i = 0; i < me->totselect; i++) {
if ((me->mselect[i].index == index) && (me->mselect[i].type == type)) {
return i;
}

View File

@ -154,12 +154,10 @@ int BKE_mesh_runtime_looptri_len(const Mesh *mesh)
/* This is a ported copy of dm_getLoopTriArray(dm). */
const MLoopTri *BKE_mesh_runtime_looptri_ensure(Mesh *mesh)
{
MLoopTri *looptri;
ThreadMutex *mesh_eval_mutex = (ThreadMutex *)mesh->runtime.eval_mutex;
BLI_mutex_lock(mesh_eval_mutex);
looptri = mesh->runtime.looptris.array;
MLoopTri *looptri = mesh->runtime.looptris.array;
if (looptri != NULL) {
BLI_assert(BKE_mesh_runtime_looptri_len(mesh) == mesh->runtime.looptris.len);
@ -180,8 +178,7 @@ void BKE_mesh_runtime_verttri_from_looptri(MVertTri *r_verttri,
const MLoopTri *looptri,
int looptri_num)
{
int i;
for (i = 0; i < looptri_num; i++) {
for (int i = 0; i < looptri_num; i++) {
r_verttri[i].tri[0] = mloop[looptri[i].tri[0]].v;
r_verttri[i].tri[1] = mloop[looptri[i].tri[1]].v;
r_verttri[i].tri[2] = mloop[looptri[i].tri[2]].v;