23 if (area >= FLT_EPSILON && uvarea >= FLT_EPSILON) {
32 return (ratio > 1.0f) ? (1.0f / ratio) : ratio;
49 for (const int face_index : range) {
50 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
51 const float area = BM_face_calc_area(&face);
52 const float uvarea = BM_face_calc_area_uv(&face, uv_offset);
53 info.tot_area += area;
54 info.tot_uv_area += uvarea;
55 r_area_ratio[face_index] = area_ratio_get(area, uvarea);
66 const Span<int> corner_verts = mr.corner_verts;
67 const Mesh &mesh = *mr.mesh;
77 for (const int face_index : range) {
78 const IndexRange face = faces[face_index];
79 const float area = bke::mesh::face_area_calc(positions, corner_verts.slice(face));
80 float uvarea = area_poly_v2(reinterpret_cast<const float (*)[2]>(&uv_map[face.start()]),
82 info.tot_area += area;
83 info.tot_uv_area += uvarea;
84 r_area_ratio[face_index] = area_ratio_get(area, uvarea);
88 [](
const AreaInfo &a,
const AreaInfo &
b) {
89 return AreaInfo{a.tot_area +
b.tot_area, a.tot_uv_area +
b.tot_uv_area};
103 gpu::VertAttrType::SFLOAT_32);
113 for (const int face_index : range) {
114 const BMFace &face = *BM_face_at_index(&const_cast<BMesh &>(bm), face_index);
115 const IndexRange face_range(BM_elem_index_get(BM_FACE_FIRST_LOOP(&face)), face.len);
116 vbo_data.slice(face_range).fill(area_ratio[face_index]);
124 for (const int face : range) {
125 vbo_data.slice(faces[face]).fill(area_ratio[face]);
139 gpu::VertAttrType::SFLOAT_32);
148 tot_area = info.tot_area;
149 tot_uv_area = info.tot_uv_area;
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
const char * CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
blender::gpu::VertBuf * GPU_vertbuf_create_on_device(const GPUVertFormat &format, uint v_len)
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
#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_discard(blender::gpu::VertBuf *)
Span< T > as_span() const
constexpr T * data() const
constexpr int64_t size_in_bytes() const
GAttributeReader lookup(const StringRef attribute_id) const
BLI_INLINE float area_ratio_to_stretch(float ratio, float tot_ratio)
void draw_subdiv_build_edituv_stretch_area_buffer(const DRWSubdivCache &cache, gpu::VertBuf *coarse_data, gpu::VertBuf *subdiv_data)
gpu::VertBufPtr extract_edituv_stretch_area(const MeshRenderData &mr, float &tot_area, float &tot_uv_area)
static AreaInfo compute_area_ratio(const MeshRenderData &mr, MutableSpan< float > r_area_ratio)
gpu::VertBufPtr extract_edituv_stretch_area_subdiv(const MeshRenderData &mr, const DRWSubdivCache &subdiv_cache, float &tot_area, float &tot_uv_area)
BLI_INLINE float area_ratio_get(float area, float uvarea)
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))
void memory_bandwidth_bound_task(const int64_t approximate_bytes_touched, const Function &function)
Value parallel_reduce(IndexRange range, int64_t grain_size, const Value &identity, const Function &function, const Reduction &reduction)
VecBase< float, 2 > float2
MeshExtractType extract_type
OffsetIndices< int > faces