Fix #119686: curves editmode handles are displayed in sculptmode

Curves cage overlay for sculpt mode restored to prior #119053 state.

Pull Request: https://projects.blender.org/blender/blender/pulls/119717
This commit is contained in:
laurynas
2024-03-21 12:24:29 +01:00
committed by Jacques Lucke
parent 6db5cf09e0
commit e2bdaf8ec7
3 changed files with 45 additions and 1 deletions

View File

@@ -94,7 +94,7 @@ static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object)
OVERLAY_PrivateData *pd = vedata->stl->pd;
Curves *curves = static_cast<Curves *>(object->data);
GPUBatch *geom_lines = DRW_curves_batch_cache_get_edit_curves_handles(curves);
GPUBatch *geom_lines = DRW_curves_batch_cache_get_sculpt_curves_cage(curves);
DRW_shgroup_call_no_cull(pd->sculpt_curves_cage_lines_grp, geom_lines, object);
}

View File

@@ -138,6 +138,7 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
GPUUniformBuf *DRW_curves_batch_cache_ubo_storage(Curves *curves);
GPUBatch *DRW_curves_batch_cache_get_edit_points(Curves *curves);
GPUBatch *DRW_curves_batch_cache_get_sculpt_curves_cage(Curves *curves);
GPUBatch *DRW_curves_batch_cache_get_edit_curves_handles(Curves *curves);
GPUBatch *DRW_curves_batch_cache_get_edit_curves_lines(Curves *curves);

View File

@@ -67,6 +67,9 @@ struct CurvesBatchCache {
GPUBatch *edit_points;
GPUBatch *edit_handles;
GPUBatch *sculpt_cage;
GPUIndexBuf *sculpt_cage_ibo;
/* Crazy-space point positions for original points. */
GPUVertBuf *edit_points_pos;
@@ -169,6 +172,9 @@ static void curves_batch_cache_clear_edit_data(CurvesBatchCache *cache)
GPU_BATCH_DISCARD_SAFE(cache->edit_points);
GPU_BATCH_DISCARD_SAFE(cache->edit_handles);
GPU_INDEXBUF_DISCARD_SAFE(cache->sculpt_cage_ibo);
GPU_BATCH_DISCARD_SAFE(cache->sculpt_cage);
GPU_VERTBUF_DISCARD_SAFE(cache->edit_curves_lines_pos);
GPU_INDEXBUF_DISCARD_SAFE(cache->edit_curves_lines_ibo);
GPU_BATCH_DISCARD_SAFE(cache->edit_curves_lines);
@@ -434,6 +440,28 @@ static void curves_batch_cache_ensure_edit_points_selection(
points_by_curve, bezier_dst_offsets, bezier_curves, attribute_right, data.slice(dst_range));
}
static void curves_batch_cache_ensure_sculpt_cage(const bke::CurvesGeometry &curves,
CurvesBatchCache &cache)
{
const int vert_len = curves.points_num();
const int curve_len = curves.curves_num();
const int index_len = vert_len + curve_len;
GPUIndexBufBuilder elb;
GPU_indexbuf_init_ex(&elb, GPU_PRIM_LINE_STRIP, index_len, vert_len);
const OffsetIndices points_by_curve = curves.points_by_curve();
for (const int i : curves.curves_range()) {
const IndexRange points = points_by_curve[i];
for (const int i_point : points) {
GPU_indexbuf_add_generic_vert(&elb, i_point);
}
GPU_indexbuf_add_primitive_restart(&elb);
}
GPU_indexbuf_build_in_place(&elb, cache.sculpt_cage_ibo);
}
static void curves_batch_cache_ensure_edit_handles(const bke::CurvesGeometry &curves,
const IndexMask bezier_curves,
const OffsetIndices<int> bezier_offsets,
@@ -879,6 +907,12 @@ GPUBatch *DRW_curves_batch_cache_get_edit_points(Curves *curves)
return DRW_batch_request(&cache.edit_points);
}
GPUBatch *DRW_curves_batch_cache_get_sculpt_curves_cage(Curves *curves)
{
CurvesBatchCache &cache = curves_batch_cache_get(*curves);
return DRW_batch_request(&cache.sculpt_cage);
}
GPUBatch *DRW_curves_batch_cache_get_edit_curves_handles(Curves *curves)
{
CurvesBatchCache &cache = curves_batch_cache_get(*curves);
@@ -1003,6 +1037,12 @@ void DRW_curves_batch_cache_create_requested(Object *ob)
DRW_vbo_request(cache.edit_points, &cache.edit_points_pos);
DRW_vbo_request(cache.edit_points, &cache.edit_points_selection);
}
if (DRW_batch_requested(cache.sculpt_cage, GPU_PRIM_LINE_STRIP)) {
DRW_ibo_request(cache.sculpt_cage, &cache.sculpt_cage_ibo);
DRW_vbo_request(cache.sculpt_cage, &cache.edit_points_pos);
DRW_vbo_request(cache.sculpt_cage, &cache.edit_points_data);
DRW_vbo_request(cache.sculpt_cage, &cache.edit_points_selection);
}
if (DRW_batch_requested(cache.edit_handles, GPU_PRIM_LINE_STRIP)) {
DRW_ibo_request(cache.edit_handles, &cache.edit_handles_ibo);
DRW_vbo_request(cache.edit_handles, &cache.edit_points_pos);
@@ -1035,6 +1075,9 @@ void DRW_curves_batch_cache_create_requested(Object *ob)
curves_batch_cache_ensure_edit_handles(
curves_orig, bezier_curves, bezier_offsets, nurbs_curves, nurbs_offsets, cache);
}
if (DRW_ibo_requested(cache.sculpt_cage_ibo)) {
curves_batch_cache_ensure_sculpt_cage(curves_orig, cache);
}
if (DRW_vbo_requested(cache.edit_curves_lines_pos)) {
curves_batch_cache_ensure_edit_curves_lines_pos(curves_orig, deformation, cache);