static void scene_changed(Main *bmain, Scene *scene) { Object *ob; Material *ma; World *wo; /* glsl */ for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->gpulamp.first) GPU_lamp_free(ob); if (ob->mode & OB_MODE_TEXTURE_PAINT) { BKE_texpaint_slots_refresh_object(scene, ob); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); GPU_drawobject_free(ob->derivedFinal); } } for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->gpumaterial.first) GPU_material_free(&ma->gpumaterial); for (wo = bmain->world.first; wo; wo = wo->id.next) if (wo->gpumaterial.first) GPU_material_free(&wo->gpumaterial); if (defmaterial.gpumaterial.first) GPU_material_free(&defmaterial.gpumaterial); }
static void rna_ImaPaint_canvas_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) { Object *ob = OBACT; bScreen *sc; Image *ima = scene->toolsettings->imapaint.canvas; for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; if (!sima->pin) ED_space_image_set(bmain, sima, scene, scene->obedit, ima); } } } } if (ob && ob->type == OB_MESH) { GPU_drawobject_free(ob->derivedFinal); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } }
static void rna_ImaPaint_stencil_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { Object *ob = OBACT; GPU_drawobject_free(ob->derivedFinal); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); }
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; } } } } } }
static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { Object *ob = OBACT; /* of course we need to invalidate here */ BKE_texpaint_slots_refresh_object(scene, ob); /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */ GPU_drawobject_free(ob->derivedFinal); WM_main_add_notifier(NC_GEOM | ND_DATA, &ob->id); }
static void rna_ImaPaint_mode_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { Object *ob = OBACT; if (ob && ob->type == OB_MESH) { /* of course we need to invalidate here */ BKE_texpaint_slots_refresh_object(scene, ob); /* we assume that changing the current mode will invalidate the uv layers so we need to refresh display */ GPU_drawobject_free(ob->derivedFinal); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); } }
/* copy the face flags, most importantly selection from the mesh to the final derived mesh, * use in object mode when selecting faces (while painting) */ void paintface_flush_flags(Object *ob, short flag) { Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MPoly *polys, *mp_orig; const int *index_array = NULL; int totpoly; int i; BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0); if (me == NULL) return; /* note, call #BKE_mesh_flush_hidden_from_verts_ex first when changing hidden flags */ /* we could call this directly in all areas that change selection, * since this could become slow for realtime updates (circle-select for eg) */ if (flag & SELECT) { BKE_mesh_flush_select_from_polys(me); } if (dm == NULL) return; /* Mesh polys => Final derived polys */ if ((index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX))) { polys = dm->getPolyArray(dm); totpoly = dm->getNumPolys(dm); /* loop over final derived polys */ for (i = 0; i < totpoly; i++) { if (index_array[i] != ORIGINDEX_NONE) { /* Copy flags onto the final derived poly from the original mesh poly */ mp_orig = me->mpoly + index_array[i]; polys[i].flag = mp_orig->flag; } } } if (flag & ME_HIDE) { /* draw-object caches hidden faces, force re-generation T46867 */ GPU_drawobject_free(dm); } }
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; } } } } } }