35 const StringRef active_name =
mesh.active_or_default_uv_map_name();
41 uv_layers.
add(default_name);
48 name =
mesh.active_uv_map_name();
54 char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
58 if (name == default_name) {
61 if (name == active_name) {
66 if (name == stencil_name) {
71 if (format->attr_len == 0) {
95 if (mr.extract_type == MeshExtractType::BMesh) {
96 const BMesh &bm = *mr.bm;
97 for (const int i : uv_layers.index_range()) {
98 MutableSpan<float2> data = uv_data.slice(i * bm.totloop, bm.totloop);
99 const int offset = CustomData_get_offset_named(&bm.ldata, CD_PROP_FLOAT2, uv_layers[i]);
100 threading::parallel_for(IndexRange(bm.totface), 2048, [&](const IndexRange range) {
101 for (const int face_index : range) {
102 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
103 const BMLoop *loop = BM_FACE_FIRST_LOOP(&face);
104 for ([[maybe_unused]] const int i : IndexRange(face.len)) {
105 const int index = BM_elem_index_get(loop);
106 data[index] = BM_ELEM_CD_GET_FLOAT_P(loop, offset);
114 const bke::AttributeAccessor attributes = mr.mesh->attributes();
115 for (const int i : uv_layers.index_range()) {
116 const VArray uv_map = *attributes.lookup_or_default<float2>(
117 uv_layers[i], bke::AttrDomain::Corner, float2(0));
118 array_utils::copy(uv_map, uv_data.slice(i * mr.corners_num, mr.corners_num));
140 const Mesh *coarse_mesh = subdiv_cache.
mesh;
161 for (
const int pack_layer_index : uv_layers.
index_range()) {
162 const StringRef name = uv_layers[pack_layer_index];
#define SNPRINTF_UTF8(dst, format,...)
constexpr T * data() const
constexpr int64_t size_in_bytes() const
int64_t index_of_try(const Key &key) const
IndexRange index_range() const
Span< Key > as_span() const
void add_new(const Key &key)
void foreach_attribute(const FunctionRef< void(const AttributeIter &)> fn) const
constexpr bool is_empty() const
bool attribute_name_is_anonymous(const StringRef name)
void draw_subdiv_extract_uvs(const DRWSubdivCache &cache, gpu::VertBuf *uvs, const int face_varying_channel, const int dst_offset)
static VectorSet< StringRef > mesh_extract_uv_format_init(GPUVertFormat *format, const MeshBatchCache &cache, const Mesh &mesh, const MeshExtractType extract_type)
static VectorSet< StringRef > all_uv_map_attributes(const Mesh &mesh)
gpu::VertBufPtr extract_uv_maps(const MeshRenderData &mr, const MeshBatchCache &cache)
gpu::VertBufPtr extract_uv_maps_subdiv(const DRWSubdivCache &subdiv_cache, const MeshBatchCache &cache)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
void memory_bandwidth_bound_task(const int64_t approximate_bytes_touched, const Function &function)
void GPU_vertformat_alias_add(GPUVertFormat *, StringRef alias)
gpu::VertBuf * GPU_vertbuf_create_on_device(const GPUVertFormat &format, uint v_len)
void GPU_vertformat_deinterleave(GPUVertFormat *format)
VecBase< float, 2 > float2
void GPU_vertformat_safe_attr_name(StringRef attr_name, char *r_safe_name, uint max_len)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
VectorSet< std::string > uv
MeshExtractType extract_type