Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_proj.c
| Show First 20 Lines • Show All 5,315 Lines • ▼ Show 20 Lines | void paint_proj_stroke_done(void *ps_handle_p) | ||||
| MEM_freeN(ps_handle); | MEM_freeN(ps_handle); | ||||
| } | } | ||||
| /* use project paint to re-apply an image */ | /* use project paint to re-apply an image */ | ||||
| static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) | static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| Image *image = BLI_findlink(&CTX_data_main(C)->image, RNA_enum_get(op->ptr, "image")); | Image *image = BLI_findlink(&CTX_data_main(C)->image, RNA_enum_get(op->ptr, "image")); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| ProjPaintState ps = {NULL}; | ProjPaintState ps = {NULL}; | ||||
| int orig_brush_size; | int orig_brush_size; | ||||
| IDProperty *idgroup; | IDProperty *idgroup; | ||||
| IDProperty *view_data = NULL; | IDProperty *view_data = NULL; | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| bool uvs, mat, tex; | bool uvs, mat, tex; | ||||
| if (ob == NULL || ob->type != OB_MESH) { | if (ob == NULL || ob->type != OB_MESH) { | ||||
| ▲ Show 20 Lines • Show All 117 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]; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *scene_layer = CTX_data_scene_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| 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"; | ||||
| CTX_data_eval_ctx(C, &eval_ctx); | CTX_data_eval_ctx(C, &eval_ctx); | ||||
| RNA_string_get(op->ptr, "filepath", filename); | RNA_string_get(op->ptr, "filepath", filename); | ||||
| maxsize = GPU_max_texture_size(); | maxsize = GPU_max_texture_size(); | ||||
| if (w > maxsize) w = maxsize; | if (w > maxsize) w = maxsize; | ||||
| if (h > maxsize) h = maxsize; | if (h > maxsize) h = maxsize; | ||||
| ibuf = ED_view3d_draw_offscreen_imbuf( | ibuf = ED_view3d_draw_offscreen_imbuf( | ||||
| &eval_ctx, scene, scene_layer, CTX_wm_view3d(C), CTX_wm_region(C), | &eval_ctx, scene, view_layer, CTX_wm_view3d(C), CTX_wm_region(C), | ||||
| w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL, | w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL, | ||||
| NULL, NULL, err_out); | NULL, NULL, err_out); | ||||
| if (!ibuf) { | if (!ibuf) { | ||||
| /* Mostly happens when OpenGL offscreen buffer was failed to create, */ | /* Mostly happens when OpenGL offscreen buffer was failed to create, */ | ||||
| /* but could be other reasons. Should be handled in the future. nazgul */ | /* but could be other reasons. Should be handled in the future. nazgul */ | ||||
| BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer: %s", err_out); | BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL off-screen buffer: %s", err_out); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines | |||||