Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_curves.cc
| Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | static void curves_discard_attributes(CurvesEvalCache &curves_cache) | ||||
| } | } | ||||
| } | } | ||||
| static void curves_batch_cache_clear_data(CurvesEvalCache &curves_cache) | static void curves_batch_cache_clear_data(CurvesEvalCache &curves_cache) | ||||
| { | { | ||||
| /* TODO: more granular update tagging. */ | /* TODO: more granular update tagging. */ | ||||
| GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_point_buf); | GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_point_buf); | ||||
| GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_length_buf); | GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_length_buf); | ||||
| GPU_VERTBUF_DISCARD_SAFE(curves_cache.data); | |||||
| DRW_TEXTURE_FREE_SAFE(curves_cache.point_tex); | DRW_TEXTURE_FREE_SAFE(curves_cache.point_tex); | ||||
| DRW_TEXTURE_FREE_SAFE(curves_cache.length_tex); | DRW_TEXTURE_FREE_SAFE(curves_cache.length_tex); | ||||
| GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_strand_buf); | GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_strand_buf); | ||||
| GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_strand_seg_buf); | GPU_VERTBUF_DISCARD_SAFE(curves_cache.proc_strand_seg_buf); | ||||
| DRW_TEXTURE_FREE_SAFE(curves_cache.strand_tex); | DRW_TEXTURE_FREE_SAFE(curves_cache.strand_tex); | ||||
| DRW_TEXTURE_FREE_SAFE(curves_cache.strand_seg_tex); | DRW_TEXTURE_FREE_SAFE(curves_cache.strand_seg_tex); | ||||
| ▲ Show 20 Lines • Show All 572 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void DRW_curves_batch_cache_create_requested(Object *ob) | void DRW_curves_batch_cache_create_requested(Object *ob) | ||||
| { | { | ||||
| Curves *curves = static_cast<Curves *>(ob->data); | Curves *curves = static_cast<Curves *>(ob->data); | ||||
| CurvesBatchCache &cache = curves_batch_cache_get(*curves); | CurvesBatchCache &cache = curves_batch_cache_get(*curves); | ||||
| if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) { | if (DRW_batch_requested(cache.edit_points, GPU_PRIM_POINTS)) { | ||||
| /* Editmode, requires "data" VBO for selection drawing. */ | |||||
| DRW_vbo_request(cache.edit_points, &cache.curves_cache.proc_point_buf); | DRW_vbo_request(cache.edit_points, &cache.curves_cache.proc_point_buf); | ||||
| DRW_vbo_request(cache.edit_points, &cache.curves_cache.data); | |||||
| } | } | ||||
| if (DRW_vbo_requested(cache.curves_cache.proc_point_buf)) { | if (DRW_vbo_requested(cache.curves_cache.proc_point_buf)) { | ||||
| curves_batch_cache_ensure_procedural_pos(*curves, cache.curves_cache, nullptr); | curves_batch_cache_ensure_procedural_pos(*curves, cache.curves_cache, nullptr); | ||||
| } | } | ||||
| if (DRW_vbo_requested(cache.curves_cache.data)) { | |||||
| blender::bke::CurvesGeometry &curves_geo = blender::bke::CurvesGeometry::wrap(curves->geometry); | |||||
| static GPUVertFormat format_data = {0}; | |||||
| uint data = GPU_vertformat_attr_add(&format_data, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); | |||||
| GPU_vertbuf_init_with_format(cache.curves_cache.data, &format_data); | |||||
| GPU_vertbuf_data_alloc(cache.curves_cache.data, curves_geo.points_num()); | |||||
| blender::VArray<float> selection; | |||||
| switch (curves->selection_domain) { | |||||
| case ATTR_DOMAIN_POINT: | |||||
| selection = curves_geo.selection_point_float(); | |||||
| for (const int point_i : selection.index_range()) { | |||||
| uint8_t vflag = 0; | |||||
| const float point_selection = selection[point_i]; | |||||
| SET_FLAG_FROM_TEST(vflag, (point_selection > 0.0f), VFLAG_VERT_SELECTED); | |||||
| GPU_vertbuf_attr_set(cache.curves_cache.data, data, point_i, &vflag); | |||||
| } | |||||
| break; | |||||
| case ATTR_DOMAIN_CURVE: | |||||
| selection = curves_geo.selection_curve_float(); | |||||
| for (const int curve_i : curves_geo.curves_range()) { | |||||
| uint8_t vflag = 0; | |||||
| const float curve_selection = selection[curve_i]; | |||||
| SET_FLAG_FROM_TEST(vflag, (curve_selection > 0.0f), VFLAG_VERT_SELECTED); | |||||
| const IndexRange points = curves_geo.points_for_curve(curve_i); | |||||
| for (const int point_i : points) { | |||||
| GPU_vertbuf_attr_set(cache.curves_cache.data, data, point_i, &vflag); | |||||
| } | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
HooglyBoogly: Better to split this into a separate function IMO, to mirror what's done with… | |||||
| } | } | ||||
Better to split this into a separate function IMO, to mirror what's done with curves_batch_cache_ensure_procedural_pos.