From c93d7a193ab450f89664a70e0204c14531be4877 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 6 May 2012 15:15:33 +0000 Subject: style cleanup: BKE_*.c files which deal with library functions --- source/blender/blenkernel/intern/texture.c | 937 +++++++++++++++-------------- 1 file changed, 469 insertions(+), 468 deletions(-) (limited to 'source/blender/blenkernel/intern/texture.c') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9b3689df941..98f5f45f525 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -80,7 +80,7 @@ int test_dlerr(const char *name, const char *symbol) { char *err; - err= BLI_dynlib_get_error_as_string(NULL); + err = BLI_dynlib_get_error_as_string(NULL); if (err) { printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err); return 1; @@ -96,14 +96,14 @@ void open_plugin_tex(PluginTex *pit) int (*version)(void); /* init all the happy variables */ - pit->doit= NULL; - pit->pname= NULL; - pit->stnames= NULL; - pit->varstr= NULL; - pit->result= NULL; - pit->cfra= NULL; - pit->version= 0; - pit->instance_init= NULL; + pit->doit = NULL; + pit->pname = NULL; + pit->stnames = NULL; + pit->varstr = NULL; + pit->result = NULL; + pit->cfra = NULL; + pit->version = 0; + pit->instance_init = NULL; /* clear the error list */ BLI_dynlib_get_error_as_string(NULL); @@ -113,42 +113,42 @@ void open_plugin_tex(PluginTex *pit) /* pit->handle= 0; */ /* open the needed object */ - pit->handle= BLI_dynlib_open(pit->name); + pit->handle = BLI_dynlib_open(pit->name); if (test_dlerr(pit->name, pit->name)) return; if (pit->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void)) BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); + version = (int (*)(void))BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); if (test_dlerr(pit->name, "plugin_tex_getversion")) return; if (version != NULL) { - pit->version= version(); - if ( pit->version >= 2 && pit->version <=6) { + pit->version = version(); + if (pit->version >= 2 && pit->version <= 6) { int (*info_func)(PluginInfo *); - PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); + PluginInfo *info = (PluginInfo *) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); + info_func = (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); if (!test_dlerr(pit->name, "plugin_getinfo")) { info->instance_init = NULL; info_func(info); - pit->doit= (int(*)(void)) info->tex_doit; - pit->callback= (void(*)(unsigned short)) info->callback; - pit->stypes= info->stypes; - pit->vars= info->nvars; - pit->pname= info->name; - pit->stnames= info->snames; - pit->varstr= info->varstr; - pit->result= info->result; - pit->cfra= info->cfra; + pit->doit = (int (*)(void))info->tex_doit; + pit->callback = (void (*)(unsigned short))info->callback; + pit->stypes = info->stypes; + pit->vars = info->nvars; + pit->pname = info->name; + pit->stnames = info->snames; + pit->varstr = info->varstr; + pit->result = info->result; + pit->cfra = info->cfra; pit->instance_init = info->instance_init; if (info->init) info->init(); } MEM_freeN(info); } else { - printf ("Plugin returned unrecognized version number\n"); + printf("Plugin returned unrecognized version number\n"); return; } } @@ -158,8 +158,8 @@ void open_plugin_tex(PluginTex *pit) /* ------------------------------------------------------------------------- */ /* very badlevel define to bypass linking with BIF_interface.h */ -#define INT 96 -#define FLO 128 +#define INT 96 +#define FLO 128 PluginTex *add_plugin_tex(char *str) { @@ -167,24 +167,24 @@ PluginTex *add_plugin_tex(char *str) VarStruct *varstr; int a; - pit= MEM_callocN(sizeof(PluginTex), "plugintex"); + pit = MEM_callocN(sizeof(PluginTex), "plugintex"); 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); - else {;} //XXX error("in 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; avars; a++, varstr++) { - if ( (varstr->type & FLO)==FLO) - pit->data[a]= varstr->def; - else if ( (varstr->type & INT)==INT) - *((int *)(pit->data+a))= (int) varstr->def; + varstr = pit->varstr; + for (a = 0; a < pit->vars; a++, varstr++) { + if ( (varstr->type & FLO) == FLO) + pit->data[a] = varstr->def; + else if ( (varstr->type & INT) == INT) + *((int *)(pit->data + a)) = (int) varstr->def; } if (pit->instance_init) @@ -197,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); @@ -207,7 +207,7 @@ void free_plugin_tex(PluginTex *pit) TexMapping *add_tex_mapping(void) { - TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "TexMapping"); + TexMapping *texmap = MEM_callocN(sizeof(TexMapping), "TexMapping"); default_tex_mapping(texmap); @@ -218,14 +218,14 @@ void default_tex_mapping(TexMapping *texmap) { memset(texmap, 0, sizeof(TexMapping)); - texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f; - texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f; + texmap->size[0] = texmap->size[1] = texmap->size[2] = 1.0f; + texmap->max[0] = texmap->max[1] = texmap->max[2] = 1.0f; unit_m4(texmap->mat); - texmap->projx= PROJ_X; - texmap->projy= PROJ_Y; - texmap->projz= PROJ_Z; - texmap->mapping= MTEX_FLAT; + texmap->projx = PROJ_X; + texmap->projy = PROJ_Y; + texmap->projz = PROJ_Z; + texmap->mapping = MTEX_FLAT; } void init_tex_mapping(TexMapping *texmap) @@ -233,7 +233,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 && - is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { + is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { unit_m4(texmap->mat); texmap->flag |= TEXMAP_UNIT_MATRIX; @@ -243,11 +243,11 @@ void init_tex_mapping(TexMapping *texmap) zero_m3(proj); if (texmap->projx != PROJ_N) - proj[texmap->projx-1][0]= 1.0f; + proj[texmap->projx - 1][0] = 1.0f; if (texmap->projy != PROJ_N) - proj[texmap->projy-1][1]= 1.0f; + proj[texmap->projy - 1][1] = 1.0f; if (texmap->projz != PROJ_N) - proj[texmap->projz-1][2]= 1.0f; + proj[texmap->projz - 1][2] = 1.0f; /* scale */ size_to_mat3(smat, texmap->size); @@ -270,7 +270,7 @@ void init_tex_mapping(TexMapping *texmap) ColorMapping *add_color_mapping(void) { - ColorMapping *colormap= MEM_callocN(sizeof(ColorMapping), "ColorMapping"); + ColorMapping *colormap = MEM_callocN(sizeof(ColorMapping), "ColorMapping"); default_color_mapping(colormap); @@ -283,15 +283,15 @@ void default_color_mapping(ColorMapping *colormap) init_colorband(&colormap->coba, 1); - colormap->bright= 1.0; - colormap->contrast= 1.0; - colormap->saturation= 1.0; + colormap->bright = 1.0; + colormap->contrast = 1.0; + colormap->saturation = 1.0; - colormap->blend_color[0]= 0.8f; - colormap->blend_color[1]= 0.8f; - colormap->blend_color[2]= 0.8f; - colormap->blend_type= MA_RAMP_BLEND; - colormap->blend_factor= 0.0f; + colormap->blend_color[0] = 0.8f; + colormap->blend_color[1] = 0.8f; + colormap->blend_color[2] = 0.8f; + colormap->blend_type = MA_RAMP_BLEND; + colormap->blend_factor = 0.0f; } /* ****************** COLORBAND ******************* */ @@ -300,41 +300,41 @@ void init_colorband(ColorBand *coba, int rangetype) { int a; - coba->data[0].pos= 0.0; - coba->data[1].pos= 1.0; + coba->data[0].pos = 0.0; + coba->data[1].pos = 1.0; - if (rangetype==0) { - coba->data[0].r= 0.0; - coba->data[0].g= 0.0; - coba->data[0].b= 0.0; - coba->data[0].a= 0.0; - - coba->data[1].r= 1.0; - coba->data[1].g= 1.0; - coba->data[1].b= 1.0; - coba->data[1].a= 1.0; + if (rangetype == 0) { + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 0.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; } else { - coba->data[0].r= 0.0; - coba->data[0].g= 0.0; - coba->data[0].b= 0.0; - coba->data[0].a= 1.0; - - coba->data[1].r= 1.0; - coba->data[1].g= 1.0; - coba->data[1].b= 1.0; - coba->data[1].a= 1.0; + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 1.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; } - - for (a=2; adata[a].r= 0.5; - coba->data[a].g= 0.5; - coba->data[a].b= 0.5; - coba->data[a].a= 1.0; - coba->data[a].pos= 0.5; + + for (a = 2; a < MAXCOLORBAND; a++) { + coba->data[a].r = 0.5; + coba->data[a].g = 0.5; + coba->data[a].b = 0.5; + coba->data[a].a = 1.0; + coba->data[a].pos = 0.5; } - coba->tot= 2; + coba->tot = 2; } @@ -342,7 +342,7 @@ ColorBand *add_colorband(int rangetype) { ColorBand *coba; - coba= MEM_callocN(sizeof(ColorBand), "colorband"); + coba = MEM_callocN(sizeof(ColorBand), "colorband"); init_colorband(coba, rangetype); return coba; @@ -356,85 +356,85 @@ 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) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + cbd1 = coba->data; + 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) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + if (in <= cbd1->pos && coba->ipotype < 2) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { CBData left, right; /* we're looking for first pos > in */ - for (a=0; atot; a++, cbd1++) if (cbd1->pos > in) break; + for (a = 0; a < coba->tot; a++, cbd1++) if (cbd1->pos > in) break; - if (a==coba->tot) { - cbd2= cbd1-1; - right= *cbd2; - right.pos= 1.0f; - cbd1= &right; + if (a == coba->tot) { + cbd2 = cbd1 - 1; + right = *cbd2; + right.pos = 1.0f; + cbd1 = &right; } - else if (a==0) { - left= *cbd1; - left.pos= 0.0f; - cbd2= &left; + else if (a == 0) { + left = *cbd1; + left.pos = 0.0f; + cbd2 = &left; } - else cbd2= cbd1-1; + else cbd2 = cbd1 - 1; - if (in >= cbd1->pos && coba->ipotype<2) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + if (in >= cbd1->pos && coba->ipotype < 2) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { - if (cbd2->pos!=cbd1->pos) - fac= (in-cbd1->pos)/(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 * is incorrect for the last element, see [#26732] */ - fac= (a != coba->tot) ? 0.0f : 1.0f; + fac = (a != coba->tot) ? 0.0f : 1.0f; } - if (coba->ipotype==4) { + if (coba->ipotype == 4) { /* constant */ - out[0]= cbd2->r; - out[1]= cbd2->g; - out[2]= cbd2->b; - out[3]= cbd2->a; + out[0] = cbd2->r; + out[1] = cbd2->g; + out[2] = cbd2->b; + out[3] = cbd2->a; 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; - else cbd0= cbd1+1; - if (a<2) cbd3= cbd2; - else cbd3= cbd2-1; + if (a >= coba->tot - 1) cbd0 = cbd1; + else cbd0 = cbd1 + 1; + 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); - out[0]= t[3]*cbd3->r +t[2]*cbd2->r +t[1]*cbd1->r +t[0]*cbd0->r; - out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g; - out[2]= t[3]*cbd3->b +t[2]*cbd2->b +t[1]*cbd1->b +t[0]*cbd0->b; - out[3]= t[3]*cbd3->a +t[2]*cbd2->a +t[1]*cbd1->a +t[0]*cbd0->a; + out[0] = t[3] * cbd3->r + t[2] * cbd2->r + t[1] * cbd1->r + t[0] * cbd0->r; + out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g; + out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b; + out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a; CLAMP(out[0], 0.0f, 1.0f); CLAMP(out[1], 0.0f, 1.0f); CLAMP(out[2], 0.0f, 1.0f); @@ -442,40 +442,40 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) } else { - if (coba->ipotype==1) { /* EASE */ - mfac= fac*fac; - fac= 3.0f*mfac-2.0f*mfac*fac; + if (coba->ipotype == 1) { /* EASE */ + mfac = fac * fac; + fac = 3.0f * mfac - 2.0f * mfac * fac; } - mfac= 1.0f-fac; + mfac = 1.0f - fac; - out[0]= mfac*cbd1->r + fac*cbd2->r; - out[1]= mfac*cbd1->g + fac*cbd2->g; - out[2]= mfac*cbd1->b + fac*cbd2->b; - out[3]= mfac*cbd1->a + fac*cbd2->a; + out[0] = mfac * cbd1->r + fac * cbd2->r; + out[1] = mfac * cbd1->g + fac * cbd2->g; + out[2] = mfac * cbd1->b + fac * cbd2->b; + out[3] = mfac * cbd1->a + fac * cbd2->a; } } } } - return 1; /* OK */ + return 1; /* OK */ } void colorband_table_RGBA(ColorBand *coba, float **array, int *size) { int a; - *size = CM_TABLE+1; - *array = MEM_callocN(sizeof(float)*(*size)*4, "ColorBand"); + *size = CM_TABLE + 1; + *array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand"); - for (a=0; a<*size; a++) - do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]); + for (a = 0; a < *size; a++) + do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]); } int vergcband(const void *a1, const void *a2) { - const CBData *x1=a1, *x2=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; } @@ -483,17 +483,17 @@ void colorband_update_sort(ColorBand *coba) { int a; - if (coba->tot<2) + if (coba->tot < 2) return; - for (a=0; atot; a++) - coba->data[a].cur= a; + for (a = 0; a < coba->tot; a++) + coba->data[a].cur = a; qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - for (a=0; atot; a++) { - if (coba->data[a].cur==coba->cur) { - coba->cur= a; + for (a = 0; a < coba->tot; a++) { + if (coba->data[a].cur == coba->cur) { + coba->cur = a; break; } } @@ -501,7 +501,7 @@ 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) { @@ -520,7 +520,7 @@ CBData *colorband_element_add(struct ColorBand *coba, float position) } coba->tot++; - coba->cur = coba->tot-1; + coba->cur = coba->tot - 1; colorband_update_sort(coba); @@ -559,7 +559,7 @@ void BKE_texture_free(Tex *tex) BKE_free_animdata((struct ID *)tex); BKE_previewimg_free(&tex->preview); - BKE_icon_delete((struct ID*)tex); + BKE_icon_delete((struct ID *)tex); tex->id.icon_id = 0; if (tex->nodetree) { @@ -576,31 +576,31 @@ void default_tex(Tex *tex) VarStruct *varstr; int a; - tex->type= TEX_CLOUDS; - tex->stype= 0; - tex->flag= TEX_CHECKER_ODD; - tex->imaflag= TEX_INTERPOL|TEX_MIPMAP|TEX_USEALPHA; - tex->extend= TEX_REPEAT; - tex->cropxmin= tex->cropymin= 0.0; - tex->cropxmax= tex->cropymax= 1.0; + tex->type = TEX_CLOUDS; + tex->stype = 0; + tex->flag = TEX_CHECKER_ODD; + tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA; + tex->extend = TEX_REPEAT; + tex->cropxmin = tex->cropymin = 0.0; + tex->cropxmax = tex->cropymax = 1.0; tex->texfilter = TXF_EWA; tex->afmax = 8; - tex->xrepeat= tex->yrepeat= 1; - tex->fie_ima= 2; - tex->sfra= 1; - tex->frames= 0; - tex->offset= 0; - tex->noisesize= 0.25; - tex->noisedepth= 2; - tex->turbul= 5.0; - tex->nabla= 0.025; // also in do_versions - tex->bright= 1.0; - tex->contrast= 1.0; - tex->saturation= 1.0; - tex->filtersize= 1.0; - tex->rfac= 1.0; - tex->gfac= 1.0; - tex->bfac= 1.0; + tex->xrepeat = tex->yrepeat = 1; + tex->fie_ima = 2; + tex->sfra = 1; + tex->frames = 0; + tex->offset = 0; + tex->noisesize = 0.25; + tex->noisedepth = 2; + tex->turbul = 5.0; + tex->nabla = 0.025; // also in do_versions + tex->bright = 1.0; + tex->contrast = 1.0; + tex->saturation = 1.0; + tex->filtersize = 1.0; + tex->rfac = 1.0; + tex->gfac = 1.0; + tex->bfac = 1.0; /* newnoise: init. */ tex->noisebasis = 0; tex->noisebasis2 = 0; @@ -621,11 +621,11 @@ void default_tex(Tex *tex) tex->vn_coltype = 0; if (tex->env) { - tex->env->stype=ENV_ANIM; - tex->env->clipsta=0.1; - tex->env->clipend=100; - tex->env->cuberes=600; - tex->env->depth=0; + tex->env->stype = ENV_ANIM; + tex->env->clipsta = 0.1; + tex->env->clipend = 100; + tex->env->cuberes = 600; + tex->env->depth = 0; } if (tex->pd) { @@ -635,8 +635,8 @@ void default_tex(Tex *tex) if (tex->vd) { tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0; - tex->vd->interp_type=TEX_VD_LINEAR; - tex->vd->file_format=TEX_VD_SMOKE; + tex->vd->interp_type = TEX_VD_LINEAR; + tex->vd->file_format = TEX_VD_SMOKE; } if (tex->ot) { @@ -645,18 +645,18 @@ void default_tex(Tex *tex) } pit = tex->plugin; if (pit) { - varstr= pit->varstr; + varstr = pit->varstr; if (varstr) { - for (a=0; avars; a++, varstr++) { + for (a = 0; a < pit->vars; a++, varstr++) { pit->data[a] = varstr->def; } } } - tex->iuser.fie_ima= 2; - tex->iuser.ok= 1; - tex->iuser.frames= 100; - tex->iuser.sfra= 1; + tex->iuser.fie_ima = 2; + tex->iuser.ok = 1; + tex->iuser.frames = 100; + tex->iuser.sfra = 1; tex->preview = NULL; } @@ -690,10 +690,10 @@ void tex_set_type(Tex *tex, int type) Tex *add_texture(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Tex *tex; - tex= BKE_libblock_alloc(&bmain->tex, ID_TE, name); + tex = BKE_libblock_alloc(&bmain->tex, ID_TE, name); default_tex(tex); @@ -704,65 +704,65 @@ Tex *add_texture(const char *name) void default_mtex(MTex *mtex) { - mtex->texco= TEXCO_ORCO; - mtex->mapto= MAP_COL; - mtex->object= NULL; - mtex->projx= PROJ_X; - mtex->projy= PROJ_Y; - mtex->projz= PROJ_Z; - mtex->mapping= MTEX_FLAT; - mtex->ofs[0]= 0.0; - mtex->ofs[1]= 0.0; - mtex->ofs[2]= 0.0; - mtex->size[0]= 1.0; - mtex->size[1]= 1.0; - mtex->size[2]= 1.0; - mtex->tex= NULL; - mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; - mtex->colormodel= 0; - mtex->r= 1.0; - mtex->g= 0.0; - mtex->b= 1.0; - mtex->k= 1.0; - mtex->def_var= 1.0; - mtex->blendtype= MTEX_BLEND; - mtex->colfac= 1.0; - mtex->norfac= 1.0; - mtex->varfac= 1.0; - mtex->dispfac=0.2; - mtex->colspecfac= 1.0f; - mtex->mirrfac= 1.0f; - mtex->alphafac= 1.0f; - mtex->difffac= 1.0f; - mtex->specfac= 1.0f; - mtex->emitfac= 1.0f; - mtex->hardfac= 1.0f; - mtex->raymirrfac= 1.0f; - mtex->translfac= 1.0f; - mtex->ambfac= 1.0f; - mtex->colemitfac= 1.0f; - mtex->colreflfac= 1.0f; - mtex->coltransfac= 1.0f; - mtex->densfac= 1.0f; - mtex->scatterfac= 1.0f; - mtex->reflfac= 1.0f; - mtex->shadowfac= 1.0f; - mtex->zenupfac= 1.0f; - mtex->zendownfac= 1.0f; - mtex->blendfac= 1.0f; - mtex->timefac= 1.0f; - mtex->lengthfac= 1.0f; - mtex->clumpfac= 1.0f; - mtex->kinkfac= 1.0f; - mtex->roughfac= 1.0f; - mtex->padensfac= 1.0f; - mtex->lifefac= 1.0f; - mtex->sizefac= 1.0f; - mtex->ivelfac= 1.0f; - mtex->dampfac= 1.0f; - mtex->gravityfac= 1.0f; - mtex->fieldfac= 1.0f; - mtex->normapspace= MTEX_NSPACE_TANGENT; + mtex->texco = TEXCO_ORCO; + mtex->mapto = MAP_COL; + mtex->object = NULL; + mtex->projx = PROJ_X; + mtex->projy = PROJ_Y; + mtex->projz = PROJ_Z; + mtex->mapping = MTEX_FLAT; + mtex->ofs[0] = 0.0; + mtex->ofs[1] = 0.0; + mtex->ofs[2] = 0.0; + mtex->size[0] = 1.0; + mtex->size[1] = 1.0; + mtex->size[2] = 1.0; + mtex->tex = NULL; + mtex->texflag = MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; + mtex->colormodel = 0; + mtex->r = 1.0; + mtex->g = 0.0; + mtex->b = 1.0; + mtex->k = 1.0; + mtex->def_var = 1.0; + mtex->blendtype = MTEX_BLEND; + mtex->colfac = 1.0; + mtex->norfac = 1.0; + mtex->varfac = 1.0; + mtex->dispfac = 0.2; + mtex->colspecfac = 1.0f; + mtex->mirrfac = 1.0f; + mtex->alphafac = 1.0f; + mtex->difffac = 1.0f; + mtex->specfac = 1.0f; + mtex->emitfac = 1.0f; + mtex->hardfac = 1.0f; + mtex->raymirrfac = 1.0f; + mtex->translfac = 1.0f; + mtex->ambfac = 1.0f; + mtex->colemitfac = 1.0f; + mtex->colreflfac = 1.0f; + mtex->coltransfac = 1.0f; + mtex->densfac = 1.0f; + mtex->scatterfac = 1.0f; + mtex->reflfac = 1.0f; + mtex->shadowfac = 1.0f; + mtex->zenupfac = 1.0f; + mtex->zendownfac = 1.0f; + mtex->blendfac = 1.0f; + mtex->timefac = 1.0f; + mtex->lengthfac = 1.0f; + mtex->clumpfac = 1.0f; + mtex->kinkfac = 1.0f; + mtex->roughfac = 1.0f; + mtex->padensfac = 1.0f; + mtex->lifefac = 1.0f; + mtex->sizefac = 1.0f; + mtex->ivelfac = 1.0f; + mtex->dampfac = 1.0f; + mtex->gravityfac = 1.0f; + mtex->fieldfac = 1.0f; + mtex->normapspace = MTEX_NSPACE_TANGENT; } @@ -772,7 +772,7 @@ MTex *add_mtex(void) { MTex *mtex; - mtex= MEM_callocN(sizeof(MTex), "add_mtex"); + mtex = MEM_callocN(sizeof(MTex), "add_mtex"); default_mtex(mtex); @@ -787,16 +787,16 @@ 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++) { + for (i = 0; i < MAX_MTEX; i++) { if (!mtex_ar[i]) { - slot= i; + slot = i; break; } } @@ -814,10 +814,10 @@ MTex *add_mtex_id(ID *id, int slot) if (mtex_ar[slot]) { id_us_min((ID *)mtex_ar[slot]->tex); MEM_freeN(mtex_ar[slot]); - mtex_ar[slot]= NULL; + mtex_ar[slot] = NULL; } - mtex_ar[slot]= add_mtex(); + mtex_ar[slot] = add_mtex(); return mtex_ar[slot]; } @@ -828,27 +828,27 @@ Tex *BKE_texture_copy(Tex *tex) { Tex *texn; - texn= BKE_libblock_copy(&tex->id); - if (texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); - else texn->ima= NULL; + texn = BKE_libblock_copy(&tex->id); + if (texn->type == TEX_IMAGE) id_us_plus((ID *)texn->ima); + else texn->ima = NULL; if (texn->plugin) { - texn->plugin= MEM_dupallocN(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 (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->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata, 1); } - texn->nodetree= ntreeCopyTree(tex->nodetree); + texn->nodetree = ntreeCopyTree(tex->nodetree); } return texn; @@ -859,35 +859,35 @@ Tex *localize_texture(Tex *tex) { Tex *texn; - texn= BKE_libblock_copy(&tex->id); + texn = BKE_libblock_copy(&tex->id); BLI_remlink(&G.main->tex, texn); /* image texture: BKE_texture_free also doesn't decrease */ if (texn->plugin) { - texn->plugin= MEM_dupallocN(texn->plugin); + texn->plugin = MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); + if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); if (texn->env) { - texn->env= BKE_copy_envmap(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->pd) texn->pd = BKE_copy_pointdensity(texn->pd); if (texn->vd) { - texn->vd= MEM_dupallocN(texn->vd); + texn->vd = MEM_dupallocN(texn->vd); if (texn->vd->dataset) - texn->vd->dataset= MEM_dupallocN(texn->vd->dataset); + texn->vd->dataset = MEM_dupallocN(texn->vd->dataset); } if (texn->ot) { - texn->ot= BKE_copy_oceantex(tex->ot); + texn->ot = BKE_copy_oceantex(tex->ot); } texn->preview = NULL; if (tex->nodetree) { - texn->nodetree= ntreeLocalize(tex->nodetree); + texn->nodetree = ntreeLocalize(tex->nodetree); } return texn; @@ -903,74 +903,74 @@ static void extern_local_texture(Tex *tex) void BKE_texture_make_local(Tex *tex) { - Main *bmain= G.main; + Main *bmain = G.main; Material *ma; World *wrld; Lamp *la; Brush *br; ParticleSettings *pa; - int a, is_local= FALSE, is_lib= FALSE; + int a, is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - 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; + ma = bmain->mat.first; while (ma) { - for (a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if (ma->id.lib) is_lib= TRUE; - else is_local= TRUE; + 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; + ma = ma->id.next; } - la= bmain->lamp.first; + la = bmain->lamp.first; while (la) { - for (a=0; amtex[a] && la->mtex[a]->tex==tex) { - if (la->id.lib) is_lib= TRUE; - else is_local= TRUE; + 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; + la = la->id.next; } - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - for (a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if (wrld->id.lib) is_lib= TRUE; - else is_local= TRUE; + 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; + wrld = wrld->id.next; } - br= bmain->brush.first; + br = bmain->brush.first; while (br) { - if (br->mtex.tex==tex) { - if (br->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (br->mtex.tex == tex) { + if (br->id.lib) is_lib = TRUE; + else is_local = TRUE; } - br= br->id.next; + br = br->id.next; } - pa= bmain->particle.first; + pa = bmain->particle.first; while (pa) { - for (a=0; amtex[a] && pa->mtex[a]->tex==tex) { - if (pa->id.lib) is_lib= TRUE; - else is_local= TRUE; + 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; + pa = pa->id.next; } if (is_local && is_lib == FALSE) { @@ -978,75 +978,75 @@ void BKE_texture_make_local(Tex *tex) extern_local_texture(tex); } else if (is_local && is_lib) { - Tex *tex_new= BKE_texture_copy(tex); + Tex *tex_new = BKE_texture_copy(tex); - tex_new->id.us= 0; + tex_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, tex->id.lib, &tex_new->id); - ma= bmain->mat.first; + ma = bmain->mat.first; while (ma) { - for (a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if (ma->id.lib==NULL) { - ma->mtex[a]->tex= tex_new; + 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--; } } } - ma= ma->id.next; + ma = ma->id.next; } - la= bmain->lamp.first; + la = bmain->lamp.first; while (la) { - for (a=0; amtex[a] && la->mtex[a]->tex==tex) { - if (la->id.lib==NULL) { - la->mtex[a]->tex= tex_new; + 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--; } } } - la= la->id.next; + la = la->id.next; } - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - for (a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if (wrld->id.lib==NULL) { - wrld->mtex[a]->tex= tex_new; + 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--; } } } - wrld= wrld->id.next; + wrld = wrld->id.next; } - br= bmain->brush.first; + br = bmain->brush.first; while (br) { - if (br->mtex.tex==tex) { - if (br->id.lib==NULL) { - br->mtex.tex= tex_new; + if (br->mtex.tex == tex) { + if (br->id.lib == NULL) { + br->mtex.tex = tex_new; tex_new->id.us++; tex->id.us--; } } - br= br->id.next; + br = br->id.next; } - pa= bmain->particle.first; + pa = bmain->particle.first; while (pa) { - for (a=0; amtex[a] && pa->mtex[a]->tex==tex) { - if (pa->id.lib==NULL) { - pa->mtex[a]->tex= tex_new; + 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--; } } } - pa= pa->id.next; + pa = pa->id.next; } } } @@ -1055,10 +1055,10 @@ void BKE_texture_make_local(Tex *tex) #if 0 /* UNUSED */ void autotexname(Tex *tex) { - Main *bmain= G.main; - char texstr[20][15]= {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", - "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", - "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; + Main *bmain = G.main; + char texstr[20][15] = {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", + "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", + "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; @@ -1067,8 +1067,8 @@ void autotexname(Tex *tex) new_id(&bmain->tex, (ID *)tex, "Noddy"); } else - if (tex->type==TEX_IMAGE) { - ima= tex->ima; + if (tex->type == TEX_IMAGE) { + ima = tex->ima; if (ima) { BLI_strncpy(di, ima->name, sizeof(di)); BLI_splitdirstring(di, fi); @@ -1078,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,21 +1089,21 @@ void autotexname(Tex *tex) Tex *give_current_object_texture(Object *ob) { Material *ma, *node_ma; - Tex *tex= NULL; + 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) { - tex= give_current_lamp_texture(ob->data); + if (ob->type == OB_LAMP) { + tex = give_current_lamp_texture(ob->data); } else { - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); - if ((node_ma=give_node_material(ma))) - ma= node_ma; + if ((node_ma = give_node_material(ma))) + ma = node_ma; - tex= give_current_material_texture(ma); + tex = give_current_material_texture(ma); } return tex; @@ -1111,12 +1111,12 @@ Tex *give_current_object_texture(Object *ob) Tex *give_current_lamp_texture(Lamp *la) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (la) { - mtex= la->mtex[(int)(la->texact)]; - if (mtex) tex= mtex->tex; + mtex = la->mtex[(int)(la->texact)]; + if (mtex) tex = mtex->tex; } return tex; @@ -1124,23 +1124,23 @@ Tex *give_current_lamp_texture(Lamp *la) void set_current_lamp_texture(Lamp *la, Tex *newtex) { - int act= la->texact; + int act = la->texact; if (la->mtex[act] && la->mtex[act]->tex) id_us_min(&la->mtex[act]->tex->id); if (newtex) { if (!la->mtex[act]) { - la->mtex[act]= add_mtex(); - la->mtex[act]->texco= TEXCO_GLOB; + la->mtex[act] = add_mtex(); + la->mtex[act]->texco = TEXCO_GLOB; } - la->mtex[act]->tex= newtex; + la->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (la->mtex[act]) { MEM_freeN(la->mtex[act]); - la->mtex[act]= NULL; + la->mtex[act] = NULL; } } @@ -1154,25 +1154,25 @@ bNode *give_current_material_texture_node(Material *ma) Tex *give_current_material_texture(Material *ma) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; bNode *node; 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); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) { - tex= (Tex *)node->id; - ma= NULL; + tex = (Tex *)node->id; + ma = NULL; } } if (ma) { - mtex= ma->mtex[(int)(ma->texact)]; - if (mtex) tex= mtex->tex; + mtex = ma->mtex[(int)(ma->texact)]; + if (mtex) tex = mtex->tex; } return tex; @@ -1181,26 +1181,26 @@ Tex *give_current_material_texture(Material *ma) 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); - break; - case ID_WO: - *mtex_ar= ((World *)id)->mtex; - if (act) *act= (((World *)id)->texact); - break; - case ID_LA: - *mtex_ar= ((Lamp *)id)->mtex; - if (act) *act= (((Lamp *)id)->texact); - break; - case ID_PA: - *mtex_ar= ((ParticleSettings *)id)->mtex; - if (act) *act= (((ParticleSettings *)id)->texact); - break; - default: - *mtex_ar = NULL; - if (act) *act= 0; - return FALSE; + case ID_MA: + *mtex_ar = ((Material *)id)->mtex; + if (act) *act = (((Material *)id)->texact); + break; + case ID_WO: + *mtex_ar = ((World *)id)->mtex; + if (act) *act = (((World *)id)->texact); + break; + case ID_LA: + *mtex_ar = ((Lamp *)id)->mtex; + if (act) *act = (((Lamp *)id)->texact); + break; + case ID_PA: + *mtex_ar = ((ParticleSettings *)id)->mtex; + if (act) *act = (((ParticleSettings *)id)->texact); + break; + default: + *mtex_ar = NULL; + if (act) *act = 0; + return FALSE; } return TRUE; @@ -1208,57 +1208,57 @@ 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: - ((Material *)id)->texact= act; - break; - case ID_WO: - ((World *)id)->texact= act; - break; - case ID_LA: - ((Lamp *)id)->texact= act; - break; - case ID_PA: - ((ParticleSettings *)id)->texact= act; - break; + case ID_MA: + ((Material *)id)->texact = act; + break; + case ID_WO: + ((World *)id)->texact = act; + break; + case ID_LA: + ((Lamp *)id)->texact = act; + break; + case ID_PA: + ((ParticleSettings *)id)->texact = act; + break; } } void set_current_material_texture(Material *ma, Tex *newtex) { - Tex *tex= NULL; + Tex *tex = NULL; bNode *node; if (ma && ma->use_nodes && ma->nodetree) { - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) { - tex= (Tex *)node->id; + tex = (Tex *)node->id; id_us_min(&tex->id); - node->id= &newtex->id; + node->id = &newtex->id; id_us_plus(&newtex->id); - ma= NULL; + ma = NULL; } } if (ma) { - int act= (int)ma->texact; + int act = (int)ma->texact; - tex= (ma->mtex[act])? ma->mtex[act]->tex: NULL; + tex = (ma->mtex[act]) ? ma->mtex[act]->tex : NULL; id_us_min(&tex->id); if (newtex) { if (!ma->mtex[act]) - ma->mtex[act]= add_mtex(); + ma->mtex[act] = add_mtex(); - ma->mtex[act]->tex= newtex; + ma->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (ma->mtex[act]) { MEM_freeN(ma->mtex[act]); - ma->mtex[act]= NULL; + ma->mtex[act] = NULL; } } } @@ -1268,7 +1268,7 @@ int has_current_material_texture(Material *ma) bNode *node; if (ma && ma->use_nodes && ma->nodetree) { - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) return 1; @@ -1279,36 +1279,36 @@ int has_current_material_texture(Material *ma) Tex *give_current_world_texture(World *world) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (!world) return NULL; - mtex= world->mtex[(int)(world->texact)]; - if (mtex) tex= mtex->tex; + mtex = world->mtex[(int)(world->texact)]; + if (mtex) tex = mtex->tex; return tex; } void set_current_world_texture(World *wo, Tex *newtex) { - int act= wo->texact; + int act = wo->texact; if (wo->mtex[act] && wo->mtex[act]->tex) id_us_min(&wo->mtex[act]->tex->id); if (newtex) { if (!wo->mtex[act]) { - wo->mtex[act]= add_mtex(); - wo->mtex[act]->texco= TEXCO_VIEW; + wo->mtex[act] = add_mtex(); + wo->mtex[act]->texco = TEXCO_VIEW; } - wo->mtex[act]->tex= newtex; + wo->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (wo->mtex[act]) { MEM_freeN(wo->mtex[act]); - wo->mtex[act]= NULL; + wo->mtex[act] = NULL; } } @@ -1323,44 +1323,44 @@ void set_current_brush_texture(Brush *br, Tex *newtex) id_us_min(&br->mtex.tex->id); if (newtex) { - br->mtex.tex= newtex; + br->mtex.tex = newtex; id_us_plus(&newtex->id); } } Tex *give_current_particle_texture(ParticleSettings *part) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (!part) return NULL; - mtex= part->mtex[(int)(part->texact)]; - if (mtex) tex= mtex->tex; + mtex = part->mtex[(int)(part->texact)]; + if (mtex) tex = mtex->tex; return tex; } void set_current_particle_texture(ParticleSettings *part, Tex *newtex) { - int act= part->texact; + int act = part->texact; if (part->mtex[act] && part->mtex[act]->tex) id_us_min(&part->mtex[act]->tex->id); if (newtex) { if (!part->mtex[act]) { - part->mtex[act]= add_mtex(); - part->mtex[act]->texco= TEXCO_ORCO; - part->mtex[act]->blendtype= MTEX_MUL; + part->mtex[act] = add_mtex(); + part->mtex[act]->texco = TEXCO_ORCO; + part->mtex[act]->blendtype = MTEX_MUL; } - part->mtex[act]->tex= newtex; + part->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (part->mtex[act]) { MEM_freeN(part->mtex[act]); - part->mtex[act]= NULL; + part->mtex[act] = NULL; } } @@ -1370,12 +1370,12 @@ EnvMap *BKE_add_envmap(void) { EnvMap *env; - env= MEM_callocN(sizeof(EnvMap), "envmap"); - env->type= ENV_CUBE; - env->stype= ENV_ANIM; - env->clipsta= 0.1; - env->clipend= 100.0; - env->cuberes= 600; + env = MEM_callocN(sizeof(EnvMap), "envmap"); + env->type = ENV_CUBE; + env->stype = ENV_ANIM; + env->clipsta = 0.1; + env->clipend = 100.0; + env->cuberes = 600; env->viewscale = 0.5; return env; @@ -1388,9 +1388,9 @@ EnvMap *BKE_copy_envmap(EnvMap *env) EnvMap *envn; int a; - envn= MEM_dupallocN(env); - envn->ok= 0; - for (a=0; a<6; a++) envn->cube[a]= NULL; + 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); return envn; @@ -1402,12 +1402,12 @@ void BKE_free_envmapdata(EnvMap *env) { unsigned int part; - for (part=0; part<6; part++) { + for (part = 0; part < 6; part++) { if (env->cube[part]) IMB_freeImBuf(env->cube[part]); - env->cube[part]= NULL; + env->cube[part] = NULL; } - env->ok= 0; + env->ok = 0; } /* ------------------------------------------------------------------------- */ @@ -1426,7 +1426,7 @@ PointDensity *BKE_add_pointdensity(void) { PointDensity *pd; - pd= MEM_callocN(sizeof(PointDensity), "pointdensity"); + pd = MEM_callocN(sizeof(PointDensity), "pointdensity"); pd->flag = 0; pd->radius = 0.3f; pd->falloff_type = TEX_PD_FALLOFF_STD; @@ -1443,7 +1443,7 @@ PointDensity *BKE_add_pointdensity(void) pd->totpoints = 0; pd->object = NULL; pd->psys = 0; - pd->psys_cache_space= TEX_PD_WORLDSPACE; + pd->psys_cache_space = TEX_PD_WORLDSPACE; pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); pd->falloff_curve->preset = CURVE_PRESET_LINE; @@ -1458,10 +1458,10 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd) { PointDensity *pdn; - pdn= MEM_dupallocN(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; } @@ -1511,11 +1511,11 @@ struct VoxelData *BKE_add_voxeldata(void) { VoxelData *vd; - vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata"); + vd = MEM_callocN(sizeof(struct VoxelData), "voxeldata"); vd->dataset = NULL; vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; - vd->interp_type= TEX_VD_LINEAR; - vd->file_format= TEX_VD_SMOKE; + vd->interp_type = TEX_VD_LINEAR; + vd->file_format = TEX_VD_SMOKE; vd->int_multiplier = 1.0; vd->extend = TEX_CLIP; vd->object = NULL; @@ -1523,13 +1523,13 @@ struct VoxelData *BKE_add_voxeldata(void) vd->ok = 0; return vd; - } +} struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) { VoxelData *vdn; - vdn= MEM_dupallocN(vd); + vdn = MEM_dupallocN(vd); vdn->dataset = NULL; return vdn; @@ -1541,7 +1541,7 @@ struct OceanTex *BKE_add_oceantex(void) { OceanTex *ot; - ot= MEM_callocN(sizeof(struct OceanTex), "ocean texture"); + ot = MEM_callocN(sizeof(struct OceanTex), "ocean texture"); ot->output = TEX_OCN_DISPLACEMENT; ot->object = NULL; @@ -1550,7 +1550,7 @@ struct OceanTex *BKE_add_oceantex(void) struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot) { - OceanTex *otn= MEM_dupallocN(ot); + OceanTex *otn = MEM_dupallocN(ot); return otn; } @@ -1568,8 +1568,9 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) // assume all plugins depend on time return 1; } - else if ( texture->ima && - ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { + else if (texture->ima && + ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) + { return 1; } else if (texture->adt) { -- cgit v1.2.3