Blender V4.3
overlay_edit_curves.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BKE_attribute.hh"
10#include "BKE_curves.h"
11
12#include "DRW_render.hh"
13
14#include "ED_view3d.hh"
15
17
18#include "draw_cache_impl.hh"
19
20#include "overlay_private.hh"
21
23{
24 using namespace blender;
25 OVERLAY_PrivateData *pd = vedata->stl->pd;
26 const DRWContextState *draw_ctx = DRW_context_state_get();
27 const Object *obact_orig = DEG_get_original_object(draw_ctx->obact);
28
29 const Curves &curves_id = *static_cast<const Curves *>(obact_orig->data);
31 bke::AttrDomain::Point;
33
34 /* Create view with depth offset. */
35 DRWView *default_view = (DRWView *)DRW_view_default_get();
36 pd->view_edit_curves = DRW_view_create_with_zoffset(default_view, draw_ctx->rv3d, 1.0f);
37}
38
40{
41 OVERLAY_PassList *psl = vedata->psl;
42 OVERLAY_PrivateData *pd = vedata->stl->pd;
43
44 /* Desired masks (write to color and depth) and blend mode for rendering. */
47
48 GPUShader *sh;
49 DRWShadingGroup *grp;
50
51 /* Run Twice for in-front passes. */
52 for (int i = 0; i < 2; i++) {
53 if (pd->edit_curves.do_points) {
57 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
58 DRW_shgroup_uniform_bool_copy(grp, "useWeight", false);
59 DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", false);
60 }
64 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
65 DRW_shgroup_uniform_bool_copy(grp, "useWeight", false);
66 DRW_shgroup_uniform_bool_copy(grp, "useGreasePencil", false);
67 }
68 {
73 DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
75 }
76}
77
79{
80 using namespace blender::draw;
81 Curves *curves = static_cast<Curves *>(ob->data);
82
83 if (pd->edit_curves.do_points) {
84 DRWShadingGroup *point_shgrp = pd->edit_curves_points_grp[in_front];
85 blender::gpu::Batch *geom_points = DRW_curves_batch_cache_get_edit_points(curves);
86 DRW_shgroup_call_no_cull(point_shgrp, geom_points, ob);
87 }
88
89 DRWShadingGroup *handles_shgrp = pd->edit_curves_handles_grp;
90 blender::gpu::Batch *geom_handles = DRW_curves_batch_cache_get_edit_curves_handles(curves);
91 DRW_shgroup_call_no_cull(handles_shgrp, geom_handles, ob);
92
93 DRWShadingGroup *lines_shgrp = pd->edit_curves_lines_grp[in_front];
94 blender::gpu::Batch *geom_lines = DRW_curves_batch_cache_get_edit_curves_lines(curves);
95 DRW_shgroup_call_no_cull(lines_shgrp, geom_lines, ob);
96}
97
104
106{
107 OVERLAY_PassList *psl = vedata->psl;
108 OVERLAY_PrivateData *pd = vedata->stl->pd;
109 OVERLAY_FramebufferList *fbl = vedata->fbl;
110
111 if (DRW_state_is_fbo()) {
113 }
114
115 int in_front = pd->edit_curves.do_zbufclip ? NOT_IN_FRONT : IN_FRONT;
116
118
119 DRW_draw_pass(psl->edit_curves_lines_ps[in_front]);
121 if (pd->edit_curves.do_points) {
122 DRW_draw_pass(psl->edit_curves_points_ps[in_front]);
123 }
124}
Low-level operations for curves that cannot be defined in the C++ header yet.
Object * DEG_get_original_object(Object *object)
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
#define DRW_PASS_CREATE(pass, state)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
#define XRAY_FLAG_ENABLED(v3d)
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
struct GPUShader GPUShader
DRWView * DRW_view_create_with_zoffset(const DRWView *parent_view, const RegionView3D *rv3d, float offset)
DRW_Global G_draw
const DRWContextState * DRW_context_state_get()
bool DRW_state_is_fbo()
const DRWView * DRW_view_default_get()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_draw_pass(DRWPass *pass)
void DRW_view_set_active(const DRWView *view)
DRWState
Definition draw_state.hh:25
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:55
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:29
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
static ulong state[N]
void OVERLAY_edit_curves_draw(OVERLAY_Data *vedata)
static void overlay_edit_curves_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front)
void OVERLAY_edit_curves_init(OVERLAY_Data *vedata)
void OVERLAY_edit_curves_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata)
GPUShader * OVERLAY_shader_edit_particle_point()
#define IN_FRONT
GPUShader * OVERLAY_shader_edit_particle_strand()
GPUShader * OVERLAY_shader_edit_curves_handle()
#define NOT_IN_FRONT
char selection_domain
RegionView3D * rv3d
GPUUniformBuf * block_ubo
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
OVERLAY_FramebufferList * fbl
GPUFrameBuffer * overlay_default_fb
DRWPass * edit_curves_lines_ps[2]
DRWPass * edit_curves_handles_ps
DRWPass * edit_curves_points_ps[2]
DRWShadingGroup * edit_curves_handles_grp
DRWShadingGroup * edit_curves_lines_grp[2]
DRWShadingGroup * edit_curves_points_grp[2]
struct OVERLAY_PrivateData::@231 edit_curves
OVERLAY_PrivateData * pd