Esempio n. 1
0
void BKE_lamp_free(Lamp *la)
{
	MTex *mtex;
	int a;

	for (a = 0; a < MAX_MTEX; a++) {
		mtex = la->mtex[a];
		if (mtex && mtex->tex) mtex->tex->id.us--;
		if (mtex) MEM_freeN(mtex);
	}
	
	BKE_free_animdata((ID *)la);

	curvemapping_free(la->curfalloff);

	/* is no lib link block, but lamp extension */
	if (la->nodetree) {
		ntreeFreeTree(la->nodetree);
		MEM_freeN(la->nodetree);
	}
	
	BKE_previewimg_free(&la->preview);
	BKE_icon_delete(&la->id);
	la->id.icon_id = 0;
}
Esempio n. 2
0
void BKE_previewimg_id_free(ID *id)
{
	PreviewImage **prv_p = BKE_previewimg_id_get_p(id);
	if (prv_p) {
		BKE_previewimg_free(prv_p);
	}
}
Esempio n. 3
0
void BKE_world_free_ex(World *wrld, bool do_id_user)
{
	MTex *mtex;
	int a;
	
	for (a = 0; a < MAX_MTEX; a++) {
		mtex = wrld->mtex[a];
		if (do_id_user && mtex && mtex->tex) mtex->tex->id.us--;
		if (mtex) MEM_freeN(mtex);
	}
	BKE_previewimg_free(&wrld->preview);

	BKE_animdata_free((ID *)wrld);

	/* is no lib link block, but world extension */
	if (wrld->nodetree) {
		ntreeFreeTree_ex(wrld->nodetree, do_id_user);
		MEM_freeN(wrld->nodetree);
	}

	if (wrld->gpumaterial.first)
		GPU_material_free(&wrld->gpumaterial);
	
	BKE_icon_delete((struct ID *)wrld);
	wrld->id.icon_id = 0;
}
Esempio n. 4
0
/** Free (or release) any data used by this texture (does not free the texure itself). */
void BKE_texture_free(Tex *tex)
{
	BKE_animdata_free((ID *)tex, false);

	/* is no lib link block, but texture extension */
	if (tex->nodetree) {
		ntreeFreeTree(tex->nodetree);
		MEM_freeN(tex->nodetree);
		tex->nodetree = NULL;
	}

	MEM_SAFE_FREE(tex->coba);
	if (tex->env) {
		BKE_texture_envmap_free(tex->env);
		tex->env = NULL;
	}
	if (tex->pd) {
		BKE_texture_pointdensity_free(tex->pd);
		tex->pd = NULL;
	}
	if (tex->vd) {
		BKE_texture_voxeldata_free(tex->vd);
		tex->vd = NULL;
	}
	if (tex->ot) {
		BKE_texture_ocean_free(tex->ot);
		tex->ot = NULL;
	}
	
	BKE_icon_id_delete((ID *)tex);
	BKE_previewimg_free(&tex->preview);
}
Esempio n. 5
0
/* not material itself */
void free_material(Material *ma)
{
	MTex *mtex;
	int a;
	
	for(a=0; a<MAX_MTEX; a++) {
		mtex= ma->mtex[a];
		if(mtex && mtex->tex) mtex->tex->id.us--;
		if(mtex) MEM_freeN(mtex);
	}
	
	if(ma->ramp_col) MEM_freeN(ma->ramp_col);
	if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
	
	BKE_free_animdata((ID *)ma);
	
	if(ma->preview)
		BKE_previewimg_free(&ma->preview);
	BKE_icon_delete((struct ID*)ma);
	ma->id.icon_id = 0;
	
	/* is no lib link block, but material extension */
	if(ma->nodetree) {
		ntreeFreeTree(ma->nodetree);
		MEM_freeN(ma->nodetree);
	}

	if(ma->gpumaterial.first)
		GPU_material_free(ma);
}
Esempio n. 6
0
/** Free (or release) any data used by this collection (does not free the collection itself). */
void BKE_collection_free(Collection *collection)
{
  /* No animdata here. */
  BKE_previewimg_free(&collection->preview);

  BLI_freelistN(&collection->gobject);
  BLI_freelistN(&collection->children);
  BLI_freelistN(&collection->parents);

  BKE_collection_object_cache_free(collection);
}
Esempio n. 7
0
/** Free (or release) any data used by this brush (does not free the brush itself). */
void BKE_brush_free(Brush *brush)
{
	if (brush->icon_imbuf) {
		IMB_freeImBuf(brush->icon_imbuf);
	}

	curvemapping_free(brush->curve);

	MEM_SAFE_FREE(brush->gradient);

	BKE_previewimg_free(&(brush->preview));
}
Esempio n. 8
0
/* not brush itself */
void free_brush(Brush *brush)
{
	if (brush->mtex.tex)
		brush->mtex.tex->id.us--;

	if (brush->icon_imbuf)
		IMB_freeImBuf(brush->icon_imbuf);

	BKE_previewimg_free(&(brush->preview));

	curvemapping_free(brush->curve);
}
Esempio n. 9
0
void BKE_previewimg_free_id(ID *id) 
{
	if (GS(id->name) == ID_MA) {
		Material *mat = (Material *)id;
		BKE_previewimg_free(&mat->preview);
	}
	else if (GS(id->name) == ID_TE) {
		Tex *tex = (Tex *)id;
		BKE_previewimg_free(&tex->preview);
	}
	else if (GS(id->name) == ID_WO) {
		World *wo = (World *)id;
		BKE_previewimg_free(&wo->preview);
	}
	else if (GS(id->name) == ID_LA) {
		Lamp *la  = (Lamp *)id;
		BKE_previewimg_free(&la->preview);
	}
	else if (GS(id->name) == ID_IM) {
		Image *img  = (Image *)id;
		BKE_previewimg_free(&img->preview);
	}
	else if (GS(id->name) == ID_BR) {
		Brush *br  = (Brush *)id;
		BKE_previewimg_free(&br->preview);
	}
}
Esempio n. 10
0
/**
 * Generate a PreviewImage from given file path, using thumbnails management, if not yet existing.
 */
