39 SNPRINTF(attr_name,
"a%s", attr_safe_name);
51 if (build_on_device) {
66 using VBOType =
typename Converter::VBOType;
69 if constexpr (std::is_same_v<T, VBOType>) {
74 for (const int i : range) {
75 data[i] = Converter::convert(attribute[indices[i]]);
87 using VBOType =
typename Converter::VBOType;
91 for (const int i : range) {
92 data.slice(faces[i]).fill(Converter::convert(attribute[i]));
101 using VBOType =
typename Converter::VBOType;
110 *
data = Converter::convert(*src);
121 using VBOType =
typename Converter::VBOType;
130 *
data = Converter::convert(src);
141 using VBOType =
typename Converter::VBOType;
148 std::fill_n(
data, face->
len, Converter::convert(src));
157 using VBOType =
typename Converter::VBOType;
166 *
data = Converter::convert(src);
177 operator bool()
const
186 if (layer.name == name) {
191 if (layer.name == name) {
196 if (layer.name == name) {
201 if (layer.name == name) {
213 using T = decltype(dummy);
214 if constexpr (!std::is_void_v<typename AttributeConverter<T>::VBOType>) {
215 switch (attr.domain) {
216 case bke::AttrDomain::Point:
217 extract_data_bmesh_vert<T>(*mr.bm, attr.offset, vbo);
219 case bke::AttrDomain::Edge:
220 extract_data_bmesh_edge<T>(*mr.bm, attr.offset, vbo);
222 case bke::AttrDomain::Face:
223 extract_data_bmesh_face<T>(*mr.bm, attr.offset, vbo);
225 case bke::AttrDomain::Corner:
226 extract_data_bmesh_loop<T>(*mr.bm, attr.offset, vbo);
229 BLI_assert_unreachable();
240 using T = decltype(dummy);
241 if constexpr (!std::is_void_v<typename AttributeConverter<T>::VBOType>) {
242 switch (attr.domain) {
243 case bke::AttrDomain::Point:
244 extract_data_mesh_mapped_corner(GVArraySpan(*attr).typed<T>(), mr.corner_verts, vbo);
246 case bke::AttrDomain::Edge:
247 extract_data_mesh_mapped_corner(GVArraySpan(*attr).typed<T>(), mr.corner_edges, vbo);
249 case bke::AttrDomain::Face:
250 extract_data_mesh_face(mr.faces, GVArraySpan(*attr).typed<T>(), vbo);
252 case bke::AttrDomain::Corner:
253 vertbuf_data_extract_direct(GVArraySpan(*attr).typed<T>(), vbo);
256 BLI_assert_unreachable();
301 const Mesh *coarse_mesh = subdiv_cache.
mesh;
332 using T =
decltype(dummy);
334 if constexpr (!std::is_void_v<typename Converter::VBOType>) {
338 Converter::gpu_component_type,
339 Converter::gpu_component_len,
360 attribute.
varray.materialize(vbo_data);
#define SNPRINTF(dst, format,...)
#define POINTER_OFFSET(v, ofs)
void GPU_vertbuf_init_build_on_device(blender::gpu::VertBuf &verts, const GPUVertFormat &format, uint v_len)
#define GPU_vertbuf_create_with_format(format)
void GPU_vertbuf_tag_dirty(blender::gpu::VertBuf *verts)
#define GPU_vertbuf_init_with_format(verts, format)
blender::gpu::VertBuf * GPU_vertbuf_calloc()
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_init_with_format_ex(blender::gpu::VertBuf &verts, const GPUVertFormat &format, GPUUsageType)
#define BM_FACE_FIRST_LOOP(p)
#define BM_ITER_MESH(ele, iter, bm, itype)
BMesh const char void * data
const CPPType & type() const
constexpr T * data() const
GAttributeReader lookup(const StringRef attribute_id) const
GAttributeReader lookup_or_default(StringRef attribute_id, AttrDomain domain, eCustomDataType data_type, const void *default_value=nullptr) const
Utilities for rendering attributes.
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
void convert_to_static_type(const CPPType &cpp_type, const Func &func)
eCustomDataType cpp_type_to_custom_data_type(const CPPType &type)
static void extract_data_bmesh_edge(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
gpu::VertBufPtr extract_attribute_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, StringRef name)
static void init_vbo_for_attribute(const MeshRenderData &mr, gpu::VertBuf &vbo, const StringRef name, const eCustomDataType type, bool build_on_device, uint32_t len)
static void extract_data_bmesh_vert(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
void draw_subdiv_interp_custom_data(const DRWSubdivCache &cache, gpu::VertBuf &src_data, gpu::VertBuf &dst_data, GPUVertCompType comp_type, int dimensions, int dst_offset)
gpu::VertBufPtr extract_attribute(const MeshRenderData &mr, StringRef name)
static gpu::VertBufPtr init_coarse_data(const eCustomDataType type, const int coarse_corners_num)
GPUVertFormat init_format_for_attribute(const eCustomDataType data_type, const StringRef vbo_name)
static void extract_data_bmesh_loop(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static void extract_data_mesh_face(const OffsetIndices< int > faces, const Span< T > attribute, gpu::VertBuf &vbo)
static void extract_data_bmesh_face(const BMesh &bm, const int cd_offset, gpu::VertBuf &vbo)
static void extract_attribute_data(const MeshRenderData &mr, const BMeshAttributeLookup &attr, gpu::VertBuf &vbo)
static BMeshAttributeLookup lookup_bmesh_attribute(const BMesh &bm, const StringRef name)
static void extract_data_mesh_mapped_corner(const Span< T > attribute, const Span< int > indices, gpu::VertBuf &vbo)
gpu::VertBufPtr extract_attr_viewer(const MeshRenderData &mr)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
ColorSceneLinear4f< eAlpha::Premultiplied > ColorGeometry4f
const char * default_color_name
MeshExtractType extract_type
const char * active_color_name