From 7c2aac2c6ea4becc6670e196a49bbd7ecaea20f5 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Fri, 27 Jan 2023 12:20:34 +0100 Subject: [PATCH 01/33] initial code --- .../draw/engines/overlay/overlay_private.hh | 2 + .../engines/overlay/overlay_sculpt_curves.cc | 74 ++++++++++++++++--- source/blender/makesdna/DNA_object_types.h | 3 +- 3 files changed, 69 insertions(+), 10 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index 5636286a8ac..4d8a00d1aa5 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -120,6 +120,7 @@ typedef struct OVERLAY_PassList { DRWPass *pointcloud_ps; DRWPass *sculpt_mask_ps; DRWPass *sculpt_curves_selection_ps; + DRWPass *sculpt_curves_edit_ps; DRWPass *volume_ps; DRWPass *wireframe_ps; DRWPass *wireframe_xray_ps; @@ -287,6 +288,7 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *pointcloud_dots_grp; DRWShadingGroup *sculpt_mask_grp; DRWShadingGroup *sculpt_curves_selection_grp; + DRWShadingGroup *sculpt_curves_edit_grp; DRWShadingGroup *viewer_attribute_curve_grp; DRWShadingGroup *viewer_attribute_curves_grp; DRWShadingGroup *viewer_attribute_mesh_grp; diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 40abfad12f5..2af83644e12 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -11,23 +11,37 @@ #include "overlay_private.hh" #include "BKE_attribute.hh" +#include "BKE_crazyspace.hh" #include "BKE_curves.hh" +#include "DEG_depsgraph_query.h" + void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; OVERLAY_PrivateData *pd = vedata->stl->pd; - const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; - DRW_PASS_CREATE(psl->sculpt_curves_selection_ps, state | pd->clipping_state); + /* Selection overlay. */ + { + const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; + DRW_PASS_CREATE(psl->sculpt_curves_selection_ps, state | pd->clipping_state); - GPUShader *sh = OVERLAY_shader_sculpt_curves_selection(); - pd->sculpt_curves_selection_grp = DRW_shgroup_create(sh, psl->sculpt_curves_selection_ps); - DRWShadingGroup *grp = pd->sculpt_curves_selection_grp; + GPUShader *sh = OVERLAY_shader_sculpt_curves_selection(); + pd->sculpt_curves_selection_grp = DRW_shgroup_create(sh, psl->sculpt_curves_selection_ps); + DRWShadingGroup *grp = pd->sculpt_curves_selection_grp; - /* Reuse the same mask opacity from sculpt mode, since it wasn't worth it to add a different - * property yet. */ - DRW_shgroup_uniform_float_copy(grp, "selection_opacity", pd->overlay.sculpt_mode_mask_opacity); + /* Reuse the same mask opacity from sculpt mode, since it wasn't worth it to add a different + * property yet. */ + DRW_shgroup_uniform_float_copy(grp, "selection_opacity", pd->overlay.sculpt_mode_mask_opacity); + } + /* Editable curves overlay. */ + { + const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; + DRW_PASS_CREATE(psl->sculpt_curves_edit_ps, state | pd->clipping_state); + + GPUShader *sh = OVERLAY_shader_viewer_attribute_curves(); + pd->sculpt_curves_edit_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); + } } static bool everything_selected(const Curves &curves_id) @@ -39,7 +53,7 @@ static bool everything_selected(const Curves &curves_id) return selection.is_single() && selection.get_internal_single(); } -void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) +static void populate_selection_overlay(OVERLAY_Data *vedata, Object *object) { OVERLAY_PrivateData *pd = vedata->stl->pd; Curves *curves = static_cast(object->data); @@ -68,6 +82,47 @@ void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) DRW_shgroup_buffer_texture(grp, "selection_tx", *texture); } +static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) +{ + using namespace blender; + using namespace blender::bke; + + OVERLAY_PrivateData *pd = vedata->stl->pd; + const DRWContextState *draw_ctx = DRW_context_state_get(); + const Depsgraph *depsgraph = draw_ctx->depsgraph; + + // float(*cage_positions)[3] = object->runtime.editcurves_eval_cage; + // std::cout << cage_positions << "\n"; + // if (cage_positions == nullptr) { + // return; + // } + + draw_ctx->object_edit; + + const Object *object_orig = DEG_get_original_object(object); + std::cout << object << " " << object_orig << " " << object->id.name << "\n"; + if (object_orig == nullptr) { + return; + } + if (object_orig->type != OB_CURVES) { + return; + } + + const crazyspace::GeometryDeformation deformation = crazyspace::get_evaluated_curves_deformation( + *depsgraph, *object); + + // std::cout << deformation.positions.size() << "\n"; + + const Curves *curves_id_orig = reinterpret_cast(object_orig->data); + const bke::CurvesGeometry &curves_orig = bke::CurvesGeometry::wrap(curves_id_orig->geometry); +} + +void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) +{ + populate_selection_overlay(vedata, object); + populate_edit_overlay(vedata, object); +} + void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; @@ -80,4 +135,5 @@ void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata) } DRW_draw_pass(psl->sculpt_curves_selection_ps); + DRW_draw_pass(psl->sculpt_curves_edit_ps); } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 889f154c1b8..0f3dd4da764 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -171,6 +171,8 @@ typedef struct Object_Runtime { /* Evaluated mesh cage in edit mode. */ struct Mesh *editmesh_eval_cage; + float (*editcurves_eval_cage)[3]; + /** Cached cage bounding box of `editmesh_eval_cage` for selection. */ struct BoundBox *editmesh_bb_cage; @@ -208,7 +210,6 @@ typedef struct Object_Runtime { /** Runtime evaluated curve-specific data, not stored in the file. */ struct CurveCache *curve_cache; - void *_pad4; unsigned short local_collections_bits; short _pad2[3]; -- 2.30.2 From b4e06720f7b62b6cf32910778e0f5554c5c05526 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 13:08:00 +0100 Subject: [PATCH 02/33] fix --- source/blender/draw/engines/overlay/overlay_sculpt_curves.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 2af83644e12..5c670345354 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -109,9 +109,9 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) } const crazyspace::GeometryDeformation deformation = crazyspace::get_evaluated_curves_deformation( - *depsgraph, *object); + *depsgraph, *object_orig); - // std::cout << deformation.positions.size() << "\n"; + std::cout << deformation.positions.size() << "\n"; const Curves *curves_id_orig = reinterpret_cast(object_orig->data); const bke::CurvesGeometry &curves_orig = bke::CurvesGeometry::wrap(curves_id_orig->geometry); -- 2.30.2 From f490d6f7f58855edf991187f330168069b0e29c5 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 14:37:14 +0100 Subject: [PATCH 03/33] initial drawing --- source/blender/blenkernel/intern/curves.cc | 20 +++++++++++++ source/blender/blenkernel/intern/object.cc | 5 ++++ .../engines/overlay/overlay_sculpt_curves.cc | 29 ++++--------------- .../draw/intern/draw_cache_impl_curves.cc | 23 +++++++++++++++ source/blender/makesdna/DNA_object_types.h | 3 +- 5 files changed, 56 insertions(+), 24 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 0bdddc9c389..e13c606cd62 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -334,6 +334,26 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob } curves_evaluate_modifiers(depsgraph, scene, object, geometry_set); + if (const blender::bke::CurvesEditHints *curve_edit_hints = + geometry_set.get_curve_edit_hints_for_read()) { + const Curves &curves_id_orig = curve_edit_hints->curves_id_orig; + const blender::bke::CurvesGeometry &curves_orig = blender::bke::CurvesGeometry::wrap( + curves_id_orig.geometry); + Curves *curves_id_cage = blender::bke::curves_new_nomain(curves_id_orig.geometry.point_num, + curves_id_orig.geometry.curve_num); + blender::bke::CurvesGeometry &curves_cage = blender::bke::CurvesGeometry::wrap( + curves_id_cage->geometry); + if (curve_edit_hints->positions.has_value()) { + curves_cage.positions_for_write().copy_from(*curve_edit_hints->positions); + } + else { + curves_cage.positions_for_write().copy_from(curves_orig.positions()); + } + curves_cage.offsets_for_write().copy_from(curves_orig.offsets()); + curves_cage.fill_curve_types(CURVE_TYPE_POLY); + object->runtime.editcurves_eval_cage = curves_id_cage; + } + /* Assign evaluated object. */ Curves *curves_eval = const_cast(geometry_set.get_curves_for_read()); if (curves_eval == nullptr) { diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index 3534156c3fd..5e43a5923e4 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -1790,6 +1790,11 @@ void BKE_object_free_derived_caches(Object *ob) } ob->runtime.editmesh_eval_cage = nullptr; + if (ob->runtime.editcurves_eval_cage) { + BKE_id_free(nullptr, ob->runtime.editcurves_eval_cage); + } + ob->runtime.editcurves_eval_cage = nullptr; + if (ob->runtime.data_eval != nullptr) { if (ob->runtime.is_data_eval_owned) { ID *data_eval = ob->runtime.data_eval; diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 5c670345354..9cd430668a0 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -39,8 +39,9 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->sculpt_curves_edit_ps, state | pd->clipping_state); - GPUShader *sh = OVERLAY_shader_viewer_attribute_curves(); + GPUShader *sh = OVERLAY_shader_edit_particle_point(); pd->sculpt_curves_edit_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); + DRW_shgroup_uniform_block(pd->sculpt_curves_edit_grp, "globalsBlock", G_draw.block_ubo); } } @@ -89,32 +90,14 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) OVERLAY_PrivateData *pd = vedata->stl->pd; const DRWContextState *draw_ctx = DRW_context_state_get(); - const Depsgraph *depsgraph = draw_ctx->depsgraph; - // float(*cage_positions)[3] = object->runtime.editcurves_eval_cage; - // std::cout << cage_positions << "\n"; - // if (cage_positions == nullptr) { - // return; - // } - - draw_ctx->object_edit; - - const Object *object_orig = DEG_get_original_object(object); - std::cout << object << " " << object_orig << " " << object->id.name << "\n"; - if (object_orig == nullptr) { - return; - } - if (object_orig->type != OB_CURVES) { + Curves *curves_id_cage = object->runtime.editcurves_eval_cage; + if (curves_id_cage == nullptr) { return; } - const crazyspace::GeometryDeformation deformation = crazyspace::get_evaluated_curves_deformation( - *depsgraph, *object_orig); - - std::cout << deformation.positions.size() << "\n"; - - const Curves *curves_id_orig = reinterpret_cast(object_orig->data); - const bke::CurvesGeometry &curves_orig = bke::CurvesGeometry::wrap(curves_id_orig->geometry); + GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves_id_cage); + DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_grp, geom_points, object); } void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 0203554db4a..721476e7eda 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -753,9 +753,32 @@ void DRW_curves_batch_cache_create_requested(Object *ob) Curves *curves = static_cast(ob->data); Object *orig = DEG_get_original_object(ob); Curves *curves_orig = static_cast(orig->data); + Curves *curves_cage = ob->runtime.editcurves_eval_cage; CurvesBatchCache &cache = curves_batch_cache_get(*curves); + if (curves_cage) { + CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage); + if (DRW_batch_requested(cage_cache.edit_points, GPU_PRIM_POINTS)) { + DRW_vbo_request(cage_cache.edit_points, &cage_cache.edit_points_pos); + DRW_vbo_request(cage_cache.edit_points, &cage_cache.edit_points_data); + } + if (DRW_batch_requested(cage_cache.edit_lines, GPU_PRIM_LINE_STRIP)) { + DRW_ibo_request(cage_cache.edit_lines, &cage_cache.edit_lines_ibo); + DRW_vbo_request(cage_cache.edit_lines, &cage_cache.edit_points_pos); + DRW_vbo_request(cage_cache.edit_lines, &cage_cache.edit_points_data); + } + if (DRW_vbo_requested(cage_cache.edit_points_pos)) { + curves_batch_cache_ensure_edit_points_pos(*curves_cage, cage_cache); + } + if (DRW_vbo_requested(cage_cache.edit_points_data)) { + curves_batch_cache_ensure_edit_points_data(*curves_cage, cage_cache); + } + if (DRW_ibo_requested(cage_cache.edit_lines_ibo)) { + curves_batch_cache_ensure_edit_lines(*curves_cage, cage_cache); + } + } + if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) { DRW_vbo_request(cache.edit_points, &cache.edit_points_pos); DRW_vbo_request(cache.edit_points, &cache.edit_points_data); diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 0f3dd4da764..3005f334242 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -171,7 +171,8 @@ typedef struct Object_Runtime { /* Evaluated mesh cage in edit mode. */ struct Mesh *editmesh_eval_cage; - float (*editcurves_eval_cage)[3]; + /** Evaluated curve cage in edit and sculpt mode. */ + struct Curves *editcurves_eval_cage; /** Cached cage bounding box of `editmesh_eval_cage` for selection. */ struct BoundBox *editmesh_bb_cage; -- 2.30.2 From 381409f041cfa48a5c73f2f36afe884f0b1ba1d8 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 14:47:45 +0100 Subject: [PATCH 04/33] cleanup --- .../draw/engines/overlay/overlay_private.hh | 3 ++- .../engines/overlay/overlay_sculpt_curves.cc | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index 4d8a00d1aa5..8a3ec849fd9 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -288,7 +288,8 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *pointcloud_dots_grp; DRWShadingGroup *sculpt_mask_grp; DRWShadingGroup *sculpt_curves_selection_grp; - DRWShadingGroup *sculpt_curves_edit_grp; + DRWShadingGroup *sculpt_curves_edit_points_grp; + DRWShadingGroup *sculpt_curves_edit_lines_grp; DRWShadingGroup *viewer_attribute_curve_grp; DRWShadingGroup *viewer_attribute_curves_grp; DRWShadingGroup *viewer_attribute_mesh_grp; diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 9cd430668a0..2a64fb087ac 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -39,9 +39,19 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->sculpt_curves_edit_ps, state | pd->clipping_state); - GPUShader *sh = OVERLAY_shader_edit_particle_point(); - pd->sculpt_curves_edit_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); - DRW_shgroup_uniform_block(pd->sculpt_curves_edit_grp, "globalsBlock", G_draw.block_ubo); + { + GPUShader *sh = OVERLAY_shader_edit_particle_point(); + pd->sculpt_curves_edit_points_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); + DRW_shgroup_uniform_block( + pd->sculpt_curves_edit_points_grp, "globalsBlock", G_draw.block_ubo); + } + { + GPUShader *sh = OVERLAY_shader_edit_particle_strand(); + pd->sculpt_curves_edit_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); + DRW_shgroup_uniform_block( + pd->sculpt_curves_edit_lines_grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_bool_copy(pd->sculpt_curves_edit_lines_grp, "useWeight", false); + } } } @@ -97,7 +107,10 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) } GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves_id_cage); - DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_grp, geom_points, object); + DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_points_grp, geom_points, object); + + struct GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves_id_cage); + DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_lines_grp, geom_lines, object); } void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) -- 2.30.2 From 9c792dd7abd2627431d62208ea83f6ccbe46e8fc Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 14:56:33 +0100 Subject: [PATCH 05/33] fix --- source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 39575015381..7901ff703bc 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -289,7 +289,7 @@ static void curves_sculptmode_enter(bContext *C) paint_init_pivot(ob, scene); /* Necessary to change the object mode on the evaluated object. */ - DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); + DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_GEOMETRY); WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); } -- 2.30.2 From 7942e0c66cc61bd7ab0ba34b7481aaca0828d59b Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 14:58:19 +0100 Subject: [PATCH 06/33] cleanup --- source/blender/blenkernel/intern/curves.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index e13c606cd62..1569f261395 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -334,6 +334,7 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob } curves_evaluate_modifiers(depsgraph, scene, object, geometry_set); + /* Create cage curves geometry for drawing. */ if (const blender::bke::CurvesEditHints *curve_edit_hints = geometry_set.get_curve_edit_hints_for_read()) { const Curves &curves_id_orig = curve_edit_hints->curves_id_orig; -- 2.30.2 From ca20af788407ec815fd92232337c887a22e4a8d5 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 15:23:54 +0100 Subject: [PATCH 07/33] cleanup --- source/blender/blenkernel/intern/curves.cc | 21 ++++++++------ .../engines/overlay/overlay_edit_curves.cc | 9 ++++-- .../draw/intern/draw_cache_impl_curves.cc | 28 ++----------------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 1569f261395..71b43171b99 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -324,35 +324,38 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob Curves *curves = static_cast(object->data); GeometrySet geometry_set = GeometrySet::create_with_curves(curves, GeometryOwnershipType::ReadOnly); - if (object->mode == OB_MODE_SCULPT_CURVES) { + const bool generate_cage = ELEM(object->mode, OB_MODE_EDIT, OB_MODE_SCULPT_CURVES); + const Curves &curves_id_orig = *static_cast( + DEG_get_original_object(object)->data); + if (generate_cage) { /* Try to propagate deformation data through modifier evaluation, so that sculpt mode can work * on evaluated curves. */ GeometryComponentEditData &edit_component = geometry_set.get_component_for_write(); edit_component.curves_edit_hints_ = std::make_unique( - *static_cast(DEG_get_original_object(object)->data)); + curves_id_orig); } curves_evaluate_modifiers(depsgraph, scene, object, geometry_set); /* Create cage curves geometry for drawing. */ - if (const blender::bke::CurvesEditHints *curve_edit_hints = - geometry_set.get_curve_edit_hints_for_read()) { - const Curves &curves_id_orig = curve_edit_hints->curves_id_orig; + if (generate_cage) { const blender::bke::CurvesGeometry &curves_orig = blender::bke::CurvesGeometry::wrap( curves_id_orig.geometry); Curves *curves_id_cage = blender::bke::curves_new_nomain(curves_id_orig.geometry.point_num, curves_id_orig.geometry.curve_num); blender::bke::CurvesGeometry &curves_cage = blender::bke::CurvesGeometry::wrap( curves_id_cage->geometry); - if (curve_edit_hints->positions.has_value()) { + curves_cage.offsets_for_write().copy_from(curves_orig.offsets()); + curves_cage.fill_curve_types(CURVE_TYPE_POLY); + object->runtime.editcurves_eval_cage = curves_id_cage; + const blender::bke::CurvesEditHints *curve_edit_hints = + geometry_set.get_curve_edit_hints_for_read(); + if (curve_edit_hints && curve_edit_hints->positions.has_value()) { curves_cage.positions_for_write().copy_from(*curve_edit_hints->positions); } else { curves_cage.positions_for_write().copy_from(curves_orig.positions()); } - curves_cage.offsets_for_write().copy_from(curves_orig.offsets()); - curves_cage.fill_curve_types(CURVE_TYPE_POLY); - object->runtime.editcurves_eval_cage = curves_id_cage; } /* Assign evaluated object. */ diff --git a/source/blender/draw/engines/overlay/overlay_edit_curves.cc b/source/blender/draw/engines/overlay/overlay_edit_curves.cc index c2b7e3ee92f..739af95270d 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_curves.cc @@ -54,14 +54,17 @@ void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata) static void overlay_edit_curves_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front) { - Curves *curves = static_cast(ob->data); + Curves *curves_id_cage = ob->runtime.editcurves_eval_cage; + if (curves_id_cage == nullptr) { + return; + } 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_id_cage); 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); + struct GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves_id_cage); DRW_shgroup_call_no_cull(lines_shgrp, geom_lines, ob); } diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 721476e7eda..ef6994d46b7 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -55,7 +55,7 @@ struct CurvesBatchCache { GPUBatch *edit_points; GPUBatch *edit_lines; - /* Editmode (original) point positions. */ + /* Positions edited in edit/sculpt mode. */ GPUVertBuf *edit_points_pos; /* Editmode data (such as selection). */ @@ -750,15 +750,10 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves, void DRW_curves_batch_cache_create_requested(Object *ob) { - Curves *curves = static_cast(ob->data); - Object *orig = DEG_get_original_object(ob); - Curves *curves_orig = static_cast(orig->data); Curves *curves_cage = ob->runtime.editcurves_eval_cage; - - CurvesBatchCache &cache = curves_batch_cache_get(*curves); - if (curves_cage) { CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage); + if (DRW_batch_requested(cage_cache.edit_points, GPU_PRIM_POINTS)) { DRW_vbo_request(cage_cache.edit_points, &cage_cache.edit_points_pos); DRW_vbo_request(cage_cache.edit_points, &cage_cache.edit_points_data); @@ -778,23 +773,4 @@ void DRW_curves_batch_cache_create_requested(Object *ob) curves_batch_cache_ensure_edit_lines(*curves_cage, cage_cache); } } - - if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) { - DRW_vbo_request(cache.edit_points, &cache.edit_points_pos); - DRW_vbo_request(cache.edit_points, &cache.edit_points_data); - } - if (DRW_batch_requested(cache.edit_lines, GPU_PRIM_LINE_STRIP)) { - DRW_ibo_request(cache.edit_lines, &cache.edit_lines_ibo); - DRW_vbo_request(cache.edit_lines, &cache.edit_points_pos); - DRW_vbo_request(cache.edit_lines, &cache.edit_points_data); - } - if (DRW_vbo_requested(cache.edit_points_pos)) { - curves_batch_cache_ensure_edit_points_pos(*curves_orig, cache); - } - if (DRW_vbo_requested(cache.edit_points_data)) { - curves_batch_cache_ensure_edit_points_data(*curves_orig, cache); - } - if (DRW_ibo_requested(cache.edit_lines_ibo)) { - curves_batch_cache_ensure_edit_lines(*curves_orig, cache); - } } -- 2.30.2 From c47fa7986b29beca431839b6205ea66881ceb7af Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 15:39:22 +0100 Subject: [PATCH 08/33] add overlay option --- release/scripts/startup/bl_ui/space_view3d.py | 2 ++ .../blender/draw/engines/overlay/overlay_sculpt_curves.cc | 4 +++- source/blender/makesdna/DNA_view3d_types.h | 1 + source/blender/makesrna/intern/rna_space.c | 6 ++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 50629e70aae..a3bc992f9a6 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6751,6 +6751,8 @@ class VIEW3D_PT_overlay_sculpt_curves(Panel): row.active = overlay.show_overlays row.prop(overlay, "sculpt_mode_mask_opacity", text="Selection Opacity") + layout.prop(overlay, "sculpt_curves_cage", text="Cage") + class VIEW3D_PT_overlay_bones(Panel): bl_space_type = 'VIEW_3D' diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 2a64fb087ac..4f5bd4afe2f 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -116,7 +116,9 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) { populate_selection_overlay(vedata, object); - populate_edit_overlay(vedata, object); + if (vedata->stl->pd->overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE) { + populate_edit_overlay(vedata, object); + } } void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata) diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index 4c5ba4c43f8..c70d9baa537 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -547,6 +547,7 @@ enum { V3D_OVERLAY_VIEWER_ATTRIBUTE = (1 << 13), V3D_OVERLAY_SCULPT_SHOW_MASK = (1 << 14), V3D_OVERLAY_SCULPT_SHOW_FACE_SETS = (1 << 15), + V3D_OVERLAY_SCULPT_CURVES_CAGE = (1 << 16), }; /** #View3DOverlay.edit_flag */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 7bdbfe75684..d7e305c9cdc 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -4714,6 +4714,12 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "sculpt_curves_cage", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_SCULPT_CURVES_CAGE); + RNA_def_property_ui_text( + prop, "Sculpt Curves Cage", "Show points that are currently being edited"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "sculpt_mode_face_sets_opacity", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_face_sets_opacity"); RNA_def_property_ui_text(prop, "Sculpt Face Sets Opacity", ""); -- 2.30.2 From 7e3a76bb3de1979ca8f7511caba5a1476f27012d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 30 Jan 2023 15:48:53 +0100 Subject: [PATCH 09/33] Curves: Cage overlay for sculpt mode. Still have to figure out some naming, but seems to work in my test cases. This also changes the overlay in edit mode so that it takes the cage into account. Differential Revision: https://developer.blender.org/D17154 --- source/blender/blenkernel/intern/curves.cc | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 71b43171b99..84389ae4a01 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -336,6 +336,7 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob curves_id_orig); } curves_evaluate_modifiers(depsgraph, scene, object, geometry_set); + Curves *curves_id_eval = const_cast(geometry_set.get_curves_for_read()); /* Create cage curves geometry for drawing. */ if (generate_cage) { @@ -350,22 +351,31 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob object->runtime.editcurves_eval_cage = curves_id_cage; const blender::bke::CurvesEditHints *curve_edit_hints = geometry_set.get_curve_edit_hints_for_read(); - if (curve_edit_hints && curve_edit_hints->positions.has_value()) { - curves_cage.positions_for_write().copy_from(*curve_edit_hints->positions); + + Span positions; + if (curve_edit_hints) { + if (curve_edit_hints->positions.has_value()) { + positions = *curve_edit_hints->positions; + } + else if (curves_id_eval && curves_id_eval->geometry.point_num == curves_orig.point_num) { + blender::bke::CurvesGeometry &curves_eval = blender::bke::CurvesGeometry::wrap( + curves_id_eval->geometry); + positions = curves_eval.positions(); + } } - else { - curves_cage.positions_for_write().copy_from(curves_orig.positions()); + if (positions.is_empty()) { + positions = curves_orig.positions(); } + curves_cage.positions_for_write().copy_from(positions); } /* Assign evaluated object. */ - Curves *curves_eval = const_cast(geometry_set.get_curves_for_read()); - if (curves_eval == nullptr) { - curves_eval = blender::bke::curves_new_nomain(0, 0); - BKE_object_eval_assign_data(object, &curves_eval->id, true); + if (curves_id_eval == nullptr) { + curves_id_eval = blender::bke::curves_new_nomain(0, 0); + BKE_object_eval_assign_data(object, &curves_id_eval->id, true); } else { - BKE_object_eval_assign_data(object, &curves_eval->id, false); + BKE_object_eval_assign_data(object, &curves_id_eval->id, false); } object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set)); } -- 2.30.2 From d0d5bcfecf39d5a68ebdb1380f38bdd4470db438 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 31 Jan 2023 13:36:08 +0100 Subject: [PATCH 10/33] enable by default --- source/blender/blenloader/intern/versioning_300.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 4c45e1433ab..eff503deb27 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3912,5 +3912,16 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) */ { /* Keep this block, even when empty. */ + + LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { + LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { + LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + v3d->overlay.flag |= V3D_OVERLAY_SCULPT_CURVES_CAGE; + } + } + } + } } } -- 2.30.2 From 3b6a8929cd853759ea18874c0ac63d2154ae500d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 31 Jan 2023 13:37:20 +0100 Subject: [PATCH 11/33] remove points overlay --- .../draw/engines/overlay/overlay_private.hh | 1 - .../engines/overlay/overlay_sculpt_curves.cc | 20 ++++--------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index 8a3ec849fd9..ab6da2cad92 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -288,7 +288,6 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *pointcloud_dots_grp; DRWShadingGroup *sculpt_mask_grp; DRWShadingGroup *sculpt_curves_selection_grp; - DRWShadingGroup *sculpt_curves_edit_points_grp; DRWShadingGroup *sculpt_curves_edit_lines_grp; DRWShadingGroup *viewer_attribute_curve_grp; DRWShadingGroup *viewer_attribute_curves_grp; diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 4f5bd4afe2f..9905e880d98 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -39,19 +39,10 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->sculpt_curves_edit_ps, state | pd->clipping_state); - { - GPUShader *sh = OVERLAY_shader_edit_particle_point(); - pd->sculpt_curves_edit_points_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); - DRW_shgroup_uniform_block( - pd->sculpt_curves_edit_points_grp, "globalsBlock", G_draw.block_ubo); - } - { - GPUShader *sh = OVERLAY_shader_edit_particle_strand(); - pd->sculpt_curves_edit_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); - DRW_shgroup_uniform_block( - pd->sculpt_curves_edit_lines_grp, "globalsBlock", G_draw.block_ubo); - DRW_shgroup_uniform_bool_copy(pd->sculpt_curves_edit_lines_grp, "useWeight", false); - } + GPUShader *sh = OVERLAY_shader_edit_particle_strand(); + pd->sculpt_curves_edit_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); + DRW_shgroup_uniform_block(pd->sculpt_curves_edit_lines_grp, "globalsBlock", G_draw.block_ubo); + DRW_shgroup_uniform_bool_copy(pd->sculpt_curves_edit_lines_grp, "useWeight", false); } } @@ -106,9 +97,6 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) return; } - GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves_id_cage); - DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_points_grp, geom_points, object); - struct GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves_id_cage); DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_lines_grp, geom_lines, object); } -- 2.30.2 From fe4a56b2dd57cc29ff184714abfa0d39d5276153 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 31 Jan 2023 13:37:34 +0100 Subject: [PATCH 12/33] cleanup --- source/blender/draw/engines/overlay/overlay_sculpt_curves.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 9905e880d98..c88dd5bfdfd 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -97,7 +97,7 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) return; } - struct GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves_id_cage); + GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves_id_cage); DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_lines_grp, geom_lines, object); } -- 2.30.2 From 8bf94fc145fc9c3a524243fe3b7de2cc5c36b7e3 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 31 Jan 2023 13:49:33 +0100 Subject: [PATCH 13/33] change depth --- source/blender/draw/engines/overlay/overlay_sculpt_curves.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index c88dd5bfdfd..600ae4514bb 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -36,7 +36,8 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) } /* Editable curves overlay. */ { - const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; + const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->sculpt_curves_edit_ps, state | pd->clipping_state); GPUShader *sh = OVERLAY_shader_edit_particle_strand(); @@ -90,7 +91,6 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) using namespace blender::bke; OVERLAY_PrivateData *pd = vedata->stl->pd; - const DRWContextState *draw_ctx = DRW_context_state_get(); Curves *curves_id_cage = object->runtime.editcurves_eval_cage; if (curves_id_cage == nullptr) { -- 2.30.2 From 153eceae0b7204995173b19f24d527d5ddcc6742 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 31 Jan 2023 17:40:36 +0100 Subject: [PATCH 14/33] use anti aliasing and take selection into account --- source/blender/draw/CMakeLists.txt | 1 + .../draw/engines/overlay/overlay_engine.cc | 4 ++ .../draw/engines/overlay/overlay_private.hh | 6 +- .../engines/overlay/overlay_sculpt_curves.cc | 32 +++++----- .../draw/engines/overlay/overlay_shader.cc | 13 ++++ .../infos/overlay_sculpt_curves_info.hh | 20 +++++++ .../overlay_varying_color_wire_vert.glsl | 14 +++++ source/blender/draw/intern/draw_cache_impl.h | 1 + .../draw/intern/draw_cache_impl_curves.cc | 60 +++++++++++++++++++ 9 files changed, 131 insertions(+), 20 deletions(-) create mode 100644 source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index d2835639686..19831bf579f 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -680,6 +680,7 @@ set(GLSL_SRC engines/overlay/shaders/overlay_point_varying_color_frag.glsl engines/overlay/shaders/overlay_point_varying_color_varying_outline_aa_frag.glsl engines/overlay/shaders/overlay_pointcloud_only_vert.glsl + engines/overlay/shaders/overlay_varying_color_wire_vert.glsl engines/overlay/shaders/overlay_sculpt_curves_selection_frag.glsl engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl engines/overlay/shaders/overlay_sculpt_mask_frag.glsl diff --git a/source/blender/draw/engines/overlay/overlay_engine.cc b/source/blender/draw/engines/overlay/overlay_engine.cc index e8300e81f2f..a1446fc94e5 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.cc +++ b/source/blender/draw/engines/overlay/overlay_engine.cc @@ -632,6 +632,10 @@ static void OVERLAY_draw_scene(void *vedata) GPU_framebuffer_bind(fbl->overlay_line_fb); } + if (pd->ctx_mode == CTX_MODE_SCULPT_CURVES) { + OVERLAY_sculpt_curves_draw_wires(data); + } + OVERLAY_wireframe_draw(data); OVERLAY_armature_draw(data); OVERLAY_particle_draw(data); diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index ab6da2cad92..55f9cfc8724 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -120,7 +120,7 @@ typedef struct OVERLAY_PassList { DRWPass *pointcloud_ps; DRWPass *sculpt_mask_ps; DRWPass *sculpt_curves_selection_ps; - DRWPass *sculpt_curves_edit_ps; + DRWPass *sculpt_curves_cage_ps; DRWPass *volume_ps; DRWPass *wireframe_ps; DRWPass *wireframe_xray_ps; @@ -288,7 +288,7 @@ typedef struct OVERLAY_PrivateData { DRWShadingGroup *pointcloud_dots_grp; DRWShadingGroup *sculpt_mask_grp; DRWShadingGroup *sculpt_curves_selection_grp; - DRWShadingGroup *sculpt_curves_edit_lines_grp; + DRWShadingGroup *sculpt_curves_cage_lines_grp; DRWShadingGroup *viewer_attribute_curve_grp; DRWShadingGroup *viewer_attribute_curves_grp; DRWShadingGroup *viewer_attribute_mesh_grp; @@ -688,6 +688,7 @@ void OVERLAY_sculpt_draw(OVERLAY_Data *vedata); void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata); void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *ob); void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata); +void OVERLAY_sculpt_curves_draw_wires(OVERLAY_Data *vedata); void OVERLAY_viewer_attribute_cache_init(OVERLAY_Data *vedata); void OVERLAY_viewer_attribute_cache_populate(OVERLAY_Data *vedata, Object *object); @@ -777,6 +778,7 @@ GPUShader *OVERLAY_shader_particle_dot(void); GPUShader *OVERLAY_shader_particle_shape(void); GPUShader *OVERLAY_shader_sculpt_mask(void); GPUShader *OVERLAY_shader_sculpt_curves_selection(void); +GPUShader *OVERLAY_shader_varying_color_wire(void); GPUShader *OVERLAY_shader_viewer_attribute_curve(void); GPUShader *OVERLAY_shader_viewer_attribute_curves(void); GPUShader *OVERLAY_shader_viewer_attribute_mesh(void); diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 600ae4514bb..a39aebb4c95 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -34,16 +34,13 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) * property yet. */ DRW_shgroup_uniform_float_copy(grp, "selection_opacity", pd->overlay.sculpt_mode_mask_opacity); } - /* Editable curves overlay. */ + /* Cage overlay. */ { - const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | - DRW_STATE_BLEND_ALPHA; - DRW_PASS_CREATE(psl->sculpt_curves_edit_ps, state | pd->clipping_state); + const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; + DRW_PASS_CREATE(psl->sculpt_curves_cage_ps, state | pd->clipping_state); - GPUShader *sh = OVERLAY_shader_edit_particle_strand(); - pd->sculpt_curves_edit_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_edit_ps); - DRW_shgroup_uniform_block(pd->sculpt_curves_edit_lines_grp, "globalsBlock", G_draw.block_ubo); - DRW_shgroup_uniform_bool_copy(pd->sculpt_curves_edit_lines_grp, "useWeight", false); + GPUShader *sh = OVERLAY_shader_varying_color_wire(); + pd->sculpt_curves_cage_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_cage_ps); } } @@ -97,8 +94,8 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) return; } - GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves_id_cage); - DRW_shgroup_call_no_cull(pd->sculpt_curves_edit_lines_grp, geom_lines, object); + GPUBatch *geom_lines = DRW_curves_batch_cache_get_cage_lines(curves_id_cage); + DRW_shgroup_call_no_cull(pd->sculpt_curves_cage_lines_grp, geom_lines, object); } void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) @@ -112,14 +109,13 @@ void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) void OVERLAY_sculpt_curves_draw(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; - OVERLAY_PrivateData *pd = vedata->stl->pd; - OVERLAY_FramebufferList *fbl = vedata->fbl; - - if (DRW_state_is_fbo()) { - GPU_framebuffer_bind(pd->painting.in_front ? fbl->overlay_in_front_fb : - fbl->overlay_default_fb); - } DRW_draw_pass(psl->sculpt_curves_selection_ps); - DRW_draw_pass(psl->sculpt_curves_edit_ps); +} + +void OVERLAY_sculpt_curves_draw_wires(OVERLAY_Data *vedata) +{ + OVERLAY_PassList *psl = vedata->psl; + + DRW_draw_pass(psl->sculpt_curves_cage_ps); } diff --git a/source/blender/draw/engines/overlay/overlay_shader.cc b/source/blender/draw/engines/overlay/overlay_shader.cc index 5fd009db715..45e397cc101 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.cc +++ b/source/blender/draw/engines/overlay/overlay_shader.cc @@ -94,6 +94,7 @@ struct OVERLAY_Shaders { GPUShader *sculpt_curves_selection; GPUShader *uniform_color; GPUShader *uniform_color_pointcloud; + GPUShader *varying_color_wire; GPUShader *viewer_attribute_mesh; GPUShader *viewer_attribute_pointcloud; GPUShader *viewer_attribute_curve; @@ -856,6 +857,18 @@ GPUShader *OVERLAY_shader_sculpt_curves_selection(void) return sh_data->sculpt_curves_selection; } +GPUShader *OVERLAY_shader_varying_color_wire(void) +{ + const DRWContextState *draw_ctx = DRW_context_state_get(); + OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; + if (!sh_data->varying_color_wire) { + sh_data->varying_color_wire = GPU_shader_create_from_info_name( + (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_varying_color_wire_clipped" : + "overlay_varying_color_wire"); + } + return sh_data->varying_color_wire; +} + GPUShader *OVERLAY_shader_viewer_attribute_mesh(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh index 46e3943b293..e3171bb46e6 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh @@ -19,3 +19,23 @@ GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_selection) GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_selection_clipped) .do_static_compilation(true) .additional_info("overlay_sculpt_curves_selection", "drw_clipped"); + +GPU_SHADER_INTERFACE_INFO(overlay_varying_color_wire_iface, "") + .no_perspective(Type::VEC2, "edgePos") + .flat(Type::VEC2, "edgeStart") + .smooth(Type::VEC4, "finalColor"); + +GPU_SHADER_CREATE_INFO(overlay_varying_color_wire) + .do_static_compilation(true) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "my_color") + .vertex_out(overlay_varying_color_wire_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .fragment_out(1, Type::VEC4, "lineOutput") + .vertex_source("overlay_varying_color_wire_vert.glsl") + .fragment_source("overlay_extra_frag.glsl") + .additional_info("draw_modelmat", "draw_view", "draw_globals"); + +GPU_SHADER_CREATE_INFO(overlay_varying_color_wire_clipped) + .do_static_compilation(true) + .additional_info("overlay_varying_color_wire", "drw_clipped"); diff --git a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl new file mode 100644 index 00000000000..cf454770af8 --- /dev/null +++ b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl @@ -0,0 +1,14 @@ + +#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl) +#pragma BLENDER_REQUIRE(common_view_lib.glsl) + +void main() +{ + vec3 world_pos = point_object_to_world(pos); + gl_Position = point_world_to_ndc(world_pos); + + finalColor = my_color; + + /* Convert to screen position [0..sizeVp]. */ + edgePos = edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; +} diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 8cc53b48af8..f51c40820a4 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -135,6 +135,7 @@ struct GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(struct Curves *cu struct GPUBatch *DRW_curves_batch_cache_get_edit_points(struct Curves *curves); struct GPUBatch *DRW_curves_batch_cache_get_edit_lines(struct Curves *curves); +struct GPUBatch *DRW_curves_batch_cache_get_cage_lines(struct Curves *curves); void DRW_curves_batch_cache_create_requested(struct Object *ob); diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index ef6994d46b7..556c0cb8580 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -55,12 +55,17 @@ struct CurvesBatchCache { GPUBatch *edit_points; GPUBatch *edit_lines; + GPUBatch *cage_lines; + /* Positions edited in edit/sculpt mode. */ GPUVertBuf *edit_points_pos; /* Editmode data (such as selection). */ GPUVertBuf *edit_points_data; + GPUVertBuf *cage_point_pos; + GPUVertBuf *cage_point_color; + GPUIndexBuf *edit_lines_ibo; /* Whether the cache is invalid. */ @@ -117,8 +122,12 @@ static void curves_batch_cache_clear_edit_data(CurvesBatchCache *cache) GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_data); GPU_INDEXBUF_DISCARD_SAFE(cache->edit_lines_ibo); + GPU_VERTBUF_DISCARD_SAFE(cache->cage_point_pos); + GPU_VERTBUF_DISCARD_SAFE(cache->cage_point_color); + GPU_BATCH_DISCARD_SAFE(cache->edit_points); GPU_BATCH_DISCARD_SAFE(cache->edit_lines); + GPU_BATCH_DISCARD_SAFE(cache->cage_lines); } static void curves_batch_cache_clear_eval_data(CurvesEvalCache &curves_cache) @@ -684,6 +693,12 @@ GPUBatch *DRW_curves_batch_cache_get_edit_lines(Curves *curves) return DRW_batch_request(&cache.edit_lines); } +GPUBatch *DRW_curves_batch_cache_get_cage_lines(struct Curves *curves) +{ + CurvesBatchCache &cache = curves_batch_cache_get(*curves); + return DRW_batch_request(&cache.cage_lines); +} + static void request_attribute(Curves &curves, const char *name) { CurvesBatchCache &cache = curves_batch_cache_get(curves); @@ -751,7 +766,11 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves, void DRW_curves_batch_cache_create_requested(Object *ob) { Curves *curves_cage = ob->runtime.editcurves_eval_cage; + Object *ob_orig = DEG_get_original_object(ob); if (curves_cage) { + const Curves *curves_id_orig = static_cast(ob_orig->data); + const blender::bke::CurvesGeometry &curves_orig = blender::bke::CurvesGeometry::wrap( + curves_id_orig->geometry); CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage); if (DRW_batch_requested(cage_cache.edit_points, GPU_PRIM_POINTS)) { @@ -763,6 +782,11 @@ void DRW_curves_batch_cache_create_requested(Object *ob) DRW_vbo_request(cage_cache.edit_lines, &cage_cache.edit_points_pos); DRW_vbo_request(cage_cache.edit_lines, &cage_cache.edit_points_data); } + if (DRW_batch_requested(cage_cache.cage_lines, GPU_PRIM_LINE_STRIP)) { + DRW_ibo_request(cage_cache.cage_lines, &cage_cache.edit_lines_ibo); + DRW_vbo_request(cage_cache.cage_lines, &cage_cache.cage_point_pos); + DRW_vbo_request(cage_cache.cage_lines, &cage_cache.cage_point_color); + } if (DRW_vbo_requested(cage_cache.edit_points_pos)) { curves_batch_cache_ensure_edit_points_pos(*curves_cage, cage_cache); } @@ -772,5 +796,41 @@ void DRW_curves_batch_cache_create_requested(Object *ob) if (DRW_ibo_requested(cage_cache.edit_lines_ibo)) { curves_batch_cache_ensure_edit_lines(*curves_cage, cage_cache); } + if (DRW_vbo_requested(cage_cache.cage_point_pos)) { + static uint pos; + static const GPUVertFormat format = [&]() { + GPUVertFormat format; + pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); + return format; + }(); + + GPU_vertbuf_init_with_format(cage_cache.cage_point_pos, &format); + GPU_vertbuf_data_alloc(cage_cache.cage_point_pos, curves_cage->geometry.point_num); + + const Span positions = + blender::bke::CurvesGeometry::wrap(curves_cage->geometry).positions(); + GPU_vertbuf_attr_fill(cage_cache.cage_point_pos, pos, positions.data()); + } + if (DRW_vbo_requested(cage_cache.cage_point_color)) { + static const GPUVertFormat format = [&]() { + GPUVertFormat format; + GPU_vertformat_attr_add(&format, "my_color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + return format; + }(); + + GPU_vertbuf_init_with_format(cage_cache.cage_point_color, &format); + GPU_vertbuf_data_alloc(cage_cache.cage_point_color, curves_cage->geometry.point_num); + blender::uchar4 *data = static_cast( + GPU_vertbuf_get_data(cage_cache.cage_point_color)); + + const blender::VArraySpan selection = + curves_orig.attributes().lookup_or_default(".selection", ATTR_DOMAIN_POINT, 1.0f); + blender::threading::parallel_for(selection.index_range(), 2048, [&](const IndexRange range) { + for (const int i : range) { + const float f = std::clamp(selection[i], 0.0f, 1.0f); + data[i] = blender::uchar4(f * 255.0f, f * 255.0f, f * 255.0f, 255); + } + }); + } } } -- 2.30.2 From 85f15b604b6dcda88326e364d40dba6fb566a8bf Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 2 Feb 2023 12:57:29 +0100 Subject: [PATCH 15/33] fixes --- source/blender/blenkernel/intern/curves.cc | 9 +++------ source/blender/draw/intern/draw_cache_impl_curves.cc | 6 ++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index d130c9f6fd4..88ca111671f 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -339,12 +339,10 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob /* Create cage curves geometry for drawing. */ if (generate_cage) { - const blender::bke::CurvesGeometry &curves_orig = blender::bke::CurvesGeometry::wrap( - curves_id_orig.geometry); + const blender::bke::CurvesGeometry &curves_orig = curves_id_orig.geometry.wrap(); Curves *curves_id_cage = blender::bke::curves_new_nomain(curves_id_orig.geometry.point_num, curves_id_orig.geometry.curve_num); - blender::bke::CurvesGeometry &curves_cage = blender::bke::CurvesGeometry::wrap( - curves_id_cage->geometry); + blender::bke::CurvesGeometry &curves_cage = curves_id_cage->geometry.wrap(); curves_cage.offsets_for_write().copy_from(curves_orig.offsets()); curves_cage.fill_curve_types(CURVE_TYPE_POLY); object->runtime.editcurves_eval_cage = curves_id_cage; @@ -357,8 +355,7 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob positions = *curve_edit_hints->positions; } else if (curves_id_eval && curves_id_eval->geometry.point_num == curves_orig.point_num) { - blender::bke::CurvesGeometry &curves_eval = blender::bke::CurvesGeometry::wrap( - curves_id_eval->geometry); + blender::bke::CurvesGeometry &curves_eval = curves_id_eval->geometry.wrap(); positions = curves_eval.positions(); } } diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 81ec1670475..8117726b726 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -766,8 +766,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) Object *ob_orig = DEG_get_original_object(ob); if (curves_cage) { const Curves *curves_id_orig = static_cast(ob_orig->data); - const blender::bke::CurvesGeometry &curves_orig = blender::bke::CurvesGeometry::wrap( - curves_id_orig->geometry); + const blender::bke::CurvesGeometry &curves_orig = curves_id_orig->geometry.wrap(); CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage); if (DRW_batch_requested(cage_cache.edit_points, GPU_PRIM_POINTS)) { @@ -804,8 +803,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) GPU_vertbuf_init_with_format(cage_cache.cage_point_pos, &format); GPU_vertbuf_data_alloc(cage_cache.cage_point_pos, curves_cage->geometry.point_num); - const Span positions = - blender::bke::CurvesGeometry::wrap(curves_cage->geometry).positions(); + const Span positions = curves_cage->geometry.wrap().positions(); GPU_vertbuf_attr_fill(cage_cache.cage_point_pos, pos, positions.data()); } if (DRW_vbo_requested(cage_cache.cage_point_color)) { -- 2.30.2 From 174a3dc3f9be242fb70ce456b53a6c419b90f4b0 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 8 Feb 2023 13:57:37 +0100 Subject: [PATCH 16/33] use less-equal drawing mode again --- source/blender/draw/engines/overlay/overlay_sculpt_curves.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index b38a0575ac9..a22fdde087e 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -36,7 +36,8 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) } /* Cage overlay. */ { - const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_ALWAYS | DRW_STATE_BLEND_ALPHA; + const DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | + DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->sculpt_curves_cage_ps, state | pd->clipping_state); GPUShader *sh = OVERLAY_shader_varying_color_wire(); -- 2.30.2 From a1a7c64365301554747c3329ce0a1673bc392813 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 8 Feb 2023 14:26:11 +0100 Subject: [PATCH 17/33] add opacity control --- release/scripts/startup/bl_ui/space_view3d.py | 7 ++++++- source/blender/blenloader/intern/versioning_300.cc | 1 + .../blender/draw/engines/overlay/overlay_sculpt_curves.cc | 7 ++++++- .../overlay/shaders/infos/overlay_sculpt_curves_info.hh | 1 + .../overlay/shaders/overlay_varying_color_wire_vert.glsl | 1 + source/blender/makesdna/DNA_view3d_types.h | 4 ++++ source/blender/makesrna/intern/rna_space.c | 7 +++++++ 7 files changed, 26 insertions(+), 2 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 8b34f1f80e4..ca267e849ca 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -6753,7 +6753,12 @@ class VIEW3D_PT_overlay_sculpt_curves(Panel): row.active = overlay.show_overlays row.prop(overlay, "sculpt_mode_mask_opacity", text="Selection Opacity") - layout.prop(overlay, "sculpt_curves_cage", text="Cage") + row = layout.row(align=True) + row.active = overlay.show_overlays + row.prop(overlay, "sculpt_curves_cage", text="") + subrow = row.row(align=True) + subrow.active = overlay.sculpt_curves_cage + subrow.prop(overlay, "sculpt_curves_cage_opacity", text="Cage Opacity") class VIEW3D_PT_overlay_bones(Panel): diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index eff503deb27..a18f2b35056 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3919,6 +3919,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.flag |= V3D_OVERLAY_SCULPT_CURVES_CAGE; + v3d->overlay.sculpt_curves_cage_opacity = 0.7f; } } } diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index a22fdde087e..89b126e2863 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -20,6 +20,7 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; OVERLAY_PrivateData *pd = vedata->stl->pd; + const View3DOverlay &overlay = vedata->stl->pd->overlay; /* Selection overlay. */ { @@ -42,6 +43,8 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) GPUShader *sh = OVERLAY_shader_varying_color_wire(); pd->sculpt_curves_cage_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_cage_ps); + DRW_shgroup_uniform_float_copy( + pd->sculpt_curves_cage_lines_grp, "opacity", overlay.sculpt_curves_cage_opacity); } } @@ -102,7 +105,9 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) void OVERLAY_sculpt_curves_cache_populate(OVERLAY_Data *vedata, Object *object) { populate_selection_overlay(vedata, object); - if (vedata->stl->pd->overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE) { + const View3DOverlay &overlay = vedata->stl->pd->overlay; + if ((overlay.flag & V3D_OVERLAY_SCULPT_CURVES_CAGE) && + overlay.sculpt_curves_cage_opacity > 0.0f) { populate_edit_overlay(vedata, object); } } diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh index e3171bb46e6..058055c00e9 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh @@ -32,6 +32,7 @@ GPU_SHADER_CREATE_INFO(overlay_varying_color_wire) .vertex_out(overlay_varying_color_wire_iface) .fragment_out(0, Type::VEC4, "fragColor") .fragment_out(1, Type::VEC4, "lineOutput") + .push_constant(Type::FLOAT, "opacity") .vertex_source("overlay_varying_color_wire_vert.glsl") .fragment_source("overlay_extra_frag.glsl") .additional_info("draw_modelmat", "draw_view", "draw_globals"); diff --git a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl index cf454770af8..1940ec6ef26 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl @@ -8,6 +8,7 @@ void main() gl_Position = point_world_to_ndc(world_pos); finalColor = my_color; + finalColor.a *= opacity; /* Convert to screen position [0..sizeVp]. */ edgePos = edgeStart = ((gl_Position.xy / gl_Position.w) * 0.5 + 0.5) * sizeViewport.xy; diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index c70d9baa537..3a84f75c48d 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -232,6 +232,10 @@ typedef struct View3DOverlay { float gpencil_vertex_paint_opacity; /** Handles display type for curves. */ int handle_display; + + /** Curves sculpt mode settings. */ + float sculpt_curves_cage_opacity; + char _pad[4]; } View3DOverlay; /** #View3DOverlay.handle_display */ diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index d7e305c9cdc..8371f3aeadd 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -4720,6 +4720,13 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) prop, "Sculpt Curves Cage", "Show points that are currently being edited"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "sculpt_curves_cage_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_curves_cage_opacity"); + RNA_def_property_ui_text( + prop, "Curves Sculpt Cage Opacity", "Opacity of the cage overlay in curves sculpt mode"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "sculpt_mode_face_sets_opacity", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "overlay.sculpt_mode_face_sets_opacity"); RNA_def_property_ui_text(prop, "Sculpt Face Sets Opacity", ""); -- 2.30.2 From 0d3b332c7a9bd847cca264060f92bbb82506c88a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 14:49:53 +0100 Subject: [PATCH 18/33] cleanup --- source/blender/blenkernel/intern/curves.cc | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 2003ad595ed..4edddd5313d 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -322,6 +322,22 @@ static void curves_evaluate_modifiers(struct Depsgraph *depsgraph, } } +static Span get_cage_positions(const blender::bke::CurvesGeometry &curves_orig, + const Curves *curves_id_eval, + const blender::bke::CurvesEditHints *curve_edit_hints) +{ + if (curve_edit_hints) { + if (curve_edit_hints->positions.has_value()) { + return *curve_edit_hints->positions; + } + else if (curves_id_eval && curves_id_eval->geometry.point_num == curves_orig.point_num) { + const blender::bke::CurvesGeometry &curves_eval = curves_id_eval->geometry.wrap(); + return curves_eval.positions(); + } + } + return curves_orig.positions(); +} + void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) { /* Free any evaluated data and restore original data. */ @@ -350,26 +366,14 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob const blender::bke::CurvesGeometry &curves_orig = curves_id_orig.geometry.wrap(); Curves *curves_id_cage = blender::bke::curves_new_nomain(curves_id_orig.geometry.point_num, curves_id_orig.geometry.curve_num); + object->runtime.editcurves_eval_cage = curves_id_cage; + blender::bke::CurvesGeometry &curves_cage = curves_id_cage->geometry.wrap(); curves_cage.offsets_for_write().copy_from(curves_orig.offsets()); curves_cage.fill_curve_types(CURVE_TYPE_POLY); - object->runtime.editcurves_eval_cage = curves_id_cage; - const blender::bke::CurvesEditHints *curve_edit_hints = - geometry_set.get_curve_edit_hints_for_read(); - Span positions; - if (curve_edit_hints) { - if (curve_edit_hints->positions.has_value()) { - positions = *curve_edit_hints->positions; - } - else if (curves_id_eval && curves_id_eval->geometry.point_num == curves_orig.point_num) { - blender::bke::CurvesGeometry &curves_eval = curves_id_eval->geometry.wrap(); - positions = curves_eval.positions(); - } - } - if (positions.is_empty()) { - positions = curves_orig.positions(); - } + Span positions = get_cage_positions( + curves_orig, curves_id_eval, geometry_set.get_curve_edit_hints_for_read()); curves_cage.positions_for_write().copy_from(positions); } -- 2.30.2 From a7f8e07386d47c8ee72d75cd9dfdc97aba048386 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 14:51:11 +0100 Subject: [PATCH 19/33] cleanup --- source/blender/blenloader/intern/versioning_300.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 1587844ec03..55641537b6f 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3920,8 +3920,6 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } } - /* Keep this block, even when empty. */ - LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { @@ -3933,5 +3931,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) } } } + + /* Keep this block, even when empty. */ } } -- 2.30.2 From 5b0bc9a7af9572f093efe4ce024455cb71bce7e3 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 14:53:50 +0100 Subject: [PATCH 20/33] cleanup --- .../engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh | 2 +- .../overlay/shaders/overlay_varying_color_wire_vert.glsl | 2 +- source/blender/draw/intern/draw_cache_impl_curves.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh index 058055c00e9..3551ee668a6 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh @@ -28,7 +28,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_varying_color_wire_iface, "") GPU_SHADER_CREATE_INFO(overlay_varying_color_wire) .do_static_compilation(true) .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "my_color") + .vertex_in(1, Type::VEC4, "color") .vertex_out(overlay_varying_color_wire_iface) .fragment_out(0, Type::VEC4, "fragColor") .fragment_out(1, Type::VEC4, "lineOutput") diff --git a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl index 1940ec6ef26..2cf534243ac 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl @@ -7,7 +7,7 @@ void main() vec3 world_pos = point_object_to_world(pos); gl_Position = point_world_to_ndc(world_pos); - finalColor = my_color; + finalColor = color; finalColor.a *= opacity; /* Convert to screen position [0..sizeVp]. */ diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 8117726b726..2f6af538dbf 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -809,7 +809,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) if (DRW_vbo_requested(cage_cache.cage_point_color)) { static const GPUVertFormat format = [&]() { GPUVertFormat format; - GPU_vertformat_attr_add(&format, "my_color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); return format; }(); -- 2.30.2 From c0b556b1af697404db94363570dc7b6a0c111c97 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 14:57:09 +0100 Subject: [PATCH 21/33] cleanup --- source/blender/draw/intern/draw_cache_impl_curves.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 2f6af538dbf..7747a4301c7 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -54,10 +54,9 @@ struct CurvesBatchCache { GPUBatch *edit_points; GPUBatch *edit_lines; - GPUBatch *cage_lines; - /* Positions edited in edit/sculpt mode. */ + /* Editmode (original) point positions. */ GPUVertBuf *edit_points_pos; /* Editmode data (such as selection). */ -- 2.30.2 From 3cb38d3a2532919107591553089521ae0d9b19bc Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 15:39:32 +0100 Subject: [PATCH 22/33] change opacity to 0.5 --- source/blender/blenloader/intern/versioning_300.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index 55641537b6f..715d919d9e8 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -3926,7 +3926,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.flag |= V3D_OVERLAY_SCULPT_CURVES_CAGE; - v3d->overlay.sculpt_curves_cage_opacity = 0.7f; + v3d->overlay.sculpt_curves_cage_opacity = 0.5f; } } } -- 2.30.2 From c7d4f1675fd3d3d54550897b75ec150334fdb2f0 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 15:59:18 +0100 Subject: [PATCH 23/33] bring back old edit mode behavior --- .../engines/overlay/overlay_edit_curves.cc | 9 +-- .../draw/intern/draw_cache_impl_curves.cc | 56 +++++++++++-------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_edit_curves.cc b/source/blender/draw/engines/overlay/overlay_edit_curves.cc index 739af95270d..c2b7e3ee92f 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_curves.cc @@ -54,17 +54,14 @@ void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata) static void overlay_edit_curves_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front) { - Curves *curves_id_cage = ob->runtime.editcurves_eval_cage; - if (curves_id_cage == nullptr) { - return; - } + Curves *curves = static_cast(ob->data); DRWShadingGroup *point_shgrp = pd->edit_curves_points_grp[in_front]; - struct GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves_id_cage); + struct GPUBatch *geom_points = DRW_curves_batch_cache_get_edit_points(curves); 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_id_cage); + struct GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves); DRW_shgroup_call_no_cull(lines_shgrp, geom_lines, ob); } diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 7747a4301c7..4694e10e576 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -761,35 +761,43 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves, void DRW_curves_batch_cache_create_requested(Object *ob) { - Curves *curves_cage = ob->runtime.editcurves_eval_cage; Object *ob_orig = DEG_get_original_object(ob); - if (curves_cage) { - const Curves *curves_id_orig = static_cast(ob_orig->data); - const blender::bke::CurvesGeometry &curves_orig = curves_id_orig->geometry.wrap(); - CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage); + Curves *curves_id = static_cast(ob->data); + const Curves *curves_id_orig = static_cast(ob_orig->data); + + CurvesBatchCache &cache = curves_batch_cache_get(*curves_id); + + if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) { + DRW_vbo_request(cache.edit_points, &cache.edit_points_pos); + DRW_vbo_request(cache.edit_points, &cache.edit_points_data); + } + if (DRW_batch_requested(cache.edit_lines, GPU_PRIM_LINE_STRIP)) { + DRW_ibo_request(cache.edit_lines, &cache.edit_lines_ibo); + DRW_vbo_request(cache.edit_lines, &cache.edit_points_pos); + DRW_vbo_request(cache.edit_lines, &cache.edit_points_data); + } + if (DRW_vbo_requested(cache.edit_points_pos)) { + curves_batch_cache_ensure_edit_points_pos(*curves_id_orig, cache); + } + if (DRW_vbo_requested(cache.edit_points_data)) { + curves_batch_cache_ensure_edit_points_data(*curves_id_orig, cache); + } + if (DRW_ibo_requested(cache.edit_lines_ibo)) { + curves_batch_cache_ensure_edit_lines(*curves_id_orig, cache); + } + + Curves *curves_cage_id = ob->runtime.editcurves_eval_cage; + if (curves_cage_id) { + const blender::bke::CurvesGeometry &curves_orig = curves_id_orig->geometry.wrap(); + CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage_id); - if (DRW_batch_requested(cage_cache.edit_points, GPU_PRIM_POINTS)) { - DRW_vbo_request(cage_cache.edit_points, &cage_cache.edit_points_pos); - DRW_vbo_request(cage_cache.edit_points, &cage_cache.edit_points_data); - } - if (DRW_batch_requested(cage_cache.edit_lines, GPU_PRIM_LINE_STRIP)) { - DRW_ibo_request(cage_cache.edit_lines, &cage_cache.edit_lines_ibo); - DRW_vbo_request(cage_cache.edit_lines, &cage_cache.edit_points_pos); - DRW_vbo_request(cage_cache.edit_lines, &cage_cache.edit_points_data); - } if (DRW_batch_requested(cage_cache.cage_lines, GPU_PRIM_LINE_STRIP)) { DRW_ibo_request(cage_cache.cage_lines, &cage_cache.edit_lines_ibo); DRW_vbo_request(cage_cache.cage_lines, &cage_cache.cage_point_pos); DRW_vbo_request(cage_cache.cage_lines, &cage_cache.cage_point_color); } - if (DRW_vbo_requested(cage_cache.edit_points_pos)) { - curves_batch_cache_ensure_edit_points_pos(*curves_cage, cage_cache); - } - if (DRW_vbo_requested(cage_cache.edit_points_data)) { - curves_batch_cache_ensure_edit_points_data(*curves_cage, cage_cache); - } if (DRW_ibo_requested(cage_cache.edit_lines_ibo)) { - curves_batch_cache_ensure_edit_lines(*curves_cage, cage_cache); + curves_batch_cache_ensure_edit_lines(*curves_cage_id, cage_cache); } if (DRW_vbo_requested(cage_cache.cage_point_pos)) { static uint pos; @@ -800,9 +808,9 @@ void DRW_curves_batch_cache_create_requested(Object *ob) }(); GPU_vertbuf_init_with_format(cage_cache.cage_point_pos, &format); - GPU_vertbuf_data_alloc(cage_cache.cage_point_pos, curves_cage->geometry.point_num); + GPU_vertbuf_data_alloc(cage_cache.cage_point_pos, curves_cage_id->geometry.point_num); - const Span positions = curves_cage->geometry.wrap().positions(); + const Span positions = curves_cage_id->geometry.wrap().positions(); GPU_vertbuf_attr_fill(cage_cache.cage_point_pos, pos, positions.data()); } if (DRW_vbo_requested(cage_cache.cage_point_color)) { @@ -813,7 +821,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) }(); GPU_vertbuf_init_with_format(cage_cache.cage_point_color, &format); - GPU_vertbuf_data_alloc(cage_cache.cage_point_color, curves_cage->geometry.point_num); + GPU_vertbuf_data_alloc(cage_cache.cage_point_color, curves_cage_id->geometry.point_num); blender::uchar4 *data = static_cast( GPU_vertbuf_get_data(cage_cache.cage_point_color)); -- 2.30.2 From f0a5bf84b2324df86e072c1bf8a30007fb2df2c7 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 16:04:26 +0100 Subject: [PATCH 24/33] cleanup --- .../draw/intern/draw_cache_impl_curves.cc | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 4694e10e576..0c4c6511c48 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -310,7 +310,7 @@ static void curves_batch_cache_ensure_procedural_pos(const Curves &curves, } static void curves_batch_cache_ensure_edit_points_pos(const Curves &curves_id, - CurvesBatchCache &cache) + GPUVertBuf &point_pos_buf) { using namespace blender; const bke::CurvesGeometry &curves = curves_id.geometry.wrap(); @@ -321,11 +321,11 @@ static void curves_batch_cache_ensure_edit_points_pos(const Curves &curves_id, pos = GPU_vertformat_attr_add(&format_pos, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); } - GPU_vertbuf_init_with_format(cache.edit_points_pos, &format_pos); - GPU_vertbuf_data_alloc(cache.edit_points_pos, curves.points_num()); + GPU_vertbuf_init_with_format(&point_pos_buf, &format_pos); + GPU_vertbuf_data_alloc(&point_pos_buf, curves.points_num()); Span positions = curves.positions(); - GPU_vertbuf_attr_fill(cache.edit_points_pos, pos, positions.data()); + GPU_vertbuf_attr_fill(&point_pos_buf, pos, positions.data()); } static void curves_batch_cache_ensure_edit_points_data(const Curves &curves_id, @@ -777,7 +777,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) DRW_vbo_request(cache.edit_lines, &cache.edit_points_data); } if (DRW_vbo_requested(cache.edit_points_pos)) { - curves_batch_cache_ensure_edit_points_pos(*curves_id_orig, cache); + curves_batch_cache_ensure_edit_points_pos(*curves_id_orig, *cache.edit_points_pos); } if (DRW_vbo_requested(cache.edit_points_data)) { curves_batch_cache_ensure_edit_points_data(*curves_id_orig, cache); @@ -800,18 +800,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) curves_batch_cache_ensure_edit_lines(*curves_cage_id, cage_cache); } if (DRW_vbo_requested(cage_cache.cage_point_pos)) { - static uint pos; - static const GPUVertFormat format = [&]() { - GPUVertFormat format; - pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - return format; - }(); - - GPU_vertbuf_init_with_format(cage_cache.cage_point_pos, &format); - GPU_vertbuf_data_alloc(cage_cache.cage_point_pos, curves_cage_id->geometry.point_num); - - const Span positions = curves_cage_id->geometry.wrap().positions(); - GPU_vertbuf_attr_fill(cage_cache.cage_point_pos, pos, positions.data()); + curves_batch_cache_ensure_edit_points_pos(*curves_cage_id, *cage_cache.cage_point_pos); } if (DRW_vbo_requested(cage_cache.cage_point_color)) { static const GPUVertFormat format = [&]() { -- 2.30.2 From f8b7f20a07e81b66a60e38c618bda648238fbd51 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 16:08:08 +0100 Subject: [PATCH 25/33] extract function --- .../draw/intern/draw_cache_impl_curves.cc | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 0c4c6511c48..7f5b0cd5551 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -366,6 +366,29 @@ static void curves_batch_cache_ensure_edit_points_data(const Curves &curves_id, } } +static void curves_batch_cache_ensure_cage_color(const blender::bke::CurvesGeometry &curves, + GPUVertBuf &point_color_buf) +{ + static const GPUVertFormat format = [&]() { + GPUVertFormat format; + GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + return format; + }(); + + GPU_vertbuf_init_with_format(&point_color_buf, &format); + GPU_vertbuf_data_alloc(&point_color_buf, curves.points_num()); + blender::uchar4 *data = static_cast(GPU_vertbuf_get_data(&point_color_buf)); + + const blender::VArraySpan selection = curves.attributes().lookup_or_default( + ".selection", ATTR_DOMAIN_POINT, 1.0f); + blender::threading::parallel_for(selection.index_range(), 2048, [&](const IndexRange range) { + for (const int i : range) { + const float f = std::clamp(selection[i], 0.0f, 1.0f); + data[i] = blender::uchar4(f * 255.0f, f * 255.0f, f * 255.0f, 255); + } + }); +} + static void curves_batch_cache_ensure_edit_lines(const Curves &curves_id, CurvesBatchCache &cache) { using namespace blender; @@ -803,25 +826,7 @@ void DRW_curves_batch_cache_create_requested(Object *ob) curves_batch_cache_ensure_edit_points_pos(*curves_cage_id, *cage_cache.cage_point_pos); } if (DRW_vbo_requested(cage_cache.cage_point_color)) { - static const GPUVertFormat format = [&]() { - GPUVertFormat format; - GPU_vertformat_attr_add(&format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - return format; - }(); - - GPU_vertbuf_init_with_format(cage_cache.cage_point_color, &format); - GPU_vertbuf_data_alloc(cage_cache.cage_point_color, curves_cage_id->geometry.point_num); - blender::uchar4 *data = static_cast( - GPU_vertbuf_get_data(cage_cache.cage_point_color)); - - const blender::VArraySpan selection = - curves_orig.attributes().lookup_or_default(".selection", ATTR_DOMAIN_POINT, 1.0f); - blender::threading::parallel_for(selection.index_range(), 2048, [&](const IndexRange range) { - for (const int i : range) { - const float f = std::clamp(selection[i], 0.0f, 1.0f); - data[i] = blender::uchar4(f * 255.0f, f * 255.0f, f * 255.0f, 255); - } - }); + curves_batch_cache_ensure_cage_color(curves_orig, *cage_cache.cage_point_color); } } } -- 2.30.2 From 0afbed0f47516f7f13860e6e80d21b8ae1214540 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 9 Feb 2023 16:12:17 +0100 Subject: [PATCH 26/33] cleanup --- source/blender/blenkernel/intern/curves.cc | 3 ++- source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index 4edddd5313d..ee818e2e7de 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -322,6 +322,7 @@ static void curves_evaluate_modifiers(struct Depsgraph *depsgraph, } } +/** Get the positions that are edited in sculpt mode. */ static Span get_cage_positions(const blender::bke::CurvesGeometry &curves_orig, const Curves *curves_id_eval, const blender::bke::CurvesEditHints *curve_edit_hints) @@ -347,7 +348,7 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob Curves *curves = static_cast(object->data); GeometrySet geometry_set = GeometrySet::create_with_curves(curves, GeometryOwnershipType::ReadOnly); - const bool generate_cage = ELEM(object->mode, OB_MODE_EDIT, OB_MODE_SCULPT_CURVES); + const bool generate_cage = object->mode == OB_MODE_SCULPT_CURVES; const Curves &curves_id_orig = *static_cast( DEG_get_original_object(object)->data); if (generate_cage) { diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 4c8d625e665..ce13691507a 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -289,7 +289,8 @@ static void curves_sculptmode_enter(bContext *C) ED_paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d); paint_init_pivot(ob, scene); - /* Necessary to change the object mode on the evaluated object. */ + /* Necessary to change the object mode on the evaluated object and to evaluate the cage that is + * edited. */ DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_GEOMETRY); WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); -- 2.30.2 From 2d7594d3225bcbb398deb4df0ec91c802a45d288 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 14:23:50 +0100 Subject: [PATCH 27/33] improve description --- source/blender/makesrna/intern/rna_space.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 15b7c43c975..68c3aeb5c83 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -4717,7 +4717,7 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna) prop = RNA_def_property(srna, "sculpt_curves_cage", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "overlay.flag", V3D_OVERLAY_SCULPT_CURVES_CAGE); RNA_def_property_ui_text( - prop, "Sculpt Curves Cage", "Show points that are currently being edited"); + prop, "Sculpt Curves Cage", "Show original curves that are currently being edited"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "sculpt_curves_cage_opacity", PROP_FLOAT, PROP_FACTOR); -- 2.30.2 From 2ca2d1cad74faf7a99c4097a7bf27d88af1441bf Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 14:30:09 +0100 Subject: [PATCH 28/33] simplify cache --- .../engines/overlay/overlay_sculpt_curves.cc | 9 +++----- .../draw/intern/draw_cache_impl_curves.cc | 21 +++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 89b126e2863..2d004bbfb46 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -88,17 +88,14 @@ static void populate_selection_overlay(OVERLAY_Data *vedata, Object *object) static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) { - using namespace blender; - using namespace blender::bke; - OVERLAY_PrivateData *pd = vedata->stl->pd; + Curves *curves = static_cast(object->data); - Curves *curves_id_cage = object->runtime.editcurves_eval_cage; - if (curves_id_cage == nullptr) { + if (object->runtime.editcurves_eval_cage == nullptr) { return; } - GPUBatch *geom_lines = DRW_curves_batch_cache_get_cage_lines(curves_id_cage); + GPUBatch *geom_lines = DRW_curves_batch_cache_get_cage_lines(curves); DRW_shgroup_call_no_cull(pd->sculpt_curves_cage_lines_grp, geom_lines, object); } diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 7497677623a..f52e82ef5c7 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -812,21 +812,20 @@ void DRW_curves_batch_cache_create_requested(Object *ob) Curves *curves_cage_id = ob->runtime.editcurves_eval_cage; if (curves_cage_id) { const blender::bke::CurvesGeometry &curves_orig = curves_id_orig->geometry.wrap(); - CurvesBatchCache &cage_cache = curves_batch_cache_get(*curves_cage_id); - if (DRW_batch_requested(cage_cache.cage_lines, GPU_PRIM_LINE_STRIP)) { - DRW_ibo_request(cage_cache.cage_lines, &cage_cache.edit_lines_ibo); - DRW_vbo_request(cage_cache.cage_lines, &cage_cache.cage_point_pos); - DRW_vbo_request(cage_cache.cage_lines, &cage_cache.cage_point_color); + if (DRW_batch_requested(cache.cage_lines, GPU_PRIM_LINE_STRIP)) { + DRW_ibo_request(cache.cage_lines, &cache.edit_lines_ibo); + DRW_vbo_request(cache.cage_lines, &cache.cage_point_pos); + DRW_vbo_request(cache.cage_lines, &cache.cage_point_color); } - if (DRW_ibo_requested(cage_cache.edit_lines_ibo)) { - curves_batch_cache_ensure_edit_lines(*curves_cage_id, cage_cache); + if (DRW_ibo_requested(cache.edit_lines_ibo)) { + curves_batch_cache_ensure_edit_lines(*curves_cage_id, cache); } - if (DRW_vbo_requested(cage_cache.cage_point_pos)) { - curves_batch_cache_ensure_edit_points_pos(*curves_cage_id, *cage_cache.cage_point_pos); + if (DRW_vbo_requested(cache.cage_point_pos)) { + curves_batch_cache_ensure_edit_points_pos(*curves_cage_id, *cache.cage_point_pos); } - if (DRW_vbo_requested(cage_cache.cage_point_color)) { - curves_batch_cache_ensure_cage_color(curves_orig, *cage_cache.cage_point_color); + if (DRW_vbo_requested(cache.cage_point_color)) { + curves_batch_cache_ensure_cage_color(curves_orig, *cache.cage_point_color); } } } -- 2.30.2 From 422723142a4f6dd408a897a0c755b0883f2dbade Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 17:12:48 +0100 Subject: [PATCH 29/33] cleanup --- .../engines/overlay/overlay_sculpt_curves.cc | 2 +- .../shaders/infos/overlay_edit_mode_info.hh | 4 +-- .../infos/overlay_sculpt_curves_info.hh | 2 +- .../overlay_edit_particle_point_vert.glsl | 2 +- .../overlay_edit_particle_strand_vert.glsl | 4 +-- .../overlay_varying_color_wire_vert.glsl | 2 +- source/blender/draw/intern/draw_cache_impl.h | 1 - .../draw/intern/draw_cache_impl_curves.cc | 21 ++++------- .../draw/intern/draw_cache_impl_particles.c | 36 +++++++++---------- 9 files changed, 33 insertions(+), 41 deletions(-) diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 2d004bbfb46..d02421395b4 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -95,7 +95,7 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) return; } - GPUBatch *geom_lines = DRW_curves_batch_cache_get_cage_lines(curves); + GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves); DRW_shgroup_call_no_cull(pd->sculpt_curves_cage_lines_grp, geom_lines, object); } diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh index b1c28bcb3e3..d993c7703c0 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh @@ -496,7 +496,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_lattice_wire_clipped) GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand) .do_static_compilation(true) .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "color") + .vertex_in(1, Type::FLOAT, "selection") .sampler(0, ImageType::FLOAT_1D, "weightTex") .push_constant(Type::BOOL, "useWeight") .vertex_out(overlay_edit_smooth_color_iface) @@ -512,7 +512,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_particle_strand_clipped) GPU_SHADER_CREATE_INFO(overlay_edit_particle_point) .do_static_compilation(true) .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::FLOAT, "color") + .vertex_in(1, Type::FLOAT, "selection") .vertex_out(overlay_edit_flat_color_iface) .fragment_out(0, Type::VEC4, "fragColor") .vertex_source("overlay_edit_particle_point_vert.glsl") diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh index 3551ee668a6..e5213330e4a 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh @@ -28,7 +28,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_varying_color_wire_iface, "") GPU_SHADER_CREATE_INFO(overlay_varying_color_wire) .do_static_compilation(true) .vertex_in(0, Type::VEC3, "pos") - .vertex_in(1, Type::VEC4, "color") + .vertex_in(1, Type::FLOAT, "selection") .vertex_out(overlay_varying_color_wire_iface) .fragment_out(0, Type::VEC4, "fragColor") .fragment_out(1, Type::VEC4, "lineOutput") diff --git a/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_point_vert.glsl index 956b27e948d..39c8683a585 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_point_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_point_vert.glsl @@ -7,7 +7,7 @@ void main() vec3 world_pos = point_object_to_world(pos); gl_Position = point_world_to_ndc(world_pos); - finalColor = mix(colorWire, colorVertexSelect, color); + finalColor = mix(colorWire, colorVertexSelect, selection); gl_PointSize = sizeVertex * 2.0; diff --git a/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_strand_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_strand_vert.glsl index 6a92206d524..5240244b1b3 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_strand_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_edit_particle_strand_vert.glsl @@ -25,10 +25,10 @@ void main() gl_Position = point_world_to_ndc(world_pos); if (useWeight) { - finalColor = vec4(weight_to_rgb(color), 1.0); + finalColor = vec4(weight_to_rgb(selection), 1.0); } else { - finalColor = mix(colorWire, colorVertexSelect, color); + finalColor = mix(colorWire, colorVertexSelect, selection); } view_clipping_distances(world_pos); diff --git a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl index 2cf534243ac..162934f64de 100644 --- a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl @@ -7,7 +7,7 @@ void main() vec3 world_pos = point_object_to_world(pos); gl_Position = point_world_to_ndc(world_pos); - finalColor = color; + finalColor = vec4(selection); finalColor.a *= opacity; /* Convert to screen position [0..sizeVp]. */ diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index f51c40820a4..8cc53b48af8 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -135,7 +135,6 @@ struct GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(struct Curves *cu struct GPUBatch *DRW_curves_batch_cache_get_edit_points(struct Curves *curves); struct GPUBatch *DRW_curves_batch_cache_get_edit_lines(struct Curves *curves); -struct GPUBatch *DRW_curves_batch_cache_get_cage_lines(struct Curves *curves); void DRW_curves_batch_cache_create_requested(struct Object *ob); diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 72122d523e4..53b5dae1512 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -53,17 +53,13 @@ struct CurvesBatchCache { GPUBatch *edit_points; GPUBatch *edit_lines; - GPUBatch *cage_lines; - /* Editmode (original) point positions. */ + /* Crazy-space point positions for original points. */ GPUVertBuf *edit_points_pos; - /* Editmode data (such as selection). */ + /* Selection of original points. */ GPUVertBuf *edit_points_data; - GPUVertBuf *cage_point_pos; - GPUVertBuf *cage_point_color; - GPUIndexBuf *edit_lines_ibo; /* Whether the cache is invalid. */ @@ -120,12 +116,8 @@ static void curves_batch_cache_clear_edit_data(CurvesBatchCache *cache) GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_data); GPU_INDEXBUF_DISCARD_SAFE(cache->edit_lines_ibo); - GPU_VERTBUF_DISCARD_SAFE(cache->cage_point_pos); - GPU_VERTBUF_DISCARD_SAFE(cache->cage_point_color); - GPU_BATCH_DISCARD_SAFE(cache->edit_points); GPU_BATCH_DISCARD_SAFE(cache->edit_lines); - GPU_BATCH_DISCARD_SAFE(cache->cage_lines); } static void curves_batch_cache_clear_eval_data(CurvesEvalCache &curves_cache) @@ -268,9 +260,10 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry CurvesBatchCache &cache) { static GPUVertFormat format_data = {0}; - static uint color; + static uint selection_id; if (format_data.attr_len == 0) { - color = GPU_vertformat_attr_add(&format_data, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + selection_id = GPU_vertformat_attr_add( + &format_data, "selection", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } GPU_vertbuf_init_with_format(cache.edit_points_data, &format_data); @@ -284,7 +277,7 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry case ATTR_DOMAIN_POINT: for (const int point_i : selection.index_range()) { const float point_selection = selection[point_i] ? 1.0f : 0.0f; - GPU_vertbuf_attr_set(cache.edit_points_data, color, point_i, &point_selection); + GPU_vertbuf_attr_set(cache.edit_points_data, selection_id, point_i, &point_selection); } break; case ATTR_DOMAIN_CURVE: @@ -292,7 +285,7 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry const float curve_selection = selection[curve_i] ? 1.0f : 0.0f; const IndexRange points = points_by_curve[curve_i]; for (const int point_i : points) { - GPU_vertbuf_attr_set(cache.edit_points_data, color, point_i, &curve_selection); + GPU_vertbuf_attr_set(cache.edit_points_data, selection_id, point_i, &curve_selection); } } break; diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index cba06eec76c..78459eec81f 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -89,21 +89,21 @@ typedef struct HairAttributeID { typedef struct EditStrandData { float pos[3]; - float color; + float selection; } EditStrandData; -static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_color_id) +static GPUVertFormat *edit_points_vert_format_get(uint *r_pos_id, uint *r_selection_id) { static GPUVertFormat edit_point_format = {0}; - static uint pos_id, color_id; + static uint pos_id, selection_id; if (edit_point_format.attr_len == 0) { /* Keep in sync with EditStrandData */ pos_id = GPU_vertformat_attr_add(&edit_point_format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - color_id = GPU_vertformat_attr_add( - &edit_point_format, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + selection_id = GPU_vertformat_attr_add( + &edit_point_format, "selection", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } *r_pos_id = pos_id; - *r_color_id = color_id; + *r_selection_id = selection_id; return &edit_point_format; } @@ -697,11 +697,11 @@ static int particle_batch_cache_fill_segments_edit( if (particle) { float weight = particle_key_weight(particle, i, strand_t); /* NaN or unclamped become 1.0f */ - seg_data->color = (weight < 1.0f) ? weight : 1.0f; + seg_data->selection = (weight < 1.0f) ? weight : 1.0f; } else { /* Computed in psys_cache_edit_paths_iter(). */ - seg_data->color = path[j].col[0]; + seg_data->selection = path[j].col[0]; } GPU_indexbuf_add_generic_vert(elb, curr_point); curr_point++; @@ -1530,8 +1530,8 @@ static void particle_batch_cache_ensure_edit_pos_and_seg(PTCacheEdit *edit, GPUVertBufRaw data_step; GPUIndexBufBuilder elb; - uint pos_id, color_id; - GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id); + uint pos_id, selection_id; + GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &selection_id); hair_cache->pos = GPU_vertbuf_create_with_format(edit_point_format); GPU_vertbuf_data_alloc(hair_cache->pos, hair_cache->point_len); @@ -1594,8 +1594,8 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit, return; } - uint pos_id, color_id; - GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id); + uint pos_id, selection_id; + GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &selection_id); cache->edit_inner_pos = GPU_vertbuf_create_with_format(edit_point_format); GPU_vertbuf_data_alloc(cache->edit_inner_pos, cache->edit_inner_point_len); @@ -1608,9 +1608,9 @@ static void particle_batch_cache_ensure_edit_inner_pos(PTCacheEdit *edit, } for (int key_index = 0; key_index < point->totkey - 1; key_index++) { PTCacheEditKey *key = &point->keys[key_index]; - float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f; + float selection = (key->flag & PEK_SELECT) ? 1.0f : 0.0f; GPU_vertbuf_attr_set(cache->edit_inner_pos, pos_id, global_key_index, key->world_co); - GPU_vertbuf_attr_set(cache->edit_inner_pos, color_id, global_key_index, &color); + GPU_vertbuf_attr_set(cache->edit_inner_pos, selection_id, global_key_index, &selection); global_key_index++; } } @@ -1652,8 +1652,8 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle return; } - uint pos_id, color_id; - GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &color_id); + uint pos_id, selection_id; + GPUVertFormat *edit_point_format = edit_points_vert_format_get(&pos_id, &selection_id); cache->edit_tip_pos = GPU_vertbuf_create_with_format(edit_point_format); GPU_vertbuf_data_alloc(cache->edit_tip_pos, cache->edit_tip_point_len); @@ -1665,10 +1665,10 @@ static void particle_batch_cache_ensure_edit_tip_pos(PTCacheEdit *edit, Particle continue; } PTCacheEditKey *key = &point->keys[point->totkey - 1]; - float color = (key->flag & PEK_SELECT) ? 1.0f : 0.0f; + float selection = (key->flag & PEK_SELECT) ? 1.0f : 0.0f; GPU_vertbuf_attr_set(cache->edit_tip_pos, pos_id, global_point_index, key->world_co); - GPU_vertbuf_attr_set(cache->edit_tip_pos, color_id, global_point_index, &color); + GPU_vertbuf_attr_set(cache->edit_tip_pos, selection_id, global_point_index, &selection); global_point_index++; } } -- 2.30.2 From 24f63cc40ad72e09444804f6c8cfa2b5f5aed72d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 17:19:13 +0100 Subject: [PATCH 30/33] cleanup --- source/blender/blenkernel/intern/curves.cc | 50 +++---------------- source/blender/blenkernel/intern/object.cc | 5 -- .../engines/overlay/overlay_sculpt_curves.cc | 4 -- source/blender/makesdna/DNA_object_types.h | 4 +- 4 files changed, 8 insertions(+), 55 deletions(-) diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index ee818e2e7de..2ee37129b11 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -322,23 +322,6 @@ static void curves_evaluate_modifiers(struct Depsgraph *depsgraph, } } -/** Get the positions that are edited in sculpt mode. */ -static Span get_cage_positions(const blender::bke::CurvesGeometry &curves_orig, - const Curves *curves_id_eval, - const blender::bke::CurvesEditHints *curve_edit_hints) -{ - if (curve_edit_hints) { - if (curve_edit_hints->positions.has_value()) { - return *curve_edit_hints->positions; - } - else if (curves_id_eval && curves_id_eval->geometry.point_num == curves_orig.point_num) { - const blender::bke::CurvesGeometry &curves_eval = curves_id_eval->geometry.wrap(); - return curves_eval.positions(); - } - } - return curves_orig.positions(); -} - void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Object *object) { /* Free any evaluated data and restore original data. */ @@ -348,43 +331,24 @@ void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, Ob Curves *curves = static_cast(object->data); GeometrySet geometry_set = GeometrySet::create_with_curves(curves, GeometryOwnershipType::ReadOnly); - const bool generate_cage = object->mode == OB_MODE_SCULPT_CURVES; - const Curves &curves_id_orig = *static_cast( - DEG_get_original_object(object)->data); - if (generate_cage) { + if (object->mode == OB_MODE_SCULPT_CURVES) { /* Try to propagate deformation data through modifier evaluation, so that sculpt mode can work * on evaluated curves. */ GeometryComponentEditData &edit_component = geometry_set.get_component_for_write(); edit_component.curves_edit_hints_ = std::make_unique( - curves_id_orig); + *static_cast(DEG_get_original_object(object)->data)); } curves_evaluate_modifiers(depsgraph, scene, object, geometry_set); - Curves *curves_id_eval = const_cast(geometry_set.get_curves_for_read()); - - /* Create cage curves geometry for drawing. */ - if (generate_cage) { - const blender::bke::CurvesGeometry &curves_orig = curves_id_orig.geometry.wrap(); - Curves *curves_id_cage = blender::bke::curves_new_nomain(curves_id_orig.geometry.point_num, - curves_id_orig.geometry.curve_num); - object->runtime.editcurves_eval_cage = curves_id_cage; - - blender::bke::CurvesGeometry &curves_cage = curves_id_cage->geometry.wrap(); - curves_cage.offsets_for_write().copy_from(curves_orig.offsets()); - curves_cage.fill_curve_types(CURVE_TYPE_POLY); - - Span positions = get_cage_positions( - curves_orig, curves_id_eval, geometry_set.get_curve_edit_hints_for_read()); - curves_cage.positions_for_write().copy_from(positions); - } /* Assign evaluated object. */ - if (curves_id_eval == nullptr) { - curves_id_eval = blender::bke::curves_new_nomain(0, 0); - BKE_object_eval_assign_data(object, &curves_id_eval->id, true); + Curves *curves_eval = const_cast(geometry_set.get_curves_for_read()); + if (curves_eval == nullptr) { + curves_eval = blender::bke::curves_new_nomain(0, 0); + BKE_object_eval_assign_data(object, &curves_eval->id, true); } else { - BKE_object_eval_assign_data(object, &curves_id_eval->id, false); + BKE_object_eval_assign_data(object, &curves_eval->id, false); } object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set)); } diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index faa037d3147..97114c6c624 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -1790,11 +1790,6 @@ void BKE_object_free_derived_caches(Object *ob) } ob->runtime.editmesh_eval_cage = nullptr; - if (ob->runtime.editcurves_eval_cage) { - BKE_id_free(nullptr, ob->runtime.editcurves_eval_cage); - } - ob->runtime.editcurves_eval_cage = nullptr; - if (ob->runtime.data_eval != nullptr) { if (ob->runtime.is_data_eval_owned) { ID *data_eval = ob->runtime.data_eval; diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index d02421395b4..14bfba7543e 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -91,10 +91,6 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object) OVERLAY_PrivateData *pd = vedata->stl->pd; Curves *curves = static_cast(object->data); - if (object->runtime.editcurves_eval_cage == nullptr) { - return; - } - GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_lines(curves); DRW_shgroup_call_no_cull(pd->sculpt_curves_cage_lines_grp, geom_lines, object); } diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 6ea33ec5e54..29d74ba2046 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -171,9 +171,6 @@ typedef struct Object_Runtime { /* Evaluated mesh cage in edit mode. */ struct Mesh *editmesh_eval_cage; - /** Evaluated curve cage in edit and sculpt mode. */ - struct Curves *editcurves_eval_cage; - /** Cached cage bounding box of `editmesh_eval_cage` for selection. */ struct BoundBox *editmesh_bb_cage; @@ -211,6 +208,7 @@ typedef struct Object_Runtime { /** Runtime evaluated curve-specific data, not stored in the file. */ struct CurveCache *curve_cache; + void *_pad4; unsigned short local_collections_bits; short _pad2[3]; -- 2.30.2 From ed7227eac5e330ed2c4102e0ec26d28bbfbaa336 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 17:25:47 +0100 Subject: [PATCH 31/33] improve shader name --- source/blender/draw/CMakeLists.txt | 2 +- .../draw/engines/overlay/overlay_private.hh | 2 +- .../draw/engines/overlay/overlay_sculpt_curves.cc | 2 +- .../blender/draw/engines/overlay/overlay_shader.cc | 14 +++++++------- .../shaders/infos/overlay_sculpt_curves_info.hh | 12 ++++++------ ...t.glsl => overlay_sculpt_curves_cage_vert.glsl} | 0 6 files changed, 16 insertions(+), 16 deletions(-) rename source/blender/draw/engines/overlay/shaders/{overlay_varying_color_wire_vert.glsl => overlay_sculpt_curves_cage_vert.glsl} (100%) diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index c2d865ed9fe..3560a982b90 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -702,7 +702,7 @@ set(GLSL_SRC engines/overlay/shaders/overlay_point_varying_color_frag.glsl engines/overlay/shaders/overlay_point_varying_color_varying_outline_aa_frag.glsl engines/overlay/shaders/overlay_pointcloud_only_vert.glsl - engines/overlay/shaders/overlay_varying_color_wire_vert.glsl + engines/overlay/shaders/overlay_sculpt_curves_cage_vert.glsl engines/overlay/shaders/overlay_sculpt_curves_selection_frag.glsl engines/overlay/shaders/overlay_sculpt_curves_selection_vert.glsl engines/overlay/shaders/overlay_sculpt_mask_frag.glsl diff --git a/source/blender/draw/engines/overlay/overlay_private.hh b/source/blender/draw/engines/overlay/overlay_private.hh index f6e53ac7c72..b9aa77106f5 100644 --- a/source/blender/draw/engines/overlay/overlay_private.hh +++ b/source/blender/draw/engines/overlay/overlay_private.hh @@ -779,7 +779,7 @@ GPUShader *OVERLAY_shader_particle_dot(void); GPUShader *OVERLAY_shader_particle_shape(void); GPUShader *OVERLAY_shader_sculpt_mask(void); GPUShader *OVERLAY_shader_sculpt_curves_selection(void); -GPUShader *OVERLAY_shader_varying_color_wire(void); +GPUShader *OVERLAY_shader_sculpt_curves_cage(void); GPUShader *OVERLAY_shader_viewer_attribute_curve(void); GPUShader *OVERLAY_shader_viewer_attribute_curves(void); GPUShader *OVERLAY_shader_viewer_attribute_mesh(void); diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index 14bfba7543e..c73386f7897 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -41,7 +41,7 @@ void OVERLAY_sculpt_curves_cache_init(OVERLAY_Data *vedata) DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->sculpt_curves_cage_ps, state | pd->clipping_state); - GPUShader *sh = OVERLAY_shader_varying_color_wire(); + GPUShader *sh = OVERLAY_shader_sculpt_curves_cage(); pd->sculpt_curves_cage_lines_grp = DRW_shgroup_create(sh, psl->sculpt_curves_cage_ps); DRW_shgroup_uniform_float_copy( pd->sculpt_curves_cage_lines_grp, "opacity", overlay.sculpt_curves_cage_opacity); diff --git a/source/blender/draw/engines/overlay/overlay_shader.cc b/source/blender/draw/engines/overlay/overlay_shader.cc index 45e397cc101..2229316d295 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.cc +++ b/source/blender/draw/engines/overlay/overlay_shader.cc @@ -91,10 +91,10 @@ struct OVERLAY_Shaders { GPUShader *particle_shape; GPUShader *pointcloud_dot; GPUShader *sculpt_mask; + GPUShader *sculpt_curves_cage; GPUShader *sculpt_curves_selection; GPUShader *uniform_color; GPUShader *uniform_color_pointcloud; - GPUShader *varying_color_wire; GPUShader *viewer_attribute_mesh; GPUShader *viewer_attribute_pointcloud; GPUShader *viewer_attribute_curve; @@ -857,16 +857,16 @@ GPUShader *OVERLAY_shader_sculpt_curves_selection(void) return sh_data->sculpt_curves_selection; } -GPUShader *OVERLAY_shader_varying_color_wire(void) +GPUShader *OVERLAY_shader_sculpt_curves_cage(void) { const DRWContextState *draw_ctx = DRW_context_state_get(); OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; - if (!sh_data->varying_color_wire) { - sh_data->varying_color_wire = GPU_shader_create_from_info_name( - (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_varying_color_wire_clipped" : - "overlay_varying_color_wire"); + if (!sh_data->sculpt_curves_cage) { + sh_data->sculpt_curves_cage = GPU_shader_create_from_info_name( + (draw_ctx->sh_cfg == GPU_SHADER_CFG_CLIPPED) ? "overlay_sculpt_curves_cage_clipped" : + "overlay_sculpt_curves_cage"); } - return sh_data->varying_color_wire; + return sh_data->sculpt_curves_cage; } GPUShader *OVERLAY_shader_viewer_attribute_mesh(void) diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh index e5213330e4a..b0b261ed9f1 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_sculpt_curves_info.hh @@ -20,23 +20,23 @@ GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_selection_clipped) .do_static_compilation(true) .additional_info("overlay_sculpt_curves_selection", "drw_clipped"); -GPU_SHADER_INTERFACE_INFO(overlay_varying_color_wire_iface, "") +GPU_SHADER_INTERFACE_INFO(overlay_sculpt_curves_cage_iface, "") .no_perspective(Type::VEC2, "edgePos") .flat(Type::VEC2, "edgeStart") .smooth(Type::VEC4, "finalColor"); -GPU_SHADER_CREATE_INFO(overlay_varying_color_wire) +GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_cage) .do_static_compilation(true) .vertex_in(0, Type::VEC3, "pos") .vertex_in(1, Type::FLOAT, "selection") - .vertex_out(overlay_varying_color_wire_iface) + .vertex_out(overlay_sculpt_curves_cage_iface) .fragment_out(0, Type::VEC4, "fragColor") .fragment_out(1, Type::VEC4, "lineOutput") .push_constant(Type::FLOAT, "opacity") - .vertex_source("overlay_varying_color_wire_vert.glsl") + .vertex_source("overlay_sculpt_curves_cage_vert.glsl") .fragment_source("overlay_extra_frag.glsl") .additional_info("draw_modelmat", "draw_view", "draw_globals"); -GPU_SHADER_CREATE_INFO(overlay_varying_color_wire_clipped) +GPU_SHADER_CREATE_INFO(overlay_sculpt_curves_cage_clipped) .do_static_compilation(true) - .additional_info("overlay_varying_color_wire", "drw_clipped"); + .additional_info("overlay_sculpt_curves_cage", "drw_clipped"); diff --git a/source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl b/source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_cage_vert.glsl similarity index 100% rename from source/blender/draw/engines/overlay/shaders/overlay_varying_color_wire_vert.glsl rename to source/blender/draw/engines/overlay/shaders/overlay_sculpt_curves_cage_vert.glsl -- 2.30.2 From 689619d0050dfb8383357e6d6ca1ece5d805c985 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 17:27:49 +0100 Subject: [PATCH 32/33] cleanup naming --- .../draw/intern/draw_cache_impl_curves.cc | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/source/blender/draw/intern/draw_cache_impl_curves.cc b/source/blender/draw/intern/draw_cache_impl_curves.cc index 53b5dae1512..7d7831391b3 100644 --- a/source/blender/draw/intern/draw_cache_impl_curves.cc +++ b/source/blender/draw/intern/draw_cache_impl_curves.cc @@ -58,7 +58,7 @@ struct CurvesBatchCache { GPUVertBuf *edit_points_pos; /* Selection of original points. */ - GPUVertBuf *edit_points_data; + GPUVertBuf *edit_points_selection; GPUIndexBuf *edit_lines_ibo; @@ -113,7 +113,7 @@ static void curves_batch_cache_clear_edit_data(CurvesBatchCache *cache) { /* TODO: more granular update tagging. */ GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_pos); - GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_data); + GPU_VERTBUF_DISCARD_SAFE(cache->edit_points_selection); GPU_INDEXBUF_DISCARD_SAFE(cache->edit_lines_ibo); GPU_BATCH_DISCARD_SAFE(cache->edit_points); @@ -255,9 +255,9 @@ static void curves_batch_cache_ensure_edit_points_pos(const bke::CurvesGeometry GPU_vertbuf_attr_fill(cache.edit_points_pos, pos, deformed_positions.data()); } -static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry &curves, - const eAttrDomain selection_domain, - CurvesBatchCache &cache) +static void curves_batch_cache_ensure_edit_points_selection(const bke::CurvesGeometry &curves, + const eAttrDomain selection_domain, + CurvesBatchCache &cache) { static GPUVertFormat format_data = {0}; static uint selection_id; @@ -266,8 +266,8 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry &format_data, "selection", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); } - GPU_vertbuf_init_with_format(cache.edit_points_data, &format_data); - GPU_vertbuf_data_alloc(cache.edit_points_data, curves.points_num()); + GPU_vertbuf_init_with_format(cache.edit_points_selection, &format_data); + GPU_vertbuf_data_alloc(cache.edit_points_selection, curves.points_num()); const OffsetIndices points_by_curve = curves.points_by_curve(); @@ -277,7 +277,7 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry case ATTR_DOMAIN_POINT: for (const int point_i : selection.index_range()) { const float point_selection = selection[point_i] ? 1.0f : 0.0f; - GPU_vertbuf_attr_set(cache.edit_points_data, selection_id, point_i, &point_selection); + GPU_vertbuf_attr_set(cache.edit_points_selection, selection_id, point_i, &point_selection); } break; case ATTR_DOMAIN_CURVE: @@ -285,7 +285,8 @@ static void curves_batch_cache_ensure_edit_points_data(const bke::CurvesGeometry const float curve_selection = selection[curve_i] ? 1.0f : 0.0f; const IndexRange points = points_by_curve[curve_i]; for (const int point_i : points) { - GPU_vertbuf_attr_set(cache.edit_points_data, selection_id, point_i, &curve_selection); + GPU_vertbuf_attr_set( + cache.edit_points_selection, selection_id, point_i, &curve_selection); } } break; @@ -761,18 +762,18 @@ void DRW_curves_batch_cache_create_requested(Object *ob) if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) { DRW_vbo_request(cache.edit_points, &cache.edit_points_pos); - DRW_vbo_request(cache.edit_points, &cache.edit_points_data); + DRW_vbo_request(cache.edit_points, &cache.edit_points_selection); } if (DRW_batch_requested(cache.edit_lines, GPU_PRIM_LINE_STRIP)) { DRW_ibo_request(cache.edit_lines, &cache.edit_lines_ibo); DRW_vbo_request(cache.edit_lines, &cache.edit_points_pos); - DRW_vbo_request(cache.edit_lines, &cache.edit_points_data); + DRW_vbo_request(cache.edit_lines, &cache.edit_points_selection); } if (DRW_vbo_requested(cache.edit_points_pos)) { curves_batch_cache_ensure_edit_points_pos(curves_orig, deformation.positions, cache); } - if (DRW_vbo_requested(cache.edit_points_data)) { - curves_batch_cache_ensure_edit_points_data( + if (DRW_vbo_requested(cache.edit_points_selection)) { + curves_batch_cache_ensure_edit_points_selection( curves_orig, eAttrDomain(curves_id->selection_domain), cache); } if (DRW_ibo_requested(cache.edit_lines_ibo)) { -- 2.30.2 From 3b2a253bcb08eefb816d6286030fcb248f0c31f0 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 14 Feb 2023 18:00:09 +0100 Subject: [PATCH 33/33] cleanup --- source/blender/editors/sculpt_paint/curves_sculpt_ops.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc index 28c0ecad9f4..54bef8d2257 100644 --- a/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/curves_sculpt_ops.cc @@ -289,9 +289,8 @@ static void curves_sculptmode_enter(bContext *C) ED_paint_cursor_start(&curves_sculpt->paint, CURVES_SCULPT_mode_poll_view3d); paint_init_pivot(ob, scene); - /* Necessary to change the object mode on the evaluated object and to evaluate the cage that is - * edited. */ - DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE | ID_RECALC_GEOMETRY); + /* Necessary to change the object mode on the evaluated object. */ + DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); WM_msg_publish_rna_prop(mbus, &ob->id, ob, Object, mode); WM_event_add_notifier(C, NC_SCENE | ND_MODE, nullptr); } -- 2.30.2