PreviewImage *BKE_previewimg_cached_thumbnail_read(
        const char *name, const char *path, const int source, bool force_update)
{
	PreviewImage *prv = NULL;
	void **prv_p;

	prv_p = BLI_ghash_lookup_p(gCachedPreviews, name);

	if (prv_p) {
		prv = *prv_p;
		BLI_assert(prv);
	}

	if (prv && force_update) {
		const char *prv_deferred_data = PRV_DEFERRED_DATA(prv);
		if (((int)prv_deferred_data[0] == source) && STREQ(&prv_deferred_data[1], path)) {
			/* If same path, no need to re-allocate preview, just clear it up. */
			BKE_previewimg_clear(prv);
		}
		else {
			BKE_previewimg_free(&prv);
		}
	}

	if (!prv) {
		/* We pack needed data for lazy loading (source type, in a single char, and path). */
		const size_t deferred_data_size = strlen(path) + 2;
		char *deferred_data;

		prv = previewimg_create_ex(deferred_data_size);
		deferred_data = PRV_DEFERRED_DATA(prv);
		deferred_data[0] = source;
		memcpy(&deferred_data[1], path, deferred_data_size - 1);

		force_update = true;
	}

	if (force_update) {
		if (prv_p) {
			*prv_p = prv;
		}
		else {
			BLI_ghash_insert(gCachedPreviews, BLI_strdup(name), prv);
		}
	}

	return prv;
}
Esempio n. 11
0
/* not brush itself */
void BKE_brush_free(Brush *brush)
{
	id_us_min((ID *)brush->mtex.tex);
	id_us_min((ID *)brush->mask_mtex.tex);
	id_us_min((ID *)brush->paint_curve);

	if (brush->icon_imbuf)
		IMB_freeImBuf(brush->icon_imbuf);

	BKE_previewimg_free(&(brush->preview));

	curvemapping_free(brush->curve);

	if (brush->gradient)
		MEM_freeN(brush->gradient);
}
Esempio n. 12
0
File: world.c Progetto: jinjoh/NOOR
void free_world(World *wrld)
{
	MTex *mtex;
	int a;
	
	for(a=0; a<MAX_MTEX; a++) {
		mtex= wrld->mtex[a];
		if(mtex && mtex->tex) mtex->tex->id.us--;
		if(mtex) MEM_freeN(mtex);
	}
	BKE_previewimg_free(&wrld->preview);

	BKE_free_animdata((ID *)wrld);

	BKE_icon_delete((struct ID*)wrld);
	wrld->id.icon_id = 0;
}
Esempio n. 13
0
void BKE_light_free(Light *la)
{
  BKE_animdata_free((ID *)la, false);

  curvemapping_free(la->curfalloff);

  /* is no lib link block, but light extension */
  if (la->nodetree) {
    ntreeFreeNestedTree(la->nodetree);
    MEM_freeN(la->nodetree);
    la->nodetree = NULL;
  }

  BKE_previewimg_free(&la->preview);
  BKE_icon_id_delete(&la->id);
  la->id.icon_id = 0;
}
Esempio n. 14
0
void BKE_texture_free(Tex *tex)
{
	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) {
		ntreeFreeTree(tex->nodetree);
		MEM_freeN(tex->nodetree);
	}
}
Esempio n. 15
0
/** Free (or release) any data used by this brush (does not free the brush itself). */
void BKE_brush_free(Brush *brush)
{
  if (brush->icon_imbuf) {
    IMB_freeImBuf(brush->icon_imbuf);
  }
  curvemapping_free(brush->curve);

  if (brush->gpencil_settings != NULL) {
    curvemapping_free(brush->gpencil_settings->curve_sensitivity);
    curvemapping_free(brush->gpencil_settings->curve_strength);
    curvemapping_free(brush->gpencil_settings->curve_jitter);
    MEM_SAFE_FREE(brush->gpencil_settings);
  }

  MEM_SAFE_FREE(brush->gradient);

  BKE_previewimg_free(&(brush->preview));
}