Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_edit_curves.cc
| Show All 16 Lines | |||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| pd->edit_curves.do_zbufclip = XRAY_FLAG_ENABLED(draw_ctx->v3d); | pd->edit_curves.do_zbufclip = XRAY_FLAG_ENABLED(draw_ctx->v3d); | ||||
| /* Create view with depth offset. */ | /* Create view with depth offset. */ | ||||
| DRWView *default_view = (DRWView *)DRW_view_default_get(); | DRWView *default_view = (DRWView *)DRW_view_default_get(); | ||||
| pd->view_edit_curves_points = default_view; | pd->view_edit_curves = DRW_view_create_with_zoffset(default_view, draw_ctx->rv3d, 1.0f); | ||||
| } | } | ||||
| void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata) | void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_TextureList *txl = vedata->txl; | OVERLAY_TextureList *txl = vedata->txl; | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| /* Desired masks (write to color and depth) and blend mode for rendering. */ | /* Desired masks (write to color and depth) and blend mode for rendering. */ | ||||
| DRWState state = (DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA | | DRWState state = (DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND_ALPHA | | ||||
| DRW_STATE_WRITE_DEPTH); | DRW_STATE_WRITE_DEPTH); | ||||
| /* Common boilerplate for shading groups. */ | /* Common boilerplate for shading groups. */ | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const View3D *v3d = draw_ctx->v3d; | const View3D *v3d = draw_ctx->v3d; | ||||
| GPUTexture **depth_tex = (pd->edit_curves.do_zbufclip) ? &dtxl->depth : &txl->dummy_depth_tx; | GPUTexture **depth_tex = (pd->edit_curves.do_zbufclip) ? &dtxl->depth : &txl->dummy_depth_tx; | ||||
| const float backwire_opacity = (pd->edit_curves.do_zbufclip) ? v3d->overlay.backwire_opacity : | const float backwire_opacity = (pd->edit_curves.do_zbufclip) ? v3d->overlay.backwire_opacity : | ||||
| 1.0f; | 1.0f; | ||||
| GPUShader *sh; | |||||
| DRWShadingGroup *grp; | |||||
| /* Run Twice for in-front passes. */ | /* Run Twice for in-front passes. */ | ||||
| for (int i = 0; i < 2; i++) { | for (int i = 0; i < 2; i++) { | ||||
| DRW_PASS_CREATE(psl->edit_curves_points_ps[i], (state | pd->clipping_state)); | DRW_PASS_CREATE(psl->edit_curves_points_ps[i], (state | pd->clipping_state)); | ||||
| sh = OVERLAY_shader_edit_curve_point(); | |||||
| grp = pd->edit_curves_points_grp[i] = DRW_shgroup_create(sh, psl->edit_curves_points_ps[i]); | |||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | |||||
| DRW_shgroup_uniform_float_copy(grp, "alpha", backwire_opacity); | |||||
| DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex); | |||||
| GPUShader *sh = OVERLAY_shader_edit_curve_point(); | DRW_PASS_CREATE(psl->edit_curves_lines_ps[i], (state | pd->clipping_state)); | ||||
| DRWShadingGroup *grp = pd->edit_curves_points_grp[i] = DRW_shgroup_create( | sh = OVERLAY_shader_edit_curve_wire(); | ||||
| sh, psl->edit_curves_points_ps[i]); | grp = pd->edit_curves_lines_grp[i] = DRW_shgroup_create(sh, psl->edit_curves_lines_ps[i]); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_float_copy(grp, "normalSize", 0.0f); | |||||
| DRW_shgroup_uniform_float_copy(grp, "alpha", backwire_opacity); | DRW_shgroup_uniform_float_copy(grp, "alpha", backwire_opacity); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex); | DRW_shgroup_uniform_texture_ref(grp, "depthTex", depth_tex); | ||||
| } | } | ||||
| } | } | ||||
| static void overlay_edit_curves_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front) | static void overlay_edit_curves_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front) | ||||
| { | { | ||||
| Curves *curves = static_cast<Curves *>(ob->data); | Curves *curves = static_cast<Curves *>(ob->data); | ||||
| DRWShadingGroup *point_shgrp = pd->edit_curves_points_grp[in_front]; | DRWShadingGroup *point_shgrp = pd->edit_curves_points_grp[in_front]; | ||||
| struct GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves); | struct GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves); | ||||
| DRW_shgroup_call_no_cull(point_shgrp, geom_points, ob); | DRW_shgroup_call_no_cull(point_shgrp, geom_points, ob); | ||||
| DRWShadingGroup *lines_shgrp = pd->edit_curves_lines_grp[in_front]; | |||||
| struct GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves); | |||||
| DRW_shgroup_call_no_cull(lines_shgrp, geom_lines, ob); | |||||
| } | } | ||||
| void OVERLAY_edit_curves_cache_populate(OVERLAY_Data *vedata, Object *ob) | void OVERLAY_edit_curves_cache_populate(OVERLAY_Data *vedata, Object *ob) | ||||
| { | { | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| if (pd->edit_curves.do_zbufclip) { | if (pd->edit_curves.do_zbufclip) { | ||||
| overlay_edit_curves_add_ob_to_pass(pd, ob, false); | overlay_edit_curves_add_ob_to_pass(pd, ob, false); | ||||
| } | } | ||||
| else { | else { | ||||
| overlay_edit_curves_add_ob_to_pass(pd, ob, true); | overlay_edit_curves_add_ob_to_pass(pd, ob, true); | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_edit_curves_draw(OVERLAY_Data *vedata) | void OVERLAY_edit_curves_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| if (pd->edit_curves.do_zbufclip) { | if (pd->edit_curves.do_zbufclip) { | ||||
| DRW_view_set_active(pd->view_edit_curves_points); | DRW_view_set_active(pd->view_edit_curves); | ||||
| DRW_draw_pass(psl->edit_curves_points_ps[NOT_IN_FRONT]); | DRW_draw_pass(psl->edit_curves_points_ps[NOT_IN_FRONT]); | ||||
| DRW_draw_pass(psl->edit_curves_lines_ps[NOT_IN_FRONT]); | |||||
| } | } | ||||
| else { | else { | ||||
| DRW_view_set_active(pd->view_edit_curves_points); | DRW_view_set_active(pd->view_edit_curves); | ||||
| DRW_draw_pass(psl->edit_curves_points_ps[IN_FRONT]); | DRW_draw_pass(psl->edit_curves_points_ps[IN_FRONT]); | ||||
| DRW_draw_pass(psl->edit_curves_lines_ps[IN_FRONT]); | |||||
| } | } | ||||
| } | } | ||||