Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_proj.c
| Show First 20 Lines • Show All 4,006 Lines • ▼ Show 20 Lines | if (ps->seam_bleed_px > 0.0f) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* Return true if evaluated mesh can be painted on, false otherwise */ | /* Return true if evaluated mesh can be painted on, false otherwise */ | ||||
| static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *ps) | static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *ps) | ||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Object *ob = ps->ob; | Object *ob = ps->ob; | ||||
| Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); | ||||
| Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); | Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); | ||||
| if (scene_eval == NULL || ob_eval == NULL) { | if (scene_eval == NULL || ob_eval == NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,681 Lines • ▼ Show 20 Lines | void paint_proj_stroke(const bContext *C, | ||||
| float size) | float size) | ||||
| { | { | ||||
| int i; | int i; | ||||
| ProjStrokeHandle *ps_handle = ps_handle_p; | ProjStrokeHandle *ps_handle = ps_handle_p; | ||||
| /* clone gets special treatment here to avoid going through image initialization */ | /* clone gets special treatment here to avoid going through image initialization */ | ||||
| if (ps_handle->is_clone_cursor_pick) { | if (ps_handle->is_clone_cursor_pick) { | ||||
| Scene *scene = ps_handle->scene; | Scene *scene = ps_handle->scene; | ||||
| struct Depsgraph *depsgraph = CTX_data_depsgraph(C); | struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| float *cursor = scene->cursor.location; | float *cursor = scene->cursor.location; | ||||
| int mval_i[2] = {(int)pos[0], (int)pos[1]}; | int mval_i[2] = {(int)pos[0], (int)pos[1]}; | ||||
| view3d_operator_needs_opengl(C); | view3d_operator_needs_opengl(C); | ||||
| if (!ED_view3d_autodist(depsgraph, ar, v3d, mval_i, cursor, false, NULL)) { | if (!ED_view3d_autodist(depsgraph, ar, v3d, mval_i, cursor, false, NULL)) { | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int mode) | ||||
| ps->pixel_sizeof = project_paint_pixel_sizeof(ps->tool); | ps->pixel_sizeof = project_paint_pixel_sizeof(ps->tool); | ||||
| BLI_assert(ps->pixel_sizeof >= sizeof(ProjPixel)); | BLI_assert(ps->pixel_sizeof >= sizeof(ProjPixel)); | ||||
| /* these can be NULL */ | /* these can be NULL */ | ||||
| ps->v3d = CTX_wm_view3d(C); | ps->v3d = CTX_wm_view3d(C); | ||||
| ps->rv3d = CTX_wm_region_view3d(C); | ps->rv3d = CTX_wm_region_view3d(C); | ||||
| ps->ar = CTX_wm_region(C); | ps->ar = CTX_wm_region(C); | ||||
| ps->depsgraph = CTX_data_depsgraph(C); | ps->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ps->scene = scene; | ps->scene = scene; | ||||
| /* allow override of active object */ | /* allow override of active object */ | ||||
| ps->ob = ob; | ps->ob = ob; | ||||
| ps->do_material_slots = (settings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); | ps->do_material_slots = (settings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); | ||||
| ps->stencil_ima = settings->imapaint.stencil; | ps->stencil_ima = settings->imapaint.stencil; | ||||
| ps->canvas_ima = (!ps->do_material_slots) ? settings->imapaint.canvas : NULL; | ps->canvas_ima = (!ps->do_material_slots) ? settings->imapaint.canvas : NULL; | ||||
| ps->clone_ima = (!ps->do_material_slots) ? settings->imapaint.clone : NULL; | ps->clone_ima = (!ps->do_material_slots) ? settings->imapaint.clone : NULL; | ||||
| ▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Lines | |||||
| static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) | static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Image *image; | Image *image; | ||||
| ImBuf *ibuf; | ImBuf *ibuf; | ||||
| char filename[FILE_MAX]; | char filename[FILE_MAX]; | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ToolSettings *settings = scene->toolsettings; | ToolSettings *settings = scene->toolsettings; | ||||
| int w = settings->imapaint.screen_grab_size[0]; | int w = settings->imapaint.screen_grab_size[0]; | ||||
| int h = settings->imapaint.screen_grab_size[1]; | int h = settings->imapaint.screen_grab_size[1]; | ||||
| int maxsize; | int maxsize; | ||||
| char err_out[256] = "unknown"; | char err_out[256] = "unknown"; | ||||
| ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); | ScrArea *sa = BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0); | ||||
| ▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | if (image) { | ||||
| val.array.type = IDP_FLOAT; | val.array.type = IDP_FLOAT; | ||||
| view_data = IDP_New(IDP_ARRAY, &val, PROJ_VIEW_DATA_ID); | view_data = IDP_New(IDP_ARRAY, &val, PROJ_VIEW_DATA_ID); | ||||
| array = (float *)IDP_Array(view_data); | array = (float *)IDP_Array(view_data); | ||||
| memcpy(array, rv3d->winmat, sizeof(rv3d->winmat)); | memcpy(array, rv3d->winmat, sizeof(rv3d->winmat)); | ||||
| array += sizeof(rv3d->winmat) / sizeof(float); | array += sizeof(rv3d->winmat) / sizeof(float); | ||||
| memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); | memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); | ||||
| array += sizeof(rv3d->viewmat) / sizeof(float); | array += sizeof(rv3d->viewmat) / sizeof(float); | ||||
| is_ortho = ED_view3d_clip_range_get( | is_ortho = ED_view3d_clip_range_get(depsgraph, v3d, rv3d, &array[0], &array[1], true); | ||||
brecht: Do this at the start of the function? Otherwise edits to the image can cause an additional… | |||||
| CTX_data_depsgraph(C), v3d, rv3d, &array[0], &array[1], true); | |||||
| /* using float for a bool is dodgy but since its an extra member in the array... | /* using float for a bool is dodgy but since its an extra member in the array... | ||||
| * easier then adding a single bool prop */ | * easier then adding a single bool prop */ | ||||
| array[2] = is_ortho ? 1.0f : 0.0f; | array[2] = is_ortho ? 1.0f : 0.0f; | ||||
| IDP_AddToGroup(idgroup, view_data); | IDP_AddToGroup(idgroup, view_data); | ||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| ▲ Show 20 Lines • Show All 506 Lines • Show Last 20 Lines | |||||
Do this at the start of the function? Otherwise edits to the image can cause an additional depsgraph evaluation when that's not what we need it for.