Blender V4.3
overlay_sculpt_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 "DRW_render.hh"
10
11#include "draw_cache_impl.hh"
12#include "overlay_private.hh"
13
14#include "BKE_attribute.hh"
15#include "BKE_crazyspace.hh"
16#include "BKE_curves.hh"
17
19
21{
22 OVERLAY_PassList *psl = vedata->psl;
23 OVERLAY_PrivateData *pd = vedata->stl->pd;
24 const View3DOverlay &overlay = vedata->stl->pd->overlay;
25
26 /* Selection overlay. */
27 {
30
34
35 /* Reuse the same mask opacity from sculpt mode, since it wasn't worth it to add a different
36 * property yet. */
38 }
39 /* Cage overlay. */
40 {
44
49 }
50}
51
52static bool everything_selected(const Curves &curves_id)
53{
54 using namespace blender;
55 const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
56 const VArray<bool> selection = *curves.attributes().lookup_or_default<bool>(
57 ".selection", bke::AttrDomain::Point, true);
58 return selection.is_single() && selection.get_internal_single();
59}
60
61static void populate_selection_overlay(OVERLAY_Data *vedata, Object *object)
62{
63 using namespace blender::draw;
64 OVERLAY_PrivateData *pd = vedata->stl->pd;
65 Curves *curves = static_cast<Curves *>(object->data);
66
67 /* As an optimization, return early if everything is selected. */
68 if (everything_selected(*curves)) {
69 return;
70 }
71
72 /* Retrieve the location of the texture. */
73 bool is_point_domain;
74 blender::gpu::VertBuf **texture = DRW_curves_texture_for_evaluated_attribute(
75 curves, ".selection", &is_point_domain);
76 if (texture == nullptr) {
77 return;
78 }
79
80 /* Evaluate curves and their attributes if necessary. */
81 DRWShadingGroup *grp = DRW_shgroup_curves_create_sub(
82 object, pd->sculpt_curves_selection_grp, nullptr);
83 if (*texture == nullptr) {
84 return;
85 }
86
87 DRW_shgroup_uniform_bool_copy(grp, "is_point_domain", is_point_domain);
88 DRW_shgroup_buffer_texture(grp, "selection_tx", *texture);
89}
90
91static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object)
92{
93 using namespace blender::draw;
94 OVERLAY_PrivateData *pd = vedata->stl->pd;
95 Curves *curves = static_cast<Curves *>(object->data);
96
97 blender::gpu::Batch *geom_lines = DRW_curves_batch_cache_get_sculpt_curves_cage(curves);
99}
100
102{
103 populate_selection_overlay(vedata, object);
104 const View3DOverlay &overlay = vedata->stl->pd->overlay;
105 if ((overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE) && overlay.sculpt_curves_cage_opacity > 0.0f)
106 {
107 populate_edit_overlay(vedata, object);
108 }
109}
110
117
Low-level operations for curves.
@ V3D_OVERLAY_SCULPT_CURVES_CAGE
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
#define DRW_PASS_CREATE(pass, state)
struct GPUShader GPUShader
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void DRW_shgroup_buffer_texture(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf *vertex_buffer)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_draw_pass(DRWPass *pass)
DRWState
Definition draw_state.hh:25
@ DRW_STATE_BLEND_ALPHA
Definition draw_state.hh:55
@ DRW_STATE_DEPTH_EQUAL
Definition draw_state.hh:39
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
static ulong state[N]
GPUShader * OVERLAY_shader_sculpt_curves_cage()
GPUShader * OVERLAY_shader_sculpt_curves_selection()
static void populate_selection_overlay(OVERLAY_Data *vedata, Object *object)
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)
static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object)
void OVERLAY_sculpt_curves_draw_wires(OVERLAY_Data *vedata)
void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata)
CurvesGeometry geometry
OVERLAY_PassList * psl
OVERLAY_StorageList * stl
DRWPass * sculpt_curves_cage_ps
DRWPass * sculpt_curves_selection_ps
DRWShadingGroup * sculpt_curves_selection_grp
DRWShadingGroup * sculpt_curves_cage_lines_grp
OVERLAY_PrivateData * pd
float sculpt_mode_mask_opacity
float sculpt_curves_cage_opacity