Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_draw_legacy.c
| Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | #endif | ||||
| /* TODO: Create a flag in `DRW_manager` because the drawing is no longer | /* TODO: Create a flag in `DRW_manager` because the drawing is no longer | ||||
| * made on the backbuffer in this case. */ | * made on the backbuffer in this case. */ | ||||
| v3d->flag &= ~V3D_INVALID_BACKBUF; | v3d->flag &= ~V3D_INVALID_BACKBUF; | ||||
| G.f &= ~G_FLAG_BACKBUFSEL; | G.f &= ~G_FLAG_BACKBUFSEL; | ||||
| } | } | ||||
| void view3d_opengl_read_pixels( | |||||
| ARegion *ar, int x, int y, int w, int h, int format, int type, void *data) | |||||
| { | |||||
| glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data); | |||||
| } | |||||
| /* TODO: Creating, attaching texture, and destroying a framebuffer is quite slow. | /* TODO: Creating, attaching texture, and destroying a framebuffer is quite slow. | ||||
| * Calling this function should be avoided during interactive drawing. */ | * Calling this function should be avoided during interactive drawing. */ | ||||
| static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data) | static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void *data) | ||||
| { | { | ||||
| DefaultTextureList *dtxl = (DefaultTextureList *)GPU_viewport_texture_list_get(viewport); | DefaultTextureList *dtxl = (DefaultTextureList *)GPU_viewport_texture_list_get(viewport); | ||||
| GPUFrameBuffer *tmp_fb = GPU_framebuffer_create(); | GPUFrameBuffer *tmp_fb = GPU_framebuffer_create(); | ||||
| GPU_framebuffer_texture_attach(tmp_fb, dtxl->depth, 0, 0); | GPU_framebuffer_texture_attach(tmp_fb, dtxl->depth, 0, 0); | ||||
| GPU_framebuffer_bind(tmp_fb); | GPU_framebuffer_bind(tmp_fb); | ||||
| glDisable(GL_SCISSOR_TEST); | |||||
| glReadPixels(rect->xmin, | glReadPixels(rect->xmin, | ||||
| rect->ymin, | rect->ymin, | ||||
| BLI_rcti_size_x(rect), | BLI_rcti_size_x(rect), | ||||
| BLI_rcti_size_y(rect), | BLI_rcti_size_y(rect), | ||||
| GL_DEPTH_COMPONENT, | GL_DEPTH_COMPONENT, | ||||
| GL_FLOAT, | GL_FLOAT, | ||||
| data); | data); | ||||
| glEnable(GL_SCISSOR_TEST); | |||||
| GPU_framebuffer_restore(); | GPU_framebuffer_restore(); | ||||
| GPU_framebuffer_free(tmp_fb); | GPU_framebuffer_free(tmp_fb); | ||||
| } | } | ||||
| void ED_view3d_select_id_validate_with_select_mode(ViewContext *vc, short select_mode) | void ED_view3d_select_id_validate_with_select_mode(ViewContext *vc, short select_mode) | ||||
| { | { | ||||
| /* TODO: Create a flag in `DRW_manager` because the drawing is no longer | /* TODO: Create a flag in `DRW_manager` because the drawing is no longer | ||||
| * made on the backbuffer in this case. */ | * made on the backbuffer in this case. */ | ||||
| if (vc->v3d->flag & V3D_INVALID_BACKBUF) { | if (vc->v3d->flag & V3D_INVALID_BACKBUF) { | ||||
| Show All 10 Lines | |||||
| void ED_view3d_backbuf_depth_validate(ViewContext *vc) | void ED_view3d_backbuf_depth_validate(ViewContext *vc) | ||||
| { | { | ||||
| if (vc->v3d->flag & V3D_INVALID_BACKBUF) { | if (vc->v3d->flag & V3D_INVALID_BACKBUF) { | ||||
| ARegion *ar = vc->ar; | ARegion *ar = vc->ar; | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| Object *obact_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); | Object *obact_eval = DEG_get_evaluated_object(vc->depsgraph, vc->obact); | ||||
| if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) { | if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) { | ||||
| GPU_scissor(ar->winrct.xmin, | GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); | ||||
| ar->winrct.ymin, | DRW_draw_depth_object(vc->ar, vc->v3d, viewport, obact_eval); | ||||
| BLI_rcti_size_x(&ar->winrct), | |||||
| BLI_rcti_size_y(&ar->winrct)); | |||||
| GPU_depth_test(true); | |||||
| GPU_clear(GPU_DEPTH_BIT); | |||||
| if (rv3d->rflag & RV3D_CLIPPING) { | |||||
| ED_view3d_clipping_set(rv3d); | |||||
| } | |||||
| draw_object_depth(rv3d, obact_eval); | |||||
| if (rv3d->rflag & RV3D_CLIPPING) { | |||||
| ED_view3d_clipping_disable(); | |||||
| } | |||||
| GPU_depth_test(false); | |||||
| } | } | ||||
| vc->v3d->flag &= ~V3D_INVALID_BACKBUF; | vc->v3d->flag &= ~V3D_INVALID_BACKBUF; | ||||
| } | } | ||||
| } | } | ||||
| uint *ED_view3d_select_id_read_rect(ViewContext *vc, const rcti *clip, uint *r_buf_len) | uint *ED_view3d_select_id_read_rect(ViewContext *vc, const rcti *clip, uint *r_buf_len) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 547 Lines • ▼ Show 20 Lines | if (d->w != ar->winx || d->h != ar->winy || !d->depths) { | ||||
| if (d->depths) { | if (d->depths) { | ||||
| MEM_freeN(d->depths); | MEM_freeN(d->depths); | ||||
| } | } | ||||
| d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths"); | d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths"); | ||||
| d->damaged = true; | d->damaged = true; | ||||
| } | } | ||||
| if (d->damaged) { | if (d->damaged) { | ||||
| view3d_opengl_read_pixels(ar, 0, 0, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); | GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0); | ||||
| rcti r = { | |||||
| .xmin = 0, | |||||
| .xmax = d->w, | |||||
| .ymin = 0, | |||||
| .ymax = d->h, | |||||
| }; | |||||
| view3d_opengl_read_Z_pixels(viewport, &r, d->depths); | |||||
| glGetDoublev(GL_DEPTH_RANGE, d->depth_range); | glGetDoublev(GL_DEPTH_RANGE, d->depth_range); | ||||
| d->damaged = false; | d->damaged = false; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* utility function to find the closest Z value, use for autodepth */ | /* utility function to find the closest Z value, use for autodepth */ | ||||
| float view3d_depth_near(ViewDepths *d) | float view3d_depth_near(ViewDepths *d) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines | |||||