diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:18:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:18:31 +0400 |
commit | 69e6894b15271884623ea6f56ead06db83acbe99 (patch) | |
tree | b68200606afaca06cf7552f6b12fc20ebd30d487 /source/blender/blenkernel/intern/texture.c | |
parent | 7b99ae0ad3017e373be2a344e30d190b70ca66b4 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 348 |
1 files changed, 175 insertions, 173 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 23a30b6522b..cd1b05971f5 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -81,7 +81,7 @@ int test_dlerr(const char *name, const char *symbol) char *err; err= BLI_dynlib_get_error_as_string(NULL); - if(err) { + if (err) { printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err); return 1; } @@ -114,7 +114,7 @@ void open_plugin_tex(PluginTex *pit) /* open the needed object */ pit->handle= BLI_dynlib_open(pit->name); - if(test_dlerr(pit->name, pit->name)) return; + if (test_dlerr(pit->name, pit->name)) return; if (pit->handle != NULL) { /* find the address of the version function */ @@ -123,7 +123,7 @@ void open_plugin_tex(PluginTex *pit) if (version != NULL) { pit->version= version(); - if( pit->version >= 2 && pit->version <=6) { + if ( pit->version >= 2 && pit->version <=6) { int (*info_func)(PluginInfo *); PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); @@ -146,7 +146,8 @@ void open_plugin_tex(PluginTex *pit) if (info->init) info->init(); } MEM_freeN(info); - } else { + } + else { printf ("Plugin returned unrecognized version number\n"); return; } @@ -171,18 +172,18 @@ PluginTex *add_plugin_tex(char *str) BLI_strncpy(pit->name, str, sizeof(pit->name)); open_plugin_tex(pit); - if(pit->doit==NULL) { - if(pit->handle==NULL) {;} //XXX error("no plugin: %s", str); + if (pit->doit==NULL) { + if (pit->handle==NULL) {;} //XXX error("no plugin: %s", str); else {;} //XXX error("in plugin: %s", str); MEM_freeN(pit); return NULL; } varstr= pit->varstr; - for(a=0; a<pit->vars; a++, varstr++) { - if( (varstr->type & FLO)==FLO) + for (a=0; a<pit->vars; a++, varstr++) { + if ( (varstr->type & FLO)==FLO) pit->data[a]= varstr->def; - else if( (varstr->type & INT)==INT) + else if ( (varstr->type & INT)==INT) *((int *)(pit->data+a))= (int) varstr->def; } @@ -196,7 +197,7 @@ PluginTex *add_plugin_tex(char *str) void free_plugin_tex(PluginTex *pit) { - if(pit==NULL) return; + if (pit==NULL) return; /* no BLI_dynlib_close: same plugin can be opened multiple times, 1 handle */ MEM_freeN(pit); @@ -231,7 +232,7 @@ void init_tex_mapping(TexMapping *texmap) { float smat[3][3], rmat[3][3], mat[3][3], proj[3][3]; - if(texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z && + if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z && is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { unit_m4(texmap->mat); @@ -241,11 +242,11 @@ void init_tex_mapping(TexMapping *texmap) /* axis projection */ zero_m3(proj); - if(texmap->projx != PROJ_N) + if (texmap->projx != PROJ_N) proj[texmap->projx-1][0]= 1.0f; - if(texmap->projy != PROJ_N) + if (texmap->projy != PROJ_N) proj[texmap->projy-1][1]= 1.0f; - if(texmap->projz != PROJ_N) + if (texmap->projz != PROJ_N) proj[texmap->projz-1][2]= 1.0f; /* scale */ @@ -302,7 +303,7 @@ void init_colorband(ColorBand *coba, int rangetype) coba->data[0].pos= 0.0; coba->data[1].pos= 1.0; - if(rangetype==0) { + if (rangetype==0) { coba->data[0].r= 0.0; coba->data[0].g= 0.0; coba->data[0].b= 0.0; @@ -325,7 +326,7 @@ void init_colorband(ColorBand *coba, int rangetype) coba->data[1].a= 1.0; } - for(a=2; a<MAXCOLORBAND; a++) { + for (a=2; a<MAXCOLORBAND; a++) { coba->data[a].r= 0.5; coba->data[a].g= 0.5; coba->data[a].b= 0.5; @@ -355,17 +356,17 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) float fac, mfac, t[4]; int a; - if(coba==NULL || coba->tot==0) return 0; + if (coba==NULL || coba->tot==0) return 0; cbd1= coba->data; - if(coba->tot==1) { + if (coba->tot==1) { out[0]= cbd1->r; out[1]= cbd1->g; out[2]= cbd1->b; out[3]= cbd1->a; } else { - if(in <= cbd1->pos && coba->ipotype<2) { + if (in <= cbd1->pos && coba->ipotype<2) { out[0]= cbd1->r; out[1]= cbd1->g; out[2]= cbd1->b; @@ -375,22 +376,22 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) CBData left, right; /* we're looking for first pos > in */ - for(a=0; a<coba->tot; a++, cbd1++) if(cbd1->pos > in) break; + for (a=0; a<coba->tot; a++, cbd1++) if(cbd1->pos > in) break; - if(a==coba->tot) { + if (a==coba->tot) { cbd2= cbd1-1; right= *cbd2; right.pos= 1.0f; cbd1= &right; } - else if(a==0) { + else if (a==0) { left= *cbd1; left.pos= 0.0f; cbd2= &left; } else cbd2= cbd1-1; - if(in >= cbd1->pos && coba->ipotype<2) { + if (in >= cbd1->pos && coba->ipotype<2) { out[0]= cbd1->r; out[1]= cbd1->g; out[2]= cbd1->b; @@ -398,7 +399,7 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) } else { - if(cbd2->pos!=cbd1->pos) + if (cbd2->pos!=cbd1->pos) fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos); else { /* was setting to 0.0 in 2.56 & previous, but this @@ -415,17 +416,17 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) return 1; } - if(coba->ipotype>=2) { + if (coba->ipotype>=2) { /* ipo from right to left: 3 2 1 0 */ - if(a>=coba->tot-1) cbd0= cbd1; + if (a>=coba->tot-1) cbd0= cbd1; else cbd0= cbd1+1; - if(a<2) cbd3= cbd2; + if (a<2) cbd3= cbd2; else cbd3= cbd2-1; CLAMP(fac, 0.0f, 1.0f); - if(coba->ipotype==3) + if (coba->ipotype==3) key_curve_position_weights(fac, t, KEY_CARDINAL); else key_curve_position_weights(fac, t, KEY_BSPLINE); @@ -441,7 +442,7 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) } else { - if(coba->ipotype==1) { /* EASE */ + if (coba->ipotype==1) { /* EASE */ mfac= fac*fac; fac= 3.0f*mfac-2.0f*mfac*fac; } @@ -465,7 +466,7 @@ void colorband_table_RGBA(ColorBand *coba, float **array, int *size) *size = CM_TABLE+1; *array = MEM_callocN(sizeof(float)*(*size)*4, "ColorBand"); - for(a=0; a<*size; a++) + for (a=0; a<*size; a++) do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]); } @@ -473,8 +474,8 @@ int vergcband(const void *a1, const void *a2) { const CBData *x1=a1, *x2=a2; - if( x1->pos > x2->pos ) return 1; - else if( x1->pos < x2->pos) return -1; + if ( x1->pos > x2->pos ) return 1; + else if ( x1->pos < x2->pos) return -1; return 0; } @@ -482,16 +483,16 @@ void colorband_update_sort(ColorBand *coba) { int a; - if(coba->tot<2) + if (coba->tot<2) return; - for(a=0; a<coba->tot; a++) + for (a=0; a<coba->tot; a++) coba->data[a].cur= a; qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - for(a=0; a<coba->tot; a++) { - if(coba->data[a].cur==coba->cur) { + for (a=0; a<coba->tot; a++) { + if (coba->data[a].cur==coba->cur) { coba->cur= a; break; } @@ -500,10 +501,10 @@ void colorband_update_sort(ColorBand *coba) CBData *colorband_element_add(struct ColorBand *coba, float position) { - if(coba->tot==MAXCOLORBAND) { + if (coba->tot==MAXCOLORBAND) { return NULL; } - else if(coba->tot > 0) { + else if (coba->tot > 0) { CBData *xnew; float col[4]; @@ -530,16 +531,16 @@ int colorband_element_remove(struct ColorBand *coba, int index) { int a; - if(coba->tot < 2) + if (coba->tot < 2) return 0; - if(index < 0 || index >= coba->tot) + if (index < 0 || index >= coba->tot) return 0; - for(a = index; a < coba->tot; a++) { + for (a = index; a < coba->tot; a++) { coba->data[a] = coba->data[a + 1]; } - if(coba->cur) coba->cur--; + if (coba->cur) coba->cur--; coba->tot--; return 1; } @@ -550,18 +551,18 @@ void free_texture(Tex *tex) { free_plugin_tex(tex->plugin); - if(tex->coba) MEM_freeN(tex->coba); - if(tex->env) BKE_free_envmap(tex->env); - if(tex->pd) BKE_free_pointdensity(tex->pd); - if(tex->vd) BKE_free_voxeldata(tex->vd); - if(tex->ot) BKE_free_oceantex(tex->ot); + if (tex->coba) MEM_freeN(tex->coba); + if (tex->env) BKE_free_envmap(tex->env); + if (tex->pd) BKE_free_pointdensity(tex->pd); + if (tex->vd) BKE_free_voxeldata(tex->vd); + if (tex->ot) BKE_free_oceantex(tex->ot); BKE_free_animdata((struct ID *)tex); BKE_previewimg_free(&tex->preview); BKE_icon_delete((struct ID*)tex); tex->id.icon_id = 0; - if(tex->nodetree) { + if (tex->nodetree) { ntreeFreeTree(tex->nodetree); MEM_freeN(tex->nodetree); } @@ -645,8 +646,8 @@ void default_tex(Tex *tex) pit = tex->plugin; if (pit) { varstr= pit->varstr; - if(varstr) { - for(a=0; a<pit->vars; a++, varstr++) { + if (varstr) { + for (a=0; a<pit->vars; a++, varstr++) { pit->data[a] = varstr->def; } } @@ -786,11 +787,11 @@ MTex *add_mtex_id(ID *id, int slot) give_active_mtex(id, &mtex_ar, &act); - if(mtex_ar==NULL) { + if (mtex_ar==NULL) { return NULL; } - if(slot==-1) { + if (slot==-1) { /* find first free */ int i; for (i= 0; i < MAX_MTEX; i++) { @@ -799,13 +800,13 @@ MTex *add_mtex_id(ID *id, int slot) break; } } - if(slot == -1) { + if (slot == -1) { return NULL; } } else { /* make sure slot is valid */ - if(slot < 0 || slot >= MAX_MTEX) { + if (slot < 0 || slot >= MAX_MTEX) { return NULL; } } @@ -828,22 +829,22 @@ Tex *copy_texture(Tex *tex) Tex *texn; texn= copy_libblock(&tex->id); - if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); + if (texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); else texn->ima= NULL; - if(texn->plugin) { + if (texn->plugin) { texn->plugin= MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); - if(texn->env) texn->env= BKE_copy_envmap(texn->env); - if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); - if(texn->vd) texn->vd= MEM_dupallocN(texn->vd); - if(texn->ot) texn->ot= BKE_copy_oceantex(texn->ot); - if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); + if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); + if (texn->env) texn->env= BKE_copy_envmap(texn->env); + if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); + if (texn->vd) texn->vd= MEM_dupallocN(texn->vd); + if (texn->ot) texn->ot= BKE_copy_oceantex(texn->ot); + if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); - if(tex->nodetree) { + if (tex->nodetree) { if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata, 1); } @@ -863,29 +864,29 @@ Tex *localize_texture(Tex *tex) /* image texture: free_texture also doesn't decrease */ - if(texn->plugin) { + if (texn->plugin) { texn->plugin= MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); - if(texn->env) { + if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); + if (texn->env) { texn->env= BKE_copy_envmap(texn->env); id_us_min(&texn->env->ima->id); } - if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); - if(texn->vd) { + if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); + if (texn->vd) { texn->vd= MEM_dupallocN(texn->vd); - if(texn->vd->dataset) + if (texn->vd->dataset) texn->vd->dataset= MEM_dupallocN(texn->vd->dataset); } - if(texn->ot) { + if (texn->ot) { texn->ot= BKE_copy_oceantex(tex->ot); } texn->preview = NULL; - if(tex->nodetree) { + if (tex->nodetree) { texn->nodetree= ntreeLocalize(tex->nodetree); } @@ -915,68 +916,68 @@ void make_local_texture(Tex *tex) * - mixed: make copy */ - if(tex->id.lib==NULL) return; + if (tex->id.lib==NULL) return; - if(tex->id.us==1) { + if (tex->id.us==1) { id_clear_lib_data(bmain, &tex->id); extern_local_texture(tex); return; } ma= bmain->mat.first; - while(ma) { - for(a=0; a<MAX_MTEX; a++) { - if(ma->mtex[a] && ma->mtex[a]->tex==tex) { - if(ma->id.lib) is_lib= TRUE; + while (ma) { + for (a=0; a<MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex==tex) { + if (ma->id.lib) is_lib= TRUE; else is_local= TRUE; } } ma= ma->id.next; } la= bmain->lamp.first; - while(la) { - for(a=0; a<MAX_MTEX; a++) { - if(la->mtex[a] && la->mtex[a]->tex==tex) { - if(la->id.lib) is_lib= TRUE; + while (la) { + for (a=0; a<MAX_MTEX; a++) { + if (la->mtex[a] && la->mtex[a]->tex==tex) { + if (la->id.lib) is_lib= TRUE; else is_local= TRUE; } } la= la->id.next; } wrld= bmain->world.first; - while(wrld) { - for(a=0; a<MAX_MTEX; a++) { - if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) { - if(wrld->id.lib) is_lib= TRUE; + while (wrld) { + for (a=0; a<MAX_MTEX; a++) { + if (wrld->mtex[a] && wrld->mtex[a]->tex==tex) { + if (wrld->id.lib) is_lib= TRUE; else is_local= TRUE; } } wrld= wrld->id.next; } br= bmain->brush.first; - while(br) { - if(br->mtex.tex==tex) { - if(br->id.lib) is_lib= TRUE; + while (br) { + if (br->mtex.tex==tex) { + if (br->id.lib) is_lib= TRUE; else is_local= TRUE; } br= br->id.next; } pa= bmain->particle.first; - while(pa) { - for(a=0; a<MAX_MTEX; a++) { - if(pa->mtex[a] && pa->mtex[a]->tex==tex) { - if(pa->id.lib) is_lib= TRUE; + while (pa) { + for (a=0; a<MAX_MTEX; a++) { + if (pa->mtex[a] && pa->mtex[a]->tex==tex) { + if (pa->id.lib) is_lib= TRUE; else is_local= TRUE; } } pa= pa->id.next; } - if(is_local && is_lib == FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &tex->id); extern_local_texture(tex); } - else if(is_local && is_lib) { + else if (is_local && is_lib) { Tex *tex_new= copy_texture(tex); tex_new->id.us= 0; @@ -985,10 +986,10 @@ void make_local_texture(Tex *tex) BKE_id_lib_local_paths(bmain, tex->id.lib, &tex_new->id); ma= bmain->mat.first; - while(ma) { - for(a=0; a<MAX_MTEX; a++) { - if(ma->mtex[a] && ma->mtex[a]->tex==tex) { - if(ma->id.lib==NULL) { + while (ma) { + for (a=0; a<MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex==tex) { + if (ma->id.lib==NULL) { ma->mtex[a]->tex= tex_new; tex_new->id.us++; tex->id.us--; @@ -998,10 +999,10 @@ void make_local_texture(Tex *tex) ma= ma->id.next; } la= bmain->lamp.first; - while(la) { - for(a=0; a<MAX_MTEX; a++) { - if(la->mtex[a] && la->mtex[a]->tex==tex) { - if(la->id.lib==NULL) { + while (la) { + for (a=0; a<MAX_MTEX; a++) { + if (la->mtex[a] && la->mtex[a]->tex==tex) { + if (la->id.lib==NULL) { la->mtex[a]->tex= tex_new; tex_new->id.us++; tex->id.us--; @@ -1011,10 +1012,10 @@ void make_local_texture(Tex *tex) la= la->id.next; } wrld= bmain->world.first; - while(wrld) { - for(a=0; a<MAX_MTEX; a++) { - if(wrld->mtex[a] && wrld->mtex[a]->tex==tex) { - if(wrld->id.lib==NULL) { + while (wrld) { + for (a=0; a<MAX_MTEX; a++) { + if (wrld->mtex[a] && wrld->mtex[a]->tex==tex) { + if (wrld->id.lib==NULL) { wrld->mtex[a]->tex= tex_new; tex_new->id.us++; tex->id.us--; @@ -1024,9 +1025,9 @@ void make_local_texture(Tex *tex) wrld= wrld->id.next; } br= bmain->brush.first; - while(br) { - if(br->mtex.tex==tex) { - if(br->id.lib==NULL) { + while (br) { + if (br->mtex.tex==tex) { + if (br->id.lib==NULL) { br->mtex.tex= tex_new; tex_new->id.us++; tex->id.us--; @@ -1035,10 +1036,10 @@ void make_local_texture(Tex *tex) br= br->id.next; } pa= bmain->particle.first; - while(pa) { - for(a=0; a<MAX_MTEX; a++) { - if(pa->mtex[a] && pa->mtex[a]->tex==tex) { - if(pa->id.lib==NULL) { + while (pa) { + for (a=0; a<MAX_MTEX; a++) { + if (pa->mtex[a] && pa->mtex[a]->tex==tex) { + if (pa->id.lib==NULL) { pa->mtex[a]->tex= tex_new; tex_new->id.us++; tex->id.us--; @@ -1061,14 +1062,14 @@ void autotexname(Tex *tex) Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; - if(tex) { - if(tex->use_nodes) { + if (tex) { + if (tex->use_nodes) { new_id(&bmain->tex, (ID *)tex, "Noddy"); } else - if(tex->type==TEX_IMAGE) { + if (tex->type==TEX_IMAGE) { ima= tex->ima; - if(ima) { + if (ima) { BLI_strncpy(di, ima->name, sizeof(di)); BLI_splitdirstring(di, fi); strcpy(di, "I."); @@ -1077,7 +1078,7 @@ void autotexname(Tex *tex) } else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } - else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); + else if (tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } } @@ -1089,15 +1090,16 @@ Tex *give_current_object_texture(Object *ob) Material *ma, *node_ma; Tex *tex= NULL; - if(ob==NULL) return NULL; - if(ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL; + if (ob==NULL) return NULL; + if (ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL; - if(ob->type==OB_LAMP) { + if (ob->type==OB_LAMP) { tex= give_current_lamp_texture(ob->data); - } else { + } + else { ma= give_current_material(ob, ob->actcol); - if((node_ma=give_node_material(ma))) + if ((node_ma=give_node_material(ma))) ma= node_ma; tex= give_current_material_texture(ma); @@ -1111,9 +1113,9 @@ Tex *give_current_lamp_texture(Lamp *la) MTex *mtex= NULL; Tex *tex= NULL; - if(la) { + if (la) { mtex= la->mtex[(int)(la->texact)]; - if(mtex) tex= mtex->tex; + if (mtex) tex= mtex->tex; } return tex; @@ -1123,11 +1125,11 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex) { int act= la->texact; - if(la->mtex[act] && la->mtex[act]->tex) + if (la->mtex[act] && la->mtex[act]->tex) id_us_min(&la->mtex[act]->tex->id); - if(newtex) { - if(!la->mtex[act]) { + if (newtex) { + if (!la->mtex[act]) { la->mtex[act]= add_mtex(); la->mtex[act]->texco= TEXCO_GLOB; } @@ -1135,7 +1137,7 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex) la->mtex[act]->tex= newtex; id_us_plus(&newtex->id); } - else if(la->mtex[act]) { + else if (la->mtex[act]) { MEM_freeN(la->mtex[act]); la->mtex[act]= NULL; } @@ -1143,7 +1145,7 @@ void set_current_lamp_texture(Lamp *la, Tex *newtex) bNode *give_current_material_texture_node(Material *ma) { - if(ma && ma->use_nodes && ma->nodetree) + if (ma && ma->use_nodes && ma->nodetree) return nodeGetActiveID(ma->nodetree, ID_TE); return NULL; @@ -1155,21 +1157,21 @@ Tex *give_current_material_texture(Material *ma) Tex *tex= NULL; bNode *node; - if(ma && ma->use_nodes && ma->nodetree) { + if (ma && ma->use_nodes && ma->nodetree) { /* first check texture, then material, this works together * with a hack that clears the active ID flag for textures on * making a material node active */ node= nodeGetActiveID(ma->nodetree, ID_TE); - if(node) { + if (node) { tex= (Tex *)node->id; ma= NULL; } } - if(ma) { + if (ma) { mtex= ma->mtex[(int)(ma->texact)]; - if(mtex) tex= mtex->tex; + if (mtex) tex= mtex->tex; } return tex; @@ -1180,23 +1182,23 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) switch(GS(id->name)) { case ID_MA: *mtex_ar= ((Material *)id)->mtex; - if(act) *act= (((Material *)id)->texact); + if (act) *act= (((Material *)id)->texact); break; case ID_WO: *mtex_ar= ((World *)id)->mtex; - if(act) *act= (((World *)id)->texact); + if (act) *act= (((World *)id)->texact); break; case ID_LA: *mtex_ar= ((Lamp *)id)->mtex; - if(act) *act= (((Lamp *)id)->texact); + if (act) *act= (((Lamp *)id)->texact); break; case ID_PA: *mtex_ar= ((ParticleSettings *)id)->mtex; - if(act) *act= (((ParticleSettings *)id)->texact); + if (act) *act= (((ParticleSettings *)id)->texact); break; default: *mtex_ar = NULL; - if(act) *act= 0; + if (act) *act= 0; return FALSE; } @@ -1205,8 +1207,8 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) void set_active_mtex(ID *id, short act) { - if(act<0) act= 0; - else if(act>=MAX_MTEX) act= MAX_MTEX-1; + if (act<0) act= 0; + else if (act>=MAX_MTEX) act= MAX_MTEX-1; switch(GS(id->name)) { case ID_MA: @@ -1229,10 +1231,10 @@ void set_current_material_texture(Material *ma, Tex *newtex) Tex *tex= NULL; bNode *node; - if(ma && ma->use_nodes && ma->nodetree) { + if (ma && ma->use_nodes && ma->nodetree) { node= nodeGetActiveID(ma->nodetree, ID_TE); - if(node) { + if (node) { tex= (Tex *)node->id; id_us_min(&tex->id); node->id= &newtex->id; @@ -1240,20 +1242,20 @@ void set_current_material_texture(Material *ma, Tex *newtex) ma= NULL; } } - if(ma) { + if (ma) { int act= (int)ma->texact; tex= (ma->mtex[act])? ma->mtex[act]->tex: NULL; id_us_min(&tex->id); - if(newtex) { - if(!ma->mtex[act]) + if (newtex) { + if (!ma->mtex[act]) ma->mtex[act]= add_mtex(); ma->mtex[act]->tex= newtex; id_us_plus(&newtex->id); } - else if(ma->mtex[act]) { + else if (ma->mtex[act]) { MEM_freeN(ma->mtex[act]); ma->mtex[act]= NULL; } @@ -1264,10 +1266,10 @@ int has_current_material_texture(Material *ma) { bNode *node; - if(ma && ma->use_nodes && ma->nodetree) { + if (ma && ma->use_nodes && ma->nodetree) { node= nodeGetActiveID(ma->nodetree, ID_TE); - if(node) + if (node) return 1; } @@ -1279,10 +1281,10 @@ Tex *give_current_world_texture(World *world) MTex *mtex= NULL; Tex *tex= NULL; - if(!world) return NULL; + if (!world) return NULL; mtex= world->mtex[(int)(world->texact)]; - if(mtex) tex= mtex->tex; + if (mtex) tex= mtex->tex; return tex; } @@ -1291,11 +1293,11 @@ void set_current_world_texture(World *wo, Tex *newtex) { int act= wo->texact; - if(wo->mtex[act] && wo->mtex[act]->tex) + if (wo->mtex[act] && wo->mtex[act]->tex) id_us_min(&wo->mtex[act]->tex->id); - if(newtex) { - if(!wo->mtex[act]) { + if (newtex) { + if (!wo->mtex[act]) { wo->mtex[act]= add_mtex(); wo->mtex[act]->texco= TEXCO_VIEW; } @@ -1303,7 +1305,7 @@ void set_current_world_texture(World *wo, Tex *newtex) wo->mtex[act]->tex= newtex; id_us_plus(&newtex->id); } - else if(wo->mtex[act]) { + else if (wo->mtex[act]) { MEM_freeN(wo->mtex[act]); wo->mtex[act]= NULL; } @@ -1316,10 +1318,10 @@ Tex *give_current_brush_texture(Brush *br) void set_current_brush_texture(Brush *br, Tex *newtex) { - if(br->mtex.tex) + if (br->mtex.tex) id_us_min(&br->mtex.tex->id); - if(newtex) { + if (newtex) { br->mtex.tex= newtex; id_us_plus(&newtex->id); } @@ -1330,10 +1332,10 @@ Tex *give_current_particle_texture(ParticleSettings *part) MTex *mtex= NULL; Tex *tex= NULL; - if(!part) return NULL; + if (!part) return NULL; mtex= part->mtex[(int)(part->texact)]; - if(mtex) tex= mtex->tex; + if (mtex) tex= mtex->tex; return tex; } @@ -1342,11 +1344,11 @@ void set_current_particle_texture(ParticleSettings *part, Tex *newtex) { int act= part->texact; - if(part->mtex[act] && part->mtex[act]->tex) + if (part->mtex[act] && part->mtex[act]->tex) id_us_min(&part->mtex[act]->tex->id); - if(newtex) { - if(!part->mtex[act]) { + if (newtex) { + if (!part->mtex[act]) { part->mtex[act]= add_mtex(); part->mtex[act]->texco= TEXCO_ORCO; part->mtex[act]->blendtype= MTEX_MUL; @@ -1355,7 +1357,7 @@ void set_current_particle_texture(ParticleSettings *part, Tex *newtex) part->mtex[act]->tex= newtex; id_us_plus(&newtex->id); } - else if(part->mtex[act]) { + else if (part->mtex[act]) { MEM_freeN(part->mtex[act]); part->mtex[act]= NULL; } @@ -1387,8 +1389,8 @@ EnvMap *BKE_copy_envmap(EnvMap *env) envn= MEM_dupallocN(env); envn->ok= 0; - for(a=0; a<6; a++) envn->cube[a]= NULL; - if(envn->ima) id_us_plus((ID *)envn->ima); + for (a=0; a<6; a++) envn->cube[a]= NULL; + if (envn->ima) id_us_plus((ID *)envn->ima); return envn; } @@ -1399,8 +1401,8 @@ void BKE_free_envmapdata(EnvMap *env) { unsigned int part; - for(part=0; part<6; part++) { - if(env->cube[part]) + for (part=0; part<6; part++) { + if (env->cube[part]) IMB_freeImBuf(env->cube[part]); env->cube[part]= NULL; } @@ -1458,7 +1460,7 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd) pdn= MEM_dupallocN(pd); pdn->point_tree = NULL; pdn->point_data = NULL; - if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); + if (pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */ return pdn; } @@ -1473,7 +1475,7 @@ void BKE_free_pointdensitydata(PointDensity *pd) MEM_freeN(pd->point_data); pd->point_data = NULL; } - if(pd->coba) { + if (pd->coba) { MEM_freeN(pd->coba); pd->coba = NULL; } @@ -1561,19 +1563,19 @@ void BKE_free_oceantex(struct OceanTex *ot) /* ------------------------------------------------------------------------- */ int BKE_texture_dependsOnTime(const struct Tex *texture) { - if(texture->plugin) { + if (texture->plugin) { // assume all plugins depend on time return 1; } - else if( texture->ima && + else if ( texture->ima && ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { return 1; } - else if(texture->adt) { + else if (texture->adt) { // assume anything in adt means the texture is animated return 1; } - else if(texture->type == TEX_NOISE) { + else if (texture->type == TEX_NOISE) { // noise always varies with time return 1; } |