Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image.c
| Context not available. | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_depsgraph.h" | #include "BKE_depsgraph.h" | ||||
| #include "BKE_DerivedMesh.h" | |||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| Context not available. | |||||
| #include "RNA_enum_types.h" | #include "RNA_enum_types.h" | ||||
| #include "GPU_draw.h" | #include "GPU_draw.h" | ||||
| #include "GPU_buffers.h" | |||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "BIF_glutil.h" | #include "BIF_glutil.h" | ||||
| Context not available. | |||||
| copy_v2_v2(pop->prevmouse, mouse); | copy_v2_v2(pop->prevmouse, mouse); | ||||
| copy_v2_v2(pop->startmouse, mouse); | copy_v2_v2(pop->startmouse, mouse); | ||||
| if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) { | |||||
| pop->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, gradient_draw_line, pop); | |||||
| } | |||||
| /* initialize from context */ | /* initialize from context */ | ||||
| if (CTX_wm_region_view3d(C)) { | if (CTX_wm_region_view3d(C)) { | ||||
| Object *ob = OBACT; | Object *ob = OBACT; | ||||
| bool uvs, mat, tex, stencil; | paint_proj_mesh_data_ensure(C, ob, op); | ||||
| if (!BKE_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, &stencil)) { | |||||
| BKE_paint_data_warning(op->reports, uvs, mat, tex, stencil); | |||||
| MEM_freeN(pop); | |||||
| WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); | |||||
| return NULL; | |||||
| } | |||||
| pop->mode = PAINT_MODE_3D_PROJECT; | pop->mode = PAINT_MODE_3D_PROJECT; | ||||
| pop->custom_paint = paint_proj_new_stroke(C, ob, mouse, mode); | pop->custom_paint = paint_proj_new_stroke(C, ob, mouse, mode); | ||||
| } | } | ||||
| Context not available. | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) { | |||||
| pop->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, gradient_draw_line, pop); | |||||
| } | |||||
| settings->imapaint.flag |= IMAGEPAINT_DRAWING; | settings->imapaint.flag |= IMAGEPAINT_DRAWING; | ||||
| ED_undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name, | ED_undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name, | ||||
| ED_image_undo_restore, ED_image_undo_free, NULL); | ED_image_undo_restore, ED_image_undo_free, NULL); | ||||
| Context not available. | |||||
| * cache in case we are loading a file */ | * cache in case we are loading a file */ | ||||
| BKE_texpaint_slots_refresh_object(scene, ob); | BKE_texpaint_slots_refresh_object(scene, ob); | ||||
| BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); | paint_proj_mesh_data_ensure(C, ob, op); | ||||
| /* entering paint mode also sets image to editors */ | /* entering paint mode also sets image to editors */ | ||||
| if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { | if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { | ||||
| Material *ma = give_current_material(ob, ob->actcol); /* set the current material active paint slot on image editor */ | Material *ma = give_current_material(ob, ob->actcol); /* set the current material active paint slot on image editor */ | ||||
| if (ma && ma->texpaintslot) | if (ma->texpaintslot) | ||||
| ima = ma->texpaintslot[ma->paint_active_slot].ima; | ima = ma->texpaintslot[ma->paint_active_slot].ima; | ||||
| } | } | ||||
| else if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { | else if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { | ||||
| ima = imapaint->canvas; | ima = imapaint->canvas; | ||||
| } | } | ||||
| if (ima) { | for (sc = bmain->screen.first; sc; sc = sc->id.next) { | ||||
| for (sc = bmain->screen.first; sc; sc = sc->id.next) { | ScrArea *sa; | ||||
| ScrArea *sa; | for (sa = sc->areabase.first; sa; sa = sa->next) { | ||||
| for (sa = sc->areabase.first; sa; sa = sa->next) { | SpaceLink *sl; | ||||
| SpaceLink *sl; | for (sl = sa->spacedata.first; sl; sl = sl->next) { | ||||
| for (sl = sa->spacedata.first; sl; sl = sl->next) { | if (sl->spacetype == SPACE_IMAGE) { | ||||
| if (sl->spacetype == SPACE_IMAGE) { | SpaceImage *sima = (SpaceImage *)sl; | ||||
| SpaceImage *sima = (SpaceImage *)sl; | |||||
| if (!sima->pin) | |||||
| if (!sima->pin) | ED_space_image_set(sima, scene, scene->obedit, ima); | ||||
| ED_space_image_set(sima, scene, scene->obedit, ima); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| toggle_paint_cursor(C, 1); | toggle_paint_cursor(C, 1); | ||||
| } | } | ||||
| GPU_drawobject_free(ob->derivedFinal); | DAG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); | WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene); | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| Context not available. | |||||