diff options
Diffstat (limited to 'source/blender/blenkernel/intern/texture.c')
-rw-r--r-- | source/blender/blenkernel/intern/texture.c | 124 |
1 files changed, 10 insertions, 114 deletions
diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index ad7c5e3f660..f4e89160487 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -41,6 +41,7 @@ #include "DNA_color_types.h" #include "DNA_particle_types.h" #include "DNA_linestyle_types.h" +#include "DNA_defaults.h" #include "IMB_imbuf.h" @@ -214,56 +215,11 @@ void BKE_texture_free(Tex *tex) void BKE_texture_default(Tex *tex) { - /* Not here, can be called with some pointers set. :/ */ - /* BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); */ - - tex->type = TEX_IMAGE; - tex->ima = NULL; - 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->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; - /* musgrave */ - tex->mg_H = 1.0; - tex->mg_lacunarity = 2.0; - tex->mg_octaves = 2.0; - tex->mg_offset = 1.0; - tex->mg_gain = 1.0; - tex->ns_outscale = 1.0; - /* distnoise */ - tex->dist_amount = 1.0; - /* voronoi */ - tex->vn_w1 = 1.0; - tex->vn_w2 = tex->vn_w3 = tex->vn_w4 = 0.0; - tex->vn_mexp = 2.5; - tex->vn_distm = 0; - tex->vn_coltype = 0; + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(tex, id)); - BKE_imageuser_default(&tex->iuser); + MEMCPY_STRUCT_AFTER(tex, DNA_struct_default_get(Tex), id); - tex->preview = NULL; + BKE_imageuser_default(&tex->iuser); } void BKE_texture_type_set(Tex *tex, int type) @@ -288,69 +244,7 @@ Tex *BKE_texture_add(Main *bmain, const char *name) void BKE_texture_mtex_default(MTex *mtex) { - mtex->texco = TEXCO_UV; - 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->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->kinkampfac = 1.0f; - mtex->roughfac = 1.0f; - mtex->twistfac = 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->brush_map_mode = MTEX_MAP_MODE_TILED; - mtex->random_angle = 2.0f * (float)M_PI; - mtex->brush_angle_mode = 0; + memcpy(mtex, DNA_struct_default_get(MTex), sizeof(*mtex)); } /* ------------------------------------------------------------------------- */ @@ -423,6 +317,9 @@ MTex *BKE_texture_mtex_add_id(ID *id, int slot) */ void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const int flag) { + /* We always need allocation of our private ID data. */ + const int flag_private_id_data = flag & ~LIB_ID_CREATE_NO_ALLOCATE; + if (!BKE_texture_is_image_user(tex_src)) { tex_dst->ima = NULL; } @@ -434,9 +331,8 @@ void BKE_texture_copy_data(Main *bmain, Tex *tex_dst, const Tex *tex_src, const if (tex_src->nodetree->execdata) { ntreeTexEndExecTree(tex_src->nodetree->execdata); } - /* Note: nodetree is *not* in bmain, however this specific case is handled at lower level - * (see BKE_libblock_copy_ex()). */ - BKE_id_copy_ex(bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag); + BKE_id_copy_ex( + bmain, (ID *)tex_src->nodetree, (ID **)&tex_dst->nodetree, flag_private_id_data); } if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0) { |