Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_curves.cc
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2017 Blender Foundation. All rights reserved. */ | * Copyright 2017 Blender Foundation. All rights reserved. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup draw | * \ingroup draw | ||||
| * | * | ||||
| * \brief Curves API for render engines | * \brief Curves API for render engines | ||||
| */ | */ | ||||
| #include <cstring> | #include <cstring> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "BLI_devirtualize_parameters.hh" | |||||
| #include "BLI_listbase.h" | #include "BLI_listbase.h" | ||||
| #include "BLI_math_base.h" | #include "BLI_math_base.h" | ||||
| #include "BLI_math_vec_types.hh" | #include "BLI_math_vec_types.hh" | ||||
| #include "BLI_math_vector.hh" | #include "BLI_math_vector.hh" | ||||
| #include "BLI_span.hh" | #include "BLI_span.hh" | ||||
| #include "BLI_task.hh" | #include "BLI_task.hh" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| ▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | static void curves_batch_cache_ensure_edit_points_data(const Curves &curves_id, | ||||
| static uint color; | static uint color; | ||||
| if (format_data.attr_len == 0) { | if (format_data.attr_len == 0) { | ||||
| color = GPU_vertformat_attr_add(&format_data, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); | color = GPU_vertformat_attr_add(&format_data, "color", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); | ||||
| } | } | ||||
| GPU_vertbuf_init_with_format(cache.edit_points_data, &format_data); | GPU_vertbuf_init_with_format(cache.edit_points_data, &format_data); | ||||
| GPU_vertbuf_data_alloc(cache.edit_points_data, curves.points_num()); | GPU_vertbuf_data_alloc(cache.edit_points_data, curves.points_num()); | ||||
| VArray<float> selection; | const VArray<bool> selection = curves.attributes().lookup_or_default<bool>( | ||||
| ".selection", eAttrDomain(curves_id.selection_domain), true); | |||||
| switch (curves_id.selection_domain) { | switch (curves_id.selection_domain) { | ||||
| case ATTR_DOMAIN_POINT: | case ATTR_DOMAIN_POINT: | ||||
| selection = curves.selection_point_float(); | |||||
| for (const int point_i : selection.index_range()) { | for (const int point_i : selection.index_range()) { | ||||
| const float point_selection = (selection[point_i] > 0.0f) ? 1.0f : 0.0f; | const float point_selection = (selection[point_i] > 0.0f) ? 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, color, point_i, &point_selection); | ||||
| } | } | ||||
| break; | break; | ||||
| case ATTR_DOMAIN_CURVE: | case ATTR_DOMAIN_CURVE: | ||||
| selection = curves.selection_curve_float(); | |||||
| for (const int curve_i : curves.curves_range()) { | for (const int curve_i : curves.curves_range()) { | ||||
| const float curve_selection = (selection[curve_i] > 0.0f) ? 1.0f : 0.0f; | const float curve_selection = (selection[curve_i] > 0.0f) ? 1.0f : 0.0f; | ||||
| const IndexRange points = curves.points_for_curve(curve_i); | const IndexRange points = curves.points_for_curve(curve_i); | ||||
| for (const int point_i : points) { | 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, color, point_i, &curve_selection); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 417 Lines • Show Last 20 Lines | |||||