Cleanup: reduce variable scope

This commit is contained in:
Campbell Barton 2022-08-26 12:51:46 +10:00
parent a3e1a9e2aa
commit 6fc7b37583
16 changed files with 29 additions and 38 deletions

View File

@ -403,7 +403,7 @@ void do_kink(ParticleKey *state,
float obmat[4][4],
int smooth_start)
{
float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3], q1[4] = {1.0f, 0.0f, 0.0f, 0.0f};
float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3];
float t, dt = 1.0f, result[3];
if (ELEM(type, PART_KINK_NO, PART_KINK_SPIRAL)) {
@ -453,6 +453,7 @@ void do_kink(ParticleKey *state,
switch (type) {
case PART_KINK_CURL: {
float curl_offset[3];
float q1[4] = {1.0f, 0.0f, 0.0f, 0.0f};
/* rotate kink vector around strand tangent */
mul_v3_v3fl(curl_offset, kink, amplitude);

View File

@ -81,7 +81,6 @@ static void detect_retrieve_libmv_features(MovieTracking *tracking,
a = libmv_countFeatures(features);
while (a--) {
MovieTrackingTrack *track;
double x, y, size, score;
bool ok = true;
float xu, yu;
@ -99,7 +98,8 @@ static void detect_retrieve_libmv_features(MovieTracking *tracking,
}
if (ok) {
track = BKE_tracking_track_add(tracking, tracksbase, xu, yu, framenr, width, height);
MovieTrackingTrack *track = BKE_tracking_track_add(
tracking, tracksbase, xu, yu, framenr, width, height);
track->flag |= SELECT;
track->pat_flag |= SELECT;
track->search_flag |= SELECT;

View File

@ -786,9 +786,9 @@ int BLI_str_utf8_offset_to_column(const char *str, int offset)
int BLI_str_utf8_offset_from_column(const char *str, int column)
{
int offset = 0, pos = 0, col;
int offset = 0, pos = 0;
while (*(str + offset) && pos < column) {
col = BLI_str_utf8_char_width_safe(str + offset);
const int col = BLI_str_utf8_char_width_safe(str + offset);
if (pos + col > column) {
break;
}

View File

@ -86,7 +86,6 @@ void BMO_mesh_delete_oflag_tagged(BMesh *bm, const short oflag, const char htype
void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type)
{
BMEdge *e;
BMFace *f;
BMIter eiter;
BMIter fiter;
@ -128,6 +127,7 @@ void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type)
case DEL_FACES:
case DEL_FACES_KEEP_BOUNDARY: {
/* go through and mark all edges and all verts of all faces for delete */
BMFace *f;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
if (BMO_face_flag_test(bm, f, oflag)) {
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
@ -257,8 +257,6 @@ void BM_mesh_delete_hflag_tagged(BMesh *bm, const char hflag, const char htype)
void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type)
{
BMEdge *e;
BMFace *f;
BMIter eiter;
BMIter fiter;
@ -271,6 +269,7 @@ void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type)
}
case DEL_EDGES: {
/* flush down to vert */
BMEdge *e;
BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, hflag)) {
BM_elem_flag_enable(e->v1, hflag);
@ -299,6 +298,8 @@ void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type)
}
case DEL_FACES: {
/* go through and mark all edges and all verts of all faces for delete */
BMFace *f;
BMEdge *e;
BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) {
if (BM_elem_flag_test(f, hflag)) {
BMLoop *l_first = BM_FACE_FIRST_LOOP(f);

View File

@ -182,9 +182,8 @@ void bmesh_disk_edge_remove(BMEdge *e, BMVert *v)
BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2)
{
BMEdge *e_iter, *e_first;
if (v1->e) {
BMEdge *e_iter, *e_first;
e_first = e_iter = v1->e;
do {

View File

@ -24,7 +24,7 @@
static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const float no[3])
{
float axis_mat[3][3];
float z_prev, z_curr;
float z_prev;
float delta_z = 0.0f;
/* Newell's Method */
@ -35,7 +35,7 @@ static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const f
z_prev = dot_m3_v3_row_z(axis_mat, l_last->v->co);
do {
z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co);
const float z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co);
delta_z += fabsf(z_curr - z_prev);
z_prev = z_curr;
} while ((l_iter = l_iter->next) != l_term);

View File

@ -52,7 +52,6 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
}
BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) {
BMFace *f_new;
float f_center[3];
BMVert *v_center = NULL;
BMLoop *l_iter, *l_first;
@ -83,8 +82,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op)
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
BMLoop *l_new;
f_new = BM_face_create_quad_tri(
BMFace *f_new = BM_face_create_quad_tri(
bm, l_iter->v, l_iter->next->v, v_center, NULL, f, BM_CREATE_NOP);
l_new = BM_FACE_FIRST_LOOP(f_new);

View File

@ -177,7 +177,7 @@ static void axisProjection(const TransInfo *t,
const float in[3],
float out[3])
{
float norm[3], vec[3], factor, angle;
float vec[3], factor, angle;
float t_con_center[3];
if (is_zero_v3(in)) {
@ -214,7 +214,7 @@ static void axisProjection(const TransInfo *t,
}
else {
float v[3];
float norm_center[3];
float norm[3], norm_center[3];
float plane[3];
view_vector_calc(t, t_con_center, norm_center);

View File

@ -178,7 +178,6 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[
const char(*palette)[4] = (const char(*)[4])(mem + palette_offset);
const int startmask = ((1 << depth) - 1) << 8;
for (size_t i = y; i > 0; i--) {
int index;
int bitoffs = 8;
int bitmask = startmask;
int nbytes = 0;
@ -189,7 +188,7 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[
for (size_t j = x; j > 0; j--) {
bitoffs -= depth;
bitmask >>= depth;
index = (bmp[0] & bitmask) >> bitoffs;
const int index = (bmp[0] & bitmask) >> bitoffs;
pcol = palette[index];
/* intentionally BGR -> RGB */
rect[0] = pcol[2];

View File

@ -209,7 +209,7 @@ static void imb_cache_filename(char *filepath, const char *name, int flags)
ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
{
ImBuf *ibuf;
int file, a;
int file;
char filepath_tx[IMB_FILENAME_SIZE];
BLI_assert(!BLI_path_is_rel(filepath));
@ -226,7 +226,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S
if (ibuf) {
BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename));
for (a = 1; a < ibuf->miptot; a++) {
for (int a = 1; a < ibuf->miptot; a++) {
BLI_strncpy(ibuf->mipmap[a - 1]->cachename, filepath_tx, sizeof(ibuf->cachename));
}
}

View File

@ -549,10 +549,8 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
ImbTIFFMemFile memFile;
uint32_t width, height;
char *format = NULL;
int level;
short spp;
int ib_depth;
int found;
/* Check whether or not we have a TIFF file. */
if (imb_is_a_tiff(mem, size) == 0) {
@ -592,8 +590,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
if (flags & IB_alphamode_detect) {
if (spp == 4) {
unsigned short extra, *extraSampleTypes;
found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes);
const int found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes);
if (found && (extraSampleTypes[0] == EXTRASAMPLE_ASSOCALPHA)) {
ibuf->flags |= IB_alphamode_premul;
@ -617,7 +614,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem,
int numlevel = TIFFNumberOfDirectories(image);
/* create empty mipmap levels in advance */
for (level = 0; level < numlevel; level++) {
for (int level = 0; level < numlevel; level++) {
if (!TIFFSetDirectory(image, level)) {
break;
}

View File

@ -169,7 +169,6 @@ void RNA_def_main(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
CollectionDefFunc *func;
/* plural must match idtypes in readblenentry.c */
MainCollectionDef lists[] = {
@ -467,7 +466,7 @@ void RNA_def_main(BlenderRNA *brna)
RNA_def_property_ui_text(prop, lists[i].name, lists[i].description);
/* collection functions */
func = lists[i].func;
CollectionDefFunc *func = lists[i].func;
if (func) {
func(brna, prop);
}

View File

@ -49,11 +49,11 @@ static void deformMatrices(ModifierData *md,
{
Key *key = BKE_key_from_object(ctx->object);
KeyBlock *kb = BKE_keyblock_from_object(ctx->object);
float scale[3][3];
(void)vertexCos; /* unused */
if (kb && kb->totelem == verts_num && kb != key->refkey) {
float scale[3][3];
int a;
if (ctx->object->shapeflag & OB_SHAPE_LOCK) {
@ -95,15 +95,14 @@ static void deformMatricesEM(ModifierData *UNUSED(md),
{
Key *key = BKE_key_from_object(ctx->object);
KeyBlock *kb = BKE_keyblock_from_object(ctx->object);
float scale[3][3];
(void)vertexCos; /* unused */
if (kb && kb->totelem == verts_num && kb != key->refkey) {
int a;
float scale[3][3];
scale_m3_fl(scale, kb->curval);
for (a = 0; a < verts_num; a++) {
for (int a = 0; a < verts_num; a++) {
copy_m3_m3(defMats[a], scale);
}
}

View File

@ -96,12 +96,11 @@ static void seq_update_muting_recursive(ListBase *channels,
int mute)
{
Sequence *seq;
int seqmute;
/* For sound we go over full meta tree to update muted state,
* since sound is played outside of evaluating the imbufs. */
for (seq = seqbasep->first; seq; seq = seq->next) {
seqmute = (mute || SEQ_render_is_muted(channels, seq));
int seqmute = (mute || SEQ_render_is_muted(channels, seq));
if (seq->type == SEQ_TYPE_META) {
/* if this is the current meta sequence, unmute because

View File

@ -84,7 +84,7 @@ bool SEQ_transform_seqbase_isolated_sel_check(ListBase *seqbase)
void SEQ_transform_fix_single_image_seq_offsets(const Scene *scene, Sequence *seq)
{
int left, start, offset;
int left, start;
if (!SEQ_transform_single_image_check(seq)) {
return;
}
@ -94,7 +94,7 @@ void SEQ_transform_fix_single_image_seq_offsets(const Scene *scene, Sequence *se
left = SEQ_time_left_handle_frame_get(scene, seq);
start = seq->start;
if (start != left) {
offset = left - start;
const int offset = left - start;
SEQ_time_left_handle_frame_set(
scene, seq, SEQ_time_left_handle_frame_get(scene, seq) - offset);
SEQ_time_right_handle_frame_set(

View File

@ -69,11 +69,10 @@ static void sig_handle_fpe(int UNUSED(sig))
# if !defined(WITH_HEADLESS)
static void sig_handle_blender_esc(int sig)
{
static int count = 0;
G.is_break = true; /* forces render loop to read queue, not sure if its needed */
if (sig == 2) {
static int count = 0;
if (count) {
printf("\nBlender killed\n");
exit(2);