Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_proj.c
| Show First 20 Lines • Show All 6,155 Lines • ▼ Show 20 Lines | static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) | ||||
| 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); | ||||
| if (!sa) { | if (!sa) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from"); | BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| View3D *v3d = sa->spacedata.first; | |||||
| ARegion *ar = BKE_area_find_region_active_win(sa); | ARegion *ar = BKE_area_find_region_active_win(sa); | ||||
| if (!ar) { | if (!ar) { | ||||
| BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from"); | BKE_report(op->reports, RPT_ERROR, "No 3D viewport found to create image from"); | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| 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) { | if (w > maxsize) { | ||||
| w = maxsize; | w = maxsize; | ||||
| } | } | ||||
| if (h > maxsize) { | if (h > maxsize) { | ||||
| h = maxsize; | h = maxsize; | ||||
| } | } | ||||
| /* Create a copy of the overlays where they are all turned off, except the | |||||
| * texture paint overlay opacity */ | |||||
| View3D *v3d = sa->spacedata.first; | |||||
| View3D v3d_copy; | |||||
jbakker: remove the `= {NULL}` | |||||
Done Inline ActionsCould just do View3D v3d_copy = *v3d; perhaps. brecht: Could just do `View3D v3d_copy = *v3d;` perhaps. | |||||
| memcpy(&v3d_copy, v3d, sizeof(View3D)); | |||||
| v3d->gridflag = 0; | |||||
| v3d->flag2 = 0; | |||||
| v3d->flag = V3D_HIDE_HELPLINES; | |||||
| memset(&v3d->overlay, 0, sizeof(View3DOverlay)); | |||||
| v3d->overlay.flag = V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT | | |||||
| V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES | | |||||
| V3D_OVERLAY_HIDE_OBJECT_XTRAS | V3D_OVERLAY_HIDE_OBJECT_ORIGINS; | |||||
| v3d->overlay.texture_paint_mode_opacity = v3d_copy.overlay.texture_paint_mode_opacity; | |||||
| ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph, | ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph, | ||||
| scene, | scene, | ||||
| v3d->shading.type, | v3d->shading.type, | ||||
| v3d, | v3d, | ||||
| ar, | ar, | ||||
| w, | w, | ||||
| h, | h, | ||||
| IB_rect, | IB_rect, | ||||
| R_ALPHAPREMUL, | R_ALPHAPREMUL, | ||||
| 0, | 0, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| err_out); | err_out); | ||||
| // Restore original v3d | |||||
| memcpy(&v3d->overlay, &v3d_copy.overlay, sizeof(View3DOverlay)); | |||||
| v3d->gridflag = v3d_copy.gridflag; | |||||
| v3d->flag2 = v3d_copy.flag2; | |||||
| v3d->flag = v3d_copy.flag; | |||||
| 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; | ||||
| } | } | ||||
| image = BKE_image_add_from_imbuf(bmain, ibuf, "image_view"); | image = BKE_image_add_from_imbuf(bmain, ibuf, "image_view"); | ||||
| ▲ Show 20 Lines • Show All 535 Lines • Show Last 20 Lines | |||||
remove the = {NULL}