Exemplo n.º 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_id_ensure(&ma->id));

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

	/* 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_id_ensure(&parent->id));

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

	/* 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) {
		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;
					}
				}
			}
		}
	}

}
Exemplo n.º 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);
			}
		}
	}
}
Exemplo n.º 3
0
static void image_changed(Main *bmain, Image *ima)
{
	Tex *tex;

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

	/* textures */
	for (tex = bmain->tex.first; tex; tex = tex->id.next)
		if (tex->ima == ima)
			texture_changed(bmain, tex);
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
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);
	}
}
Exemplo n.º 6
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);
}
Exemplo n.º 7
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, BKE_main_blendfile_path_from_global());

        /* 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 = BKE_appdir_folder_id(BLENDER_DATAFILES, "brushicons");

          BLI_make_file_string(
              BKE_main_blendfile_path_from_global(), 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_id_ensure(&brush->id));
        }
      }
    }
  }

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

  return brush->icon_imbuf;
}
Exemplo n.º 8
0
static void world_changed(Main *bmain, World *wo)
{
	Material *ma;

	/* icons */
	BKE_icon_changed(BKE_icon_id_ensure(&wo->id));
	
	/* glsl */
	for (ma = bmain->mat.first; ma; ma = ma->id.next)
		if (ma->gpumaterial.first)
			GPU_material_free(&ma->gpumaterial);

	if (defmaterial.gpumaterial.first)
		GPU_material_free(&defmaterial.gpumaterial);
	
	if (wo->gpumaterial.first)
		GPU_material_free(&wo->gpumaterial);
}
Exemplo n.º 9
0
/* Helper function to join 2 areas, it has a return value, 0=failed 1=success
 * used by the split, join operators
 */
int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2)
{
  int dir;

  dir = area_getorientation(sa1, sa2);
  /*printf("dir is : %i\n", dir);*/

  if (dir == -1) {
    return 0;
  }

  if (dir == 0) {
    sa1->v1 = sa2->v1;
    sa1->v2 = sa2->v2;
    screen_geom_edge_add(scr, sa1->v2, sa1->v3);
    screen_geom_edge_add(scr, sa1->v1, sa1->v4);
  }
  else if (dir == 1) {
    sa1->v2 = sa2->v2;
    sa1->v3 = sa2->v3;
    screen_geom_edge_add(scr, sa1->v1, sa1->v2);
    screen_geom_edge_add(scr, sa1->v3, sa1->v4);
  }
  else if (dir == 2) {
    sa1->v3 = sa2->v3;
    sa1->v4 = sa2->v4;
    screen_geom_edge_add(scr, sa1->v2, sa1->v3);
    screen_geom_edge_add(scr, sa1->v1, sa1->v4);
  }
  else if (dir == 3) {
    sa1->v1 = sa2->v1;
    sa1->v4 = sa2->v4;
    screen_geom_edge_add(scr, sa1->v1, sa1->v2);
    screen_geom_edge_add(scr, sa1->v3, sa1->v4);
  }

  screen_delarea(C, scr, sa2);
  BKE_screen_remove_double_scrverts(scr);
  /* Update preview thumbnail */
  BKE_icon_changed(scr->id.icon_id);

  return 1;
}
Exemplo n.º 10
0
ImBuf* get_brush_icon(Brush *brush)
{
	static const int flags = IB_rect|IB_multilayer|IB_metadata;

	char path[240];
	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);

				brush->icon_imbuf= IMB_loadiffname(path, flags);

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

					path[0]= 0;

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

					if (path[0])
						brush->icon_imbuf= IMB_loadiffname(path, flags);
				}

				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;
}
Exemplo n.º 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_id_ensure(&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_id_ensure(&ma->id));

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

	/* 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_id_ensure(&wo->id));
		
		if (wo->gpumaterial.first)
			GPU_material_free(&wo->gpumaterial);		
	}

	/* 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) {
		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;
					}
				}
			}
		}
	}
}