Blender V5.0
draw_attributes.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BKE_customdata.hh"
6
7#include "GPU_shader.hh"
8
9#include "draw_attributes.hh"
10
11namespace blender::draw {
12
17
19{
20 for (const std::string &req : b->as_span()) {
21 if (!a->contains(req)) {
22 return false;
23 }
24 }
25
26 return true;
27}
28
30{
31 if (attrs->size() >= GPU_MAX_ATTR) {
32 return;
33 }
34 attrs->add_as(name);
35}
36
38 const StringRef name,
39 int *r_layer_index,
40 eCustomDataType *r_type)
41{
42 const eCustomDataType possible_attribute_types[11] = {
54 };
55
56 for (int i = 0; i < ARRAY_SIZE(possible_attribute_types); i++) {
57 const eCustomDataType attr_type = possible_attribute_types[i];
58 int layer_index = CustomData_get_named_layer(&custom_data, attr_type, name);
59 if (layer_index == -1) {
60 continue;
61 }
62
63 *r_layer_index = layer_index;
64 *r_type = attr_type;
65 return true;
66 }
67
68 return false;
69}
70
71} // namespace blender::draw
CustomData interface, see also DNA_customdata_types.h.
int CustomData_get_named_layer(const CustomData *data, eCustomDataType type, blender::StringRef name)
#define ARRAY_SIZE(arr)
@ CD_PROP_BYTE_COLOR
@ CD_PROP_FLOAT
@ CD_PROP_FLOAT3
@ CD_PROP_INT32_2D
@ CD_PROP_COLOR
@ CD_PROP_QUATERNION
@ CD_PROP_INT32
@ CD_PROP_FLOAT2
@ CD_PROP_INT16_2D
static constexpr int GPU_MAX_ATTR
Definition GPU_shader.hh:33
bool add_as(ForwardKey &&key)
void add_multiple(Span< Key > keys)
int64_t size() const
bool contains(const Key &key) const
Span< Key > as_span() const
Utilities for rendering attributes.
void drw_attributes_add_request(VectorSet< std::string > *attrs, const StringRef name)
bool drw_attributes_overlap(const VectorSet< std::string > *a, const VectorSet< std::string > *b)
void drw_attributes_merge(VectorSet< std::string > *dst, const VectorSet< std::string > *src)
bool drw_custom_data_match_attribute(const CustomData &custom_data, const StringRef name, int *r_layer_index, eCustomDataType *r_type)
const char * name
i
Definition text_draw.cc:230