Blender  V3.3
overlay_sculpt_curves.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2022 Blender Foundation. */
3 
8 #include "DRW_render.h"
9 
10 #include "draw_cache_impl.h"
11 #include "overlay_private.h"
12 
13 #include "BKE_curves.hh"
14 
16 {
17  OVERLAY_PassList *psl = vedata->psl;
18  OVERLAY_PrivateData *pd = vedata->stl->pd;
19 
22 
26 
27  /* Reuse the same mask opacity from sculpt mode, since it wasn't worth it to add a different
28  * property yet. */
30 }
31 
32 static bool everything_selected(const Curves &curves_id)
33 {
34  if (!(curves_id.flag & CV_SCULPT_SELECTION_ENABLED)) {
35  /* When the selection is disabled, conceptually everything is selected. */
36  return true;
37  }
39  curves_id.geometry);
40  blender::VArray<float> selection;
41  switch (curves_id.selection_domain) {
42  case ATTR_DOMAIN_POINT:
43  selection = curves.selection_point_float();
44  break;
45  case ATTR_DOMAIN_CURVE:
46  selection = curves.selection_curve_float();
47  break;
48  }
49  return selection.is_single() && selection.get_internal_single() == 1.0f;
50 }
51 
53 {
54  OVERLAY_PrivateData *pd = vedata->stl->pd;
55  Curves *curves = static_cast<Curves *>(object->data);
56 
57  /* As an optimization, return early if everything is selected. */
59  return;
60  }
61 
62  /* Retrieve the location of the texture. */
63  const char *name = curves->selection_domain == ATTR_DOMAIN_POINT ? ".selection_point_float" :
64  ".selection_curve_float";
65 
66  bool is_point_domain;
68  curves, name, &is_point_domain);
69  if (texture == nullptr) {
70  return;
71  }
72 
73  /* Evaluate curves and their attributes if necessary. */
75  object, pd->sculpt_curves_selection_grp, nullptr);
76  if (*texture == nullptr) {
77  return;
78  }
79 
80  DRW_shgroup_uniform_bool_copy(grp, "is_point_domain", is_point_domain);
81  DRW_shgroup_uniform_texture(grp, "selection_tx", *texture);
82 }
83 
85 {
86  OVERLAY_PassList *psl = vedata->psl;
87  OVERLAY_PrivateData *pd = vedata->stl->pd;
88  OVERLAY_FramebufferList *fbl = vedata->fbl;
89 
90  if (DRW_state_is_fbo()) {
92  fbl->overlay_default_fb);
93  }
94 
96 }
@ ATTR_DOMAIN_CURVE
Definition: BKE_attribute.h:31
@ ATTR_DOMAIN_POINT
Definition: BKE_attribute.h:27
Low-level operations for curves.
@ CV_SCULPT_SELECTION_ENABLED
DRWState
Definition: DRW_render.h:298
@ DRW_STATE_BLEND_ALPHA
Definition: DRW_render.h:328
@ DRW_STATE_DEPTH_EQUAL
Definition: DRW_render.h:312
@ DRW_STATE_WRITE_COLOR
Definition: DRW_render.h:303
#define DRW_PASS_CREATE(pass, state)
Definition: DRW_render.h:690
void GPU_framebuffer_bind(GPUFrameBuffer *fb)
struct GPUShader GPUShader
Definition: GPU_shader.h:20
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
struct GPUTexture ** DRW_curves_texture_for_evaluated_attribute(struct Curves *curves, const char *name, bool *r_is_point_domain)
struct DRWShadingGroup * DRW_shgroup_curves_create_sub(struct Object *object, struct DRWShadingGroup *shgrp, struct GPUMaterial *gpu_material)
Definition: draw_curves.cc:303
bool DRW_state_is_fbo(void)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
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)
const int state
ccl_gpu_kernel_postfix ccl_global float int int int int sh
GPUShader * OVERLAY_shader_sculpt_curves_selection(void)
void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata)
static bool everything_selected(const Curves &curves_id)
void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object)
void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata)
CurvesGeometry geometry
char selection_domain
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
OVERLAY_FramebufferList * fbl
struct GPUFrameBuffer * overlay_in_front_fb
struct GPUFrameBuffer * overlay_default_fb
DRWPass * sculpt_curves_selection_ps
View3DOverlay overlay
DRWShadingGroup * sculpt_curves_selection_grp
struct OVERLAY_PrivateData::@257 painting
struct OVERLAY_PrivateData * pd
float sculpt_mode_mask_opacity