Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_image_proj.c
| Show First 20 Lines • Show All 6,234 Lines • ▼ Show 20 Lines | static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) | ||||
| v3d_copy.gizmo_flag = V3D_GIZMO_HIDE; | v3d_copy.gizmo_flag = V3D_GIZMO_HIDE; | ||||
| memset(&v3d_copy.overlay, 0, sizeof(View3DOverlay)); | memset(&v3d_copy.overlay, 0, sizeof(View3DOverlay)); | ||||
| v3d_copy.overlay.flag = V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT | | v3d_copy.overlay.flag = V3D_OVERLAY_HIDE_CURSOR | V3D_OVERLAY_HIDE_TEXT | | ||||
| V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES | | V3D_OVERLAY_HIDE_MOTION_PATHS | V3D_OVERLAY_HIDE_BONES | | ||||
| V3D_OVERLAY_HIDE_OBJECT_XTRAS | V3D_OVERLAY_HIDE_OBJECT_ORIGINS; | V3D_OVERLAY_HIDE_OBJECT_XTRAS | V3D_OVERLAY_HIDE_OBJECT_ORIGINS; | ||||
| v3d_copy.overlay.texture_paint_mode_opacity = v3d->overlay.texture_paint_mode_opacity; | v3d_copy.overlay.texture_paint_mode_opacity = v3d->overlay.texture_paint_mode_opacity; | ||||
| RV3DMatrixStore *rv3d_mats; | |||||
| ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph, | ibuf = ED_view3d_draw_offscreen_imbuf(depsgraph, | ||||
| scene, | scene, | ||||
| v3d_copy.shading.type, | v3d_copy.shading.type, | ||||
| &v3d_copy, | &v3d_copy, | ||||
| region, | region, | ||||
| w, | w, | ||||
| h, | h, | ||||
| IB_rect, | IB_rect, | ||||
| R_ALPHAPREMUL, | R_ALPHAPREMUL, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| err_out); | err_out, | ||||
| &rv3d_mats); | |||||
| 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 All 11 Lines | if (image) { | ||||
| bool is_ortho; | bool is_ortho; | ||||
| float *array; | float *array; | ||||
| val.array.len = PROJ_VIEW_DATA_SIZE; | val.array.len = PROJ_VIEW_DATA_SIZE; | ||||
| 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)); | /* Use the rv3d_mats returned from ED_view3d_draw_offscreen_imbuf (they are restored to the | ||||
| array += sizeof(rv3d->winmat) / sizeof(float); | * original there). */ | ||||
| memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); | memcpy(array, rv3d_mats->winmat, sizeof(rv3d_mats->winmat)); | ||||
| array += sizeof(rv3d->viewmat) / sizeof(float); | array += sizeof(rv3d_mats->winmat) / sizeof(float); | ||||
| memcpy(array, rv3d_mats->viewmat, sizeof(rv3d_mats->viewmat)); | |||||
| array += sizeof(rv3d_mats->viewmat) / sizeof(float); | |||||
| is_ortho = ED_view3d_clip_range_get(depsgraph, v3d, rv3d, &array[0], &array[1], true); | is_ortho = ED_view3d_clip_range_get(depsgraph, 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 than adding a single bool prop */ | * easier than 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); | ||||
| MEM_freeN(rv3d_mats); | |||||
| } | } | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| void PAINT_OT_image_from_view(wmOperatorType *ot) | void PAINT_OT_image_from_view(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| ▲ Show 20 Lines • Show All 495 Lines • Show Last 20 Lines | |||||