Blender  V2.93
overlay_edit_curve.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * Copyright 2019, Blender Foundation.
17  */
18 
23 #include "DRW_render.h"
24 
25 #include "DNA_curve_types.h"
26 
27 #include "overlay_private.h"
28 
30 {
31  OVERLAY_PassList *psl = vedata->psl;
32  OVERLAY_PrivateData *pd = vedata->stl->pd;
33  const DRWContextState *draw_ctx = DRW_context_state_get();
34  View3D *v3d = draw_ctx->v3d;
35  DRWShadingGroup *grp;
36  GPUShader *sh;
38 
42 
43  /* Run Twice for in-front passes. */
44  for (int i = 0; i < 2; i++) {
48 
51  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
53 
54  pd->edit_curve_wire_grp[i] = grp = DRW_shgroup_create(sh, psl->edit_curve_wire_ps[i]);
55  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
56  DRW_shgroup_uniform_float_copy(grp, "normalSize", 0.0f);
57  }
58  {
61 
64  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
65  DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles);
66  DRW_shgroup_uniform_int_copy(grp, "curveHandleDisplay", pd->edit_curve.handle_display);
68 
71  DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles);
72  DRW_shgroup_uniform_int_copy(grp, "curveHandleDisplay", pd->edit_curve.handle_display);
73  DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
74  }
75 }
76 
78 {
79  OVERLAY_PrivateData *pd = vedata->stl->pd;
80  bool draw_normals = (pd->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_NORMALS) != 0;
81  bool do_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0;
82 
83  Curve *cu = ob->data;
84  struct GPUBatch *geom;
85 
87  if (geom) {
88  DRW_shgroup_call_no_cull(pd->edit_curve_wire_grp[do_xray], geom, ob);
89  }
90 
91  if ((cu->flag & CU_3D) && draw_normals) {
93  DRW_shgroup_call_instances(pd->edit_curve_normal_grp[do_xray], ob, geom, 3);
94  }
95 
97  if (geom) {
99  }
100 
102  if (geom) {
104  }
105 }
106 
108 {
109  OVERLAY_PrivateData *pd = vedata->stl->pd;
110  struct GPUBatch *geom;
111 
113  if (geom) {
115  }
116 
118  if (geom) {
120  }
121 }
122 
124 {
125  OVERLAY_PassList *psl = vedata->psl;
126  OVERLAY_FramebufferList *fbl = vedata->fbl;
127 
128  if (DRW_state_is_fbo()) {
130  }
131 
134 
136 }
@ CU_3D
@ OB_DRAW_IN_FRONT
@ V3D_OVERLAY_EDIT_CU_NORMALS
@ CURVE_HANDLE_NONE
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
Definition: DRW_render.h:433
DRWState
Definition: DRW_render.h:312
@ DRW_STATE_BLEND_ALPHA
Definition: DRW_render.h:340
@ DRW_STATE_WRITE_DEPTH
Definition: DRW_render.h:314
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:315
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition: DRW_render.h:323
@ DRW_STATE_DEPTH_ALWAYS
Definition: DRW_render.h:321
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:593
GPUBatch
Definition: GPU_batch.h:93
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:33
GPUBatch * DRW_cache_curve_edge_normal_get(Object *ob)
Definition: draw_cache.c:2942
GPUBatch * DRW_cache_curve_edge_wire_get(Object *ob)
Definition: draw_cache.c:2929
GPUBatch * DRW_cache_curve_vert_overlay_get(Object *ob)
Definition: draw_cache.c:2958
GPUBatch * DRW_cache_curve_edge_overlay_get(Object *ob)
Definition: draw_cache.c:2950
struct DRW_Global G_draw
Definition: draw_common.c:45
bool DRW_state_is_fbo(void)
const DRWContextState * DRW_context_state_get(void)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_uniform_block(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo)
void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, Object *ob, struct GPUBatch *geom, uint count)
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
DRWShadingGroup * DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_draw_pass(DRWPass *pass)
static ulong state[N]
void OVERLAY_edit_curve_draw(OVERLAY_Data *vedata)
void OVERLAY_edit_curve_cache_populate(OVERLAY_Data *vedata, Object *ob)
void OVERLAY_edit_curve_cache_init(OVERLAY_Data *vedata)
void OVERLAY_edit_surf_cache_populate(OVERLAY_Data *vedata, Object *ob)
GPUShader * OVERLAY_shader_edit_curve_handle(void)
GPUShader * OVERLAY_shader_edit_curve_wire(void)
GPUShader * OVERLAY_shader_edit_curve_point(void)
struct View3D * v3d
Definition: DRW_render.h:742
struct GPUUniformBuf * block_ubo
Definition: draw_common.h:210
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
OVERLAY_FramebufferList * fbl
struct GPUFrameBuffer * overlay_default_fb
DRWPass * edit_curve_handle_ps
DRWPass * edit_curve_wire_ps[2]
OVERLAY_ShadingData shdata
View3DOverlay overlay
struct OVERLAY_PrivateData::@240 edit_curve
DRWShadingGroup * edit_curve_wire_grp[2]
DRWShadingGroup * edit_curve_normal_grp[2]
DRWShadingGroup * edit_curve_points_grp
DRWShadingGroup * edit_curve_handle_grp
struct OVERLAY_PrivateData * pd
void * data
View3DOverlay overlay