예제 #1
0
static void material_changed(Main *bmain, Material *ma)
{
	Material *parent;
	Object *ob;
	Scene *scene;
	int texture_draw = false;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&ma->id));

	/* glsl */
	if (ma->gpumaterial.first)
		GPU_material_free(ma);

	/* find node materials using this */
	for (parent = bmain->mat.first; parent; parent = parent->id.next) {
		if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) {
			/* pass */
		}
		else {
			continue;
		}

		BKE_icon_changed(BKE_icon_getid(&parent->id));

		if (parent->gpumaterial.first)
			GPU_material_free(parent);
	}

	/* find if we have a scene with textured display */
	for (scene = bmain->scene.first; scene; scene = scene->id.next) {
		if (scene->customdata_mask & CD_MASK_MTFACE) {
			texture_draw = true;
			break;
		}
	}

	/* find textured objects */
	if (texture_draw && !(U.gameflags & USER_DISABLE_VBO)) {
		for (ob = bmain->object.first; ob; ob = ob->id.next) {
			DerivedMesh *dm = ob->derivedFinal;
			Material ***material = give_matarar(ob);
			short a, *totmaterial = give_totcolp(ob);

			if (dm && totmaterial && material) {
				for (a = 0; a < *totmaterial; a++) {
					if ((*material)[a] == ma) {
						GPU_drawobject_free(dm);
						break;
					}
				}
			}
		}
	}

}
예제 #2
0
static void texture_changed(Main *bmain, Tex *tex)
{
	Material *ma;
	Lamp *la;
	World *wo;
	Scene *scene;
	bNode *node;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&tex->id));

	/* find materials */
	for (ma = bmain->mat.first; ma; ma = ma->id.next) {
		if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)) ;
		else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) ;
		else continue;

		BKE_icon_changed(BKE_icon_getid(&ma->id));

		if (ma->gpumaterial.first)
			GPU_material_free(ma);
	}

	/* find lamps */
	for (la = bmain->lamp.first; la; la = la->id.next) {
		if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) ;
		else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) ;
		else continue;

		BKE_icon_changed(BKE_icon_getid(&la->id));
	}

	/* find worlds */
	for (wo = bmain->world.first; wo; wo = wo->id.next) {
		if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) ;
		else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) ;
		else continue;

		BKE_icon_changed(BKE_icon_getid(&wo->id));
	}

	/* find compositing nodes */
	for (scene = bmain->scene.first; scene; scene = scene->id.next) {
		if (scene->use_nodes && scene->nodetree) {
			for (node = scene->nodetree->nodes.first; node; node = node->next) {
				if (node->id == &tex->id)
					ED_node_changed_update(&scene->id, node);
			}
		}
	}
}
예제 #3
0
int ui_id_icon_get(bContext *C, ID *id, const bool big)
{
	int iconid = 0;
	
	/* icon */
	switch (GS(id->name)) {
		case ID_BR:
			iconid = ui_id_brush_get_icon(C, id);
			break;
		case ID_MA: /* fall through */
		case ID_TE: /* fall through */
		case ID_IM: /* fall through */
		case ID_WO: /* fall through */
		case ID_LA: /* fall through */
			iconid = BKE_icon_getid(id);
			/* checks if not exists, or changed */
			ui_id_icon_render(C, id, big);
			break;
		/*case ID_IL: 
			iconid= BKE_icon_getid(id);
			break;*/
		default:
			break;
	}

	return iconid;
}
예제 #4
0
static void image_changed(Main *bmain, Image *ima)
{
	Tex *tex;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&ima->id));

	/* textures */
	for (tex = bmain->tex.first; tex; tex = tex->id.next)
		if (tex->ima == ima)
			texture_changed(bmain, tex);
}
예제 #5
0
static void world_changed(Main *bmain, World *wo)
{
	Material *ma;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&wo->id));

	/* glsl */
	for (ma = bmain->mat.first; ma; ma = ma->id.next)
		if (ma->gpumaterial.first)
			GPU_material_free(ma);
}
예제 #6
0
static int ui_id_brush_get_icon(bContext *C, ID *id)
{
	Brush *br = (Brush *)id;

	if (br->flag & BRUSH_CUSTOM_ICON) {
		BKE_icon_getid(id);
		ui_id_brush_render(C, id);
	}
	else {
		Object *ob = CTX_data_active_object(C);
		SpaceImage *sima;
		EnumPropertyItem *items = NULL;
		int tool, mode = 0;

		/* XXX: this is not nice, should probably make brushes
		 * be strictly in one paint mode only to avoid
		 * checking various context stuff here */

		if (CTX_wm_view3d(C) && ob) {
			if (ob->mode & OB_MODE_SCULPT)
				mode = OB_MODE_SCULPT;
			else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))
				mode = OB_MODE_VERTEX_PAINT;
			else if (ob->mode & OB_MODE_TEXTURE_PAINT)
				mode = OB_MODE_TEXTURE_PAINT;
		}
		else if ((sima = CTX_wm_space_image(C)) &&
		         (sima->mode == SI_MODE_PAINT))
		{
			mode = OB_MODE_TEXTURE_PAINT;
		}

		/* reset the icon */
		if (mode == OB_MODE_SCULPT) {
			items = brush_sculpt_tool_items;
			tool = br->sculpt_tool;
		}
		else if (mode == OB_MODE_VERTEX_PAINT) {
			items = brush_vertex_tool_items;
			tool = br->vertexpaint_tool;
		}
		else if (mode == OB_MODE_TEXTURE_PAINT) {
			items = brush_image_tool_items;
			tool = br->imagepaint_tool;
		}

		if (!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id))
			id->icon_id = 0;
	}

	return id->icon_id;
}
예제 #7
0
static void material_changed(Main *bmain, Material *ma)
{
	Material *parent;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&ma->id));

	/* glsl */
	if (ma->gpumaterial.first)
		GPU_material_free(ma);

	/* find node materials using this */
	for (parent = bmain->mat.first; parent; parent = parent->id.next) {
		if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)) ;
		else continue;

		BKE_icon_changed(BKE_icon_getid(&parent->id));

		if (parent->gpumaterial.first)
			GPU_material_free(parent);
	}
}
예제 #8
0
static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int hideflag)
{
	int i, nids= BLI_countlist(lb);
		
	if (nr) *nr= -1;
	
	if (nr && nids>MAX_IDPUP) {
		BLI_dynstr_append(pupds, "DataBrowse %x-2");
		*nr= -2;
	} else {
		ID *id;
		
		for (i=0, id= lb->first; id; id= id->next, i++) {
			char buf[32];
			
			if (nr && id==link) *nr= i+1;

			if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.')
				continue;
			if (hideflag & IDPUP_NO_VIEWER)
				if (GS(id->name)==ID_IM)
					if ( ((Image *)id)->source==IMA_SRC_VIEWER )
						continue;
			
			get_flags_for_id(id, buf);
				
			BLI_dynstr_append(pupds, buf);
			BLI_dynstr_append(pupds, id->name+2);
			BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1);
			BLI_dynstr_append(pupds, buf);
			
			/* icon */
			switch(GS(id->name))
			{
			case ID_MA: /* fall through */
			case ID_TE: /* fall through */
			case ID_IM: /* fall through */
			case ID_WO: /* fall through */
			case ID_LA: /* fall through */
				BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) );
				BLI_dynstr_append(pupds, buf);
				break;
			default:
				break;
			}
			
			if(id->next)
				BLI_dynstr_append(pupds, "|");
		}
	}
}
예제 #9
0
static void lamp_changed(Main *bmain, Lamp *la)
{
	Object *ob;
	Material *ma;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&la->id));

	/* glsl */
	for (ob = bmain->object.first; ob; ob = ob->id.next)
		if (ob->data == la && ob->gpulamp.first)
			GPU_lamp_free(ob);

	for (ma = bmain->mat.first; ma; ma = ma->id.next)
		if (ma->gpumaterial.first)
			GPU_material_free(ma);
}
예제 #10
0
ImBuf *get_brush_icon(Brush *brush)
{
	static const int flags = IB_rect | IB_multilayer | IB_metadata;

	char path[FILE_MAX];
	const char *folder;

	if (!(brush->icon_imbuf)) {
		if (brush->flag & BRUSH_CUSTOM_ICON) {

			if (brush->icon_filepath[0]) {
				// first use the path directly to try and load the file

				BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath));
				BLI_path_abs(path, G.main->name);

				/* use default colorspaces for brushes */
				brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);

				// otherwise lets try to find it in other directories
				if (!(brush->icon_imbuf)) {
					folder = BLI_get_folder(BLENDER_DATAFILES, "brushicons");

					BLI_make_file_string(G.main->name, path, folder, brush->icon_filepath);

					if (path[0]) {
						/* use fefault color spaces */
						brush->icon_imbuf = IMB_loadiffname(path, flags, NULL);
					}
				}

				if (brush->icon_imbuf)
					BKE_icon_changed(BKE_icon_getid(&brush->id));
			}
		}
	}

	if (!(brush->icon_imbuf))
		brush->id.icon_id = 0;

	return brush->icon_imbuf;
}
예제 #11
0
static void texture_changed(Main *bmain, Tex *tex)
{
	Material *ma;
	Lamp *la;
	World *wo;
	Scene *scene;
	Object *ob;
	bNode *node;
	bool texture_draw = false;

	/* icons */
	BKE_icon_changed(BKE_icon_getid(&tex->id));

	/* paint overlays */
	for (scene = bmain->scene.first; scene; scene = scene->id.next)
		BKE_paint_invalidate_overlay_tex(scene, tex);

	/* find materials */
	for (ma = bmain->mat.first; ma; ma = ma->id.next) {
		if (!material_uses_texture(ma, tex))
			continue;

		BKE_icon_changed(BKE_icon_getid(&ma->id));

		if (ma->gpumaterial.first)
			GPU_material_free(ma);
	}

	/* find lamps */
	for (la = bmain->lamp.first; la; la = la->id.next) {
		if (mtex_use_tex(la->mtex, MAX_MTEX, tex)) {
			lamp_changed(bmain, la);
		}
		else if (la->nodetree && nodes_use_tex(la->nodetree, tex)) {
			lamp_changed(bmain, la);
		}
		else {
			continue;
		}
	}

	/* find worlds */
	for (wo = bmain->world.first; wo; wo = wo->id.next) {
		if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)) {
			/* pass */
		}
		else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)) {
			/* pass */
		}
		else {
			continue;
		}

		BKE_icon_changed(BKE_icon_getid(&wo->id));
	}

	/* find compositing nodes */
	for (scene = bmain->scene.first; scene; scene = scene->id.next) {
		if (scene->use_nodes && scene->nodetree) {
			for (node = scene->nodetree->nodes.first; node; node = node->next) {
				if (node->id == &tex->id)
					ED_node_tag_update_id(&scene->id);
			}
		}

		if (scene->customdata_mask & CD_MASK_MTFACE)
			texture_draw = true;
	}

	/* find textured objects */
	if (texture_draw && !(U.gameflags & USER_DISABLE_VBO)) {
		for (ob = bmain->object.first; ob; ob = ob->id.next) {
			DerivedMesh *dm = ob->derivedFinal;
			Material ***material = give_matarar(ob);
			short a, *totmaterial = give_totcolp(ob);

			if (dm && totmaterial && material) {
				for (a = 0; a < *totmaterial; a++) {
					if (ob->matbits && ob->matbits[a])
						ma = ob->mat[a];
					else
						ma = (*material)[a];

					if (ma && material_uses_texture(ma, tex)) {
						GPU_drawobject_free(dm);
						break;
					}
				}
			}
		}
	}
}